/* =====================================================================
   Painel administrativo — Flávio Mendes Advogados Associados
   Paleta: #1D3D4B (azul-petróleo) · #C39C37 (dourado) · #F4F1EA (claro)
   Fontes: Inter (interface) · Cormorant Garamond (títulos) — as mesmas do app.

   Organização: 1. tokens · 2. base · 3. layout · 4. componentes · 5. páginas
                6. utilidades · 7. responsivo
   ===================================================================== */

/* ---------------------------------------------------------------------
   1. Tokens
   --------------------------------------------------------------------- */
:root {
    color-scheme: light;

    /* Marca */
    --primary: #1D3D4B;
    --primary-700: #132A34;
    --primary-600: #26505F;
    --primary-100: #e6edf0;
    --primary-rgb: 29, 61, 75;
    --gold: #C39C37;
    --gold-dark: #9A7A26;
    --gold-200: #f3d9ae;
    --gold-100: #f6ecdc;
    --gold-rgb: 195, 156, 55;

    /* Superfícies e texto */
    --light: #F4F1EA;
    --bg: #f7f7f5;
    --bg-soft: #faf9f6;
    --bg-hover: #fbfaf7;
    --white: #ffffff;
    --neutral-100: #eeece6;
    --neutral-200: #e9e5dc;
    --text: #1c2b31;
    --muted: #66757c;
    --border: #e3e0d8;
    --border-soft: #f0eee8;
    --border-strong: #cfcac0;

    /* Estados */
    --success: #2e7d4f;
    --success-700: #256641;
    --success-100: #e5f3ea;
    --danger: #b3261e;
    --danger-200: #e6b8b3;
    --danger-100: #fbe9e7;
    --warning: #a15c07;
    --warning-200: #eccb96;
    --warning-100: #fdf1dc;
    --info: #1f5d7a;
    --info-200: #b8d3e0;
    --info-100: #e3f0f6;

    /* Espaçamento (4 px) */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-7: 32px;
    --sp-8: 40px;

    /* Tipografia */
    --fs-xs: 11.5px;
    --fs-sm: 12.5px;
    --fs-base: 14px;
    --fs-md: 15px;
    --fs-lg: 16px;
    --fs-xl: 20px;
    --fs-display: 28px;
    --fs-stat: 30px;

    /* Forma */
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(14, 33, 41, .06), 0 1px 3px rgba(14, 33, 41, .05);
    --shadow-md: 0 6px 20px rgba(14, 33, 41, .08);
    --shadow-lg: 0 20px 60px rgba(14, 33, 41, .22);

    /* Camadas */
    --z-picker: 25;
    --z-topbar: 30;
    --z-backdrop: 35;
    --z-sidebar: 40;
    --z-menu: 50;
    --z-modal: 100;
    --z-toast: 110;

    /* Layout */
    --sidebar-w: 260px;
    --topbar-h: 65px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-title: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --ease: .15s ease;
}

/* ---------------------------------------------------------------------
   2. Base
   --------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    font-size: var(--fs-base);
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--gold-dark); text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; color: var(--primary); }
p { margin: 0 0 10px; }
img { max-width: 100%; }
code, .mono { font-family: var(--font-mono); font-size: var(--fs-sm); }
pre { margin: 0; }
summary { cursor: pointer; }
summary::-webkit-details-marker { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Foco visível (teclado) */
a:focus-visible, button:focus-visible, .btn:focus-visible, summary:focus-visible,
.nav-link:focus-visible, .tab:focus-visible, .chip:focus-visible, .stat:focus-visible, .picker-item:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------------------------------------------------------------------
   3. Layout
   --------------------------------------------------------------------- */
.app { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }
.content { flex: 1; padding: var(--sp-6) var(--sp-7); max-width: 1400px; width: 100%; }
.footer { padding: var(--sp-4) var(--sp-7); color: var(--muted); font-size: var(--fs-sm); border-top: 1px solid var(--border); background: var(--white); }

