/* Ciot1946 - Stile ispirato a ciot1946.it: moderno, caldo, arancione */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
    --font-display: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    --color-bg: #faf8f6;
    --color-surface: #ffffff;
    --color-text: #2c2c2c;
    --color-text-muted: #777;
    --color-border: #e8e0d8;
    --color-accent: #D94B2B;
    --color-accent-hover: #c03a1e;
    --color-accent-light: rgba(217, 75, 43, 0.08);
    --color-accent-yellow: #F5A623;
    --sidebar-width: 250px;
    --header-height: 64px;
    --font-size-base: 16px;
    --radius: 6px;
}

[data-theme="dark"] {
    --color-bg: #1a1614;
    --color-surface: #262220;
    --color-text: #ece6e0;
    --color-text-muted: #a09890;
    --color-border: #3d3530;
    --color-accent: #E85A3A;
    --color-accent-hover: #F07050;
    --color-accent-light: rgba(232, 90, 58, 0.12);
    --color-accent-yellow: #F5A623;
}

html[data-font-size="small"] {
    --font-size-base: 14px;
}
html[data-font-size="medium"] {
    --font-size-base: 16px;
}
html[data-font-size="large"] {
    --font-size-base: 18px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: var(--font-size-base);
    font-weight: 400;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
    min-height: 100vh;
}

.app-sidebar,
.app-sidebar *:not(.material-icons),
.app-main,
.app-main *:not(.material-icons),
[class*="q-"]:not(.material-icons) {
    font-family: var(--font-body) !important;
}

.app-layout {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: width 0.2s ease, min-width 0.2s ease, border-color 0.2s ease;
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--color-accent);
    text-decoration: none;
}
.app-logo img {
    height: 36px;
    width: auto;
}
.app-logo:hover {
    color: var(--color-accent-hover);
}

.app-nav {
    flex: 1;
    padding: 1rem 0;
}

.app-nav a {
    display: block;
    padding: 0.75rem 1.5rem;
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
}

.app-nav a:hover {
    background: var(--color-accent-light);
    color: var(--color-accent);
}

.app-nav a.active {
    background: var(--color-accent-light);
    color: var(--color-accent);
    border-left: 3px solid var(--color-accent);
    padding-left: calc(1.5rem - 3px);
    font-weight: 600;
}

.app-layout.sidebar-collapsed .app-sidebar {
    width: 0;
    min-width: 0;
    overflow: hidden;
    border-right-width: 0;
}
.app-layout.sidebar-collapsed .app-main {
    margin-left: 0;
}

.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left 0.2s ease;
}

.app-header {
    flex: 0 0 auto;
    height: var(--header-height);
    min-height: var(--header-height);
    padding: 0 1.25rem 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.app-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.app-sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--color-text);
    cursor: pointer;
    border-radius: var(--radius);
    transition: background 0.15s, color 0.15s;
}
.app-sidebar-toggle:hover {
    background: var(--color-accent-light);
    color: var(--color-accent);
}

.icon-hamburger {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
}
.icon-hamburger span {
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
}

.app-header .page-title {
    margin: 0;
    font-size: 1.25rem;
}

.app-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.app-header-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius);
    color: var(--color-text);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.app-header-icon:hover {
    background: var(--color-accent-light);
    color: var(--color-accent);
}
.app-header-icon .material-icons {
    font-size: 22px;
}

.app-header-account-name {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.app-header-account:hover .app-header-account-name {
    color: var(--color-accent);
}

.app-content {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 0rem;
}

.page-title {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 600;
    margin: 0 0 1.5rem;
    color: var(--color-text);
}

/* Login */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #faf8f6 0%, #f5ede6 100%);
}

.login-box {
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}
.login-logo img {
    height: 48px;
    width: auto;
}

.login-box .form-group {
    margin-bottom: 1.25rem;
}

.login-box label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text);
}

.login-box input[type="email"],
.login-box input[type="password"],
.login-box input[type="text"],
.login-box select {
    width: 100%;
    padding: 0.65rem 0.85rem;
    font-family: var(--font-body);
    font-size: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    color: var(--color-text);
    transition: border-color 0.2s;
}

