/* ==========================================================================
   REC — design system
   ========================================================================== */

:root {
    --ink: #101828;
    --ink-soft: #344054;
    --muted: #667085;
    --faint: #98a2b3;
    --line: #eaecf0;
    --line-soft: #f2f4f7;
    --bg: #f7f8fa;
    --paper: #ffffff;

    --brand: #2f6bed;
    --brand-dark: #1d4fd7;
    --brand-soft: #eef4ff;

    --green: #12b76a;
    --green-ink: #027a48;
    --green-soft: #ecfdf3;
    --amber: #f79009;
    --amber-ink: #b54708;
    --amber-soft: #fffaeb;
    --red: #f04438;
    --red-ink: #b42318;
    --red-soft: #fef3f2;
    --purple: #9b6bff;
    --purple-ink: #6941c6;
    --purple-soft: #f5f3ff;
    --cyan: #06aed4;
    --cyan-ink: #0e7090;
    --cyan-soft: #ecfdff;

    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --pill: 999px;

    --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-md: 0 4px 12px rgba(16, 24, 40, .07), 0 2px 4px rgba(16, 24, 40, .04);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);

    --sidebar-w: 232px;
    --detail-w: 356px;
    --topbar-h: 60px;

    --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); text-decoration: none; }

h1, h2, h3, h4 { font-weight: 600; letter-spacing: -.01em; color: var(--ink); }

.ico { flex: 0 0 auto; display: block; }
.muted { color: var(--muted); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   Shell
   -------------------------------------------------------------------------- */

.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    min-height: 100vh;
}

.app-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: padding-right .22s ease;
}

.app-main {
    flex: 1;
    padding: 22px 24px 44px;
    min-width: 0;
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */

.sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--paper);
    border-right: 1px solid var(--line);
    overflow: hidden auto;
    scrollbar-width: thin;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px 16px 16px;
    color: var(--ink);
}

/* Il logo è un PNG 134x40: lo mostro sotto la dimensione nativa per restare nitido. */
.brand-logo { width: 112px; height: auto; display: block; flex: 0 0 auto; }
.brand-logo-mark { display: none; width: 30px; height: auto; }

.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.brand-text strong { font-size: 14px; font-weight: 650; letter-spacing: -.01em; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 6px 10px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    font-size: 13.5px;
    font-weight: 500;
    transition: background .14s ease, color .14s ease;
}

.nav-item .ico { color: var(--faint); transition: color .14s ease; }
.nav-item:hover { background: var(--line-soft); color: var(--ink); }
.nav-item:hover .ico { color: var(--muted); }
.nav-item.is-active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.nav-item.is-active .ico { color: var(--brand); }
.nav-item span { flex: 1; min-width: 0; }

.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 19px;
    padding: 0 6px;
    border-radius: var(--pill);
    background: var(--red);
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.nav-item.is-active .nav-badge { background: var(--brand); }

.sidebar-section {
    padding: 16px 20px 6px;
    color: var(--faint);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .02em;
}

.quick-filters { display: flex; flex-direction: column; gap: 1px; padding: 0 10px; }

.quick-filter {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    font-size: 13px;
}

.quick-filter:hover { background: var(--line-soft); color: var(--ink); }
.quick-filter.is-active { background: var(--line-soft); color: var(--ink); font-weight: 600; }
.quick-filter span { flex: 1; min-width: 0; }
.quick-filter b { color: var(--muted); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }

.dot {
    width: 8px;
    height: 8px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--faint);
}

.dot-blue { background: var(--brand); }
.dot-green { background: var(--green); }
.dot-amber { background: var(--amber); }
.dot-red { background: var(--red); }
.dot-purple { background: var(--purple); }
.dot-cyan { background: var(--cyan); }
.dot-gray { background: var(--faint); }

.sidebar-foot { margin-top: auto; padding: 10px; border-top: 1px solid var(--line); }

.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
}

.user-card:hover { background: var(--line-soft); }
.user-card .user-meta { flex: 1; min-width: 0; line-height: 1.25; }
.user-card .user-meta strong { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card .user-meta small { color: var(--muted); font-size: 11.5px; }
.user-card > .ico { color: var(--faint); }

.user-menu {
    margin: 6px 0 0;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
    box-shadow: var(--shadow-md);
}

.user-menu[hidden] { display: none; }
.user-menu form { margin: 0; }

.user-menu button,
.user-menu a {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 9px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--ink-soft);
    font-size: 13px;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}