/* Sidebar */
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
    background: var(--primary); color: #fff;
    display: flex; flex-direction: column; z-index: var(--z-sidebar);
    box-shadow: 2px 0 12px rgba(0, 0, 0, .08);
}
.sidebar-logo { display: block; padding: 18px 18px 14px; border-bottom: 1px solid rgba(255, 255, 255, .08); text-decoration: none; }
.sidebar-logo:hover { text-decoration: none; }
.sidebar-logo img { display: block; width: 100%; height: auto; border-radius: 4px; }
.sidebar-logo-sub { display: block; margin-top: var(--sp-2); font-size: 10.5px; letter-spacing: 2px; text-transform: uppercase; color: var(--gold); text-align: center; }
.nav { flex: 1; overflow-y: auto; padding: var(--sp-3) 10px; }
.nav-menu { list-style: none; margin: 0; padding: 0; }
.nav-section { margin: var(--sp-4) 10px 6px; font-size: 10.5px; letter-spacing: 1.5px; text-transform: uppercase; color: rgba(255, 255, 255, .45); }
.nav-item { margin-bottom: 2px; }
.nav-link {
    display: flex; align-items: center; gap: 11px;
    padding: 9px var(--sp-3); border-radius: 8px;
    color: rgba(255, 255, 255, .82); font-size: var(--fs-base); font-weight: 500;
    border-left: 3px solid transparent;
    transition: background var(--ease), color var(--ease);
}
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(var(--gold-rgb), .16); color: #fff; border-left-color: var(--gold); }
.nav-link.active .icon { color: var(--gold); }
.nav-link:focus-visible { outline-offset: -2px; outline-color: var(--gold-200); }
.nav-label { flex: 1; }
.nav-badge { background: var(--gold); color: var(--primary-700); font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px; line-height: 1.5; }
.nav-badge[hidden] { display: none; }
.icon { flex-shrink: 0; }

.user-box { display: flex; align-items: center; gap: 10px; padding: 14px var(--sp-4); border-top: 1px solid rgba(255, 255, 255, .08); background: rgba(0, 0, 0, .12); }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--gold); color: var(--primary-700); display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.user-meta { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: rgba(255, 255, 255, .6); }
.logout-link { color: rgba(255, 255, 255, .7); padding: 6px; border-radius: 6px; display: flex; }
.logout-link:hover { color: #fff; background: rgba(255, 255, 255, .1); }

/* Topbar / cabeçalho da página */
.topbar {
    position: sticky; top: 0; z-index: var(--z-topbar);
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    min-height: var(--topbar-h);
    padding: 10px var(--sp-7); background: var(--white); border-bottom: 1px solid var(--border);
}
.page-heading { flex: 1; min-width: 0; }
.page-title { font-family: var(--font-title); font-size: var(--fs-display); font-weight: 700; line-height: 1.15; letter-spacing: .2px; }
.breadcrumb { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: var(--fs-sm); color: var(--muted); margin-bottom: 1px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { opacity: .5; }
.topbar-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.menu-toggle { display: none; width: 40px; height: 40px; border: 1px solid var(--border); background: var(--white); border-radius: 8px; cursor: pointer; padding: 10px 9px; flex-direction: column; justify-content: space-between; }
.menu-toggle span { display: block; height: 2px; background: var(--primary); border-radius: 2px; }
.sidebar-backdrop { display: none; }

/* ---------------------------------------------------------------------
   4. Componentes
   --------------------------------------------------------------------- */

/* Cards e estatísticas */
.card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp-5); margin-bottom: var(--sp-5); box-shadow: var(--shadow-sm); }
.card-header { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); flex-wrap: wrap; margin: -4px 0 var(--sp-4); padding-bottom: var(--sp-3); border-bottom: 1px solid var(--border); }
.card-title { font-size: var(--fs-lg); font-weight: 600; color: var(--primary); }
.card-subtitle { font-size: var(--fs-sm); color: var(--muted); }
.card-flush { padding: 0; }
.card-flush .card-header { margin: 0; padding: var(--sp-4) var(--sp-5); }
.card-flush .pagination { padding: 0 var(--sp-5) var(--sp-4); margin-top: var(--sp-3); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--sp-4); margin-bottom: 22px; }
.stat {
    background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
    padding: var(--sp-4) 18px; display: flex; flex-direction: column; gap: 4px;
    box-shadow: var(--shadow-sm); border-top: 3px solid var(--primary); color: var(--text);
    transition: box-shadow var(--ease), transform var(--ease);
}
a.stat:hover { text-decoration: none; box-shadow: var(--shadow-md); color: var(--text); transform: translateY(-1px); }
.stat.gold { border-top-color: var(--gold); }
.stat.alert { border-top-color: var(--danger); }
.stat.active { background: var(--gold-100); }
.stat-label { font-size: var(--fs-sm); color: var(--muted); text-transform: uppercase; letter-spacing: .6px; font-weight: 600; }
.stat-value { font-size: var(--fs-stat); font-weight: 700; color: var(--primary); line-height: 1.1; }
.stat-hint { font-size: var(--fs-sm); color: var(--muted); }

