:root {
    --bg: #f4f7fb;
    --surface: rgba(255, 255, 255, 0.82);
    --surface-strong: #ffffff;
    --surface-soft: #eef4ff;
    --text: #0f172a;
    --muted: #64748b;
    --border: rgba(148, 163, 184, 0.22);
    --border-strong: rgba(148, 163, 184, 0.34);
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: rgba(37, 99, 235, 0.10);
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    --shadow-soft: 0 4px 16px rgba(15, 23, 42, 0.06);
    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --sidebar-width: 290px;
}

body.dark {
    --bg: #091120;
    --surface: rgba(15, 23, 42, 0.88);
    --surface-strong: #0f172a;
    --surface-soft: #152238;
    --text: #e5edf9;
    --muted: #94a3b8;
    --border: rgba(148, 163, 184, 0.14);
    --border-strong: rgba(148, 163, 184, 0.22);
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-soft: rgba(59, 130, 246, 0.14);
    --shadow: 0 10px 40px rgba(2, 6, 23, 0.45);
    --shadow-soft: 0 4px 16px rgba(2, 6, 23, 0.32);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(59, 130, 246, 0.10), transparent 28%),
        radial-gradient(circle at top right, rgba(37, 99, 235, 0.08), transparent 22%),
        var(--bg);
    color: var(--text);
    transition: background 0.25s ease, color 0.25s ease;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px 18px;
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(18px);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

body.dark .sidebar {
    background: rgba(8, 15, 29, 0.72);
}

.sidebar-top {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 10px 6px;
}

.brand-logo {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), #60a5fa);
    color: white;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 1.1rem;
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.22);
}

.brand-copy {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.brand-subtitle {
    font-size: 0.85rem;
    color: var(--muted);
}

.company-pill {
    padding: 16px;
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, var(--surface-soft), transparent);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}

.company-pill-label {
    display: block;
    font-size: 0.76rem;
    color: var(--muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.company-pill-name {
    display: block;
    font-size: 1rem;
    line-height: 1.4;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    padding: 0 16px;
    border-radius: 16px;
    color: var(--muted);
    font-weight: 600;
    transition: 0.2s ease;
}

.nav-link:hover {
    background: var(--surface-soft);
    color: var(--text);
}

.nav-link.active {
    background: linear-gradient(135deg, var(--primary), #3b82f6);
    color: white;
    box-shadow: 0 14px 26px rgba(37, 99, 235, 0.24);
}

.nav-icon {
    width: 22px;
    text-align: center;
    font-size: 1rem;
}

.sidebar-bottom {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.theme-toggle,
.logout-link,
.button,
.button-secondary {
    min-height: 48px;
    border-radius: 14px;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 18px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s ease;
}

.theme-toggle,
.button-secondary,
.logout-link {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

.theme-toggle:hover,
.button-secondary:hover,
.logout-link:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-soft);
}

.button,
.primary-button {
    background: linear-gradient(135deg, var(--primary), #3b82f6);
    color: white;
    border: 0;
    box-shadow: 0 14px 28px rgba(37, 99, 235, 0.22);
}

.button:hover,
.primary-button:hover {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary));
    transform: translateY(-1px);
}

.main-area {
    min-width: 0;
    padding: 28px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
    margin-bottom: 26px;
}

.page-title {
    margin: 0;
    font-size: 2rem;
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.page-subtitle {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.98rem;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-user {
    min-width: 170px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
    text-align: right;
}

.topbar-user-label {
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
    margin-bottom: 4px;
}

.content {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

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

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 22px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.card-title {
    margin: 0 0 8px;
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.card-subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: "";
    position: absolute;
    inset: auto -20px -35px auto;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.14), transparent 65%);
    pointer-events: none;
}

.stat-label {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    margin: 0;
}

.stat-meta {
    margin-top: 10px;
    color: var(--muted);
    font-size: 0.92rem;
}

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

.section-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.table-wrap {
    overflow-x: auto;
    border-radius: 18px;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 15px 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}

.table th {
    font-size: 0.82rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 800;
}

.table tr:last-child td {
    border-bottom: 0;
}

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

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    background: var(--surface-soft);
    color: var(--text);
    border: 1px solid var(--border);
}

.badge-success {
    background: rgba(22, 163, 74, 0.10);
    color: var(--success);
    border-color: rgba(22, 163, 74, 0.18);
}

.badge-warning {
    background: rgba(217, 119, 6, 0.10);
    color: var(--warning);
    border-color: rgba(217, 119, 6, 0.18);
}

.badge-danger {
    background: rgba(220, 38, 38, 0.10);
    color: var(--danger);
    border-color: rgba(220, 38, 38, 0.18);
}

.form-card {
    max-width: 1100px;
}

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

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group.full {
    grid-column: 1 / -1;
}

label {
    font-size: 0.92rem;
    font-weight: 700;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    min-height: 52px;
    padding: 0 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface-strong);
    color: var(--text);
    outline: none;
    transition: 0.2s ease;
}

textarea {
    min-height: 130px;
    padding: 14px 16px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(37, 99, 235, 0.46);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 22px;
    flex-wrap: wrap;
}

.hero-card {
    min-height: 240px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background:
        linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(255, 255, 255, 0)),
        var(--surface);
}

