/* ============================================
   TECNOVITI AIPROJECT — Design System
   Stile: Precisione Industriale Italiana
   ============================================ */

:root {
    --bg:         #F3F2EE;
    --bg-card:    #FFFFFF;
    --bg-dark:    #111110;
    --bg-panel:   #1A1917;

    --ink:        #111110;
    --ink-2:      #3D3C3A;
    --ink-3:      #767472;
    --ink-4:      #B0AEA9;

    --accent:     #1B4FBF;
    --accent-h:   #153D99;
    --accent-bg:  #EBF0FD;

    --border:     #E2E0DB;
    --border-2:   #D0CEC8;

    --green:      #2D6A4F;
    --green-bg:   #F0FAF5;
    --orange:     #B45309;
    --orange-bg:  #FEF8EE;
    --red:        #B91C1C;
    --red-bg:     #FEF2F2;

    --font-display: 'Barlow Condensed', sans-serif;
    --font-body:    'Barlow', sans-serif;
    --font-mono:    'JetBrains Mono', monospace;
    --radius:     4px;
    --radius-lg:  8px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
    font-family: var(--font-body);
    font-size: 0.95rem;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.mono { font-family: var(--font-mono); font-size: 0.85em; }

/* ── Header ── */
.site-header {
    background: var(--bg-dark);
    border-bottom: 2px solid var(--accent);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    height: 54px;
    display: flex;
    align-items: center;
    gap: 2rem;
}

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

.brand-mark {
    width: 34px;
    height: 34px;
    background: var(--accent);
    color: white;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
}

.brand-text { display: flex; flex-direction: column; }
.brand-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.12em;
    color: white;
    line-height: 1;
}
.brand-sub {
    font-size: 0.65rem;
    color: var(--ink-4);
    letter-spacing: 0.06em;
    line-height: 1;
    margin-top: 2px;
}

.header-nav { margin-left: 2rem; display: flex; gap: 0.5rem; }
.nav-link {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    color: var(--ink-4);
    text-decoration: none;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius);
    transition: color 0.15s, background 0.15s;
}
.nav-link:hover { color: white; background: rgba(255,255,255,0.08); }
.nav-link.active { color: white; }

.header-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}
.user-name {
    font-size: 0.82rem;
    color: var(--ink-3);
    letter-spacing: 0.02em;
}
.logout-link {
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--ink-4);
    text-decoration: none;
    border: 1px solid rgba(255,255,255,0.12);
    padding: 0.25rem 0.7rem;
    border-radius: var(--radius);
    transition: all 0.15s;
}
.logout-link:hover { color: white; border-color: rgba(255,255,255,0.3); }

/* ── Main ── */
.site-main { min-height: calc(100vh - 54px); }

/* ── Toast ── */
.toast-container {
    position: fixed;
    top: 70px;
    right: 1.5rem;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.toast {
    background: var(--ink);
    color: white;
    padding: 0.7rem 1.2rem;
    border-radius: var(--radius);
    font-size: 0.88rem;
    border-left: 3px solid var(--accent);
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    transition: opacity 0.3s, transform 0.3s;
    max-width: 340px;
}
.toast-error { border-left-color: var(--red); }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-decoration: none;
    border: none;
    cursor: pointer;
    padding: 0.6rem 1.3rem;
    border-radius: var(--radius);
    transition: all 0.15s;
    white-space: nowrap;
}
.btn-accent {
    background: var(--accent);
    color: white;
}
.btn-accent:hover { background: var(--accent-h); }

.btn-ghost {
    background: transparent;
    color: var(--ink-2);
    border: 1.5px solid var(--border-2);
}
.btn-ghost:hover { border-color: var(--ink-3); color: var(--ink); }

/* ── Page layout ── */
.page-wrap {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 2rem;
}

.page-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 1.25rem;
}

.page-title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.6rem;
    letter-spacing: 0.06em;
    color: var(--ink);
    line-height: 1;
}
.page-count {
    font-size: 0.8rem;
    color: var(--ink-3);
    letter-spacing: 0.04em;
    margin-top: 0.2rem;
}

/* ── Table card ── */
.table-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.tv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.tv-table th {
    background: var(--bg-dark);
    color: var(--ink-4);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 0.7rem 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    white-space: nowrap;
}

.tv-table td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--ink-2);
}

.tv-table tbody tr:last-child td { border-bottom: none; }

