 :root {
    --bg: #f4f7fb;
    --surface: rgba(255, 255, 255, 0.9);
    --surface-strong: #ffffff;
    --text: #101828;
    --muted: #667085;
    --line: #d7dfeb;
    --primary: #0f766e;
    --primary-strong: #115e59;
    --primary-soft: rgba(15, 118, 110, 0.12);
    --danger: #b42318;
    --danger-soft: rgba(180, 35, 24, 0.12);
    --success: #027a48;
    --success-soft: rgba(2, 122, 72, 0.12);
    --shadow: 0 24px 60px rgba(15, 23, 42, 0.09);
    --radius: 24px;
}

body[data-theme="dark"] {
    --bg: #07111f;
    --surface: rgba(10, 18, 32, 0.88);
    --surface-strong: #0f172a;
    --text: #eef2ff;
    --muted: #9fb0c7;
    --line: rgba(148, 163, 184, 0.22);
    --primary: #34d399;
    --primary-strong: #10b981;
    --primary-soft: rgba(52, 211, 153, 0.16);
    --danger: #f97066;
    --danger-soft: rgba(249, 112, 102, 0.16);
    --success: #32d583;
    --success-soft: rgba(50, 213, 131, 0.16);
    --shadow: 0 24px 60px rgba(2, 6, 23, 0.45);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    background:
        radial-gradient(circle at top right, rgba(15, 118, 110, 0.14), transparent 30%),
        radial-gradient(circle at left bottom, rgba(14, 165, 233, 0.10), transparent 30%),
        var(--bg);
    color: var(--text);
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea {
    font: inherit;
}
button {
    cursor: pointer;
    border: 0;
}

.page-shell {
    width: min(1200px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 40px;
}

.topbar,
.hero-card,
.panel-card,
.login-card,
.preview-card,
.stat-card,
.help-card {
    backdrop-filter: blur(14px);
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 22px 24px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    position: sticky;
    top: 12px;
    z-index: 20;
}

.eyebrow {
    margin: 0 0 6px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .18em;
    color: var(--muted);
}

h1, h2, h3, p {
    margin-top: 0;
}

h1 {
    margin-bottom: 8px;
    font-size: clamp(28px, 3vw, 40px);
}

.subtitle {
    margin: 0;
    color: var(--muted);
    max-width: 780px;
}

.topbar-actions,
.hero-actions,
.inline-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.ghost-btn,
.primary-btn,
.primary-link,
.tab-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0 18px;
    border-radius: 16px;
    transition: .2s ease;
}

.ghost-btn {
    background: var(--surface-strong);
    color: var(--text);
    border: 1px solid var(--line);
}

.primary-btn,
.primary-link,
.tab-link.is-active,
.secondary-tone {
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: #ffffff;
    box-shadow: 0 14px 28px rgba(15, 118, 110, 0.22);
}

.primary-btn:hover,
.primary-link:hover,
.ghost-btn:hover,
.tab-link:hover {
    transform: translateY(-1px);
}

.secondary-tone {
    border: none;
}

.login-layout,
.grid.two-col,
.reports-grid {
    display: grid;
    gap: 22px;
}

.login-layout,
.grid.two-col {
    grid-template-columns: 1.05fr .95fr;
}

.login-card,
.preview-card,
.hero-card,
.panel-card,
.stat-card {
    border-radius: 28px;
    padding: 24px;
}

.card-head {
    margin-bottom: 18px;
}

.card-head p,
.help-note,
.empty-state,
.empty-cell,
.summary-list li span,
.mini-item p,
.stat-inline span,
.invoice-note {
    color: var(--muted);
}

.demo-box,
.invoice-preview-box,
.invoice-row,
.invoice-item,
.summary-list li,
.mini-item,
.stat-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: var(--surface-strong);
    border: 1px solid var(--line);
    border-radius: 18px;
}

.gradient-card {
    background:
        linear-gradient(145deg, rgba(15, 118, 110, 0.16), rgba(14, 165, 233, 0.08)),
        var(--surface);
}

.gradient-card ul {
    margin: 18px 0 0;
    padding-inline-start: 20px;
    line-height: 1.9;
}

.stack-form {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 8px;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--surface-strong);
    color: var(--text);
    border-radius: 16px;
    padding: 14px 16px;
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
}

.split-fields {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.app-layout {
    display: grid;
    gap: 22px;
}

.hero-card {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
}

.tab-nav {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.tab-link {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--line);
}

.tab-link.is-active {
    border-color: transparent;
}

.table-wrap {
    overflow: auto;
    border-radius: 22px;
    border: 1px solid var(--line);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 680px;
    background: var(--surface-strong);
}

th,
td {
    padding: 16px;
    border-bottom: 1px solid var(--line);
    text-align: right;
    white-space: nowrap;
}

thead th {
    background: var(--primary-soft);
    color: var(--text);
    font-size: 14px;
}

tbody tr:hover {
    background: var(--primary-soft);
}

.clickable-row {
    cursor: pointer;
}

.inline-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.stats-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card span {
    display: block;
    margin-bottom: 10px;
    color: var(--muted);
}

.stat-card strong {
    font-size: 28px;
}

.summary-list,
.mini-list {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.printable-panel .invoice-sheet {
    display: grid;
    gap: 12px;
}

.invoice-items {
    display: grid;
    gap: 10px;
}

.invoice-note {
    margin: 0;
    padding: 14px 16px;
    background: var(--surface-strong);
    border: 1px dashed var(--line);
    border-radius: 16px;
}

.alert {
    padding: 14px 16px;
    border-radius: 18px;
    margin-bottom: 18px;
    font-weight: 700;
}

.alert-success {
    background: var(--success-soft);
    color: var(--success);
    border: 1px solid rgba(2, 122, 72, 0.24);
}

.alert-error {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid rgba(180, 35, 24, 0.24);
}

.help-drawer {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.36);
    padding: 20px;
    display: none;
    align-items: flex-start;
    justify-content: flex-start;
    z-index: 40;
}

.help-drawer.is-open {
    display: flex;
}

.help-card {
    width: min(420px, 100%);
    border-radius: 28px;
    padding: 22px;
}

.help-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: var(--surface-strong);
    color: var(--text);
    border: 1px solid var(--line);
}

.empty-state,
.empty-cell {
    text-align: center;
    padding: 24px;
}

@media (max-width: 1024px) {
    .login-layout,
    .grid.two-col,
    .reports-grid,
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .page-shell {
        width: min(100% - 20px, 100%);
        padding-top: 16px;
    }

    .topbar,
    .hero-card,
    .inline-head,
    .split-fields,
    .demo-box,
    .invoice-preview-box,
    .invoice-row,
    .invoice-item,
    .summary-list li,
    .mini-item,
    .stat-inline {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }

    .topbar,
    .hero-card {
        position: static;
    }

    .topbar-actions,
    .hero-actions,
    .inline-actions,
    .tab-nav {
        width: 100%;
    }

    .ghost-btn,
    .primary-btn,
    .primary-link,
    .tab-link {
        width: 100%;
    }

    th,
    td {
        padding: 14px 12px;
    }
}
