/* =========================================================
   Quantaviz BI — design system
   Inspirado em Stripe / Linear / Notion / Vercel / shadcn:
   neutro, clean, espaçamento generoso, sombras discretas.
   ========================================================= */

:root {
    --bg: #fafafa;
    --surface: #ffffff;
    --surface-2: #f4f4f5;
    --surface-3: #ececee;
    --border: #e4e4e7;
    --border-strong: #d4d4d8;
    --text: #18181b;
    --text-muted: #71717a;
    --text-faint: #a1a1aa;

    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-soft: #eef2ff;
    --accent-ink: #ffffff;
    --accent-ring: rgba(79, 70, 229, 0.28);

    --success: #16a34a;
    --success-soft: #f0fdf4;
    --success-ink: #15803d;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --danger-ink: #b91c1c;
    --warning: #d97706;
    --warning-soft: #fffbeb;
    --warning-ink: #b45309;

    --sidebar-grad-start: #ffffff;
    --sidebar-grad-end: #f2f2f4;
    --sidebar-border: #e4e4e7;
    --sidebar-tile-bg: #ffffff;
    --sidebar-tile-border: #e4e4e7;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(24, 24, 27, 0.05);
    --shadow-md: 0 4px 16px rgba(24, 24, 27, 0.08);
    --shadow-lg: 0 16px 40px rgba(24, 24, 27, 0.14);

    --sidebar-w: 260px;
    --sidebar-w-collapsed: 72px;
    --topbar-h: 64px;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: var(--font-sans);
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #09090b;
        --surface: #18181b;
        --surface-2: #212124;
        --surface-3: #27272a;
        --border: #27272a;
        --border-strong: #3f3f46;
        --text: #fafafa;
        --text-muted: #a1a1aa;
        --text-faint: #71717a;

        --accent: #818cf8;
        --accent-hover: #a5b4fc;
        --accent-soft: #1e1b4b;
        --accent-ink: #1e1a3d;
        --accent-ring: rgba(129, 140, 248, 0.35);

        --success: #4ade80;
        --success-soft: #0f2417;
        --success-ink: #86efac;
        --danger: #f87171;
        --danger-soft: #2c1416;
        --danger-ink: #fca5a5;
        --warning: #fbbf24;
        --warning-soft: #2a2010;
        --warning-ink: #fcd34d;

        --sidebar-grad-start: #18181b;
        --sidebar-grad-end: #0d0d0f;
        --sidebar-border: #27272a;
        --sidebar-tile-bg: #212124;
        --sidebar-tile-border: #3f3f46;

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
        --shadow-lg: 0 24px 56px rgba(0, 0, 0, 0.6);
    }
}
:root[data-theme="dark"] {
    --bg: #09090b; --surface: #18181b; --surface-2: #212124; --surface-3: #27272a;
    --border: #27272a; --border-strong: #3f3f46;
    --text: #fafafa; --text-muted: #a1a1aa; --text-faint: #71717a;
    --accent: #818cf8; --accent-hover: #a5b4fc; --accent-soft: #1e1b4b; --accent-ink: #1e1a3d; --accent-ring: rgba(129, 140, 248, 0.35);
    --success: #4ade80; --success-soft: #0f2417; --success-ink: #86efac;
    --danger: #f87171; --danger-soft: #2c1416; --danger-ink: #fca5a5;
    --warning: #fbbf24; --warning-soft: #2a2010; --warning-ink: #fcd34d;
    --sidebar-grad-start: #18181b; --sidebar-grad-end: #0d0d0f; --sidebar-border: #27272a;
    --sidebar-tile-bg: #212124; --sidebar-tile-border: #3f3f46;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4); --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45); --shadow-lg: 0 24px 56px rgba(0, 0, 0, 0.6);
}
:root[data-theme="light"] {
    --bg: #fafafa; --surface: #ffffff; --surface-2: #f4f4f5; --surface-3: #ececee;
    --border: #e4e4e7; --border-strong: #d4d4d8;
    --text: #18181b; --text-muted: #71717a; --text-faint: #a1a1aa;
    --accent: #4f46e5; --accent-hover: #4338ca; --accent-soft: #eef2ff; --accent-ink: #ffffff; --accent-ring: rgba(79, 70, 229, 0.28);
    --success: #16a34a; --success-soft: #f0fdf4; --success-ink: #15803d;
    --danger: #dc2626; --danger-soft: #fef2f2; --danger-ink: #b91c1c;
    --warning: #d97706; --warning-soft: #fffbeb; --warning-ink: #b45309;
    --sidebar-grad-start: #ffffff; --sidebar-grad-end: #f2f2f4; --sidebar-border: #e4e4e7;
    --sidebar-tile-bg: #ffffff; --sidebar-tile-border: #e4e4e7;
    --shadow-sm: 0 1px 2px rgba(24, 24, 27, 0.05); --shadow-md: 0 4px 16px rgba(24, 24, 27, 0.08); --shadow-lg: 0 16px 40px rgba(24, 24, 27, 0.14);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.55;
}
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; margin: 0; letter-spacing: -0.015em; }
p { margin: 0 0 0.6rem; }
a { color: var(--accent); }
img { max-width: 100%; }
button { font-family: inherit; }

