/* ============================================================
   AfterSolves Admin — Premium Design System v4.9
   ------------------------------------------------------------
   Design tokens:
     • Brand: AfterSolves amber-orange (light) / electric yellow (dark)
     • Surface: warm off-white (#FAFAFA / #0a0a0a) with subtle warmth
     • Card: layered translucent glass with crisp edge highlight
     • Typography: Poppins (UI), tabular figures for numbers
     • Motion: 220ms cubic-bezier(0.22, 1, 0.36, 1)
   ============================================================ */

:root {
    --as-orange: #f97316;
    --as-orange-600: #ea580c;
    --as-yellow: #facc15;
    --as-yellow-400: #facc15;
    --as-yellow-300: #fde047;
    --as-ink: #1c1c1c;
    --as-ink-soft: #525252;
    --as-line: #ececf0;
    --as-surface: #FAFAFA;
    --as-radius: 14px;
    --as-radius-sm: 10px;
    --as-radius-lg: 20px;
    --as-shadow-sm: 0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.04);
    --as-shadow-md: 0 4px 14px -4px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.04);
    --as-shadow-lg: 0 18px 48px -12px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.04);
    --as-ring: 0 0 0 3px rgba(249, 115, 22, 0.14);
    --as-ease: cubic-bezier(0.22, 1, 0.36, 1);
    --as-dur: 220ms;
}

.dark {
    --as-orange: #facc15;
    --as-yellow: #facc15;
    --as-line: #262626;
    --as-surface: #0a0a0a;
    --as-ring: 0 0 0 3px rgba(250, 204, 21, 0.18);
    --as-shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --as-shadow-md: 0 4px 14px -4px rgba(0,0,0,.6), 0 1px 3px rgba(0,0,0,.4);
    --as-shadow-lg: 0 18px 48px -12px rgba(0,0,0,.7), 0 2px 8px rgba(0,0,0,.4);
}

body { font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
html, body { overflow-x: clip; }
@supports not (overflow-x: clip) { html, body { overflow-x: hidden; } }

body {
    color: rgb(28 28 28);
    background: var(--as-surface);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}
.dark body { color: rgb(229 229 229); background: var(--as-surface); }

/* Tabular numerals everywhere money or counts appear */
.tabular-nums { font-variant-numeric: tabular-nums; }

/* ===== Scrollbar — slim, brand-tinted ===== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(234, 179, 8, 0.35);
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
.dark ::-webkit-scrollbar-thumb { background: rgba(82, 82, 82, 0.7); background-clip: padding-box; border: 2px solid transparent; }
::-webkit-scrollbar-thumb:hover { background: rgba(249, 115, 22, 0.7); background-clip: padding-box; border: 2px solid transparent; }

/* ===== Page transitions ===== */
.as-page { animation: asFadeUp 0.34s var(--as-ease) both; }
@keyframes asFadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) { .as-page { animation: none; } }

/* ============================================================
   SIDEBAR — premium admin shell
   ============================================================ */
#as-sidebar {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.85) 0%, rgba(255,250,240,0.75) 100%);
    backdrop-filter: blur(28px) saturate(1.8);
    -webkit-backdrop-filter: blur(28px) saturate(1.8);
    border-right: 1px solid rgba(234, 179, 8, 0.18);
}
.dark #as-sidebar {
    background: linear-gradient(180deg, rgba(20,20,20,0.85) 0%, rgba(15,15,15,0.9) 100%);
    border-right-color: rgba(255,255,255,0.06);
}