/* Dashboard row hover */
.tv-row {
    cursor: pointer;
    transition: background 0.1s;
}
.tv-row:hover { background: #F8F7F3; }
.tv-row:hover .row-arrow { opacity: 1; transform: translateX(3px); }

.row-arrow {
    color: var(--accent);
    font-size: 1rem;
    opacity: 0;
    transition: opacity 0.15s, transform 0.15s;
    display: block;
    text-align: right;
}

.td-date { white-space: nowrap; }
.date-day { display: block; font-weight: 500; color: var(--ink); }
.date-time { display: block; font-size: 0.78rem; color: var(--ink-3); }

.td-client { font-weight: 500; color: var(--ink); }
.td-rif { color: var(--ink-3); }
.td-center { text-align: center; }
.td-action { width: 40px; }

/* ── Badges ── */
.tipo-tag {
    display: inline-block;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    padding: 0.2rem 0.6rem;
    border-radius: 2px;
}
.tipo-preventivo { background: #DBEAFE; color: #1E40AF; }
.tipo-ordine { background: #D1FAE5; color: #065F46; }

.status-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    color: var(--ink-2);
}
.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ink-4);
    flex-shrink: 0;
}
.status-draft .status-dot   { background: var(--ink-4); }
.status-processing .status-dot { background: #F59E0B; }
.status-ready .status-dot   { background: #3B82F6; }
.status-approved .status-dot { background: var(--green); }
.status-sent .status-dot    { background: #8B5CF6; }
.status-error .status-dot   { background: var(--red); }

/* ── Empty state ── */
.empty-row td, td.empty-row {
    text-align: center;
    padding: 4rem 1rem !important;
}
.empty-icon { font-size: 2rem; color: var(--ink-4); margin-bottom: 0.75rem; }
.empty-text { font-family: var(--font-display); font-weight: 600; font-size: 1rem; letter-spacing: 0.05em; color: var(--ink-3); margin-bottom: 0.3rem; }
.empty-sub { font-size: 0.82rem; color: var(--ink-4); }

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17,17,16,0.7);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1rem;
}
.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 540px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.25);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 1.75rem 0;
}
.modal-title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: 0.06em;
    color: var(--ink);
}
.modal-close {
    color: var(--ink-3);
    text-decoration: none;
    font-size: 1rem;
    line-height: 1;
    transition: color 0.15s;
}
.modal-close:hover { color: var(--ink); }

.upload-form { padding: 1.5rem 1.75rem; }

.tipo-section { margin-bottom: 1.5rem; }
.tipo-label-text {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    color: var(--ink-3);
    margin-bottom: 0.6rem;
}

.tipo-group { display: flex; gap: 0.75rem; }

.tipo-card {
    flex: 1;
    cursor: pointer;
}
.tipo-card input[type="radio"] { display: none; }
.tipo-card-inner {
    border: 1.5px solid var(--border-2);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    transition: all 0.15s;
}
.tipo-card:hover .tipo-card-inner { border-color: var(--ink-3); }
.tipo-card input:checked + .tipo-card-inner {
    border-color: var(--accent);
    background: var(--accent-bg);
}
.tipo-card-icon { font-size: 1.4rem; margin-bottom: 0.4rem; }
.tipo-card-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.1em;
    color: var(--ink);
    margin-bottom: 0.15rem;
}
.tipo-card-desc { font-size: 0.76rem; color: var(--ink-3); }