.skip-link {
    position: absolute; left: -9999px; top: 0; z-index: 2000;
    background: var(--accent); color: var(--accent-ink); padding: 10px 16px; border-radius: var(--radius-sm);
}
.skip-link:focus { left: 12px; top: 12px; }

*:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-ring);
    border-radius: var(--radius-sm);
}

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--sidebar-grad-start) 0%, var(--sidebar-grad-end) 100%);
    border-right: 1px solid var(--sidebar-border);
    display: flex; flex-direction: column; z-index: 100;
    transition: width 0.2s ease, transform 0.2s ease;
}
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }

.sidebar-brand {
    display: flex; align-items: center; justify-content: center; gap: 12px; padding: 20px 20px 18px;
    border-bottom: 1px solid var(--sidebar-border); min-height: 30px;
}
.sidebar.collapsed .sidebar-brand { padding: 20px 0 18px; }

.brand-logo-plate {
    width: 40px; height: 40px; flex-shrink: 0; border-radius: var(--radius);
    background: var(--sidebar-tile-bg); border: 1px solid var(--sidebar-tile-border);
    display: flex; align-items: center; justify-content: center; overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.brand-logo-plate img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; padding: 5px; }
.brand-logo-plate .fallback-icon { color: var(--accent); font-size: 1.05rem; }

.sidebar-toggle {
    position: absolute; top: 22px; right: -13px; width: 26px; height: 26px; border-radius: 50%;
    background: var(--surface); color: var(--text-muted); border: 1px solid var(--border-strong); cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 11px; z-index: 5;
    box-shadow: var(--shadow-sm); transition: color 0.15s ease, border-color 0.15s ease;
}
.sidebar-toggle:hover { color: var(--accent); border-color: var(--accent); }
.sidebar.collapsed .sidebar-toggle i { transform: rotate(180deg); }

.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 14px 0 20px; }
.menu { list-style: none; margin: 0; padding: 0; }
.menu-item { position: relative; margin: 0 10px 2px; }
.menu-link {
    all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 9px 12px; color: var(--text-muted); cursor: pointer; font-size: 0.89rem; font-weight: 500;
    border-radius: var(--radius-sm);
}
.menu-link:hover { background: var(--surface-2); color: var(--text); }
.menu-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar.collapsed .menu-item { margin: 0 14px 2px; }