.login-box input:focus,
.login-box select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(217, 75, 43, 0.1);
}

.login-box .btn {
    width: 100%;
    padding: 0.75rem 1rem;
    margin-top: 0.5rem;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    background: var(--color-accent);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
}

.login-box .btn:hover {
    background: var(--color-accent-hover);
    box-shadow: 0 2px 8px rgba(217, 75, 43, 0.25);
}

.login-message {
    padding: 0.75rem;
    margin-bottom: 1rem;
    background: rgba(60, 140, 60, 0.15);
    border: 1px solid rgba(60, 140, 60, 0.4);
    border-radius: var(--radius);
    color: #2a7a2a;
    font-size: 0.9rem;
}

.login-error {
    padding: 0.75rem;
    margin-bottom: 1rem;
    background: rgba(200, 60, 60, 0.15);
    border: 1px solid rgba(200, 60, 60, 0.4);
    border-radius: var(--radius);
    color: #b33;
    font-size: 0.9rem;
}

.login-forgot {
    margin-top: 1.25rem;
    text-align: center;
    font-size: 0.9rem;
}

.login-forgot a {
    color: var(--color-accent);
    text-decoration: none;
}

.login-forgot a:hover {
    text-decoration: underline;
}

.login-text {
    margin-bottom: 1.25rem;
    font-size: 0.95rem;
    color: var(--color-text-muted);
}

.captcha-group input {
    max-width: 6rem;
}

/* Impostazioni */
.settings-section {
    max-width: 520px;
    margin-bottom: 2rem;
}

.settings-section h3 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    margin: 0 0 1rem;
    color: var(--color-text);
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--color-border);
}

.settings-row:last-child {
    border-bottom: none;
}

.settings-row label {
    font-size: 0.95rem;
    color: var(--color-text);
}

.settings-row select {
    padding: 0.4rem 0.75rem;
    font-family: var(--font-body);
    font-size: 0.95rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    color: var(--color-text);
}

.btn-save {
    padding: 0.6rem 1.25rem;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    background: var(--color-accent);
    color: #fff;
    cursor: pointer;
    margin-top: 0.5rem;
}

.btn-save:hover {
    background: var(--color-accent-hover);
}

.placeholder-page {
    padding: 2rem 0;
    color: var(--color-text-muted);
}

.placeholder-page p {
    margin: 0.5rem 0;
}

/* Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1.5fr);
    grid-auto-rows: minmax(220px, auto);
    gap: 1.5rem;
}
.dash-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}
.dash-card-title {
    margin: 0 0 0.75rem;
    font-family: var(--font-display);
    font-size: 1.1rem;
}
.dash-placeholder {
    font-size: 0.9rem;
    color: var(--color-text-muted);
}
.dash-chart {
    width: 100%;
    height: 260px;
}
.dash-activities-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 260px;
    overflow-y: auto;
}
.dash-activity-item {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.85rem;
}
.dash-activity-item:last-child {
    border-bottom: none;
}
.dash-activity-main {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.15rem;
}
.dash-activity-type {
    font-weight: 600;
    color: var(--color-accent);
}
.dash-activity-time {
    color: var(--color-text-muted);
}
.dash-activity-sub {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    color: var(--color-text-muted);
}
.dash-activity-user {
    font-weight: 500;
}
.dash-activities-empty {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

/* Importazione */
.import-section {
    padding: 0.5rem 0;
}
.import-section h2 {
    font-family: var(--font-display);
    font-weight: 600;
}
.import-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin: 1.5rem 0;
}
.import-card {
    flex: 1;
    min-width: 260px;
    padding: 1.25rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}
.import-card h3 {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
}
.import-card p {
    margin: 0.5rem 0;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}
.import-card code {
    background: var(--color-bg);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-size: 0.85em;
}
.import-form {
    margin-top: 1rem;
}

