:root {
    --bg: #eef4f8;
    --panel: rgba(255, 255, 255, 0.78);
    --panel-strong: rgba(255, 255, 255, 0.94);
    --text: #17212b;
    --muted: #657487;
    --line: rgba(58, 74, 92, 0.14);
    --brand: #155eef;
    --brand-dark: #0f47ba;
    --success: #11845b;
    --shadow: 0 18px 48px rgba(29, 45, 63, 0.14);
}

[data-bs-theme="dark"] {
    --bg: #11161d;
    --panel: rgba(27, 34, 44, 0.76);
    --panel-strong: rgba(31, 39, 50, 0.96);
    --text: #edf4fb;
    --muted: #a9b5c3;
    --line: rgba(225, 234, 244, 0.13);
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
}

* {
    letter-spacing: 0;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 5% 0%, rgba(21, 94, 239, 0.12), transparent 28rem),
        linear-gradient(135deg, var(--bg), #f8fbfd 62%, #eaf7f1);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-bs-theme="dark"] body {
    background:
        radial-gradient(circle at 5% 0%, rgba(42, 123, 255, 0.16), transparent 28rem),
        linear-gradient(135deg, var(--bg), #151a21 62%, #0f1c19);
}

a {
    text-decoration: none;
}

.app-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    background: rgba(11, 20, 32, 0.92);
    color: #fff;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: inherit;
}

.brand:hover {
    color: inherit;
}

