:root {
    color-scheme: dark;
    --bg: #07111a;
    --panel: rgba(10, 22, 34, 0.74);
    --text: #eff6ff;
    --muted: #9db1c7;
    --line: rgba(172, 196, 222, 0.18);
    --accent: #76e4b3;
    --accent-strong: #c8fff0;
    --danger: #ff8a80;
    --shadow: 0 30px 80px rgba(0, 0, 0, 0.3);
    --bg-layer: radial-gradient(circle at top left, rgba(118, 228, 179, 0.14), transparent 28%),
        radial-gradient(circle at 90% 10%, rgba(80, 160, 255, 0.18), transparent 24%),
        linear-gradient(180deg, #09121b 0%, #07111a 100%);
}

body[data-theme="light"] {
    color-scheme: light;
    --bg: #f3ecdf;
    --panel: rgba(255, 252, 247, 0.88);
    --text: #112130;
    --muted: #5c6c7e;
    --line: rgba(17, 33, 48, 0.12);
    --accent: #0f9f74;
    --accent-strong: #0f5f47;
    --danger: #c34b3f;
    --shadow: 0 24px 70px rgba(102, 74, 38, 0.14);
    --bg-layer: radial-gradient(circle at top left, rgba(15, 159, 116, 0.12), transparent 28%),
        radial-gradient(circle at 90% 10%, rgba(0, 124, 255, 0.1), transparent 24%),
        linear-gradient(180deg, #f7f2e9 0%, #efe6d8 100%);
}

* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
body { margin: 0; font-family: "Outfit", sans-serif; background: var(--bg-layer); color: var(--text); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 280px minmax(0, 1fr); align-items: start; }
.public-shell { min-height: 100vh; }
.sidebar { position: sticky; top: 0; min-height: 100vh; padding: 28px 22px; border-right: 1px solid var(--line); background: rgba(7, 17, 26, 0.45); backdrop-filter: blur(18px); display: flex; flex-direction: column; justify-content: space-between; gap: 20px; overflow-y: auto; }
body[data-theme="light"] .sidebar { background: rgba(255, 250, 241, 0.72); }
.brand-kicker, .section-label, .muted-line { margin: 0; text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.72rem; color: var(--muted); }
.brand-mark { display: inline-grid; justify-items: start; gap: 10px; margin-top: 10px; font-family: "Space Grotesk", sans-serif; font-size: 1.25rem; font-weight: 700; }
.brand-logo { width: 56px; height: 56px; object-fit: contain; border-radius: 14px; background: rgba(255,255,255,0.08); padding: 6px; }
.sidebar-nav, .sidebar-footer, .forms, .grid, .list-card, .totals-box { display: grid; gap: 12px; }
.sidebar-nav a, .sidebar-footer a, .button, .theme-toggle { padding: 12px 16px; border-radius: 14px; border: 1px solid var(--line); background: transparent; }
.sidebar-nav a:hover, .sidebar-footer a:hover, .button:hover, .theme-toggle:hover { background: rgba(255,255,255,0.03); }
.content-shell { min-width: 0; padding: 28px; }
.app-topbar { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 22px; }
.app-topbar h1, .auth-card h1 { margin: 8px 0 0; font-family: "Space Grotesk", sans-serif; line-height: 1; letter-spacing: -0.04em; }
.app-topbar h1 { font-size: clamp(2rem, 4vw, 3.4rem); }
.topbar-actions, .panel-actions, .table-actions, .stack, .filter-bar, .report-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.user-chip, .panel, .table-card, .metric-card, .auth-card, .list-row, .totals-box div, input, select, textarea, .flash, .empty-state, .badge, .pill { border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); border-radius: 20px; }
.user-chip, .metric-card, .list-row, .totals-box div, .flash, .badge, .pill { padding: 12px 14px; box-shadow: none; }
.panel, .table-card, .auth-card { padding: 24px; }
.table-card { overflow: hidden; }
.plain-link { color: var(--accent-strong); }
.inline-form { display: inline; }
.print-shell { max-width: 1100px; margin: 0 auto; padding: 28px; }
.invoice-header { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: start; }
.invoice-meta, .invoice-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.invoice-client, .invoice-payment { display: grid; grid-template-columns: 1fr 320px; gap: 16px; }
.qr-preview { width: 220px; height: 220px; border-radius: 24px; border: 1px solid var(--line); background: rgba(255,255,255,0.04); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.qr-preview img { width: 100%; height: 100%; object-fit: cover; }
.builder-table input, .builder-table select { min-width: 0; }
.builder-table { width: 100%; table-layout: fixed; }
.calc-value { display: inline-block; min-width: 92px; font-variant-numeric: tabular-nums; }
.builder-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.builder-summary div { padding: 16px; border-radius: 18px; border: 1px solid var(--line); background: rgba(255,255,255,0.03); }
.builder-summary strong { display: block; margin-top: 6px; font-family: "Space Grotesk", sans-serif; font-size: 1.35rem; }
.signature-panel { display: grid; gap: 14px; padding: 18px; border: 1px solid var(--line); border-radius: 22px; background: rgba(255,255,255,0.03); }
.signature-pad { width: 100%; max-width: 100%; min-height: 220px; border-radius: 18px; border: 1px dashed var(--line); background: #fff; touch-action: none; }
.grid.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.metric-card strong { display: block; font-family: "Space Grotesk", sans-serif; font-size: 1.8rem; }
.metric-card span, .helper, th, td small, .inline-note { color: var(--muted); }
.section-row { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 18px; margin-top: 18px; }
.panel-header { display: flex; justify-content: space-between; gap: 14px; align-items: start; margin-bottom: 18px; }
.panel-header h2 { margin: 8px 0 0; font-family: "Space Grotesk", sans-serif; font-size: 1.5rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 14px 10px; border-bottom: 1px solid var(--line); }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.12em; }
.badge.success { background: rgba(118, 228, 179, 0.12); color: var(--accent-strong); }
.badge.warn { background: rgba(255, 197, 97, 0.12); color: #ffd28d; }
.badge.danger { background: rgba(255, 138, 128, 0.12); color: #ffc1ba; }
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.input-group { display: grid; gap: 8px; }
.input-group.full { grid-column: 1 / -1; }
input, select, textarea { width: 100%; padding: 13px 14px; color: var(--text); }
textarea { min-height: 100px; resize: vertical; }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(100%, 520px); }
.auth-card h1 { font-size: 2.6rem; }
.flash.error { background: rgba(255, 138, 128, 0.08); color: #ffd3ce; }
.flash.success { background: rgba(118, 228, 179, 0.08); color: var(--accent-strong); }
.empty-state { padding: 28px; text-align: center; border-style: dashed; }
.danger-link { color: var(--danger); background: none; border: 0; padding: 0; cursor: pointer; }
.button.primary { background: var(--accent); color: #062016; border-color: transparent; font-weight: 700; }
.button.secondary { background: rgba(255,255,255,0.03); }
.add-client-button { background: linear-gradient(135deg, var(--accent), #8ef0c7); color: #062016; border-color: transparent; box-shadow: 0 12px 28px rgba(118, 228, 179, 0.25); }
.sidebar-nav a { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notification-button { position: relative; display: inline-grid; place-items: center; width: 48px; height: 48px; padding: 0; border-radius: 14px; border: 1px solid var(--line); background: transparent; color: var(--text); }
.notification-bell { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 999px; background: rgba(255,255,255,0.06); font-size: 1rem; }
.notification-button.has-alert .notification-bell { animation: bellShake 1.8s ease-in-out infinite; color: #ffcf73; }
.notification-count { position: absolute; top: -6px; right: -4px; display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #062016; font-weight: 700; font-size: 0.75rem; }
.topbar-actions { position: relative; }
.notification-panel { position: absolute; top: calc(100% + 8px); right: 0; width: min(360px, calc(100vw - 36px)); padding: 18px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); box-shadow: var(--shadow); z-index: 20; }
.notification-panel[hidden] { display: none !important; }
.gst-calculator-card { gap: 18px; }
.calculator-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.calculator-grid button { padding: 16px 10px; border-radius: 18px; border: 1px solid var(--line); background: rgba(255,255,255,0.03); color: var(--text); font-weight: 600; }
.notification-list { display: grid; gap: 10px; margin-top: 12px; }
.notification-item { display: grid; gap: 4px; padding: 12px; border-radius: 16px; border: 1px solid var(--line); background: rgba(255,255,255,0.03); }
.notification-item span, .notification-item em { color: var(--muted); font-style: normal; }
.field-label { display: flex; align-items: center; gap: 8px; }
.field-help { width: 24px; height: 24px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255,255,255,0.05); color: var(--text); cursor: pointer; }
.feature-lock { padding: 0; border: 0; background: none; cursor: pointer; text-align: left; }
.asset-preview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-top: 18px; }
.asset-preview-card { display: grid; gap: 10px; padding: 14px; border-radius: 18px; border: 1px solid var(--line); background: rgba(255,255,255,0.03); }
.asset-preview-card span { color: var(--muted); font-size: 0.85rem; }
.asset-preview-card img { width: 100%; height: 120px; object-fit: contain; border-radius: 14px; background: rgba(255,255,255,0.9); padding: 8px; }
.asset-preview-card.compact img { height: 80px; }
.document-signoff { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.upgrade-modal { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(6, 15, 22, 0.72); z-index: 50; }
.upgrade-modal[hidden] { display: none !important; }
.upgrade-modal-card { width: min(100%, 460px); padding: 24px; border-radius: 24px; border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); }
.filter-bar { margin-bottom: 18px; }
.filter-bar > * { flex: 1 1 160px; }
.report-hero { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 22px; padding: 22px 24px; border: 1px solid var(--line); border-radius: 24px; background: linear-gradient(135deg, rgba(118, 228, 179, 0.1), rgba(80, 160, 255, 0.08)); }
.report-hero-copy h2 { margin: 8px 0 10px; font-family: "Space Grotesk", sans-serif; }
.report-footer-note { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; color: var(--muted); flex-wrap: wrap; }
.collapsible-panel { overflow: hidden; }
.collapsible-toggle { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0; border: 0; background: none; color: inherit; cursor: pointer; text-align: left; }
.collapsible-toggle h2, .collapsible-toggle p { pointer-events: none; }
.collapsible-icon { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 999px; border: 1px solid var(--line); color: var(--accent-strong); font-size: 1.1rem; flex: 0 0 auto; }
.collapsible-body[hidden] { display: none !important; }
.section-row.expandable-layout { grid-template-columns: minmax(0, 1fr) 340px; }
.section-row.expandable-layout .collapsible-panel.is-collapsed { padding-bottom: 18px; }
.section-row.expandable-layout .collapsible-panel.is-collapsed .panel-header { margin-bottom: 0; }
.section-row.expandable-layout .collapsible-panel.is-collapsed .collapsible-icon { transform: rotate(-90deg); }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
td, th { overflow-wrap: anywhere; }
@media (max-width: 1100px) { .app-shell { grid-template-columns: 1fr; } .sidebar { position: relative; min-height: auto; border-right: 0; border-bottom: 1px solid var(--line); } .grid.metrics, .section-row, .form-grid, .builder-summary, .section-row.expandable-layout { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px) { .content-shell, .sidebar, .print-shell { padding: 18px; } .grid.metrics, .section-row, .form-grid, .invoice-meta, .invoice-summary, .invoice-client, .invoice-payment, .builder-summary, .footer-surface { grid-template-columns: 1fr; } .app-topbar, .report-hero { flex-direction: column; align-items: start; } .topbar-actions { width: 100%; justify-content: space-between; } .invoice-header { grid-template-columns: 1fr; } .notification-panel { left: 0; right: auto; width: 100%; } .builder-table th:nth-child(7), .builder-table th:nth-child(8), .builder-table th:nth-child(9), .builder-table th:nth-child(10), .builder-table td:nth-child(7), .builder-table td:nth-child(8), .builder-table td:nth-child(9), .builder-table td:nth-child(10) { display: none; } .calculator-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media print { @page { size: A4; margin: 8mm; } .no-print { display: none !important; } body { background: #fff; color: #111; font-size: 11px; } .print-shell, .panel, .table-card, .list-row, .totals-box div { box-shadow: none; background: #fff; } .panel, .table-card { padding: 12px; } table { font-size: 10px; } .invoice-header, .invoice-client, .invoice-payment { gap: 10px; } }
.icon-toggle { display: inline-grid; place-items: center; width: 48px; height: 48px; padding: 0; }
.theme-icon { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 999px; background: rgba(255,255,255,0.08); color: var(--accent-strong); border: 1px solid rgba(255,255,255,0.08); font-size: 1rem; line-height: 1; }
.site-footer { margin-top: 34px; padding-top: 12px; }
.footer-surface { border: 1px solid var(--line); border-radius: 28px; background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02)); padding: 24px; display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 22px; box-shadow: var(--shadow); }
.footer-brand strong { display: block; font-family: "Space Grotesk", sans-serif; font-size: 1.35rem; margin-top: 10px; }
.site-footer p { margin: 8px 0 0; color: var(--muted); }
.footer-links { display: grid; gap: 10px; align-content: start; }
.footer-links a { color: var(--text); opacity: 0.9; }
.auth-page-footer { width: min(100%, 1100px); margin: 0 auto 24px; padding: 0 24px; }

@keyframes bellShake {
    0%, 100% { transform: rotate(0deg); }
    10% { transform: rotate(14deg); }
    20% { transform: rotate(-12deg); }
    30% { transform: rotate(10deg); }
    40% { transform: rotate(-8deg); }
    50% { transform: rotate(0deg); }
}

/* Clean modern dashboard look inspired by provided reference */
:root {
    --bg: #f4f6fb;
    --panel: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --line: #e8ecf4;
    --accent: #6d28d9;
    --accent-strong: #5b21b6;
    --shadow: 0 10px 30px rgba(17, 24, 39, 0.06);
    --bg-layer: linear-gradient(180deg, #f8faff 0%, #f3f6fd 100%);
}

body[data-theme="dark"] {
    --bg: #0f172a;
    --panel: #111b34;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --line: #223053;
    --accent: #7c3aed;
    --accent-strong: #c4b5fd;
    --shadow: 0 18px 40px rgba(2, 6, 23, 0.45);
    --bg-layer: linear-gradient(180deg, #0b1224 0%, #0f172a 100%);
}

body { background: var(--bg-layer); color: var(--text); }
.app-shell { grid-template-columns: 250px minmax(0, 1fr); background: transparent; }
.sidebar { background: rgba(255, 255, 255, 0.72); border-right: 1px solid var(--line); backdrop-filter: blur(12px); }
body[data-theme="dark"] .sidebar { background: rgba(15, 23, 42, 0.78); }
.brand-mark { font-size: 1.15rem; }
.brand-logo { width: 44px; height: 44px; border-radius: 12px; }
.sidebar-nav a { border-radius: 12px; border: 1px solid transparent; background: transparent; }
.sidebar-nav a.is-active { background: linear-gradient(90deg, #5b4ee6, #7c3aed); color: #fff; box-shadow: 0 8px 18px rgba(91, 78, 230, 0.35); }
.sidebar-nav a:hover { border-color: var(--line); background: rgba(109, 40, 217, 0.06); }
body[data-theme="dark"] .sidebar-nav a:hover { background: rgba(124, 58, 237, 0.18); }

.content-shell { padding: 18px 22px 28px; }
.app-topbar { background: rgba(255, 255, 255, 0.8); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; margin-bottom: 18px; }
body[data-theme="dark"] .app-topbar { background: rgba(15, 23, 42, 0.72); }
.app-topbar h1 { font-size: 1.85rem; margin-top: 2px; }
.topbar-actions { align-items: center; }
.user-chip { border-radius: 999px; padding: 8px 12px; }

.panel, .table-card, .auth-card, .metric-card, .list-row, .totals-box div, input, select, textarea, .flash, .empty-state, .badge, .pill {
    border-radius: 18px;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    background: var(--panel);
}

.button.primary {
    background: linear-gradient(90deg, #5b4ee6, #7c3aed);
    color: #fff;
    box-shadow: 0 10px 24px rgba(91, 78, 230, 0.28);
}

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.kpi-card { border: 1px solid var(--line); border-radius: 18px; background: var(--panel); padding: 18px; box-shadow: var(--shadow); display: grid; gap: 8px; }
.kpi-icon { width: 46px; height: 46px; border-radius: 14px; display: inline-grid; place-items: center; color: #fff; font-weight: 700; }
.icon-purple { background: linear-gradient(135deg, #5b4ee6, #8b5cf6); }
.icon-teal { background: linear-gradient(135deg, #14b8a6, #22d3ee); }
.icon-pink { background: linear-gradient(135deg, #ec4899, #f43f5e); }
.icon-amber { background: linear-gradient(135deg, #f59e0b, #f97316); }
.kpi-label { color: var(--muted); font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600; }
.kpi-card strong { font-size: 2rem; font-family: "Space Grotesk", sans-serif; line-height: 1.1; }

.cta-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.cta-card { border-radius: 18px; padding: 24px; display: flex; justify-content: space-between; align-items: center; color: #fff; box-shadow: 0 14px 30px rgba(0, 0, 0, 0.16); }
.cta-card h3 { margin: 0 0 8px; font-family: "Space Grotesk", sans-serif; font-size: 1.9rem; line-height: 1; }
.cta-card p { margin: 0; opacity: 0.9; }
.cta-quotation { background: linear-gradient(120deg, #5b4ee6 0%, #8b5cf6 45%, #ec4899 100%); }
.cta-invoice { background: linear-gradient(120deg, #14b8a6 0%, #06b6d4 100%); }
.cta-plus { width: 58px; height: 58px; border-radius: 999px; display: inline-grid; place-items: center; font-size: 2rem; background: rgba(255, 255, 255, 0.2); }

.dashboard-layout { grid-template-columns: 1fr 320px; align-items: start; }
.recent-panel h2 { font-size: 2rem; }
.modern-list { display: grid; gap: 12px; }
.modern-list-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto auto; align-items: center; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
body[data-theme="dark"] .modern-list-row { background: rgba(17, 27, 52, 0.8); }
.list-icon { width: 40px; height: 40px; border-radius: 12px; background: #ede9fe; color: #6d28d9; display: inline-grid; place-items: center; font-weight: 700; }
.list-main strong { display: block; font-size: 1rem; }
.list-main p, .list-meta p { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; }
.list-meta strong { display: block; text-align: right; }
.plan-panel .totals-box div { border-radius: 14px; }

@media (max-width: 1200px) {
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cta-grid { grid-template-columns: 1fr; }
    .dashboard-layout { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .modern-list-row { grid-template-columns: 40px minmax(0, 1fr); }
    .list-meta, .modern-list-row .badge { grid-column: 2 / -1; justify-self: start; text-align: left; }
    .cta-card h3 { font-size: 1.4rem; }
}