.eyebrow {
    display: inline-flex;
    align-self: flex-start;
    margin-bottom: 16px;
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero-card h2 {
    margin: 0 0 14px;
    font-size: 2.3rem;
    line-height: 1.05;
    letter-spacing: -0.04em;
    max-width: 760px;
}

.hero-card p {
    margin: 0;
    color: var(--muted);
    font-size: 1.02rem;
    max-width: 760px;
    line-height: 1.7;
}

.button-row {
    display: flex;
    gap: 12px;
    margin-top: 26px;
    flex-wrap: wrap;
}

.empty-state {
    padding: 34px 20px;
    text-align: center;
    color: var(--muted);
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 480px;
    padding: 28px;
    border-radius: 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.login-card h1 {
    margin: 0 0 10px;
    font-size: 2rem;
    letter-spacing: -0.03em;
}

.login-card p {
    margin: 0 0 24px;
    color: var(--muted);
    line-height: 1.7;
}

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

.alert-danger {
    background: rgba(220, 38, 38, 0.10);
    color: var(--danger);
    border: 1px solid rgba(220, 38, 38, 0.18);
}

.alert-success {
    background: rgba(22, 163, 74, 0.10);
    color: var(--success);
    border: 1px solid rgba(22, 163, 74, 0.18);
}

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

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .main-area {
        padding: 20px;
    }

    .topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar-user {
        text-align: left;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .grid-4,
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .page-title {
        font-size: 1.65rem;
    }

    .hero-card h2 {
        font-size: 1.8rem;
    }

    .card {
        padding: 18px;
    }
}
.form-card form {
    width: 100%;
}

.section-header p {
    margin: 6px 0 0;
}

.button-secondary {
    white-space: nowrap;
}

table form button.button-secondary {
    min-height: 40px;
    padding: 0 14px;
    border-radius: 12px;
}

select {
    appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position:
        calc(100% - 18px) calc(50% - 3px),
        calc(100% - 12px) calc(50% - 3px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    padding-right: 40px;
}

/* =========================
   AUTH / LOGIN NEW STYLE
   ========================= */

.auth-page {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    background:
        radial-gradient(circle at top center, rgba(37, 99, 235, 0.18), transparent 28%),
        linear-gradient(180deg, #eef4ff 0%, #f8fbff 48%, #eef5ff 100%);
    color: #0f172a;
}

body.auth-page.dark {
    background:
        radial-gradient(circle at top center, rgba(59, 130, 246, 0.16), transparent 24%),
        linear-gradient(180deg, #071226 0%, #09162d 50%, #081120 100%);
    color: #e5edf9;
}

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
}

.auth-card {
    width: 100%;
    max-width: 520px;
    padding: 42px 38px 34px;
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(18px);
    border: 1px solid rgba(148, 163, 184, 0.20);
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.10);
}

body.auth-page.dark .auth-card {
    background: rgba(8, 15, 29, 0.88);
    border: 1px solid rgba(148, 163, 184, 0.16);
    box-shadow: 0 20px 60px rgba(2, 6, 23, 0.42);
}

.auth-logo-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 28px;
    text-align: center;
}

.auth-logo {
    width: 84px;
    height: 84px;
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2563eb, #60a5fa);
    color: #ffffff;
    font-size: 2rem;
    font-weight: 800;
    box-shadow: 0 18px 35px rgba(37, 99, 235, 0.25);
    letter-spacing: -0.02em;
}

.auth-brand {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: #0f172a;
}

body.auth-page.dark .auth-brand {
    color: #ffffff;
}

.auth-heading {
    text-align: center;
    margin-bottom: 28px;
}

.auth-heading h1 {
    margin: 0 0 10px;
    font-size: 2rem;
    line-height: 1.1;
    letter-spacing: -0.04em;
    font-weight: 800;
}

.auth-heading p {
    margin: 0;
    font-size: 1rem;
    color: #64748b;
    line-height: 1.7;
}

body.auth-page.dark .auth-heading p {
    color: #94a3b8;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.auth-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.auth-form label {
    font-size: 0.95rem;
    font-weight: 700;
    color: inherit;
}

.auth-form input[type="email"],
.auth-form input[type="text"],
.auth-form input[type="password"] {
    width: 100%;
    height: 58px;
    min-height: 58px;
    max-height: 58px;
    padding: 0 18px;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: #ffffff;
    color: #0f172a;
    font-size: 1rem;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

body.auth-page.dark .auth-form input[type="email"],
body.auth-page.dark .auth-form input[type="text"],
body.auth-page.dark .auth-form input[type="password"] {
    background: #0f172a;
    color: #e5edf9;
    border: 1px solid rgba(148, 163, 184, 0.18);
}

.auth-form input:focus {
    outline: none;
    border-color: rgba(37, 99, 235, 0.55);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10);
}

.auth-submit {
    width: 100%;
    height: 58px;
    margin-top: 8px;
    border: 0;
    border-radius: 16px;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: #ffffff;
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 16px 30px rgba(37, 99, 235, 0.24);
}

.auth-submit:hover {
    transform: translateY(-1px);
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
}

.auth-demo-box {
    margin-top: 20px;
    padding: 16px 18px;
    border-radius: 16px;
    background: rgba(37, 99, 235, 0.06);
    border: 1px solid rgba(37, 99, 235, 0.12);
    font-size: 0.94rem;
    line-height: 1.7;
    color: #334155;
}

body.auth-page.dark .auth-demo-box {
    background: rgba(59, 130, 246, 0.10);
    border: 1px solid rgba(59, 130, 246, 0.16);
    color: #cbd5e1;
}

.auth-footer-text {
    margin-top: 24px;
    text-align: center;
    font-size: 0.95rem;
    color: #64748b;
    font-weight: 600;
}

body.auth-page.dark .auth-footer-text {
    color: #94a3b8;
}

@media (max-width: 640px) {
    .auth-card {
        padding: 32px 22px 26px;
        border-radius: 22px;
    }

    .auth-logo {
        width: 72px;
        height: 72px;
        font-size: 1.7rem;
        border-radius: 20px;
    }

    .auth-brand {
        font-size: 1.55rem;
    }

    .auth-heading h1 {
        font-size: 1.7rem;
    }

    .auth-form input[type="email"],
    .auth-form input[type="text"],
    .auth-form input[type="password"],
    .auth-submit {
        height: 54px;
        min-height: 54px;
        max-height: 54px;
    }
}
.invoice-view-card {
    max-width: 1200px;
}

.invoice-head-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 12px;
}

.invoice-box {
    padding: 20px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: var(--surface-soft);
    line-height: 1.8;
}

.invoice-box-label {
    display: inline-block;
    margin-bottom: 10px;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.invoice-meta-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 22px;
}

.invoice-meta-item {
    padding: 16px 18px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
}

.invoice-meta-item span {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.84rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
}

.invoice-meta-item strong {
    font-size: 1rem;
}

.invoice-summary {
    width: 100%;
    max-width: 380px;
    margin-left: auto;
    margin-top: 24px;
    padding: 18px 20px;
    border-radius: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}

.invoice-summary-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.invoice-summary-row:last-child {
    border-bottom: 0;
}

.invoice-summary-row.total {
    font-size: 1.08rem;
    font-weight: 800;
}

.invoice-notes {
    margin-top: 24px;
    padding: 20px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: var(--surface-soft);
}

.invoice-notes p {
    margin: 0;
    line-height: 1.8;
    color: var(--text);
}

@media (max-width: 980px) {
    .invoice-head-grid,
    .invoice-meta-grid {
        grid-template-columns: 1fr;
    }

    .invoice-summary {
        max-width: 100%;
    }
}
.inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.button-danger {
    min-height: 40px;
    padding: 0 14px;
    border-radius: 12px;
    border: 0;
    background: linear-gradient(135deg, #dc2626, #ef4444);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s ease;
}

.button-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(220, 38, 38, 0.20);
}