.menu-icon { width: 18px; text-align: center; font-size: 0.95rem; color: var(--text-faint); flex-shrink: 0; }
.menu-link.active .menu-icon, .menu-link:hover .menu-icon { color: currentColor; }
.menu-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-arrow { font-size: 0.68rem; color: var(--text-faint); transition: transform 0.2s ease; }
.menu-item.open > .menu-link .menu-arrow { transform: rotate(90deg); }
.submenu {
    list-style: none; margin: 2px 0 4px; padding: 0; max-height: 0; overflow: hidden;
    transition: max-height 0.2s ease-in-out;
}
.menu-item.open .submenu { max-height: 320px; }
.submenu a {
    display: block; padding: 8px 12px 8px 40px; color: var(--text-muted);
    text-decoration: none; font-size: 0.86rem; border-radius: var(--radius-sm); margin: 0 0 1px;
}
.submenu a:hover { color: var(--text); background: var(--surface-2); }
.submenu a.active { color: var(--accent); font-weight: 600; background: var(--accent-soft); }

.sidebar.collapsed .menu-text,
.sidebar.collapsed .menu-arrow,
.sidebar.collapsed .submenu { display: none; }
.sidebar.collapsed .menu-link { justify-content: center; padding: 10px 0; }
.sidebar.collapsed .menu-item.open .submenu { display: none; }

/* ---------- App shell / topbar ---------- */
.app-shell { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; transition: margin-left 0.2s ease; }
.sidebar.collapsed ~ .app-shell { margin-left: var(--sidebar-w-collapsed); }