.brand-mark {
    width: 44px;
    height: 44px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 8px;
    background: linear-gradient(135deg, #155eef, #16a36f);
    color: #fff;
    font-weight: 800;
}

.brand small,
.eyebrow,
.section-head p,
.action-tile small,
.metric-card span,
.mini-result span,
.invoice-line span {
    color: var(--muted);
}

.sidebar .brand small,
.sidebar-footer,
.sidebar .nav-link {
    color: rgba(255, 255, 255, 0.72);
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-height: 46px;
    border-radius: 8px;
    padding: 0.75rem 0.85rem;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.sidebar-footer {
    margin-top: auto;
    display: grid;
    gap: 0.75rem;
}

.btn-ghost {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.main-panel {
    padding: 1.25rem clamp(1rem, 3vw, 2.5rem) 2.5rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.topbar h1 {
    font-size: clamp(1.55rem, 2vw, 2.2rem);
    margin: 0;
    font-weight: 800;
}

.topbar-actions,
.toolbar,
.sticky-actions,
.print-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.glass-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
    padding: clamp(1rem, 2.5vw, 1.5rem);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 34px;
    border-radius: 999px;
    padding: 0.4rem 0.75rem;
    color: #106145;
    background: rgba(17, 132, 91, 0.12);
    font-weight: 700;
    font-size: 0.85rem;
}

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

.action-tile {
    min-height: 170px;
    display: grid;
    align-content: center;
    gap: 0.65rem;
    color: var(--text);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.action-tile:hover {
    color: var(--text);
    transform: translateY(-3px);
}

.tile-icon {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: rgba(21, 94, 239, 0.14);
    color: var(--brand);
    font-size: 1.45rem;
}

.success-tile .tile-icon {
    background: rgba(17, 132, 91, 0.14);
    color: var(--success);
}

.action-tile strong {
    font-size: 1.45rem;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 1rem;
}

.metric-card {
    display: grid;
    gap: 0.35rem;
}

.metric-card i {
    color: var(--brand);
}

.metric-card strong {
    font-size: 1.2rem;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.section-head h2 {
    font-size: 1.2rem;
    margin: 0 0 0.25rem;
    font-weight: 800;
}

.section-head p {
    margin: 0;
}

.calculator-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(340px, 0.75fr);
    gap: 1rem;
    align-items: start;
}

.calc-form {
    min-width: 0;
}

.form-control,
.form-select,
.input-group-text {
    border-radius: 8px;
    border-color: var(--line);
    min-height: 44px;
}

.sticky-actions {
    position: sticky;
    bottom: 0;
    margin: 1.25rem -1.5rem -1.5rem;
    padding: 1rem 1.5rem;
    background: var(--panel-strong);
    border-top: 1px solid var(--line);
    border-radius: 0 0 8px 8px;
}

.results-stack {
    display: grid;
    gap: 1rem;
}

.result-hero {
    background: linear-gradient(135deg, rgba(21, 94, 239, 0.95), rgba(20, 130, 118, 0.92));
    color: #fff;
}

.result-hero span {
    color: rgba(255, 255, 255, 0.78);
}

.result-hero strong {
    display: block;
    font-size: clamp(1.9rem, 3vw, 2.8rem);
    line-height: 1.1;
    margin-top: 0.35rem;
}

.success-hero {
    background: linear-gradient(135deg, #11845b, #159e73);
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.mini-result {
    display: grid;
    gap: 0.2rem;
    padding: 1rem;
}

.mini-result i {
    color: var(--brand);
}

.mini-result strong {
    font-size: 1rem;
    overflow-wrap: anywhere;
}

.invoice-preview {
    display: grid;
    gap: 0.8rem;
}

.invoice-mini-head,
.invoice-line {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
}

.invoice-mini-head {
    justify-content: flex-start;
}

.invoice-line {
    padding-top: 0.75rem;
    border-top: 1px dashed var(--line);
}

.invoice-line.total strong {
    color: var(--success);
}

.table {
    --bs-table-bg: transparent;
}

.table th {
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
}

.status-dot {
    display: inline-flex;
    border-radius: 999px;
    padding: 0.25rem 0.55rem;
    background: rgba(21, 94, 239, 0.1);
    color: var(--brand);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: capitalize;
}

.status-dot.paid {
    background: rgba(17, 132, 91, 0.12);
    color: var(--success);
}

.status-dot.cancelled {
    background: rgba(202, 56, 56, 0.12);
    color: #b42318;
}

.login-main {
    grid-column: 1 / -1;
    min-height: 100vh;
}

.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1rem;
}

.login-card {
    width: min(100%, 430px);
}

.brand-login {
    margin-bottom: 1.5rem;
}

.login-card h1 {
    font-size: 1.7rem;
    font-weight: 800;
    margin-bottom: 1rem;
}

.signup-card {
    width: min(100%, 760px);
}

.auth-switch {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.auth-switch a {
    font-weight: 700;
}

.public-plans {
    width: min(1120px, 100%);
    margin: 0 auto;
    padding: clamp(1rem, 3vw, 2rem);
}

.public-plans-head,
.plan-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.plans-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    align-items: stretch;
}

.plan-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.plan-card.popular {
    border-color: rgba(17, 132, 91, 0.34);
    box-shadow: 0 20px 58px rgba(17, 132, 91, 0.18);
}

.popular-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    border-radius: 999px;
    padding: 0.3rem 0.6rem;
    background: rgba(17, 132, 91, 0.12);
    color: var(--success);
    font-size: 0.78rem;
    font-weight: 800;
}

.plan-card h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 800;
}

.plan-price {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
}

.plan-price strong {
    font-size: 2rem;
    line-height: 1;
}

.plan-price span,
.plan-card p {
    color: var(--muted);
}

.plan-features {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 0.65rem;
    flex: 1;
}

.plan-features li {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.plan-features i {
    color: var(--success);
    margin-top: 0.1rem;
}

.invoice-json {
    white-space: pre-wrap;
    font-size: 0.85rem;
}

.print-actions {
    margin-bottom: 1rem;
}

.invoice-document {
    background: #fff;
    color: #17212b;
    max-width: 920px;
    margin: 0 auto;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.invoice-doc-head,
.invoice-parties,
.invoice-footer {
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
}

.company-block {
    display: flex;
    gap: 1rem;
}

.company-block img {
    width: 64px;
    height: 64px;
    object-fit: contain;
}

.invoice-doc-head h1,
.invoice-doc-head h2 {
    margin: 0 0 0.5rem;
    font-weight: 800;
}

.invoice-doc-head p,
.invoice-parties p,
.invoice-footer p {
    margin: 0.15rem 0;
    color: #566274;
}

.invoice-meta {
    min-width: 250px;
    text-align: right;
}

.invoice-meta p {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.invoice-parties {
    margin: 2rem 0;
    padding: 1rem;
    border: 1px solid #d9e1ec;
    border-radius: 8px;
}

.invoice-parties h3 {
    font-size: 1.1rem;
    font-weight: 800;
}

.qr-box {
    width: 104px;
    height: 104px;
    border: 1px dashed #aab7c7;
    display: grid;
    place-items: center;
    text-align: center;
    border-radius: 8px;
    font-size: 0.72rem;
}

.qr-box i {
    font-size: 2rem;
}

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

.invoice-table th,
.invoice-table td {
    border: 1px solid #d9e1ec;
    padding: 0.75rem;
}

.invoice-table thead th,
.invoice-table tfoot th {
    background: #eef4f8;
}

.invoice-footer {
    margin-top: 2rem;
}

.signature {
    width: 260px;
    min-height: 120px;
    display: grid;
    align-content: end;
    text-align: center;
    border-top: 1px solid #17212b;
    padding-top: 0.75rem;
}

@media (max-width: 1180px) {
    .metric-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

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

    .calculator-layout {
        grid-template-columns: 1fr;
    }
}

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

    .sidebar {
        position: static;
        height: auto;
    }

    .sidebar .nav {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .topbar,
    .section-head,
    .public-plans-head,
    .plan-strip,
    .invoice-doc-head,
    .invoice-parties,
    .invoice-footer {
        flex-direction: column;
    }

    .dashboard-grid,
    .metric-grid,
    .result-grid {
        grid-template-columns: 1fr;
    }

    .invoice-meta {
        text-align: left;
    }
}

@media (max-width: 560px) {
    .main-panel {
        padding: 1rem;
    }

    .sticky-actions {
        position: static;
        margin: 1rem 0 0;
        padding: 1rem 0 0;
        background: transparent;
    }

    .sticky-actions .btn,
    .topbar-actions .btn,
    .toolbar .btn,
    .print-actions .btn {
        width: 100%;
    }

    .sidebar .nav {
        grid-template-columns: 1fr;
    }
}

@media print {
    body {
        background: #fff;
    }

    .sidebar,
    .topbar,
    .print-actions,
    .toast-container {
        display: none !important;
    }

    .app-shell,
    .main-panel {
        display: block;
        padding: 0;
        min-height: auto;
    }

    .invoice-document {
        max-width: none;
        box-shadow: none;
        border-radius: 0;
        padding: 0;
    }
}