.upload-zone {
    border: 2px dashed var(--border-2);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    margin-bottom: 1.5rem;
    transition: border-color 0.15s;
    cursor: pointer;
}
.upload-zone:hover { border-color: var(--accent); }
.upload-icon { font-size: 1.8rem; margin-bottom: 0.5rem; color: var(--ink-3); }
.upload-text { font-weight: 500; color: var(--ink-2); margin-bottom: 0.25rem; }
.upload-hint { font-size: 0.78rem; color: var(--ink-4); margin-bottom: 0.75rem; }
.upload-input { font-size: 0.82rem; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* ── Login ── */
body.login-page {
    background: var(--bg-dark);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-layout {
    display: flex;
    width: 100%;
    max-width: 900px;
    min-height: 540px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 32px 80px rgba(0,0,0,0.5);
}

.login-brand-panel {
    flex: 1;
    background: var(--bg-panel);
    border-right: 1px solid rgba(255,255,255,0.06);
    padding: 3rem;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Subtle grid texture */
.login-brand-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 32px 32px;
    pointer-events: none;
}

.login-brand-content { flex: 1; position: relative; }

.login-logo-mark {
    width: 52px;
    height: 52px;
    background: var(--accent);
    color: white;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: 0.1em;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    margin-bottom: 2rem;
}

.login-brand-name {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 2rem;
    letter-spacing: 0.15em;
    color: white;
    line-height: 1;
    margin-bottom: 0.75rem;
}

.login-brand-claim {
    font-size: 0.9rem;
    color: var(--ink-3);
    line-height: 1.6;
    margin-bottom: 2.5rem;
    font-weight: 300;
}

.login-features { display: flex; flex-direction: column; gap: 0.75rem; }

.login-feature {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.82rem;
    color: var(--ink-3);
}
.feature-icon {
    color: var(--accent);
    font-size: 0.5rem;
    flex-shrink: 0;
}

.login-brand-footer {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.15);
    letter-spacing: 0.08em;
    position: relative;
}

.login-form-panel {
    flex: 1;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

.login-form-inner { width: 100%; max-width: 320px; }

.login-form-header { margin-bottom: 2rem; }
.login-form-header h2 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.3rem;
    letter-spacing: 0.04em;
    color: var(--ink);
    margin-bottom: 0.25rem;
}
.login-form-header p {
    font-size: 0.85rem;
    color: var(--ink-3);
}

.form-group { margin-bottom: 1.1rem; }
.form-label {
    display: block;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    color: var(--ink-3);
    margin-bottom: 0.4rem;
}
.form-input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 1.5px solid var(--border-2);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--ink);
    background: white;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}
.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(27,79,191,0.08);
}

.form-group-inline { margin-bottom: 1.5rem; }
.check-label {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--ink-2);
}
.check-input { display: none; }
.check-box {
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--border-2);
    border-radius: 3px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.check-input:checked + .check-box {
    background: var(--accent);
    border-color: var(--accent);
}
.check-input:checked + .check-box::after {
    content: '✓';
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
}

.btn-login {
    width: 100%;
    padding: 0.8rem 1.5rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.1em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.15s;
}
.btn-login:hover { background: var(--accent-h); }
.btn-arrow { font-size: 1rem; }

/* ── Review page ── */
.review-top {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.back-link,
.back-btn {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    color: var(--ink-3);
    text-decoration: none;
    transition: color 0.15s;
    margin-right: 0.5rem;
}
.back-link:hover, .back-btn:hover { color: var(--ink); }

.review-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.88rem;
    color: var(--ink-2);
}
.breadcrumb-sep { color: var(--ink-4); }
.breadcrumb-client { font-weight: 500; }
.breadcrumb-rif { color: var(--ink-3); }