.topbar {
    height: var(--topbar-h); flex-shrink: 0; background: var(--surface); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar-title { font-size: 1.2rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 6px; }
.mobile-menu-btn { display: none; }

.icon-btn {
    width: 36px; height: 36px; border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent;
    color: var(--text-muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
    text-decoration: none; font-size: 0.92rem; transition: background-color 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.theme-icon-light { display: none; }
:root[data-theme="dark"] .theme-icon-dark { display: none; }
:root[data-theme="dark"] .theme-icon-light { display: inline; }

.user-menu { display: flex; align-items: center; gap: 10px; padding-left: 10px; margin-left: 6px; border-left: 1px solid var(--border); }
.user-avatar {
    width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
    display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 0.76rem; flex-shrink: 0;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-name { font-weight: 600; font-size: 0.87rem; }
.user-company { font-size: 0.75rem; color: var(--text-muted); }

.page { flex: 1; padding: 20px; width: 100%; max-width: none; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: var(--radius-sm);
    padding: 9px 16px; font-size: 0.87rem; font-weight: 500; border: 1px solid transparent; cursor: pointer;
    text-decoration: none; transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--text-faint); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-outline-danger { background: transparent; color: var(--danger); border-color: var(--danger-soft); }
.btn-outline-danger:hover { background: var(--danger-soft); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-icon-only { padding: 8px; width: 36px; height: 36px; }

/* ---------- Page header / cards ---------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; }
.page-header h1 { font-size: 1.5rem; }
.page-header p { color: var(--text-muted); margin: 4px 0 0; font-size: 0.9rem; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-body { padding: 22px 24px; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat-card .stat-value { font-family: var(--font-sans); font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-card .stat-label { color: var(--text-muted); font-size: 0.8rem; margin-top: 2px; }

/* ---------- Report / client grids ---------- */
.toolbar-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.search-box { position: relative; max-width: 340px; flex: 1; min-width: 220px; }
.search-box i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-faint); font-size: 0.85rem; }
.search-box input { padding-left: 36px; }

.department-grid, .client-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px;
}
.department-card, .client-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 24px 20px; display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; text-decoration: none; color: var(--text); min-height: 190px; cursor: pointer;
    box-shadow: var(--shadow-sm); transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    position: relative; opacity: 0; animation: card-in 0.25s ease forwards;
}
@keyframes card-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.department-card:hover, .client-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.department-logo, .client-card img { max-width: 100%; max-height: 72px; height: auto; margin-bottom: 14px; object-fit: contain; }
.department-logo-fallback { font-size: 36px; color: var(--text-faint); margin-bottom: 14px; }
.department-title, .card-title { font-size: 0.98rem; font-weight: 600; margin: 0; }
.favorite-btn {
    position: absolute; top: 10px; right: 10px; width: 28px; height: 28px; border-radius: 50%; border: none;
    background: var(--surface-2); color: var(--text-faint); display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 0.8rem; transition: color 0.15s ease;
}
.favorite-btn:hover { color: var(--warning); }
.favorite-btn.is-favorite { color: var(--warning); }
.favorite-btn.is-favorite i { font-weight: 900; }

/* ---------- Report iframe view ---------- */
.report-toolbar { display: none; align-items: center; gap: 12px; padding: 10px 4px 18px; flex-shrink: 0; }
.iframe-container { display: none; flex: 1; background: #fff; width:100%; height:100%; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border); }
#report-iframe { display:block; width: 100%; height: 100%;  min-height:800px; border: 0; }
.page.iframe-view { display: flex; flex-direction: column; height: calc(100vh - var(--topbar-h)); width:100%;  max-width:none; padding:12px 16px; }
.page.iframe-view .report-toolbar { display: flex; }
.page.iframe-view .report-grid-view { display: none; }
.page.iframe-view .iframe-container { display: flex; }

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 76px 20px; color: var(--text-muted); }
.empty-state i { font-size: 2.2rem; color: var(--text-faint); margin-bottom: 14px; }
.empty-state h2 { color: var(--text); margin-bottom: 6px; font-size: 1.15rem; }

/* ---------- Forms ---------- */
.form-card { max-width: 640px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.form-grid .field.full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-grid .field { margin-bottom: 0; }
.field label { font-size: 0.82rem; font-weight: 500; color: var(--text); }
.field .hint { font-size: 0.78rem; color: var(--text-faint); }
input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="search"], input[type="file"], input[type="date"], select, textarea {
    width: 100%; padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
    background: var(--surface); color: var(--text); font-size: 0.9rem; font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
textarea { resize: vertical; min-height: 90px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.current-image-preview { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.current-image-preview img { max-height: 52px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); padding: 4px; }

.form-message { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 0.85rem; }
.form-message.success { background: var(--success-soft); color: var(--success-ink); }
.form-message.error { background: var(--danger-soft); color: var(--danger-ink); }

.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 18px; font-size: 0.88rem; display: flex; align-items: center; gap: 10px; border: 1px solid transparent; }
.alert-success { background: var(--success-soft); color: var(--success-ink); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.alert-error { background: var(--danger-soft); color: var(--danger-ink); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert-info { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
th { text-align: left; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 600; padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.mono, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 0.86em; }
.table-actions { display: flex; gap: 6px; }
.table-actions form { display: inline; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 0.74rem; font-weight: 600; padding: 3px 10px; border-radius: 100px; }
.badge-success { background: var(--success-soft); color: var(--success-ink); }
.badge-danger { background: var(--danger-soft); color: var(--danger-ink); }
.badge-warning { background: var(--warning-soft); color: var(--warning-ink); }
.badge-neutral { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

.filters-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters-bar select, .filters-bar input { width: auto; min-width: 160px; }

.pagination { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 18px; }
.pagination a, .pagination span { padding: 7px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); text-decoration: none; color: var(--text); font-size: 0.84rem; }
.pagination a:hover { background: var(--surface-2); border-color: var(--border-strong); }
.pagination .active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pagination .disabled { opacity: 0.4; pointer-events: none; }

/* ---------- Gestão departamento x usuários ---------- */
.management-grid { display: grid; grid-template-columns: 1fr auto 1fr; gap: 18px; align-items: stretch; }
.management-actions { display: flex; flex-direction: column; justify-content: center; gap: 10px; }
.management-actions .btn { width: 160px; }
.user-box h4 { margin-bottom: 12px; }
.user-box .listbox-filter { margin-bottom: 10px; }
.select-all-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 0.85rem; color: var(--text-muted); }
.select-all-row input { width: auto; }
select[multiple] { height: auto; padding: 4px; }
select[multiple] option { padding: 8px 10px; border-radius: 4px; }
select[multiple] option:checked { background: var(--accent-soft); color: var(--accent); }
@media (max-width: 860px) {
    .management-grid { grid-template-columns: 1fr; }
    .management-actions { flex-direction: row; }
    .management-actions .btn { flex: 1; width: auto; }
}

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(24, 24, 27, 0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.modal-overlay[hidden] { display: none; }
.modal { background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 440px; box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto; border: 1px solid var(--border); animation: modal-in 0.15s ease; }
@keyframes modal-in { from { opacity: 0; transform: scale(0.98); } to { opacity: 1; transform: scale(1); } }
.modal-sm { max-width: 400px; }
.modal-lg { max-width: 660px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 1.05rem; }
.modal-body { padding: 20px 22px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.ticket-log-list { max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; background: var(--surface-2); }
.ticket-log-card { padding: 8px 4px; border-bottom: 1px dashed var(--border); font-size: 0.85rem; }
.ticket-log-card:last-child { border-bottom: none; }
.ticket-log-card .old-value { color: var(--danger); text-decoration: line-through; }
.ticket-log-card .new-value { color: var(--success); }
.ticket-log-card time { display: block; color: var(--text-faint); font-size: 0.76rem; margin-top: 2px; }
.field-row-inline { display: flex; gap: 10px; }
.field[hidden] { display: none; }

/* ---------- Toasts ---------- */
.toast-stack { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 1200; max-width: 340px; }
.toast {
    background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md); padding: 12px 16px; font-size: 0.87rem; display: flex; align-items: flex-start; gap: 10px;
    animation: toast-in 0.18s ease-out;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast i { margin-top: 2px; }
.toast.success i { color: var(--success); }
.toast.error i { color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Session warning ---------- */
.session-warning {
    position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--surface);
    border: 1px solid var(--border-strong); box-shadow: var(--shadow-md); border-radius: var(--radius); padding: 12px 18px;
    display: flex; align-items: center; gap: 12px; font-size: 0.85rem; z-index: 1100;
}
.session-warning[hidden] { display: none; }
.session-warning i { color: var(--warning); }

/* ---------- Skeleton ---------- */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: skeleton-loading 1.4s ease infinite; border-radius: var(--radius); }
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- Login ---------- */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--bg); }
.login-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); width: 100%; max-width: 384px; padding: 36px 32px;
    opacity: 0; animation: fade-up 0.35s ease forwards;
}
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.login-logo { text-align: center; margin-bottom: 22px; }
.login-logo img { max-width: 140px; height: auto; }
.login-card h1 { font-size: 1.3rem; text-align: center; margin-bottom: 6px; }
.login-card .login-sub { text-align: center; color: var(--text-muted); font-size: 0.87rem; margin-bottom: 26px; }
.login-card .btn-primary { width: 100%; padding: 11px; font-size: 0.9rem; }
.login-lock-info { text-align: center; font-size: 0.78rem; color: var(--text-faint); margin-top: 16px; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
    .sidebar { transform: translateX(-100%); width: var(--sidebar-w); }
    .sidebar.open { transform: translateX(0); }
    .app-shell { margin-left: 0; }
    .sidebar.collapsed ~ .app-shell { margin-left: 0; }
    .mobile-menu-btn { display: inline-flex; }
    .sidebar-toggle { display: none; }
    .page { padding: 20px 16px 50px; }
    .form-grid { grid-template-columns: 1fr; }
    .user-meta { display: none; }
    .sidebar-overlay { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 90; display: none; }
    .sidebar-overlay.visible { display: block; }
}
@media (max-width: 640px) {
    .table-wrap table { min-width: 640px; }
}
@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
