:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --line: #e5eaf2;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #2563eb;
}
body {
    background: var(--bg);
    color: var(--text);
}
.app-shell {
    min-height: 100vh;
    position: relative;
}
.sidebar {
    background: #111827;
    color: #fff;
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    overflow-y: auto;
    z-index: 1030;
}
.sidebar-backdrop { display: none; }
.brand { display: flex; gap: 12px; align-items: center; }
.brand-badge {
    width: 44px; height: 44px; border-radius: 14px;
    display: grid; place-items: center; background: rgba(255,255,255,.12); font-size: 20px;
}
.sidebar .nav-link {
    color: rgba(255,255,255,.76);
    border-radius: 14px;
    padding: 12px 14px;
}
.nav-section-label {
    margin: 10px 2px 0;
    color: rgba(255,255,255,.45);
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.sidebar .nav-link.active, .sidebar .nav-link:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar .nav-link i { margin-right: 10px; }
.content-area {
    display: block;
    padding: 24px;
    margin-left: 280px;
    width: calc(100% - 280px);
    max-width: calc(100% - 280px);
    overflow-x: hidden;
}
.topbar {
    margin-bottom: 24px;
    position: sticky;
    top: 0;
    z-index: 1020;
    background: rgba(244,247,251,.9);
    backdrop-filter: blur(12px);
    padding: 8px 0 12px;
}
.page-title { font-size: 1.7rem; font-weight: 700; }
.sidebar-toggle {
    display: none;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    align-items: center;
    justify-content: center;
}
.sidebar-toggle i {
    font-size: 1.35rem;
    line-height: 1;
}
.card-soft {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(17,24,39,.04);
}
.stat-card { padding: 20px; }
.stat-value { font-size: 2rem; font-weight: 700; }
.login-page {
    min-height: 100vh; display: grid; place-items: center;
    background: linear-gradient(135deg, #eff6ff, #f8fafc 60%, #eef2ff);
}
.login-card { width: 100%; max-width: 420px; }
.login-flashes {
    display: grid;
    gap: 12px;
}
.login-separator {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 1.25rem 0 1rem;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.login-separator::before,
.login-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--line);
}
.btn-google {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    font-weight: 600;
    padding: .75rem 1rem;
}
.btn-google:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: var(--text);
}
.btn-google:focus {
    background: #fff;
    color: var(--text);
    box-shadow: 0 0 0 .25rem rgba(37,99,235,.15);
}
.btn-google:disabled,
.btn-google[aria-disabled="true"] {
    pointer-events: none;
    opacity: .7;
}
.btn-google-mark {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: conic-gradient(#4285f4 0 25%, #34a853 25% 50%, #fbbc05 50% 75%, #ea4335 75% 100%);
    color: #fff;
    font-size: .95rem;
    font-weight: 700;
    box-shadow: inset 0 0 0 2px rgba(255,255,255,.88);
}
.login-help {
    font-size: .875rem;
    color: var(--muted);
}
.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}
.admin-stat-card {
    padding: 18px 20px;
}
.admin-stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    margin: 8px 0 6px;
}
.admin-badge {
    color: var(--text);
}
.admin-filter-bar {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fbfdff;
}
.admin-user-list {
    display: grid;
    gap: 16px;
}
.admin-user-card {
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px;
    background: #fbfdff;
}
.admin-user-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 8px;
}
.admin-user-meta {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}
.admin-mini-stat {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.admin-mini-stat span {
    color: var(--muted);
    font-size: .82rem;
}
.admin-mini-stat strong {
    font-size: 1.1rem;
}
.admin-user-overview {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.admin-overview-card {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    padding: 14px 16px;
}
.admin-delete-form {
    display: flex;
    justify-content: flex-end;
}
.admin-empty-state {
    border: 1px dashed #cbd5e1;
    border-radius: 18px;
    padding: 28px;
    text-align: center;
    background: #fff;
}
.table thead th { font-size: .82rem; text-transform: uppercase; color: var(--muted); }
.invoice-paper {
    background: white; border-radius: 20px; padding: 32px; border: 1px solid var(--line);
    position: relative;
}
.invoice-paid-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 0 0 22px;
    padding: 14px 18px;
    border: 1px solid #fecaca;
    border-radius: 18px;
    background: linear-gradient(135deg, #fff1f2, #fff7f7);
}
.invoice-paid-banner-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: .85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    white-space: nowrap;
}
.invoice-paid-banner-text {
    color: #dc2626;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.35;
}
.invoice-paper .summary-box { background: #f8fafc; border-radius: 16px; padding: 16px; }
.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    min-height: 210px;
}
.invoice-header-main {
    flex: 1 1 auto;
    min-width: 0;
    padding-right: 8px;
}
.invoice-header-side {
    display: flex;
    flex: 0 0 200px;
    flex-direction: column;
    align-items: flex-end;
    gap: 16px;
    min-height: 178px;
}
.invoice-logo {
    max-height: 70px;
    max-width: 180px;
    object-fit: contain;
}
.invoice-qr-top {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}
.invoice-qr-code {
    width: 180px;
    height: 180px;
    display: grid;
    place-items: center;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 10px;
}
.invoice-qr-code canvas,
.invoice-qr-code img {
    display: block;
    width: 100%;
    height: auto;
}
.invoice-qr-caption {
    text-align: right;
    width: 180px;
}
.invoice-overflow-note {
    display: none;
    margin: 0 0 20px;
    color: var(--muted);
    font-size: .95rem;
}
.invoice-has-overflow-note .invoice-overflow-note {
    display: block;
}
.invoice-final-section {
    break-inside: avoid;
    page-break-inside: avoid;
}
.ares-search-box {
    background: #f8fafc;
    border-color: var(--line) !important;
}
.ares-result-item {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--panel);
    border-radius: 16px;
    padding: 14px 16px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    text-align: left;
    transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.ares-result-item + .ares-result-item {
    margin-top: 10px;
}
.ares-result-item:hover {
    border-color: var(--primary);
    box-shadow: 0 10px 24px rgba(37,99,235,.08);
    transform: translateY(-1px);
}
.ares-result-main,
.ares-result-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.ares-result-meta {
    align-items: flex-end;
}
.tax-calendar-list {
    display: grid;
    gap: 14px;
}
.tax-calendar-item {
    display: grid;
    grid-template-columns: 96px 1fr auto;
    gap: 16px;
    align-items: start;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--panel);
}
.tax-calendar-date {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.tax-calendar-date strong {
    font-size: 1.05rem;
}
.tax-calendar-date span {
    color: var(--muted);
    font-size: .82rem;
    text-transform: uppercase;
}
.tax-calendar-content {
    min-width: 0;
}
.tax-calendar-deadline {
    white-space: nowrap;
    font-weight: 600;
    color: var(--primary);
}
.tax-mini-list {
    display: grid;
    gap: 10px;
}
.tax-mini-item {
    display: grid;
    grid-template-columns: 72px 1fr;
    gap: 12px;
    align-items: start;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.tax-mini-item:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}
.tax-settings-grid {
    display: grid;
    gap: 10px;
}
.tax-filter-bar {
    background: linear-gradient(180deg, #ffffff, #fbfdff);
}
.tax-filter-check {
    min-height: 44px;
    display: flex;
    align-items: center;
}
.tax-settings-section + .tax-settings-section {
    margin-top: 18px;
}
.tax-settings-actions {
    justify-content: flex-end;
}
.tax-setting-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #f8fafc;
}
.tax-profile-note {
    color: var(--muted);
    line-height: 1.55;
}
.tax-calendar-empty {
    border: 1px dashed #cbd5e1;
    border-radius: 16px;
    padding: 18px;
    background: #fff;
    color: var(--muted);
    text-align: center;
}
@media (max-width: 991px) {
    body.sidebar-open {
        overflow: hidden;
    }
    .app-shell { min-height: 100vh; }
    .sidebar {
        min-height: auto;
        gap: 24px;
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: 0 24px 60px rgba(15,23,42,.35);
    }
    body.sidebar-open .sidebar {
        transform: translateX(0);
    }
    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15,23,42,.48);
        opacity: 0;
        visibility: hidden;
        transition: opacity .25s ease, visibility .25s ease;
        z-index: 1025;
    }
    body.sidebar-open .sidebar-backdrop {
        opacity: 1;
        visibility: visible;
    }
    .content-area {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
        padding: 16px;
    }
    .topbar {
        padding-top: 0;
    }
    .sidebar-toggle {
        display: inline-flex;
        flex: 0 0 auto;
    }
    .page-title {
        font-size: 1.45rem;
    }
    .invoice-header {
        flex-direction: column;
        min-height: 0;
    }
    .invoice-header-main {
        padding-right: 0;
    }
    .invoice-header-side {
        width: 100%;
        flex: none;
        align-items: flex-start;
        min-height: 0;
    }
    .invoice-qr-top,
    .invoice-qr-caption {
        align-items: flex-start;
        text-align: left;
    }
    .ares-result-item {
        flex-direction: column;
    }
    .ares-result-meta {
        align-items: flex-start;
    }
    .tax-calendar-item {
        grid-template-columns: 1fr;
    }
    .tax-calendar-deadline {
        white-space: normal;
    }
    .tax-settings-actions {
        justify-content: stretch;
        width: 100%;
    }
    .admin-stats-grid,
    .admin-user-meta,
    .admin-user-overview {
        grid-template-columns: 1fr;
    }
}
@media print {
    .sidebar, .topbar, .no-print, .btn, form, .alert { display: none !important; }
    .content-area { padding: 0; }
    body, .app-shell { background: white; }
    .invoice-paper {
        border: 0;
        box-shadow: none;
        border-radius: 0;
        padding: 18mm 18mm 14mm 14mm;
    }
    .invoice-header {
        display: block;
        min-height: 0;
        margin-bottom: 10mm !important;
        padding-right: 52mm;
    }
    .invoice-header-main {
        padding-right: 0;
    }
    .invoice-header-side {
        position: absolute;
        top: 14mm;
        right: 14mm;
        width: 42mm;
        min-height: 0;
        align-items: flex-end;
        gap: 4mm;
    }
    .invoice-logo {
        max-width: 42mm;
        max-height: 18mm;
    }
    .invoice-qr-top {
        gap: 2mm;
        align-items: flex-end;
    }
    .invoice-qr-code {
        width: 42mm;
        height: 42mm;
        border-radius: 0;
        padding: 2mm;
        page-break-inside: avoid;
    }
    .invoice-qr-caption {
        width: 42mm;
        font-size: 9pt;
        line-height: 1.2;
    }
    .invoice-paid-banner {
        gap: 4mm;
        margin-bottom: 6mm;
        padding: 3mm 4mm;
        border-radius: 5mm;
        border-width: .4mm;
    }
    .invoice-paid-banner-label {
        padding: 2mm 4mm;
        font-size: 9pt;
    }
    .invoice-paid-banner-text {
        font-size: 10.5pt;
    }
    .invoice-overflow-note {
        display: none;
        margin: 0 0 5mm;
        font-size: 10pt;
        color: #6b7280;
    }
    .invoice-has-overflow-note .invoice-overflow-note {
        display: block;
    }
    .invoice-final-section {
        page-break-inside: avoid;
        break-inside: avoid;
    }
    .invoice-has-overflow-note .invoice-final-section {
        page-break-before: always;
        break-before: page;
    }
}