/* Nav link — refined with active accent bar */
.as-nav-link {
    display: flex; align-items: center; gap: 0.7rem;
    padding: 0.55rem 0.85rem;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 500;
    color: rgb(82 82 82);
    transition: all var(--as-dur) var(--as-ease);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    text-decoration: none;
}
.dark .as-nav-link { color: rgb(212 212 212); }
.as-nav-link::before {
    content: '';
    position: absolute;
    left: -3px; top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 3px; height: 60%;
    background: linear-gradient(180deg, var(--as-orange), var(--as-yellow));
    border-radius: 999px;
    transition: transform var(--as-dur) var(--as-ease);
}
.as-nav-link:hover {
    background: rgba(254, 249, 195, 0.45);
    color: rgb(234 88 12);
    transform: translateX(2px);
}
.dark .as-nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: rgb(250 204 21);
}
.as-nav-link.active {
    background: linear-gradient(135deg, rgba(249,115,22,0.12) 0%, rgba(250,204,21,0.08) 100%);
    color: rgb(234 88 12);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.4), 0 2px 8px -2px rgba(249, 115, 22, 0.18);
}
.dark .as-nav-link.active {
    background: linear-gradient(135deg, rgba(250,204,21,0.12) 0%, rgba(250,204,21,0.04) 100%);
    color: rgb(250 204 21);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 2px 8px -2px rgba(250, 204, 21, 0.15);
}
.as-nav-link.active::before { transform: translateY(-50%) scaleY(1); }

/* ============================================================
   CARDS — refined glass with subtle gradient sheen
   ============================================================ */
.as-card {
    background: linear-gradient(180deg, rgba(255,255,255,0.78) 0%, rgba(255,255,255,0.6) 100%);
    backdrop-filter: blur(24px) saturate(1.6);
    -webkit-backdrop-filter: blur(24px) saturate(1.6);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: var(--as-radius);
    padding: 1.35rem;
    box-shadow: var(--as-shadow-sm);
    transition: all var(--as-dur) var(--as-ease);
    position: relative;
}
.as-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(234, 179, 8, 0.15));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}
.dark .as-card {
    background: linear-gradient(180deg, rgba(38,38,38,0.7) 0%, rgba(28,28,28,0.6) 100%);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border-color: rgba(255, 255, 255, 0.06);
    box-shadow: var(--as-shadow-md);
}
.dark .as-card::before {
    background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
}

.as-card-hover { transition: all var(--as-dur) var(--as-ease); cursor: pointer; }
.as-card-hover:hover {
    transform: translateY(-2px);
    box-shadow: var(--as-shadow-lg);
    border-color: rgba(249, 115, 22, 0.35);
}
.dark .as-card-hover:hover {
    border-color: rgba(250, 204, 21, 0.25);
}

/* ============================================================
   KPI Tile — hero metric with glow
   ============================================================ */
.as-kpi {
    background: linear-gradient(180deg, rgba(255,255,255,0.78) 0%, rgba(255,252,245,0.65) 100%);
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: var(--as-radius);
    padding: 1.1rem 1.25rem;
    transition: all var(--as-dur) var(--as-ease);
    box-shadow: var(--as-shadow-sm);
    position: relative;
    overflow: hidden;
}
.as-kpi::after {
    content: '';
    position: absolute;
    top: -50%; right: -30%;
    width: 70%; height: 200%;
    background: radial-gradient(ellipse at center, rgba(249, 115, 22, 0.06) 0%, transparent 70%);
    pointer-events: none;
    transition: opacity var(--as-dur) var(--as-ease);
    opacity: 0.6;
}
.as-kpi:hover::after { opacity: 1; }
.dark .as-kpi {
    background: linear-gradient(180deg, rgba(32,32,32,0.7) 0%, rgba(22,22,22,0.55) 100%);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border-color: rgba(255, 255, 255, 0.05);
    box-shadow: var(--as-shadow-sm);
}
.dark .as-kpi::after {
    background: radial-gradient(ellipse at center, rgba(250, 204, 21, 0.06) 0%, transparent 70%);
}
.as-kpi:hover {
    border-color: rgba(249, 115, 22, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 8px 28px -6px rgba(249, 115, 22, 0.12);
}
.dark .as-kpi:hover {
    border-color: rgba(250, 204, 21, 0.3);
    box-shadow: 0 8px 28px -6px rgba(250, 204, 21, 0.08);
}

/* ============================================================
   BUTTONS — refined with subtle gradient + press feedback
   ============================================================ */
.as-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--as-dur) var(--as-ease);
    cursor: pointer;
    border: 1px solid transparent;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
}
.as-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.as-btn:active:not(:disabled) { transform: translateY(0.5px) scale(0.99); }