.import-section--inline {
    padding: 16px 16px;
}
.import-card--compact {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1.5rem;
    padding: 0.9rem 1.2rem;
}
.import-card--compact h2 {
    margin: 0;
    font-size: 1rem;
}
.import-card--compact .import-card-text {
    margin: 0.15rem 0 0;
    font-size: 0.85rem;
}
.import-inline-header {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}
.import-form--inline {
    margin-top: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
}
.import-file-input {
    display: none;
}
.import-file-trigger {
    display: inline-block;
}
.import-file-name {
    min-width: 160px;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.btn-primary {
    padding: 0.5rem 1rem;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius);
    background: var(--color-accent);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-primary:hover {
    background: var(--color-accent-hover);
}
.import-message {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
}
.import-message--success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}
.import-message--warning {
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffcc80;
}
.import-message--error {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
}
.import-cli-hint {
    margin-top: 2rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

/* Utenti / Profilo */
.utenti-section {
    margin-bottom: 2.5rem;
}
.utenti-section .page-subtitle {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0 0 1rem;
    color: var(--color-text);
}
.form-utenti .form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}
.form-utenti .form-group {
    margin-bottom: 1rem;
}
.form-utenti .form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
    font-weight: 500;
}
.form-utenti input[type="email"],
.form-utenti input[type="password"],
.form-utenti input[type="text"],
.form-utenti select {
    padding: 0.5rem 0.75rem;
    font-family: var(--font-body);
    font-size: 0.95rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    color: var(--color-text);
    min-width: 160px;
}
.form-utenti .form-actions {
    margin-bottom: 0;
}
.form-utenti .form-actions button,
.form-utenti .form-actions a.btn {
    margin-right: 0.5rem;
}
.btn-secondary {
    display: inline-block;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--color-text);
    text-decoration: none;
    cursor: pointer;
}
.btn-secondary:hover {
    background: var(--color-bg);
}
.form-result {
    margin-top: 0.75rem;
    font-size: 0.9rem;
}
.form-result.success { color: #2e7d32; }
.form-result.error { color: #c62828; }
.table-utenti {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}
.table-utenti th,
.table-utenti td {
    padding: 0.65rem 0.85rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}
.table-utenti th {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}
.table-utenti .btn-link {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.9rem;
    color: var(--color-accent);
    cursor: pointer;
    text-decoration: none;
    margin-right: 0.75rem;
}
.table-utenti .btn-link:hover {
    text-decoration: underline;
}
.table-utenti .btn-link-danger {
    color: #c62828;
}
.form-delete-inline {
    display: inline;
}
.utenti-profilo .form-utenti {
    max-width: 400px;
}
.import-message.success { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.import-message.error { background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }

/* Righe tabella cliccabili */
.dati-table-clickable tbody tr {
    cursor: pointer;
}
.dati-table-clickable tbody tr:hover td {
    background-color: var(--color-accent-light) !important;
}

/* Dati: sfondo alternato */
.q-table tbody tr.dati-row-alt,
    .q-table tbody tr.dati-row-alt td {
    background-color: #f5ede6 !important;
}
.q-table tbody tr.selected td {
    background-color: #e8d5c5 !important;
}

/* Dati Clienti / Fornitori - layout compatto */
.dati-section {
    margin-bottom: 1rem;
}
.dati-msg-compact {
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
}
.dati-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}
.dati-count {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}
.btn-sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.8rem;
}
.form-dati {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
    margin-bottom: 0;
}
.form-dati.form-dati-modal .dati-modal-body {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 1rem;
    align-items: flex-end;
}
.form-dati .form-group-inline {
    margin-bottom: 0;
    min-width: 120px;
}
.form-dati .form-group-inline label {
    display: block;
    margin-bottom: 0.2rem;
    font-size: 0.78rem;
    color: var(--color-text-muted);
}
.form-dati .form-group-inline input {
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    min-width: 100px;
}
.table-wrap {
    overflow-x: auto;
    margin-top: 0.5rem;
}
.table-wrap-compact {
    margin-top: 0;
}
.table-dati {
    font-size: 0.9rem;
}
.table-dati-compact {
    font-size: 0.8rem;
}
.table-dati-compact th,
.table-dati-compact td {
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid var(--color-border);
}
.table-dati-compact th {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-text-muted);
}
.q-table thead th,
.q-table th {
    font-weight: 700;
}
.q-table tbody td,
.q-table td {
    font-weight: 400;
}
.table-dati thead th,
.table-dati-compact thead th {
    font-weight: 700;
}
.table-dati tbody td,
.table-dati-compact tbody td {
    font-weight: 400;
}
.table-utenti tbody td {
    font-weight: 400;
}