.grid { display: grid; gap: 18px; }
.grid > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-all { grid-column: 1 / -1; }
.layout-main-aside { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 18px; align-items: start; }
.layout-main-aside > * { min-width: 0; }

/* Formulários */
.form-group { margin-bottom: 14px; }
label { display: block; margin-bottom: 5px; font-weight: 600; font-size: 13px; color: var(--primary); }
label small, .help { font-weight: 400; color: var(--muted); font-size: var(--fs-sm); }
.help { display: block; margin-top: 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="datetime-local"], input[type="search"], input[type="tel"], input[type="url"],
input[type="file"], select, textarea {
    width: 100%; padding: 9px 11px; font: inherit; color: var(--text);
    background: var(--white); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    transition: border-color var(--ease), box-shadow var(--ease);
}
select { appearance: none; -webkit-appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2366757c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
select[multiple] { background-image: none; padding-right: 11px; }
input[type="file"] { padding: 7px; background: var(--bg); }
textarea { resize: vertical; min-height: 96px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(var(--gold-rgb), .18); }
input[disabled], select[disabled], textarea[disabled] { background: #f1f0ec; color: var(--muted); }
input::placeholder, textarea::placeholder { color: #9aa6ab; }
.checkbox { display: flex; align-items: center; gap: var(--sp-2); font-weight: 500; }
.checkbox input { width: auto; accent-color: var(--primary); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }

/* Erro por campo */
.is-invalid, input.is-invalid:focus, select.is-invalid:focus, textarea.is-invalid:focus { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(179, 38, 30, .14); }
.field-error { display: flex; align-items: center; gap: 5px; margin-top: 5px; font-size: var(--fs-sm); color: var(--danger); font-weight: 500; }
.field-error .icon { width: 14px; height: 14px; }

.form-section { margin-bottom: 22px; }
.form-section > h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--gold-dark); margin-bottom: var(--sp-3); padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: var(--sp-2); align-items: center; }
.form-actions .spacer { flex: 1; }

/* Grade de formulário em 12 colunas */
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 0 18px; }
.form-grid > * { min-width: 0; grid-column: span 12; }
.form-grid > .col-2 { grid-column: span 2; }
.form-grid > .col-3 { grid-column: span 3; }
.form-grid > .col-4 { grid-column: span 4; }
.form-grid > .col-5 { grid-column: span 5; }
.form-grid > .col-6 { grid-column: span 6; }
.form-grid > .col-8 { grid-column: span 8; }
.form-grid > .col-9 { grid-column: span 9; }
.form-grid > .col-12 { grid-column: span 12; }