.review-meta-bar {
    display: flex;
    gap: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
    overflow: hidden;
}
.meta-item {
    flex: 1;
    padding: 0.85rem 1.25rem;
    border-right: 1px solid var(--border);
    min-width: 0;
}
.meta-item:last-child { border-right: none; }
.meta-label {
    display: block;
    font-family: var(--font-display);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: var(--ink-4);
    margin-bottom: 0.2rem;
}
.meta-value {
    display: block;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.legend-strip {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    background: var(--bg-dark);
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.legend-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.65rem;
    letter-spacing: 0.14em;
    color: var(--ink-4);
    flex-shrink: 0;
}
.legend-items {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    color: var(--ink-3);
}
.legend-bar {
    width: 20px;
    height: 3px;
    border-radius: 2px;
    flex-shrink: 0;
}
.lb-green  { background: var(--green); }
.lb-orange { background: var(--orange); }
.lb-red    { background: var(--red); }
.lb-empty  { background: var(--border-2); }

/* ── Review table ── */
.review-table { font-size: 0.85rem; }

.rv-row td { padding: 0.65rem 1rem; }

.rv-green td:first-child { border-left: 3px solid var(--green); }
.rv-orange td:first-child { border-left: 3px solid var(--orange); }
.rv-red td:first-child { border-left: 3px solid var(--red); }
.rv-empty td:first-child { border-left: 3px solid var(--border-2); }
.rv-manual td:first-child { border-left: 3px solid #8B5CF6; }

.rv-orange { background: var(--orange-bg); }
.rv-red { background: var(--red-bg); }
.rv-empty { background: #FAFAF8; }

.td-num { text-align: center; color: var(--ink-4); font-size: 0.78rem; width: 40px; }
.td-code { width: 120px; }
.td-qty { text-align: right; width: 70px; }
.td-um { width: 50px; color: var(--ink-3); }
.td-price { width: 120px; }
.td-note { width: 130px; }
.td-source { font-size: 0.72rem; color: var(--ink-4); line-height: 1.3; max-width: 160px; }

.desc-text { display: block; font-weight: 500; color: var(--ink); }
.desc-orig { display: block; font-size: 0.75rem; color: var(--ink-4); margin-top: 0.15rem; }

.price-val { font-family: var(--font-mono); font-size: 0.85rem; }

.price-input {
    width: 100px;
    padding: 0.3rem 0.5rem;
    border: 1.5px solid var(--border-2);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--ink);
    transition: border-color 0.15s;
    outline: none;
}
.price-input:focus { border-color: var(--accent); }

.note-input {
    width: 120px;
    padding: 0.3rem 0.5rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.82rem;
    color: var(--ink);
    outline: none;
    transition: border-color 0.15s;
}
.note-input:focus { border-color: var(--accent); }

/* Column widths */
.th-num  { width: 40px; text-align: center; }
.th-code { width: 120px; }
.th-qty  { width: 70px; }
.th-um   { width: 50px; }
.th-price { width: 110px; }
.th-total { width: 100px; text-align: right; }
.th-note  { width: 120px; }
.th-source{ width: 150px; }

.td-total { text-align: right; padding-right: 1rem; }
.total-val { font-size: 0.88rem; color: var(--ink-2); }
.total-big { color: var(--ink); font-weight: 600; }
.total-empty { color: var(--ink-4); }

.total-footer-row { background: var(--bg) !important; border-top: 2px solid var(--border-2); }
.total-footer-label {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    color: var(--ink-3);
    text-align: right;
    padding: 0.75rem 0.5rem;
}
.total-footer-val {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ink);
    text-align: right;
    padding-right: 1rem;
}

/* ── Action bar ── */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}
.action-hint {
    font-size: 0.8rem;
    color: var(--ink-3);
    flex: 1;
}
.action-hint::before { content: '◆ '; color: var(--accent); }
.action-btns { display: flex; gap: 0.75rem; }

/* ── Status banners ── */
.status-banner {
    margin-top: 1.5rem;
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
}
.banner-approved {
    background: var(--green-bg);
    border: 1px solid #A7F3D0;
    color: var(--green);
}
.banner-sent {
    background: #F5F3FF;
    border: 1px solid #DDD6FE;
    color: #5B21B6;
}

/* ── Dashboard action buttons ── */
.td-action-btns {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: flex-end;
    white-space: nowrap;
}
.delete-form { display: inline; }

.btn-apri {
    display: inline-block;
    padding: 0.35rem 0.85rem;
    background: var(--accent);
    color: white;
    border-radius: var(--radius);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.07em;
    text-decoration: none;
    transition: background 0.15s;
    white-space: nowrap;
}
.btn-apri:hover { background: var(--accent-h); }