.table-dati .cell-actions {
    white-space: nowrap;
}
.table-dati .btn-link,
.table-dati-compact .btn-link {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.8rem;
    margin-right: 0.5rem;
    color: var(--color-accent);
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
}
.table-dati .btn-link:hover,
.table-dati-compact .btn-link:hover {
    text-decoration: underline;
}
.table-dati-compact .btn-link-danger {
    color: #c62828;
}
.dati-edit-section {
    padding: 0.6rem 0;
    border-top: 1px solid var(--color-border);
    margin-bottom: 0.75rem;
}
.dati-edit-compact .dati-edit-title {
    font-size: 0.95rem;
    margin: 0 0 0.5rem;
    font-weight: 600;
}
.form-dati-inline {
    margin-bottom: 0;
}

/* Modal popup */
.dati-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0.2s, opacity 0.2s;
}
.dati-modal.dati-modal-open {
    visibility: visible;
    opacity: 1;
}
.dati-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    cursor: pointer;
}
.dati-modal-box {
    position: relative;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}
.dati-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.85rem;
    border-bottom: 1px solid var(--color-border);
}
.dati-modal-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}
.dati-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0 0.25rem;
}
.dati-modal-close:hover {
    color: var(--color-text);
}
.dati-modal-body {
    padding: 0.85rem;
}
.dati-modal-footer {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    padding: 0.6rem 0.85rem;
    border-top: 1px solid var(--color-border);
}
.dati-form-result {
    margin: 0.5rem 0.85rem 0;
    font-size: 0.8rem;
}

/* Quasar primary color override */
.q-btn--standard.bg-primary,
.q-btn.bg-primary {
    background: var(--color-accent) !important;
    color: #fff !important;
}
.q-btn--standard.bg-primary:hover,
.q-btn.bg-primary:hover {
    background: var(--color-accent-hover) !important;
}
.q-tab--active.text-primary,
.q-tabs__indicator.text-primary,
.text-primary {
    color: var(--color-accent) !important;
}
.bg-primary {
    background: var(--color-accent) !important;
}

/* Force all Quasar buttons to Ciot brand color */
.q-btn {
    color: #fff !important;
}
.q-btn.q-btn--standard {
    background: var(--color-accent) !important;
    color: #fff !important;
}
.q-btn.q-btn--standard:hover {
    background: var(--color-accent-hover) !important;
}
.q-btn.q-btn--flat,
.q-btn.q-btn--outline {
    color: var(--color-accent) !important;
    background: transparent !important;
}
.q-btn.q-btn--flat:hover,
.q-btn.q-btn--outline:hover {
    background: var(--color-accent-light) !important;
}
.q-checkbox__inner--truthy .q-checkbox__bg,
.q-checkbox__inner--indet .q-checkbox__bg {
    background: var(--color-accent) !important;
    border-color: var(--color-accent) !important;
}

/* ── Chat Widget ── */
.cw-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }

.cw-fab {
    width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
    background: var(--color-accent); color: #fff;
    box-shadow: 0 4px 16px rgba(0,0,0,.25);
    display: flex; align-items: center; justify-content: center;
    transition: transform .2s, background .2s;
}
.cw-fab:hover { transform: scale(1.08); }
.cw-fab .material-icons { font-size: 26px; }
.cw-fab-active { background: #555; }

.cw-panel {
    position: absolute; bottom: 68px; right: 0;
    width: 380px; max-width: calc(100vw - 32px);
    height: 520px; max-height: calc(100vh - 100px);
    background: #fff; border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    display: flex; flex-direction: column; overflow: hidden;
}

.cw-header {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 16px;
    background: var(--color-accent); color: #fff;
    flex-shrink: 0;
}
.cw-header-title { font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cw-header-spacer { flex: 1; }
.cw-back, .cw-new { cursor: pointer; font-size: 22px; opacity: .9; }
.cw-back:hover, .cw-new:hover { opacity: 1; }

.cw-body { flex: 1; overflow-y: auto; }
.cw-body-chat { display: flex; flex-direction: column; }

.cw-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: #888; padding: 2rem; text-align: center; }
.cw-new-btn {
    margin-top: 1rem; padding: .5rem 1.2rem; border-radius: 8px; border: none;
    background: var(--color-accent); color: #fff; cursor: pointer; font-size: .9rem;
}
.cw-new-btn:hover { opacity: .9; }

.cw-chat-list { padding: 4px 0; }
.cw-chat-item {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 16px; cursor: pointer; border-bottom: 1px solid #f0f0f0;
    transition: background .15s;
}
.cw-chat-item:hover { background: #f8f8f8; }
.cw-chat-item-title { flex: 1; font-size: .9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cw-chat-item-date { font-size: .75rem; color: #999; white-space: nowrap; }
.cw-chat-item-del { font-size: 18px; color: #bbb; cursor: pointer; }
.cw-chat-item-del:hover { color: #e74c3c; }

.cw-messages { flex: 1; overflow-y: auto; padding: 12px 12px 4px; display: flex; flex-direction: column; gap: 6px; }

.cw-msg { display: flex; flex-direction: column; max-width: 85%; }
.cw-msg-user { align-self: flex-end; align-items: flex-end; }
.cw-msg-assistant { align-self: flex-start; align-items: flex-start; }

.cw-msg-bubble {
    padding: 8px 14px; border-radius: 16px; font-size: .88rem; line-height: 1.45;
    word-wrap: break-word; overflow-wrap: break-word;
}
.cw-msg-user .cw-msg-bubble { background: var(--color-accent); color: #fff; border-bottom-right-radius: 4px; }
.cw-msg-assistant .cw-msg-bubble { background: #f0f0f0; color: #222; border-bottom-left-radius: 4px; }
.cw-msg-assistant .cw-msg-bubble p { margin: 0 0 .4em; }
.cw-msg-assistant .cw-msg-bubble p:last-child { margin-bottom: 0; }
.cw-msg-assistant .cw-msg-bubble ul, .cw-msg-assistant .cw-msg-bubble ol { margin: .3em 0; padding-left: 1.4em; }
.cw-msg-assistant .cw-msg-bubble li { margin-bottom: .15em; }
.cw-msg-assistant .cw-msg-bubble strong { font-weight: 600; }
.cw-msg-assistant .cw-msg-bubble code { background: #e0e0e0; padding: 1px 4px; border-radius: 3px; font-size: .85em; }

.cw-msg-time { font-size: .7rem; color: #aaa; margin-top: 2px; padding: 0 4px; }

.cw-typing {
    display: flex; align-items: center; gap: 4px; padding: 10px 16px !important;
}
.cw-typing span {
    width: 8px; height: 8px; border-radius: 50%; background: #aaa;
    animation: cw-dot 1.4s infinite ease-in-out both;
}
.cw-typing span:nth-child(1) { animation-delay: -.32s; }
.cw-typing span:nth-child(2) { animation-delay: -.16s; }
@keyframes cw-dot { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

.cw-input-bar {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; border-top: 1px solid #e8e8e8;
    background: #fafafa; flex-shrink: 0;
}
.cw-input {
    flex: 1; border: 1px solid #ddd; border-radius: 20px;
    padding: 8px 14px; font-size: .88rem; outline: none;
    background: #fff; transition: border-color .2s;
}
.cw-input:focus { border-color: var(--color-accent); }
.cw-send {
    width: 36px; height: 36px; border-radius: 50%; border: none;
    background: var(--color-accent); color: #fff;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: opacity .2s;
}
.cw-send:disabled { opacity: .4; cursor: not-allowed; }
.cw-send .material-icons { font-size: 20px; }

@media (max-width: 480px) {
    .cw-panel { width: calc(100vw - 16px); height: calc(100vh - 80px); right: -16px; bottom: 60px; border-radius: 12px; }
    .cw-container { bottom: 12px; right: 12px; }
}