.as-btn-primary {
    background: linear-gradient(135deg, rgb(249, 115, 22) 0%, rgb(234, 88, 12) 100%);
    color: white;
    box-shadow: 0 4px 14px -4px rgba(249, 115, 22, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.as-btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 22px -4px rgba(249, 115, 22, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.dark .as-btn-primary {
    background: linear-gradient(135deg, rgb(250, 204, 21) 0%, rgb(226, 190, 11) 100%);
    color: rgb(23 23 23);
    box-shadow: 0 4px 14px -4px rgba(250, 204, 21, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
.dark .as-btn-primary:hover:not(:disabled) {
    box-shadow: 0 8px 22px -4px rgba(250, 204, 21, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.as-btn-secondary {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
    color: rgb(64 64 64);
    border-color: rgba(234, 179, 8, 0.4);
    box-shadow: var(--as-shadow-sm);
}
.dark .as-btn-secondary {
    background: rgba(38, 38, 38, 0.7);
    color: rgb(212 212 212);
    border-color: rgba(82, 82, 82, 0.5);
}
.as-btn-secondary:hover:not(:disabled) {
    background: rgba(254, 249, 195, 0.55);
    border-color: rgba(249, 115, 22, 0.4);
    color: rgb(234 88 12);
}
.dark .as-btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(250, 204, 21, 0.25);
    color: rgb(250 204 21);
}

.as-btn-ghost {
    background: transparent;
    color: rgb(82 82 82);
}
.dark .as-btn-ghost { color: rgb(212 212 212); }
.as-btn-ghost:hover:not(:disabled) {
    background: rgba(254, 249, 195, 0.4);
    backdrop-filter: blur(8px);
    color: rgb(234 88 12);
}
.dark .as-btn-ghost:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.05);
    color: rgb(250 204 21);
}

.as-btn-danger {
    background: linear-gradient(135deg, rgb(239 68 68) 0%, rgb(220 38 38) 100%);
    color: white;
    box-shadow: 0 4px 14px -4px rgba(239, 68, 68, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.as-btn-danger:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 22px -4px rgba(239, 68, 68, 0.5);
}

/* ============================================================
   INPUTS — refined with focus glow
   ============================================================ */
.as-input, .as-textarea, .as-select {
    width: 100%;
    padding: 0.55rem 0.85rem;
    border-radius: 10px;
    border: 1px solid rgba(234, 179, 8, 0.35);
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
    font-size: 0.875rem;
    color: rgb(38 38 38);
    transition: all var(--as-dur) var(--as-ease);
    font-family: inherit;
}
.dark .as-input, .dark .as-textarea, .dark .as-select {
    background: rgba(20, 20, 20, 0.65);
    border-color: rgba(82, 82, 82, 0.5);
    color: rgb(245 245 245);
}
.as-input::placeholder, .as-textarea::placeholder { color: rgb(160 160 160); }
.dark .as-input::placeholder, .dark .as-textarea::placeholder { color: rgb(115 115 115); }
.as-input:focus, .as-textarea:focus, .as-select:focus {
    outline: none;
    border-color: rgb(249, 115, 22);
    box-shadow: var(--as-ring), 0 2px 8px -2px rgba(249, 115, 22, 0.12);
    background: rgba(255, 255, 255, 0.92);
}
.dark .as-input:focus, .dark .as-textarea:focus, .dark .as-select:focus {
    border-color: rgb(250, 204, 21);
    box-shadow: var(--as-ring), 0 2px 8px -2px rgba(250, 204, 21, 0.1);
    background: rgba(20, 20, 20, 0.92);
}
.as-input.text-right { text-align: right; font-variant-numeric: tabular-nums; }

.as-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: rgb(82 82 82);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.dark .as-label { color: rgb(163 163 163); }

/* ============================================================
   BADGES — refined pill with subtle border
   ============================================================ */
.as-badge {
    display: inline-flex; align-items: center; gap: 0.25rem;
    padding: 0.18rem 0.6rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.4;
    border: 1px solid transparent;
    white-space: nowrap;
}
.as-badge-green { background: rgb(220 252 231); color: rgb(22 101 52); border-color: rgba(34, 197, 94, 0.2); }
.dark .as-badge-green { background: rgba(20, 50, 20, 0.6); color: rgb(187 247 208); border-color: rgba(34, 197, 94, 0.25); }
.as-badge-yellow { background: rgb(254 249 195); color: rgb(133 77 14); border-color: rgba(234, 179, 8, 0.25); }
.dark .as-badge-yellow { background: rgba(146, 64, 14, 0.4); color: rgb(254 215 170); border-color: rgba(234, 179, 8, 0.25); }
.as-badge-red { background: rgb(254 226 226); color: rgb(153 27 27); border-color: rgba(239, 68, 68, 0.2); }
.dark .as-badge-red { background: rgba(127, 29, 29, 0.5); color: rgb(254 202 202); border-color: rgba(239, 68, 68, 0.25); }
.as-badge-blue { background: rgb(219 234 254); color: rgb(30 64 175); border-color: rgba(59, 130, 246, 0.2); }
.dark .as-badge-blue { background: rgba(30, 58, 138, 0.5); color: rgb(147 197 253); border-color: rgba(59, 130, 246, 0.25); }
.as-badge-gray { background: rgb(245 245 245); color: rgb(64 64 64); border-color: rgba(115, 115, 115, 0.15); }
.dark .as-badge-gray { background: rgb(38 38 38); color: rgb(229 229 229); border-color: rgba(115, 115, 115, 0.25); }
.as-badge-purple { background: rgb(243 232 255); color: rgb(107 33 168); border-color: rgba(168, 85, 247, 0.2); }
.dark .as-badge-purple { background: rgba(88, 28, 135, 0.5); color: rgb(216 180 254); border-color: rgba(168, 85, 247, 0.25); }

/* ============================================================
   TABLES — clean, scannable, with row hover + link affordance
   ============================================================ */
.as-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    table-layout: auto;
}
.as-table thead th {
    text-align: left;
    padding: 0.7rem 1rem;
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgb(115 115 115);
    border-bottom: 1px solid rgb(230 230 235);
    white-space: nowrap;
    vertical-align: bottom;
    background: rgba(254, 249, 195, 0.15);
}
.dark .as-table thead th {
    color: rgb(163 163 163);
    border-bottom-color: rgb(60 60 60);
    background: rgba(255, 255, 255, 0.02);
}
.as-table thead th:first-child { border-top-left-radius: 10px; }
.as-table thead th:last-child { border-top-right-radius: 10px; }
.as-table thead th.text-right, .as-table thead th.as-num { text-align: right; }
.as-table tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgb(240 240 245);
    vertical-align: middle;
    color: rgb(30 30 30);
}
.dark .as-table tbody td {
    border-bottom-color: rgb(38 38 38);
    color: rgb(229 229 229);
}
.as-table tbody td.text-right, .as-table tbody td.as-num,
.as-table .tabular-nums {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.as-table tbody tr { transition: background 0.15s; }
.as-table tbody tr:hover { background: rgba(255, 200, 100, 0.07); }
.dark .as-table tbody tr:hover { background: rgba(255, 255, 255, 0.04); }

/* Clickable rows — show pointer + chevron hint */
.as-table .as-row-link,
.as-table tr[onclick],
.as-table tr.cursor-pointer {
    cursor: pointer;
}
.as-table .as-row-link:hover {
    background: rgba(249, 115, 22, 0.06);
}
.dark .as-table .as-row-link:hover {
    background: rgba(250, 204, 21, 0.05);
}

/* Fixed-width columns */
.as-table col.col-desc { width: auto; }
.as-table col.col-qty { width: 70px; }
.as-table col.col-price { width: 120px; }
.as-table col.col-amount { width: 130px; }
.as-table col.col-actions { width: 1%; }

/* Action buttons cell */
.as-table td.as-actions,
.as-table .as-actions {
    white-space: nowrap;
    text-align: right;
    width: 1%;
    padding-right: 0.75rem;
}
.as-actions .as-btn { padding: 0.3rem; }
.as-actions .as-btn i { width: 14px; height: 14px; }

/* Horizontal scroll wrapper */
.as-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -0.25rem; padding: 0 0.25rem; }

/* ============================================================
   RESPONSIVE CARD-LIST on mobile
   ============================================================ */
@media (max-width: 640px) {
    .as-table-card-mobile thead { display: none; }
    .as-table-card-mobile tbody, .as-table-card-mobile tr, .as-table-card-mobile td { display: block; width: 100%; }
    .as-table-card-mobile tr {
        background: white;
        border: 1px solid rgba(254, 240, 138, 0.5);
        border-radius: 0.85rem;
        margin-bottom: 0.75rem;
        padding: 0.5rem 0.75rem;
        cursor: pointer;
        box-shadow: var(--as-shadow-sm);
    }
    .dark .as-table-card-mobile tr { background: rgb(28 28 28); border-color: rgb(60 60 60); }
    .as-table-card-mobile tr:hover { background: rgb(254 249 195); }
    .dark .as-table-card-mobile tr:hover { background: rgb(38 38 38); }
    .as-table-card-mobile td {
        border: none;
        padding: 0.4rem 0;
        display: flex;
        justify-content: space-between;
        gap: 1rem;
    }
    .as-table-card-mobile td::before {
        content: attr(data-label);
        font-size: 0.7rem;
        color: rgb(115 115 115);
        text-transform: uppercase;
        letter-spacing: 0.05em;
        font-weight: 600;
    }
    .dark .as-table-card-mobile td::before { color: rgb(163 163 163); }
    .as-table-card-mobile td.as-actions::before { display: none; }
    .as-table-card-mobile td.as-actions { justify-content: flex-end; }
}

/* ============================================================
   TOAST — premium glass
   ============================================================ */
.as-toast {
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(24px) saturate(1.6);
    -webkit-backdrop-filter: blur(24px) saturate(1.6);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 12px;
    padding: 0.85rem 1rem;
    box-shadow: var(--as-shadow-lg);
    font-size: 0.875rem;
    animation: asToastIn 0.3s var(--as-ease) both;
}
.dark .as-toast {
    background: rgba(28, 28, 28, 0.82);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border-color: rgba(255, 255, 255, 0.08);
    color: rgb(245 245 245);
}
.as-toast-success { border-left: 3px solid rgb(34 197 94); }
.as-toast-error { border-left: 3px solid rgb(239 68 68); }
.as-toast-info { border-left: 3px solid rgb(249 115 22); }
.dark .as-toast-info { border-left-color: rgb(250 204 21); }
@keyframes asToastIn {
    from { opacity: 0; transform: translateX(20px) scale(0.96); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

/* ============================================================
   MODAL — premium glass with deeper shadow
   ============================================================ */
.as-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: asFade 0.22s ease both;
}
.as-modal {
    background: linear-gradient(180deg, rgba(255,255,255,0.92) 0%, rgba(255,250,240,0.88) 100%);
    backdrop-filter: blur(28px) saturate(1.7);
    -webkit-backdrop-filter: blur(28px) saturate(1.7);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 18px;
    max-width: 32rem;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--as-shadow-lg);
    animation: asModalIn 0.32s var(--as-ease) both;
}
.dark .as-modal {
    background: linear-gradient(180deg, rgba(32,32,32,0.92) 0%, rgba(22,22,22,0.92) 100%);
    backdrop-filter: blur(28px) saturate(1.5);
    -webkit-backdrop-filter: blur(28px) saturate(1.5);
    border-color: rgba(255, 255, 255, 0.06);
}
@keyframes asFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes asModalIn {
    from { opacity: 0; transform: scale(0.96) translateY(12px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ============================================================
   SPINNER — refined with brand gradient
   ============================================================ */
.as-spinner {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid rgba(234, 179, 8, 0.4);
    border-top-color: rgb(249, 115, 22);
    border-radius: 50%;
    animation: asSpin 0.7s linear infinite;
}
.dark .as-spinner {
    border-color: rgba(82, 82, 82, 0.5);
    border-top-color: rgb(250 204 21);
}
@keyframes asSpin { to { transform: rotate(360deg); } }

/* ============================================================
   EMPTY STATE — refined with subtle icon container
   ============================================================ */
.as-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: rgb(115 115 115);
    font-size: 0.875rem;
}
.dark .as-empty { color: rgb(163 163 163); }
.as-empty i[data-lucide] { opacity: 0.55; }

/* ============================================================
   PRINT STYLES — clean A4 for invoices & agreements
   ============================================================ */
@media print {
    .no-print { display: none !important; }
    .print-only { display: block !important; }
    body { background: white !important; color: black !important; }
    #as-sidebar, header.sticky, #as-sidebar-overlay { display: none !important; }
    main { padding: 0 !important; }

    @page {
        size: A4;
        margin: 1.2cm 1.5cm 1.5cm 1.5cm;
    }

    .print-area {
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .print-area, .print-area * {
        color: #000 !important;
        background: #fff !important;
    }
    .print-area a { color: #000 !important; text-decoration: underline; }

    .print-area { font-size: 11pt; line-height: 1.6; }
    .print-area h1 { font-size: 22pt; margin: 0 0 0.5cm 0; }
    .print-area h2 { font-size: 14pt; margin: 0.6cm 0 0.2cm 0; }
    .print-area h3 { font-size: 12pt; margin: 0.5cm 0 0.15cm 0; }
    .print-area p { margin: 0 0 0.25cm 0; text-align: justify; }
    .print-area ul, .print-area ol { margin: 0.25cm 0; padding-left: 0.8cm; }
    .print-area li { margin-bottom: 0.1cm; }

    .print-area table { width: 100%; border-collapse: collapse; margin: 0.3cm 0; }
    .print-area table th, .print-area table td {
        border: 1px solid #ddd !important;
        padding: 6pt 8pt; font-size: 10pt; text-align: left;
    }
    .print-area table th { background: #f5f5f5 !important; font-weight: 600; }

    .signature-block, .print-area .grid { page-break-inside: avoid; }
    h1, h2, h3, h4 { page-break-after: avoid; }
    tr, .as-card { page-break-inside: avoid; }

    .as-card.print-area {
        background: #fff !important;
        border: none !important;
        box-shadow: none !important;
    }
}
.print-only { display: none; }

/* ============================================================
   DARK MODE TEXT SAFETY NET
   ============================================================ */
.dark { color: rgb(229 229 229); }
.dark table { color: rgb(229 229 229); }
.dark td { color: inherit; }
.dark th { color: rgb(163 163 163); }
.dark p { color: inherit; }
.dark h1, .dark h2, .dark h3, .dark h4, .dark h5, .dark h6 { color: rgb(245 245 245); }
.dark strong { color: rgb(245 245 245); }
.dark .prose { color: rgb(229 229 229); }
.dark .prose h1, .dark .prose h2, .dark .prose h3, .dark .prose h4 { color: rgb(245 245 245); }
.dark .prose strong { color: rgb(245 245 245); }
.dark .prose a { color: rgb(96 165 250); }

/* ============================================================
   DOCUMENT PRINT ISOLATION (invoice, quotation, agreement)
   ============================================================ */
.as-doc-print { background: #ffffff; }
.dark .as-doc-print { background: #000000; }

/* ============================================================
   EMAIL RENDER ISOLATION — force light mode
   ============================================================ */
.as-email-render {
    color-scheme: light !important;
    background: #ffffff !important;
    color: #000000 !important;
}
.as-email-render * { color: inherit !important; }
.as-email-render a { color: rgb(0, 102, 204) !important; }
.dark .as-email-render { color: #000000 !important; background: #ffffff !important; }
.dark .as-email-render * { color: inherit !important; }

/* ============================================================
   AGREEMENT DOCUMENT ISOLATION
   ============================================================ */
.as-agr-doc {
    color-scheme: light !important;
    background: #ffffff !important;
    color: #1d1d1f !important;
}
.as-agr-doc * { color: inherit !important; }
.dark .as-agr-doc { color: #1d1d1f !important; background: #ffffff !important; }
.dark .as-agr-doc * { color: inherit !important; }
.dark .as-agr-doc .subtitle, .dark .as-agr-doc footer { color: #6e6e73 !important; }

/* ============================================================
   EMAIL MANAGER (Gmail-style)
   ============================================================ */
.as-email-list-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(254, 240, 138, 0.4);
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}
.dark .as-email-list-item { border-bottom-color: rgb(38 38 38); }
.as-email-list-item:hover { background: rgba(254, 249, 195, 0.5); }
.dark .as-email-list-item:hover { background: rgba(38, 38, 38, 0.7); }
.as-email-list-item.unread { font-weight: 600; background: rgba(255, 251, 235, 0.6); }
.dark .as-email-list-item.unread { background: rgba(38, 38, 38, 0.7); }

/* ============================================================
   RICH TEXT EDITOR (Quill-style)
   ============================================================ */
.as-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.5rem;
    border-bottom: 1px solid rgba(234, 179, 8, 0.4);
    background: rgba(254, 251, 235, 0.5);
    border-radius: 10px 10px 0 0;
}
.dark .as-editor-toolbar {
    border-bottom-color: rgb(60 60 60);
    background: rgba(28, 28, 28, 0.5);
}
.as-editor-btn {
    padding: 0.35rem 0.55rem;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    background: transparent;
    color: rgb(82 82 82);
    border: 1px solid transparent;
    transition: all 0.15s;
}
.dark .as-editor-btn { color: rgb(212 212 212); }
.as-editor-btn:hover {
    background: white;
    border-color: rgba(234, 179, 8, 0.5);
    color: rgb(234 88 12);
}
.dark .as-editor-btn:hover {
    background: rgb(45 45 45);
    border-color: rgb(60 60 60);
    color: rgb(250 204 21);
}

[contenteditable="true"] {
    background: white;
    color: rgb(38 38 38);
    min-height: 200px;
}
.dark [contenteditable="true"] {
    background: rgb(20 20 20) !important;
    color: rgb(229 229 229) !important;
}
.dark [contenteditable="true"] * { color: inherit; }
.dark [contenteditable="true"] a { color: rgb(96 165 250); }

/* ============================================================
   TABS — refined with sliding underline
   ============================================================ */
.as-tab {
    padding: 0.65rem 1.1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: rgb(115 115 115);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.18s var(--as-ease);
    white-space: nowrap;
}
.dark .as-tab { color: rgb(163 163 163); }
.as-tab:hover { color: rgb(249 115 22); }
.dark .as-tab:hover { color: rgb(250 204 21); }
.as-tab.active {
    color: rgb(249 115 22);
    border-bottom-color: rgb(249 115 22);
    font-weight: 600;
}
.dark .as-tab.active {
    color: rgb(250 204 21);
    border-bottom-color: rgb(250 204 21);
}

/* ============================================================
   MOBILE SIDEBAR
   ============================================================ */
@media (max-width: 1023px) {
    #as-sidebar { transform: translateX(-100%); transition: transform 0.32s var(--as-ease); }
    #as-sidebar.open { transform: translateX(0); }
}

/* ============================================================
   COLLAPSED SIDEBAR (desktop)
   ============================================================ */
@media (min-width: 1024px) {
    #as-sidebar.lg\:w-16 { width: 4rem; }
    #as-sidebar.lg\:w-16 .sidebar-label { display: none; }
    #as-sidebar.lg\:w-16 .as-nav-link {
        justify-content: center;
        padding: 0.6rem 0;
    }
    #as-sidebar.lg\:w-16 .as-nav-link::before { display: none; }
    #as-sidebar.lg\:w-16 .as-nav-link span { display: none; }
}

/* ============================================================
   HEADER REFINEMENT — search bar + brand strip
   ============================================================ */
header.sticky {
    background: linear-gradient(180deg, rgba(255,255,255,0.78) 0%, rgba(255,250,240,0.65) 100%);
    backdrop-filter: blur(24px) saturate(1.6);
    -webkit-backdrop-filter: blur(24px) saturate(1.6);
    border-bottom: 1px solid rgba(234, 179, 8, 0.18);
}
.dark header.sticky {
    background: linear-gradient(180deg, rgba(20,20,20,0.78) 0%, rgba(15,15,15,0.65) 100%);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

/* ============================================================
   SECTION HEADING — small uppercase label
   ============================================================ */
.as-section-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgb(115 115 115);
}
.dark .as-section-label { color: rgb(163 163 163); }

/* ============================================================
   DIVIDER — subtle gradient line
   ============================================================ */
.as-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(234, 179, 8, 0.4) 50%, transparent 100%);
    margin: 1rem 0;
}
.dark .as-divider { background: linear-gradient(90deg, transparent 0%, rgba(82, 82, 82, 0.6) 50%, transparent 100%); }