/* Barra de filtros e chips */
.filters-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp-3); }
.filters-bar .form-group { margin: 0; min-width: 150px; }
.filters-bar .grow { flex: 1; min-width: 220px; }
.filters-bar input, .filters-bar select { padding: 8px 10px; }
.filters-bar .checkbox { padding-bottom: 9px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: -8px 0 var(--sp-4); }
.chips-label { font-size: var(--fs-sm); color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--white); border: 1px solid var(--border-strong); color: var(--text); font-size: var(--fs-sm); font-weight: 500; line-height: 1.4; transition: background var(--ease), border-color var(--ease); }
.chip:hover { text-decoration: none; border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip .chip-count { background: rgba(0, 0, 0, .08); padding: 0 6px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.chip.active .chip-count { background: rgba(255, 255, 255, .22); }
.chip .icon { width: 13px; height: 13px; opacity: .7; }
.chip-remove { color: var(--muted); }
.chip-remove:hover { color: var(--danger); }

/* Botões */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px var(--sp-4); font: inherit; font-size: var(--fs-base); font-weight: 600; line-height: 1.2;
    border: 1px solid transparent; border-radius: var(--radius-sm); cursor: pointer;
    text-decoration: none; white-space: nowrap; position: relative;
    transition: background var(--ease), color var(--ease), border-color var(--ease), box-shadow var(--ease);
}
.btn:hover { text-decoration: none; }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); color: #fff; }
.btn-secondary { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-secondary:hover { background: var(--primary-100); color: var(--primary); }
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: var(--gold-dark); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border-strong); }
.btn-ghost:hover { color: var(--primary); border-color: var(--primary); background: var(--white); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: var(--success-700); color: #fff; }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger-200); }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: #8f1d16; color: #fff; }
.btn-warning { background: transparent; color: var(--warning); border-color: var(--warning-200); }
.btn-warning:hover { background: var(--warning-100); color: var(--warning); }
.btn-info { background: transparent; color: var(--info); border-color: var(--info-200); }
.btn-info:hover { background: var(--info-100); color: var(--info); }
.btn-sm { padding: 5px 10px; font-size: var(--fs-sm); }
.btn-sm .icon { width: 14px; height: 14px; }
.btn-lg { padding: 12px 22px; font-size: var(--fs-md); }
.btn-block { width: 100%; }
.btn-icon { padding: 7px; width: 34px; height: 34px; }
.btn-icon.btn-sm { padding: 5px; width: 28px; height: 28px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
    content: ''; position: absolute; width: 16px; height: 16px; left: calc(50% - 8px); top: calc(50% - 8px);
    border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; border-radius: 50%;
    animation: girar .7s linear infinite;
}
.btn-secondary.is-loading::after, .btn-ghost.is-loading::after, .btn-danger.is-loading::after, .btn-warning.is-loading::after, .btn-info.is-loading::after { border-color: rgba(var(--primary-rgb), .25); border-top-color: var(--primary); }
@keyframes girar { to { transform: rotate(360deg); } }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.inline-form { display: inline; margin: 0; }
.row-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; white-space: nowrap; }

/* Menu de ações (⋯) com <details> */
.menu { position: relative; display: inline-block; }
.menu > summary { list-style: none; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: var(--z-menu); min-width: 180px; padding: 6px; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); }
.menu.menu-up .menu-list { top: auto; bottom: calc(100% + 4px); }
.menu-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border: 0; border-radius: 5px; background: transparent; font: inherit; font-size: 13.5px; color: var(--text); text-align: left; cursor: pointer; white-space: nowrap; }
.menu-item:hover { background: var(--bg-soft); color: var(--primary); text-decoration: none; }
.menu-item .icon { width: 15px; height: 15px; color: var(--muted); }
.menu-item-danger { color: var(--danger); }
.menu-item-danger:hover { background: var(--danger-100); color: var(--danger); }
.menu-item-danger .icon { color: var(--danger); }
.menu-sep { height: 1px; margin: 5px 4px; background: var(--border-soft); }