.user-menu button:hover,
.user-menu a:hover { background: var(--line-soft); color: var(--ink); }

/* --------------------------------------------------------------------------
   Avatars
   -------------------------------------------------------------------------- */

.avatar {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 11.5px;
    font-weight: 650;
    letter-spacing: .01em;
    text-transform: uppercase;
    background: var(--line-soft);
    color: var(--ink-soft);
}

.avatar-sm { width: 28px; height: 28px; font-size: 10.5px; }
.avatar-lg { width: 44px; height: 44px; font-size: 14px; }

.avatar-t1 { background: #eef4ff; color: #2f5fd0; }
.avatar-t2 { background: #ecfdf3; color: #027a48; }
.avatar-t3 { background: #fef3f2; color: #b42318; }
.avatar-t4 { background: #f5f3ff; color: #6941c6; }
.avatar-t5 { background: #fffaeb; color: #b54708; }
.avatar-t6 { background: #ecfdff; color: #0e7090; }

/* --------------------------------------------------------------------------
   Topbar
   -------------------------------------------------------------------------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 16px;
    height: var(--topbar-h);
    padding: 0 20px;
    background: rgba(255, 255, 255, .88);
    backdrop-filter: saturate(160%) blur(8px);
    border-bottom: 1px solid var(--line);
}

.topbar-search { flex: 1; display: flex; justify-content: center; min-width: 0; }

.search-field {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 440px;
}

.search-field > .ico {
    position: absolute;
    left: 11px;
    color: var(--faint);
    pointer-events: none;
}

.search-field input {
    width: 100%;
    height: 36px;
    padding: 0 52px 0 34px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: #fbfbfc;
    color: var(--ink);
    font-family: inherit;
    font-size: 13px;
    outline: 0;
    transition: border-color .14s ease, box-shadow .14s ease, background .14s ease;
}

.search-field input::placeholder { color: var(--faint); }

.search-field input:focus {
    background: var(--paper);
    border-color: #b9cdfb;
    box-shadow: 0 0 0 3px rgba(47, 107, 237, .12);
}

.kbd {
    position: absolute;
    right: 8px;
    display: inline-flex;
    align-items: center;
    gap: 1px;
    padding: 2px 6px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--paper);
    color: var(--faint);
    font-size: 11px;
    font-weight: 600;
    pointer-events: none;
}

.topbar-actions { display: flex; align-items: center; gap: 6px; }

.icon-btn {
    position: relative;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    transition: background .14s ease, color .14s ease, border-color .14s ease;
}

.icon-btn:hover { background: var(--line-soft); color: var(--ink); }
.icon-btn.is-bordered { border-color: var(--line); background: var(--paper); }
.icon-btn.is-bordered:hover { background: var(--line-soft); }

.icon-btn .count {
    position: absolute;
    top: 3px;
    right: 3px;
    min-width: 15px;
    height: 15px;
    padding: 0 4px;
    border: 2px solid var(--paper);
    border-radius: var(--pill);
    background: var(--red);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    line-height: 11px;
    font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn,
.btn-primary,
.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-danger,
.btn-outline-light {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 36px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--paper);
    color: var(--ink-soft);
    font-family: inherit;
    font-size: 13px;
    font-weight: 550;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: var(--shadow-xs);
    transition: background .14s ease, border-color .14s ease, color .14s ease, box-shadow .14s ease;
}

.btn:hover,
.btn-outline-secondary:hover,
.btn-outline-light:hover { background: #fbfbfc; border-color: #dcdfe4; color: var(--ink); }

.btn:focus-visible { outline: 2px solid rgba(47, 107, 237, .4); outline-offset: 1px; }

.btn-primary {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .1);
}

.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }

.btn-outline-primary { color: var(--brand-dark); border-color: #c7d7fb; background: var(--paper); }
.btn-outline-primary:hover { background: var(--brand-soft); border-color: #adc6f9; color: var(--brand-dark); }

.btn-outline-danger { color: var(--red-ink); border-color: #fcd7d3; }
.btn-outline-danger:hover { background: var(--red-soft); border-color: #f9b9b3; color: var(--red-ink); }

.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; }
.btn-lg { height: 42px; padding: 0 18px; font-size: 14px; }
.btn-block { width: 100%; }
.btn[disabled], .btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--line-soft); border-color: transparent; }

.btn-whatsapp { color: var(--green-ink); border-color: #b7ecca; background: var(--green-soft); box-shadow: none; }
.btn-whatsapp:hover { background: #d9fbe6; border-color: #9ae2b6; color: var(--green-ink); }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

.form-control,
.form-select,
select.form-select {
    width: 100%;
    min-height: 36px;
    padding: 7px 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--paper);
    color: var(--ink);
    font-family: inherit;
    font-size: 13.5px;
    box-shadow: var(--shadow-xs);
    outline: 0;
    transition: border-color .14s ease, box-shadow .14s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: #b9cdfb;
    box-shadow: 0 0 0 3px rgba(47, 107, 237, .12);
}

.form-label { display: block; margin-bottom: 5px; color: var(--ink-soft); font-size: 12.5px; font-weight: 550; }
textarea.form-control { min-height: 76px; resize: vertical; }

.form-check-input {
    width: 16px;
    height: 16px;
    margin: 0;
    border: 1.5px solid #d0d5dd;
    border-radius: 4px;
    background: var(--paper);
    cursor: pointer;
    appearance: none;
    transition: background .12s ease, border-color .12s ease;
}

.form-check-input:checked {
    background: var(--brand) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' d='M3.5 8.4l3 3 6-6.4'/%3E%3C/svg%3E") center/13px no-repeat;
    border-color: var(--brand);
}

.form-check-input:focus-visible { outline: 2px solid rgba(47, 107, 237, .35); outline-offset: 1px; }

.check-inline { display: inline-flex; align-items: center; gap: 8px; margin: 0; color: var(--ink-soft); font-size: 13px; cursor: pointer; }

/* --------------------------------------------------------------------------
   Page head
   -------------------------------------------------------------------------- */

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.page-head h1 { margin: 0; font-size: 21px; font-weight: 650; }
.page-head .page-sub { margin-top: 3px; color: var(--muted); font-size: 13px; }
.page-head-actions { display: flex; align-items: center; gap: 6px; }
.page-head-actions form { margin: 0; }

.back {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 500;
}

.back:hover { color: var(--ink); }

.section-title {
    margin: 22px 0 10px;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 650;
    letter-spacing: .06em;
    text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   KPI cards
   -------------------------------------------------------------------------- */

.kpi-row {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.kpi {
    position: relative;
    display: block;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
    color: inherit;
    box-shadow: var(--shadow-xs);
    overflow: hidden;
    transition: border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}

a.kpi:hover { border-color: #d7dbe2; box-shadow: var(--shadow-sm); color: inherit; }
a.kpi.is-active { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }

.kpi-head { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; }
.kpi-head span { color: var(--muted); font-size: 12px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-value { display: block; font-size: 21px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-foot { display: flex; align-items: center; gap: 5px; margin-top: 4px; color: var(--muted); font-size: 11.5px; }
.kpi-foot .ico { color: currentColor; }
.kpi-foot.is-up { color: var(--green-ink); }
.kpi-foot.is-down { color: var(--red-ink); }

/* Variante semplice: solo etichetta + valore, senza indicatori. */
.kpi > span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; font-weight: 550; }
.kpi > strong:not(.kpi-value) { font-size: 20px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

.kpi-share { margin: 12px -14px -14px; height: 4px; background: var(--line-soft); }
.kpi-share i { display: block; height: 100%; border-radius: 0 var(--pill) var(--pill) 0; background: var(--faint); }
.kpi-tone-blue .kpi-share i { background: var(--brand); }
.kpi-tone-green .kpi-share i { background: var(--green); }
.kpi-tone-purple .kpi-share i { background: var(--purple); }
.kpi-tone-cyan .kpi-share i { background: var(--cyan); }
.kpi-tone-red .kpi-share i { background: var(--red); }
.kpi-tone-amber .kpi-share i { background: var(--amber); }

.kpi-tone-red .kpi-value { color: var(--red-ink); }
.kpi-tone-green .kpi-value { color: var(--green-ink); }

/* --------------------------------------------------------------------------
   Toolbar + chips
   -------------------------------------------------------------------------- */

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 11px;
    border: 1px solid var(--line);
    border-radius: var(--pill);
    background: var(--paper);
    color: var(--ink-soft);
    font-size: 12.5px;
    font-weight: 550;
    white-space: nowrap;
    box-shadow: var(--shadow-xs);
    transition: background .14s ease, border-color .14s ease, color .14s ease;
}

.chip:hover { background: #fbfbfc; border-color: #dcdfe4; color: var(--ink); }
.chip b { color: var(--muted); font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; }

.chip.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip.is-active:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.chip.is-active b {
    padding: 0 5px;
    border-radius: var(--pill);
    background: rgba(255, 255, 255, .22);
    color: #fff;
}

.toolbar-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

.advanced-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
    box-shadow: var(--shadow-xs);
}

/* Macrofiltri: restringono card, chip e tabella allo stesso ambito. */
.scope-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
    box-shadow: var(--shadow-xs);
}

.scope-bar.is-active {
    border-color: #c7d7fe;
    background: #f5f8ff;
}

.scope-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding-right: 4px;
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.scope-title .ico { color: var(--brand); }

.scope-field { display: inline-flex; align-items: center; gap: 7px; margin: 0; }
.scope-field-label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.scope-field .form-select { width: auto; min-width: 190px; }

.scope-hint {
    margin-left: auto;
    color: var(--muted);
    font-size: 12.5px;
}

.scope-reset {
    color: var(--brand);
    font-size: 12.5px;
    font-weight: 600;
}

.scope-reset:hover { text-decoration: underline; }

.advanced-filters[hidden] { display: none; }
.advanced-filters .af-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.advanced-filters .search-inline { display: flex; gap: 8px; margin-left: auto; min-width: 280px; }

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.card-box {
    padding: 18px;
    margin-bottom: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
    box-shadow: var(--shadow-xs);
}

.card-box > h2 {
    margin: 0 0 14px;
    font-size: 14.5px;
    font-weight: 620;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.card-head h2 { margin: 0; font-size: 14.5px; font-weight: 620; }

/* --------------------------------------------------------------------------
   Data table
   -------------------------------------------------------------------------- */

.data-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
}

.bulk-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    background: var(--brand-soft);
}

.bulk-bar[hidden] { display: none; }
.bulk-bar .bulk-count { color: var(--brand-dark); font-size: 13px; font-weight: 600; }
.bulk-actions { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }

.table-wrap { overflow-x: auto; }

.table {
    width: 100%;
    margin: 0;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.table thead th {
    padding: 9px 12px;
    border-bottom: 1px solid var(--line);
    background: #fcfcfd;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
}

.table tbody td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
    color: var(--ink-soft);
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s ease; }
.table tbody tr:hover { background: #fcfcfd; }
.table tbody tr.is-selected { background: var(--brand-soft); }
.table .col-check { width: 40px; padding-right: 0; }
.table .col-chevron { width: 36px; text-align: right; }
.table .col-chevron .ico { color: var(--faint); margin-left: auto; }
.table .cell-amount { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .cell-actions { width: 1%; white-space: nowrap; }
.table .cell-actions form,
.table .cell-actions .icon-btn { display: inline-flex; vertical-align: middle; margin: 0 0 0 6px; }
.table .cell-actions form:first-child,
.table .cell-actions .icon-btn:first-child { margin-left: 0; }
.table .col-grow { width: 99%; }

.note-form { margin-bottom: 8px; }
.note-list { margin: 18px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; }
.note-list li {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--paper);
}
.note-list p { margin: 0 0 8px; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; }
.note-list small { color: var(--muted); font-size: 12px; }
.table tr.is-muted td { color: var(--muted); }
.table .empty-cell { padding: 44px 16px; text-align: center; color: var(--muted); }

.row-clickable { cursor: pointer; }
.table tbody tr.is-open { background: var(--brand-soft); box-shadow: inset 2px 0 0 var(--brand); }

.cell-client { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-client .client-text { min-width: 0; line-height: 1.3; }
.cell-client .client-name { display: block; color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-client .client-sub { display: block; color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.comm-list { display: flex; flex-direction: column; gap: 3px; }

.comm-line {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--muted);
    font-size: 11.5px;
    white-space: nowrap;
}

.comm-line .ico { color: var(--faint); }
.comm-line.tone-green { color: var(--green-ink); }
.comm-line.tone-green .ico { color: var(--green); }
.comm-line.tone-blue { color: #175cd3; }
.comm-line.tone-blue .ico { color: var(--brand); }
.comm-line.tone-red { color: var(--red-ink); }
.comm-line.tone-red .ico { color: var(--red); }
.comm-line.tone-amber { color: var(--amber-ink); }
.comm-line.tone-amber .ico { color: var(--amber); }

.activity-cell { display: flex; align-items: flex-start; gap: 6px; min-width: 0; }
.activity-cell .ico { margin-top: 2px; color: var(--faint); }
.activity-cell .activity-text { min-width: 0; line-height: 1.3; }
.activity-cell .activity-when { display: block; color: var(--ink-soft); font-size: 12px; font-weight: 550; }
.activity-cell .activity-what { display: block; color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }

.table-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 14px;
    border-top: 1px solid var(--line);
    background: #fcfcfd;
    color: var(--muted);
    font-size: 12.5px;
    flex-wrap: wrap;
}

.per-page { display: flex; align-items: center; gap: 7px; }

.per-page select {
    height: 30px;
    min-height: 30px;
    padding: 0 24px 0 9px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2398a2b3' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9.5l6 6 6-6'/%3E%3C/svg%3E") right 5px center/13px no-repeat;
    color: var(--ink-soft);
    font-family: inherit;
    font-size: 12.5px;
    appearance: none;
    cursor: pointer;
}

.pager { display: flex; align-items: center; gap: 3px; }

.pager a,
.pager span {
    display: grid;
    place-items: center;
    min-width: 30px;
    height: 30px;
    padding: 0 7px;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--ink-soft);
    font-size: 12.5px;
    font-weight: 550;
    font-variant-numeric: tabular-nums;
}

.pager a:hover { background: var(--line-soft); color: var(--ink); }
.pager .is-current { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager .is-disabled { color: #cdd2da; }
.pager .gap { color: var(--faint); }

/* --------------------------------------------------------------------------
   Pills / badges
   -------------------------------------------------------------------------- */

.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border: 1px solid transparent;
    border-radius: var(--pill);
    background: var(--line-soft);
    color: var(--ink-soft);
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-status::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: .85;
}

.badge-status.no-dot::before { display: none; }
.badge-status.big { padding: 5px 12px; font-size: 12.5px; }

/* La palette è limitata a .badge-status: le classi .tone-* restano
   riutilizzabili altrove senza trascinarsi dietro uno sfondo. */
.badge-status.tone-blue,
.badge-status.status-open,
.badge-status.deadline-in_window,
.badge-status.consegnato,
.badge-status.cliccato { background: var(--brand-soft); color: #175cd3; }

.badge-status.tone-green,
.badge-status.status-paid,
.badge-status.deadline-paid_in_time,
.badge-status.pagato,
.badge-status.aperta,
.badge-status.letto,
.badge-status.letta { background: var(--green-soft); color: var(--green-ink); }

.badge-status.tone-purple,
.badge-status.status-partial,
.badge-status.parziale { background: var(--purple-soft); color: var(--purple-ink); }

.badge-status.tone-amber,
.badge-status.deadline-paid_late,
.badge-status.inviata,
.badge-status.inviato,
.badge-status.nuovo,
.badge-status.aperto { background: var(--amber-soft); color: var(--amber-ink); }

.badge-status.tone-red,
.badge-status.deadline-overdue,
.badge-status.errore { background: var(--red-soft); color: var(--red-ink); }

.badge-status.tone-gray,
.badge-status.status-cancelled,
.badge-status.deadline-not_contacted,
.badge-status.deadline-cancelled,
.badge-status.chiuso,
.badge-status.mai-cliccato { background: var(--line-soft); color: var(--muted); }

.badge-status.deadline-overdue { font-weight: 650; }

.pill-time {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: var(--pill);
    background: var(--line-soft);
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.pill-time.tone-amber { background: var(--amber-soft); color: var(--amber-ink); }
.pill-time.tone-red { background: var(--red-soft); color: var(--red-ink); }
.pill-time.tone-blue { background: var(--brand-soft); color: #175cd3; }
.pill-time.tone-green { background: var(--green-soft); color: var(--green-ink); }

.badge-label {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--pill);
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
}
.badge-label.label-peer,
.badge-label.label-admin { background: var(--purple-soft); color: var(--purple-ink); }
.badge-label.label-segreteria { background: var(--cyan-soft); color: var(--cyan-ink); }

.client-assign {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

.assign-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
}
.assign-form .scope-field .form-select { min-width: 160px; }
.assign-comment { display: flex; flex-direction: column; gap: 4px; flex: 1 1 100%; margin: 0; }
.assign-comment .form-control { min-height: 64px; }
.assign-block { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.assign-block .assign-form { flex-direction: column; align-items: stretch; }
.assign-block .assign-form .scope-field { display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
.assign-block .assign-form .form-select { min-width: 0; width: 100%; }

/* --------------------------------------------------------------------------
   Detail drawer
   -------------------------------------------------------------------------- */

.detail-backdrop {
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(16, 24, 40, .35);
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
}

body.detail-open .detail-backdrop { opacity: 1; visibility: visible; }

.detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    width: var(--detail-w);
    max-width: 100vw;
    display: flex;
    flex-direction: column;
    background: var(--paper);
    border-left: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    transform: translateX(102%);
    transition: transform .24s cubic-bezier(.32, .72, 0, 1);
}

body.detail-open .detail-panel { transform: translateX(0); }

.detail-body { flex: 1; overflow: hidden auto; scrollbar-width: thin; }

.detail-loading { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: 13px; }

.detail-head {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--line);
}

.detail-head .detail-id { flex: 1; min-width: 0; }
.detail-head h2 { margin: 0 0 2px; font-size: 15.5px; font-weight: 650; }
.detail-head .detail-contacts { color: var(--muted); font-size: 12px; line-height: 1.5; word-break: break-word; }

.detail-flag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 5px;
    color: var(--green-ink);
    font-size: 11.5px;
    font-weight: 600;
}

.detail-flag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.detail-flag.is-closed { color: var(--muted); }
.detail-flag.is-closed::before { background: var(--faint); }

.detail-tabs { display: flex; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--line); }

.detail-tab {
    padding: 10px 9px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--muted);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 550;
    cursor: pointer;
    transition: color .14s ease, border-color .14s ease;
}

.detail-tab:hover { color: var(--ink); }
.detail-tab.is-active { color: var(--brand-dark); border-bottom-color: var(--brand); font-weight: 620; }

.detail-pane { padding: 16px; }
.detail-pane[hidden] { display: none; }

.detail-block { padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--line-soft); }
.detail-block:last-child { padding-bottom: 0; margin-bottom: 0; border-bottom: 0; }

.detail-block > h3 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 620;
}

.detail-block > h3 .link-more { color: var(--brand); font-size: 12px; font-weight: 550; display: inline-flex; align-items: center; gap: 4px; }

.amount-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.amount-row .field-label { display: block; color: var(--muted); font-size: 11.5px; margin-bottom: 3px; }
.amount-row .amount-big { font-size: 22px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

.kv-list { display: grid; gap: 8px; margin: 12px 0 0; }
.kv-list > div { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kv-list dt { color: var(--muted); font-size: 12px; font-weight: 500; }
.kv-list dd { margin: 0; color: var(--ink-soft); font-size: 12.5px; font-weight: 550; text-align: right; font-variant-numeric: tabular-nums; }

.detail-cta { display: flex; gap: 6px; margin-top: 14px; }
.detail-cta .btn { flex: 1; min-width: 0; }
.detail-cta .btn-icon { flex: 0 0 36px; padding: 0; }

.invoice-list { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; list-style: none; }

.invoice-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line-soft);
}

.invoice-row:last-child { border-bottom: 0; }
.invoice-row .invoice-id { flex: 1; min-width: 0; line-height: 1.35; }
.invoice-row .invoice-id strong { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink); }
.invoice-row .invoice-id small { color: var(--muted); font-size: 11.5px; }
.invoice-row .invoice-amount { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.invoice-row .invoice-doc { color: var(--red-ink); display: grid; place-items: center; }
.invoice-row .invoice-doc:hover { color: #912018; }

.timeline-feed { position: relative; margin: 0; padding: 0 0 0 22px; list-style: none; }

.timeline-feed::before {
    content: "";
    position: absolute;
    top: 6px;
    bottom: 10px;
    left: 5px;
    width: 1.5px;
    background: var(--line);
}

.timeline-feed > li { position: relative; padding: 0 0 16px; }
.timeline-feed > li:last-child { padding-bottom: 0; }

.timeline-feed > li::before {
    content: "";
    position: absolute;
    top: 9px;
    left: -22px;
    width: 11px;
    height: 11px;
    border: 2.5px solid var(--paper);
    border-radius: 50%;
    background: var(--brand);
    box-shadow: 0 0 0 1.5px var(--brand);
}

.timeline-feed > li.is-muted::before { background: var(--faint); box-shadow: 0 0 0 1.5px var(--line); }

.feed-item { display: flex; align-items: flex-start; gap: 9px; }

.feed-icon {
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    border-radius: var(--radius-sm);
    display: grid;
    place-items: center;
    background: var(--line-soft);
    color: var(--muted);
}

.feed-icon.tone-green { background: var(--green-soft); color: var(--green-ink); }
.feed-icon.tone-blue { background: var(--brand-soft); color: #175cd3; }
.feed-icon.tone-purple { background: var(--purple-soft); color: var(--purple-ink); }
.feed-icon.tone-red { background: var(--red-soft); color: var(--red-ink); }
.feed-icon.tone-amber { background: var(--amber-soft); color: var(--amber-ink); }

.feed-text { min-width: 0; line-height: 1.4; padding-top: 1px; }
.feed-text strong { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink); }
.feed-text span { display: block; color: var(--muted); font-size: 11.5px; }
.feed-text time { display: block; color: var(--faint); font-size: 11px; margin-top: 2px; }

.detail-foot { border-top: 1px solid var(--line); padding: 11px 14px 13px; background: #fcfcfd; }
.detail-foot form { margin: 0; }

/* --------------------------------------------------------------------------
   Meta lists, timeline, whatsapp thread
   -------------------------------------------------------------------------- */

.case-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.case-grid .card-box { margin-bottom: 0; }

.meta { display: grid; gap: 9px; margin: 0; }
.meta > div { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 10px; align-items: baseline; }
.meta dt { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.meta dd { margin: 0; color: var(--ink-soft); font-size: 13px; }

.actions-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions-row form { margin: 0; }

.upload-box { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.upload-box .form-control { flex: 1; min-width: 240px; }

.timeline { margin: 0; padding: 0; list-style: none; }
.timeline li { display: flex; align-items: baseline; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.timeline li:last-child { border-bottom: 0; }
.timeline time { flex: 0 0 130px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.wa-chat .wa-thread { margin: 0; padding: 8px 0 4px; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.wa-bubble {
    max-width: min(72%, 520px);
    padding: 9px 12px 10px;
    border-radius: 14px;
    border: 1px solid var(--line-soft);
    background: #f6f7f9;
}
.wa-bubble.is-out { align-self: flex-end; background: var(--green-soft); border-color: #b7ecca; }
.wa-bubble.is-in { align-self: flex-start; }
.wa-bubble.is-new { box-shadow: inset 3px 0 0 var(--open); }
.wa-bubble.is-failed { border-color: #fcd7d3; background: var(--red-soft); }
.wa-bubble .wa-body { white-space: pre-wrap; word-break: break-word; font-size: 13.5px; line-height: 1.45; }
.wa-foot {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
}
.wa-foot time { display: block; margin: 0; color: inherit; font-size: inherit; }
.wa-ticks {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    line-height: 0;
}
.wa-ticks.is-pending,
.wa-ticks.is-sent,
.wa-ticks.is-delivered { color: #8696a0; }
.wa-ticks.is-read { color: #53bdeb; }
.wa-ticks.is-failed { color: #e35d6a; }
.wa-media { display: block; margin: 2px 0 6px; }
.wa-media img { display: block; max-width: 100%; max-height: 360px; border-radius: 10px; }
.wa-player { display: block; width: 100%; max-width: 420px; margin: 2px 0 6px; }
.wa-file {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 2px 0 6px;
    padding: 7px 10px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--line);
    font-size: 13px;
}
.wa-download {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    font-size: 12.5px;
    font-weight: 550;
}
.wa-composer { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.wa-composer textarea {
    width: 100%;
    resize: vertical;
    min-height: 72px;
    margin-bottom: 8px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font: inherit;
}
.wa-composer textarea:disabled { background: #f4f5f6; }
.wa-composer-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.wa-composer-actions label.btn { margin: 0; cursor: pointer; }
.wa-composer-actions label.btn input[type=file] { display: none; }
.wa-composer-actions .btn-whatsapp { margin-left: auto; }
.wa-composer-actions .is-disabled { opacity: .5; pointer-events: none; }
.wa-window-note { margin: 0 0 10px; font-size: 12.5px; color: var(--amber-ink); }

.detail-pane .wa-thread { max-height: 360px; overflow-y: auto; padding-right: 4px; }
.detail-pane .wa-bubble { max-width: 92%; }

.table tbody tr.wa-unread,
.table tbody tr.wa-unread td { background: var(--amber-soft); }
.wa-preview { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --------------------------------------------------------------------------
   Alerts
   -------------------------------------------------------------------------- */

.alert {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 11px 38px 11px 13px;
    margin-bottom: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper);
    color: var(--ink-soft);
    font-size: 13px;
    box-shadow: var(--shadow-xs);
}

.alert-success { background: var(--green-soft); border-color: #b7ecca; color: var(--green-ink); }
.alert-danger { background: var(--red-soft); border-color: #fcd7d3; color: var(--red-ink); }
.alert-warning { background: var(--amber-soft); border-color: #fbe2ae; color: var(--amber-ink); }
.alert-info { background: var(--brand-soft); border-color: #c7d7fb; color: #175cd3; }

.alert .btn-close {
    position: absolute;
    top: 9px;
    right: 9px;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: 5px;
    background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E") center/11px no-repeat;
    opacity: .5;
    cursor: pointer;
}

.alert .btn-close:hover { opacity: .9; background-color: rgba(16, 24, 40, .06); }

/* --------------------------------------------------------------------------
   Modals (Bootstrap overrides)
   -------------------------------------------------------------------------- */

.modal-content { border: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.modal-header { padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.modal-title { font-size: 15.5px; font-weight: 620; }
.modal-body { padding: 16px 18px; font-size: 13.5px; }
.modal-body ul { margin: 8px 0 0; padding-left: 18px; }
.modal-footer { padding: 12px 18px 16px; border-top: 1px solid var(--line); gap: 8px; }
.modal-header .btn-close { width: 24px; height: 24px; }

/* --------------------------------------------------------------------------
   Empty state
   -------------------------------------------------------------------------- */

.empty-state { display: grid; justify-items: center; gap: 4px; padding: 52px 20px; text-align: center; }
.empty-state .empty-icon {
    width: 44px;
    height: 44px;
    margin-bottom: 6px;
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    background: var(--line-soft);
    color: var(--faint);
}
.empty-state strong { font-size: 14px; font-weight: 620; }
.empty-state p { margin: 0; color: var(--muted); font-size: 13px; }

/* --------------------------------------------------------------------------
   Auth
   -------------------------------------------------------------------------- */

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: radial-gradient(1200px 600px at 50% -10%, #eaf0ff 0%, var(--bg) 55%);
}

.auth-card {
    width: 100%;
    max-width: 384px;
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--paper);
    box-shadow: var(--shadow-md);
}

.auth-brand { display: flex; align-items: center; justify-content: center; margin-bottom: 24px; }
.auth-brand .brand-logo { width: 134px; }
.auth-brand .brand-text strong { font-size: 15px; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (min-width: 1500px) {
    body.detail-open .app-body { padding-right: var(--detail-w); }
    body.detail-open .detail-backdrop { opacity: 0; visibility: hidden; }
}

@media (max-width: 1280px) {
    .kpi-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .case-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1024px) {
    :root { --sidebar-w: 68px; }
    .sidebar .brand-text,
    .sidebar .brand-logo,
    .nav-item span,
    .nav-item .nav-badge,
    .sidebar-section,
    .quick-filters,
    .user-card .user-meta,
    .user-card > .ico { display: none; }
    /* Nella barra compatta resta solo il segno grafico del logo. */
    .sidebar .brand-logo-mark { display: block; }
    .sidebar-brand { justify-content: center; padding: 20px 0 18px; }
    .nav-item { justify-content: center; padding: 10px; }
    .user-card { justify-content: center; }
    .kbd { display: none; }
    .search-field input { padding-right: 12px; }
}

@media (max-width: 860px) {
    .app-main { padding: 16px 14px 36px; }
    .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .case-grid { grid-template-columns: minmax(0, 1fr); }
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar-actions { justify-content: flex-end; }
    .chips { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
    .advanced-filters .search-inline { margin-left: 0; min-width: 100%; }
    .scope-field { flex: 1 1 100%; }
    .scope-field .form-select { flex: 1; min-width: 0; }
    .scope-hint { margin-left: 0; }
    .detail-panel { width: 100%; }
    .page-head { flex-direction: column; }
    .meta > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
    .timeline li { flex-direction: column; gap: 2px; }
}

@media (max-width: 560px) {
    .kpi-row { grid-template-columns: minmax(0, 1fr); }
    .table-foot { justify-content: center; }
}