.btn-elimina {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    background: none;
    color: var(--red);
    border: 1.5px solid currentColor;
    border-radius: var(--radius);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.btn-elimina:hover { background: var(--red-bg); }

/* ── Stats toolbar ── */
.stats-toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.stats-filter-form {
    display: flex;
    gap: 0.5rem;
}
.filter-select {
    padding: 0.35rem 0.7rem;
    border: 1.5px solid var(--border-2);
    border-radius: var(--radius);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.8rem;
    letter-spacing: 0.04em;
    color: var(--ink);
    background: white;
    cursor: pointer;
    outline: none;
}
.filter-select:focus { border-color: var(--accent); }
.btn-sm { font-size: 0.75rem; padding: 0.35rem 0.75rem; }

/* ── Confidence warnings ── */
.conf-warning-bar {
    background: #FFFBEB;
    border: 1.5px solid #F59E0B;
    border-radius: var(--radius);
    padding: 0.75rem 1.25rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: #92400E;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.conf-warn-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.rv-low-conf {
    background: #FFFDF0 !important;
    outline: 1.5px solid #F59E0B;
    outline-offset: -1px;
}
.rv-low-conf td { background: transparent !important; }

.conf-badge {
    display: inline-block;
    color: #D97706;
    font-size: 0.75rem;
    margin-left: 4px;
    cursor: help;
    vertical-align: middle;
}

/* ── Stats ── */
.stats-badge {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    color: var(--accent);
    border: 1.5px solid var(--accent);
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}
.kpi-grid-sm { margin-bottom: 1.5rem; }

.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.4rem 1.5rem;
    position: relative;
    overflow: hidden;
}
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
}
.kpi-c-blue   { border-top: 3px solid #1B4FBF; background: linear-gradient(135deg, #fff 60%, #EBF0FD); }
.kpi-c-orange { border-top: 3px solid #E87B0C; background: linear-gradient(135deg, #fff 60%, #FEF3E8); }
.kpi-c-green  { border-top: 3px solid #16A34A; background: linear-gradient(135deg, #fff 60%, #EDFAF3); }
.kpi-c-yellow { border-top: 3px solid #EAB308; background: linear-gradient(135deg, #fff 60%, #FEFCE8); }
.kpi-c-blue::before   { background: #1B4FBF; }
.kpi-c-orange::before { background: #E87B0C; }
.kpi-c-green::before  { background: #16A34A; }
.kpi-c-yellow::before { background: #EAB308; }
.kpi-sm { padding: 1rem 1.25rem; }

.kpi-icon {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
    opacity: 0.18;
    position: absolute;
    top: 1rem; right: 1.1rem;
    line-height: 1;
}
.kpi-c-blue .kpi-icon   { color: #1B4FBF; }
.kpi-c-orange .kpi-icon { color: #E87B0C; }
.kpi-c-green .kpi-icon  { color: #16A34A; }
.kpi-c-yellow .kpi-icon { color: #EAB308; }

.kpi-label {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.65rem;
    letter-spacing: 0.14em;
    color: var(--ink-3);
    margin-bottom: 0.5rem;
}
.kpi-value {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 2.2rem;
    letter-spacing: -0.01em;
    color: var(--ink);
    line-height: 1;
    margin-bottom: 0.5rem;
}
.kpi-value-sm {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.6rem;
    color: var(--ink);
    line-height: 1;
}
.kpi-trend {
    font-size: 0.75rem;
    font-weight: 500;
}
.kpi-up   { color: #2D6A4F; }
.kpi-down { color: var(--red); }
.kpi-neutral { color: var(--ink-3); }

.charts-row {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 1rem;
    margin-bottom: 1rem;
}
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}
.chart-header { margin-bottom: 1.25rem; }
.chart-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    color: var(--ink);
}
.chart-subtitle {
    font-size: 0.75rem;
    color: var(--ink-3);
    margin-top: 0.15rem;
}
.chart-wrap { height: 220px; }
.chart-donut-wrap { position: relative; display: flex; align-items: center; justify-content: center; }
.donut-center {
    position: absolute;
    text-align: center;
    pointer-events: none;
}
.donut-total {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 2rem;
    color: var(--ink);
    line-height: 1;
}
.donut-label {
    font-size: 0.7rem;
    color: var(--ink-3);
    letter-spacing: 0.08em;
    font-family: var(--font-display);
    font-weight: 600;
}
.donut-legend {
    display: flex;
    gap: 1.5rem;
    margin-top: 1rem;
    justify-content: center;
}
.dl-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--ink-2);
}
.dl-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.dl-blue { background: var(--accent); }
.dl-ink  { background: var(--ink); }

.tables-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}
.table-half {
    margin-bottom: 0 !important;
}
.table-card-header {
    padding: 1rem 1.25rem 0.75rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}
.table-card-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    color: var(--ink);
}
.table-card-sub {
    font-size: 0.72rem;
    color: var(--ink-3);
}

.th-rank  { width: 30px; text-align: center; }
.th-right { text-align: right; }
.th-bar-col { width: 80px; }
.td-rank  { text-align: center; font-family: var(--font-mono); font-size: 0.75rem; color: var(--ink-3); }
.td-right { text-align: right; }
.td-client-name { font-size: 0.82rem; }
.td-desc-sm { font-size: 0.78rem; color: var(--ink-2); }
.td-center { text-align: center; }
.td-bar-cell { padding-right: 0.75rem; }

.mini-bar {
    height: 4px;
    background: var(--accent);
    border-radius: 2px;
    min-width: 3px;
    opacity: 0.6;
    transition: opacity 0.15s;
}
tr:hover .mini-bar { opacity: 1; }

.tv-row-static { cursor: default; }
.tv-row-static:hover { background: var(--bg); }

/* Month bars */
.month-bars {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    padding: 1.25rem 1.25rem 1rem;
    height: 140px;
}
.month-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
}
.month-bar-wrap {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
}
.month-bar-val {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.7rem;
    color: var(--ink-2);
}
.month-bar-fill {
    width: 100%;
    background: var(--accent);
    border-radius: 2px 2px 0 0;
    min-height: 4px;
    opacity: 0.75;
    transition: opacity 0.15s;
}
.month-col:hover .month-bar-fill { opacity: 1; }
.month-label {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    color: var(--ink-3);
    margin-top: 0.4rem;
}

/* ── Processing overlay ── */
.proc-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(17,17,16,0.97);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}
.proc-overlay.proc-active { display: flex; }

.proc-grid-bg {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(27,79,191,0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(27,79,191,0.04) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
}

.proc-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 3rem 3.5rem;
    background: rgba(26,25,23,0.9);
    border: 1px solid rgba(27,79,191,0.3);
    border-radius: 12px;
    box-shadow: 0 0 80px rgba(27,79,191,0.15), 0 32px 80px rgba(0,0,0,0.6);
    min-width: 380px;
    overflow: hidden;
}

/* Scan line */
.proc-scan {
    position: absolute;
    top: -2px; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #1B4FBF, transparent);
    animation: proc-scan 2.4s ease-in-out infinite;
}
@keyframes proc-scan {
    0%   { top: -2px; opacity: 0; }
    10%  { opacity: 1; }
    90%  { opacity: 1; }
    100% { top: calc(100% + 2px); opacity: 0; }
}

/* Ring spinner */
.proc-logo-ring {
    position: relative;
    width: 96px;
    height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.proc-ring-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    animation: proc-ring-rot 2s linear infinite;
}
@keyframes proc-ring-rot { to { transform: rotate(360deg); } }

.proc-ring-track {
    fill: none;
    stroke: rgba(27,79,191,0.15);
    stroke-width: 3;
}
.proc-ring-spin {
    fill: none;
    stroke: #1B4FBF;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 80 246;
    stroke-dashoffset: 0;
    filter: drop-shadow(0 0 6px #1B4FBF);
}

.proc-logo-mark {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: 0.04em;
    color: white;
    position: relative;
    z-index: 1;
    min-width: 3.5ch;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.proc-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.22em;
    color: #1B4FBF;
}

.proc-status {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.5);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    min-height: 1.2em;
    transition: opacity 0.3s;
}

.proc-steps {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    width: 100%;
    border-top: 1px solid rgba(255,255,255,0.06);
    padding-top: 1.25rem;
}

.proc-step {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.2);
    transition: color 0.3s;
    font-family: var(--font-body);
}

.proc-step-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    flex-shrink: 0;
    transition: background 0.3s, box-shadow 0.3s;
}

.proc-step-check {
    margin-left: auto;
    font-size: 0.7rem;
    color: #16A34A;
    opacity: 0;
    transition: opacity 0.3s;
    flex-shrink: 0;
}

.proc-step-active {
    color: rgba(255,255,255,0.85);
}
.proc-step-active .proc-step-dot {
    background: #1B4FBF;
    box-shadow: 0 0 8px #1B4FBF;
    animation: proc-dot-pulse 1s ease-in-out infinite;
}

.proc-step-done { color: rgba(255,255,255,0.35); }
.proc-step-done .proc-step-dot { background: #16A34A; box-shadow: none; animation: none; }
.proc-step-done .proc-step-check { opacity: 1; }

@keyframes proc-dot-pulse {
    0%, 100% { box-shadow: 0 0 4px #1B4FBF; }
    50%       { box-shadow: 0 0 12px #1B4FBF, 0 0 20px rgba(27,79,191,0.4); }
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .login-layout { flex-direction: column; max-width: 440px; }
    .login-brand-panel { display: none; }
    .review-meta-bar { flex-direction: column; }
    .meta-item { border-right: none; border-bottom: 1px solid var(--border); }
    .meta-item:last-child { border-bottom: none; }
    .page-wrap { padding: 1rem; }
    .review-table { font-size: 0.78rem; }
    .td-source { display: none; }
    .th-source { display: none; }
    .legend-strip { gap: 0.75rem; }
}