/* Tabelas */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
    text-align: left; padding: 10px var(--sp-3); font-size: var(--fs-xs); font-weight: 600;
    text-transform: uppercase; letter-spacing: .5px; color: var(--muted);
    background: var(--bg-soft); border-bottom: 1px solid var(--border); white-space: nowrap;
}
thead th.th-acoes { text-align: right; }
tbody td { padding: 11px var(--sp-3); border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }
tr.row-highlight { background: #fdf8ef; }
tr.row-highlight:hover { background: #fbf2e2; }
td.empty { text-align: center; padding: 34px var(--sp-3); color: var(--muted); }
.cell-muted { color: var(--muted); font-size: var(--fs-sm); }
.cell-truncate { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.numero-processo { font-family: var(--font-mono); font-size: var(--fs-sm); background: var(--primary-100); color: var(--primary); padding: 2px 7px; border-radius: 4px; white-space: nowrap; }
.row-link { font-weight: 600; color: var(--text); }
.row-link:hover { color: var(--primary); }

/* Estado vazio */
.empty-state { text-align: center; padding: var(--sp-8) var(--sp-5); color: var(--muted); }
.empty-state .icon { width: 36px; height: 36px; color: var(--border-strong); margin-bottom: 10px; }
.empty-state h3 { font-size: var(--fs-md); color: var(--primary); margin-bottom: 4px; }
.empty-state p { margin-bottom: 14px; }
td.empty .empty-state { padding: var(--sp-4) 0; }

/* Badges */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; line-height: 1.4; white-space: nowrap; background: var(--neutral-100); color: var(--muted); }
.badge-success, .badge-ativo, .badge-vinculada, .badge-concluido, .badge-enviado, .badge-concluido { background: var(--success-100); color: var(--success); }
.badge-danger, .badge-inativo, .badge-descartada, .badge-falhou, .badge-token_invalido { background: var(--danger-100); color: var(--danger); }
.badge-warning, .badge-pendente, .badge-novo, .badge-processando { background: var(--warning-100); color: var(--warning); }
.badge-info, .badge-em_analise, .badge-aberta { background: var(--info-100); color: var(--info); }
.badge-primary, .badge-admin { background: var(--primary); color: #fff; }
.badge-gold, .badge-atendente { background: var(--gold-100); color: var(--gold-dark); }
.badge-count { background: var(--gold); color: #fff; }
.badge-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; background: currentColor; }

/* Alertas e toasts */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: var(--sp-3) 14px; border-radius: var(--radius-sm); margin-bottom: var(--sp-4); border: 1px solid; border-left-width: 4px; font-size: var(--fs-base); }
.alert > .icon { flex-shrink: 0; margin-top: 2px; }
.alert-body { flex: 1; min-width: 0; }
.alert-success { background: var(--success-100); color: #1f5a38; border-color: #b9dcc6; border-left-color: var(--success); }
.alert-error { background: var(--danger-100); color: #8a1f18; border-color: #efc2bd; border-left-color: var(--danger); }
.alert-warning { background: var(--warning-100); color: #7a4605; border-color: #efd4a5; border-left-color: var(--warning); }
.alert-info { background: var(--info-100); color: #174a61; border-color: #bcd8e5; border-left-color: var(--info); }
.alert-close { background: transparent; border: 0; padding: 2px; cursor: pointer; color: inherit; opacity: .6; display: flex; }
.alert-close:hover { opacity: 1; }
.disclaimer { font-size: var(--fs-sm); color: var(--muted); background: var(--light); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 10px var(--sp-3); margin-bottom: var(--sp-4); }

.toast-stack { position: fixed; right: var(--sp-5); bottom: var(--sp-5); z-index: var(--z-toast); display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast-stack .alert { margin: 0; box-shadow: var(--shadow-lg); pointer-events: auto; background: var(--white); animation: toast-in .25s ease; }
.toast-stack .alert.saindo { animation: toast-out .25s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(12px); } }

/* Diálogo (confirmação) e lightbox */
.dialog { border: 0; padding: 0; background: transparent; max-width: calc(100vw - 32px); }
.dialog::backdrop { background: rgba(14, 33, 41, .5); backdrop-filter: blur(2px); }
.dialog-box { width: 440px; max-width: 100%; background: var(--white); border-radius: var(--radius-lg); padding: var(--sp-6); box-shadow: var(--shadow-lg); margin: 0; }
.dialog-icon { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 14px; background: var(--primary-100); color: var(--primary); }
.dialog-icon .icon { width: 22px; height: 22px; }
.dialog.perigo .dialog-icon { background: var(--danger-100); color: var(--danger); }
.dialog-title { font-size: var(--fs-xl); font-weight: 600; margin-bottom: 6px; }
.dialog-text { color: var(--muted); margin-bottom: var(--sp-5); white-space: pre-line; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.lightbox { border: 0; padding: 0; background: transparent; max-width: 96vw; max-height: 96vh; }
.lightbox::backdrop { background: rgba(14, 33, 41, .85); }
.lightbox img { display: block; max-width: 96vw; max-height: 90vh; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); }
.lightbox-close { position: fixed; top: var(--sp-4); right: var(--sp-4); }

/* Detalhes, abas, paginação */
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--sp-6); }
.detail-item { padding: 9px 0; border-bottom: 1px solid var(--border-soft); }
.detail-item .detail-label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 2px; }
.detail-item .detail-value { font-size: 14.5px; color: var(--text); font-weight: 500; word-break: break-word; }
.detail-full { grid-column: 1 / -1; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab { padding: 9px 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; align-items: center; gap: 6px; }
.tab:hover { color: var(--primary); text-decoration: none; }
.tab.active { color: var(--primary); border-bottom-color: var(--gold); }

.pagination { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; margin-top: var(--sp-4); }
.pagination a, .pagination span { min-width: 34px; padding: 6px 10px; text-align: center; border: 1px solid var(--border); border-radius: 6px; background: var(--white); font-size: 13px; }
.pagination a:hover { border-color: var(--primary); text-decoration: none; }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .gap { border: none; background: transparent; }

.text-box { background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; white-space: pre-wrap; word-break: break-word; line-height: 1.6; max-height: 520px; overflow: auto; }
.json-box { background: var(--primary-700); color: #e9eef0; border-radius: var(--radius-sm); padding: var(--sp-3); font-size: 12px; white-space: pre-wrap; word-break: break-word; max-height: 360px; overflow: auto; }
.restricted { display: flex; align-items: center; gap: 10px; padding: 14px; border-radius: var(--radius-sm); background: var(--light); color: var(--muted); border: 1px dashed var(--border-strong); }

.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 10px 0; border-bottom: 1px solid var(--border-soft); display: flex; justify-content: space-between; gap: var(--sp-3); align-items: center; }
.list-plain li:last-child { border-bottom: none; }

/* Upload */
.upload-area { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 26px; text-align: center; cursor: pointer; background: var(--bg-hover); transition: border-color var(--ease), background var(--ease); }
.upload-area:hover, .upload-area.dragover { border-color: var(--gold); background: var(--gold-100); }
.upload-area .file-input { display: none; }
.upload-area .icon { color: var(--gold-dark); }
.upload-text { font-weight: 600; color: var(--primary); margin: 6px 0 2px; }
.upload-subtext { font-size: var(--fs-sm); color: var(--muted); }
.thumb { width: 64px; height: 46px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); display: block; }
.thumb-empty { width: 64px; height: 46px; border-radius: 4px; background: var(--neutral-100); }

/* Seletor de cliente (autocomplete) */
.picker { position: relative; }
.picker-input[aria-expanded="true"] { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.picker-results { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: var(--z-picker); background: var(--white); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); max-height: 280px; overflow-y: auto; }
.picker-item { display: block; width: 100%; text-align: left; padding: 9px var(--sp-3); border: 0; border-bottom: 1px solid var(--border-soft); background: transparent; font: inherit; color: var(--text); cursor: pointer; }
.picker-item:hover, .picker-item:focus, .picker-item[aria-selected="true"] { background: var(--gold-100); outline: none; }
.picker-item small { display: block; color: var(--muted); font-size: var(--fs-sm); }
.picker-empty { padding: 10px var(--sp-3); color: var(--muted); font-size: 13px; }

/* Conversas (chat) — layout atual; o inbox novo entra na Fase 3 */
.chat { display: flex; flex-direction: column; height: calc(100vh - 220px); min-height: 460px; padding: 0; overflow: hidden; }
.chat-header { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.chat-body { flex: 1; overflow-y: auto; padding: 18px; background: var(--light); display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 72%; padding: 10px 13px; border-radius: 12px; box-shadow: var(--shadow-sm); word-break: break-word; }
.bubble-cliente { align-self: flex-start; background: var(--white); border: 1px solid var(--border); border-bottom-left-radius: 3px; }
.bubble-equipe { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 3px; }
.bubble-equipe a { color: var(--gold-200); }
.bubble-meta { font-size: 11px; opacity: .72; margin-top: 5px; }
.bubble-author { font-size: var(--fs-xs); font-weight: 600; margin-bottom: 3px; }
.bubble-equipe .bubble-author { color: var(--gold-200); }
.bubble-text { white-space: pre-wrap; }
.bubble-attach { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; padding: 6px 9px; border-radius: 6px; background: rgba(0, 0, 0, .06); font-size: var(--fs-sm); }
.bubble-equipe .bubble-attach { background: rgba(255, 255, 255, .12); }
.chat-form { border-top: 1px solid var(--border); padding: var(--sp-3) 14px; background: var(--white); }
.chat-form textarea { min-height: 64px; }
.chat-form-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: var(--sp-2); }
.chat-form-row input[type="file"] { flex: 1; min-width: 200px; }
.day-sep { align-self: center; font-size: 11px; color: var(--muted); background: var(--neutral-200); padding: 2px 10px; border-radius: 10px; }
.chat-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.chat-layout .card { margin-bottom: 0; }

/* Importação */
.status-ok { color: var(--success); font-weight: 600; }
.status-ignorar { color: var(--danger); font-weight: 600; }
.steps { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: 18px; }
.step { padding: 6px var(--sp-3); border-radius: 999px; background: var(--neutral-100); color: var(--muted); font-size: var(--fs-sm); font-weight: 600; }
.step.active { background: var(--primary); color: #fff; }

/* ---------------------------------------------------------------------
   5. Login e páginas centralizadas
   --------------------------------------------------------------------- */
.page-center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: var(--sp-5); background: var(--primary); background-image: radial-gradient(circle at 20% 10%, rgba(var(--gold-rgb), .16), transparent 45%), radial-gradient(circle at 90% 90%, rgba(255, 255, 255, .06), transparent 40%); }
.center-card { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 420px; padding: 34px var(--sp-7); text-align: center; }
.center-card h1 { font-family: var(--font-title); font-size: 30px; margin: 6px 0 8px; }
.center-card p { color: var(--muted); }
.center-card-icon { font-family: var(--font-title); font-size: 46px; color: var(--gold); font-weight: 700; }
.login-card { text-align: left; }
.login-logo { background: var(--primary); border-radius: var(--radius); padding: var(--sp-3); margin-bottom: 22px; }
.login-logo img { display: block; width: 100%; height: auto; }
.login-card h1 { text-align: center; }
.login-card .lead { text-align: center; margin-bottom: var(--sp-5); }
.login-footer { text-align: center; margin-top: 18px; font-size: var(--fs-sm); color: var(--muted); }

/* ---------------------------------------------------------------------
   6. Utilidades
   --------------------------------------------------------------------- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--muted); }
.text-small { font-size: var(--fs-sm); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-wrap-any { overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0; } .mt-10 { margin-top: 10px; } .mt-20 { margin-top: 20px; }
.mb-0 { margin-bottom: 0; } .mb-10 { margin-bottom: 10px; } .mb-20 { margin-bottom: 20px; }
.flex { display: flex; } .flex-wrap { flex-wrap: wrap; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.gap-10 { gap: 10px; } .gap-20 { gap: 20px; }
.w-240 { min-width: 240px; } .max-560 { max-width: 560px; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------------
   7. Responsivo
   --------------------------------------------------------------------- */
@media (min-width: 1200px) {
    /* Cabeçalho de tabela fixo abaixo da topbar (só quando a tabela cabe na largura) */
    .card-flush .table-responsive { overflow: visible; }
    .card-flush thead th { position: sticky; top: var(--topbar-h); z-index: 1; }
}
@media (max-width: 1100px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .chat-layout, .layout-main-aside { grid-template-columns: minmax(0, 1fr); }
    .form-grid > .col-3, .form-grid > .col-4 { grid-column: span 6; }
    .form-grid > .col-2 { grid-column: span 3; }
}
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
    body.menu-open .sidebar { transform: translateX(0); }
    body.menu-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(14, 33, 41, .45); z-index: var(--z-backdrop); }
    .main { margin-left: 0; }
    .menu-toggle { display: inline-flex; }
    .topbar { padding: 10px var(--sp-4); }
    .page-title { font-size: 23px; }
    .content { padding: var(--sp-4); }
    .footer { padding: 14px var(--sp-4); }
    .bubble { max-width: 90%; }
    .toast-stack { right: var(--sp-4); bottom: var(--sp-4); }
}
@media (max-width: 640px) {
    .grid-2, .grid-3, .grid-4, .detail-grid { grid-template-columns: minmax(0, 1fr); }
    .form-grid > * { grid-column: span 12 !important; }
    .btn { white-space: normal; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .stat-value { font-size: 24px; }
    .topbar-actions { width: 100%; }
    .filters-bar .form-group, .filters-bar .grow { min-width: 100%; }
    .card { padding: 14px; }
    .card-flush { padding: 0; }
    .chat { height: calc(100vh - 170px); }
    .dialog-box { padding: var(--sp-5); }
    .dialog-actions .btn { flex: 1; }

    /* Tabelas viram cartões: <table class="table-cards"> + td[data-label] (painel.js preenche) */
    table.table-cards thead { display: none; }
    table.table-cards, table.table-cards tbody, table.table-cards tr, table.table-cards td { display: block; width: 100%; }
    table.table-cards tr { border-bottom: 1px solid var(--border); padding: 10px 14px; }
    table.table-cards tr:last-child { border-bottom: 0; }
    table.table-cards td { display: flex; gap: 10px; justify-content: space-between; align-items: center; padding: 5px 0; border: 0; text-align: right; }
    table.table-cards td::before { content: attr(data-label); flex-shrink: 0; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; text-align: left; }
    table.table-cards td[data-label=""]::before, table.table-cards td.empty::before { display: none; }
    table.table-cards td.empty { display: block; text-align: center; }
    table.table-cards td .row-actions { justify-content: flex-end; }
    table.table-cards td .cell-truncate { max-width: 100%; white-space: normal; }
}
