:root {
    --bg: #07111f;
    --bg-soft: #0d1829;
    --panel: rgba(11, 22, 38, 0.88);
    --panel-strong: rgba(16, 29, 48, 0.96);
    --panel-border: rgba(145, 178, 255, 0.14);
    --text: #edf4ff;
    --muted: #9eb2d1;
    --primary: #5fb7ff;
    --primary-strong: #2b8fff;
    --success: #39d98a;
    --danger: #ff6d7d;
    --warning: #ffbf69;
    --shadow: 0 30px 80px rgba(0, 0, 0, 0.34);
    --radius-xl: 28px;
    --radius-lg: 20px;
    --radius-md: 16px;
    --radius-sm: 12px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    min-height: 100%;
    font-family: "Segoe UI", "Inter", sans-serif;
    color: var(--text);
    background: radial-gradient(circle at top left, #163159 0%, var(--bg) 40%, #040913 100%);
}

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

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

.shell-bg {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

.shell-orb {
    position: absolute;
    border-radius: 999px;
    filter: blur(90px);
    opacity: 0.45;
}

.orb-a {
    width: 32rem;
    height: 32rem;
    background: #1d72ff;
    top: -8rem;
    left: -6rem;
}

.orb-b {
    width: 24rem;
    height: 24rem;
    background: #1e9980;
    top: 16rem;
    right: -5rem;
}

.orb-c {
    width: 22rem;
    height: 22rem;
    background: #6a49ff;
    bottom: -6rem;
    left: 35%;
}

.admin-frame {
    position: relative;
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    min-height: 100vh;
    padding: 18px;
}

.sidebar,
.main-panel,
.login-card,
.standalone,
.invoice-shell {
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow);
}

.sidebar {
    display: flex;
    flex-direction: column;
    padding: 22px;
    border-radius: var(--radius-xl);
    background: linear-gradient(180deg, rgba(9, 20, 35, 0.92), rgba(7, 16, 29, 0.86));
}

.brand-lockup {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 24px;
}

.brand-logo {
    width: 52px;
    height: 52px;
    object-fit: contain;
    border-radius: 18px;
    background: rgba(255,255,255,0.06);
    padding: 8px;
}

.brand-title {
    font-weight: 700;
    letter-spacing: -0.03em;
}

.brand-subtitle,
.sidebar-meta,
.topbar-label,
.field-help,
.metric-label,
.table-meta,
.empty-state p,
.invoice-meta,
.login-subtitle {
    color: var(--muted);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.nav-link {
    display: flex;
    gap: 14px;
    align-items: center;
    padding: 14px 16px;
    border-radius: 18px;
    color: #bdd1ef;
    border: 1px solid transparent;
    transition: 0.2s ease;
}

.nav-link:hover,
.nav-link.is-active {
    background: rgba(95, 183, 255, 0.1);
    color: #fff;
    border-color: rgba(95, 183, 255, 0.2);
}

.nav-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
}

.nav-icon svg {
    width: 20px;
    height: 20px;
}

.sidebar-foot {
    border-top: 1px solid rgba(255,255,255,0.08);
    padding-top: 18px;
}

.sidebar-user {
    font-weight: 700;
    margin-top: 4px;
}

.sidebar-role {
    color: #8ac4ff;
    margin-top: 2px;
    margin-bottom: 12px;
}

.ghost-link {
    color: #bdd1ef;
}

.main-panel {
    border-radius: var(--radius-xl);
    padding: 24px;
    background: linear-gradient(180deg, rgba(9, 20, 35, 0.72), rgba(7, 16, 29, 0.86));
}

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

.topbar-title {
    margin: 4px 0 0;
    font-size: 2rem;
    letter-spacing: -0.04em;
}

.page-grid {
    display: grid;
    gap: 22px;
}

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

.metric-card,
.panel,
.table-card,
.invoice-card,
.invoice-sidebar {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-lg);
}

.metric-card {
    padding: 18px;
}

.metric-value {
    display: block;
    margin-top: 12px;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.05em;
}

.panel,
.table-card,
.invoice-card,
.invoice-sidebar {
    padding: 22px;
}

.panel-head,
.table-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 18px;
}

.panel-title,
.table-title,
.section-title {
    margin: 0;
    font-size: 1.2rem;
    letter-spacing: -0.03em;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 16px;
    border-radius: 14px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: 0.2s ease;
}

.button-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: #021223;
    font-weight: 700;
}

.button-secondary {
    background: rgba(255,255,255,0.04);
    border-color: rgba(255,255,255,0.08);
    color: var(--text);
}

.button-danger {
    background: rgba(255, 109, 125, 0.14);
    border-color: rgba(255, 109, 125, 0.2);
    color: #ffd7dc;
}

.button:hover {
    transform: translateY(-1px);
}

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

.input,
.select,
.textarea {
    width: 100%;
    padding: 13px 14px;
    border-radius: 14px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--text);
}

.select.is-native-hidden {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

.textarea {
    min-height: 120px;
    resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: rgba(95, 183, 255, 0.45);
    box-shadow: 0 0 0 3px rgba(95, 183, 255, 0.12);
}

input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    margin: 0 8px 0 0;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(255,255,255,0.04);
    vertical-align: -3px;
    position: relative;
    cursor: pointer;
    transition: 0.2s ease;
}

input[type="checkbox"]:checked {
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    border-color: rgba(95, 183, 255, 0.45);
}

input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 1px;
    width: 4px;
    height: 9px;
    border: solid #03111f;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(95, 183, 255, 0.12);
}

.field label:has(input[type="checkbox"]) {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
}

.custom-select {
    position: relative;
}

.custom-select-trigger {
    width: 100%;
    min-height: 49px;
    padding: 13px 46px 13px 14px;
    border-radius: 14px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    transition: 0.2s ease;
}

.custom-select-trigger:hover,
.custom-select.is-open .custom-select-trigger {
    border-color: rgba(95, 183, 255, 0.45);
    box-shadow: 0 0 0 3px rgba(95, 183, 255, 0.12);
}

.custom-select-trigger::after {
    content: "";
    position: absolute;
    right: 16px;
    top: 50%;
    width: 8px;
    height: 8px;
    border-right: 2px solid #aecdff;
    border-bottom: 2px solid #aecdff;
    transform: translateY(-65%) rotate(45deg);
    transition: 0.2s ease;
}

.custom-select.is-open .custom-select-trigger::after {
    transform: translateY(-25%) rotate(-135deg);
}

.custom-select-label {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.custom-select-menu {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 8px);
    z-index: 40;
    padding: 8px;
    border-radius: 16px;
    background: rgba(10, 20, 35, 0.98);
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: var(--shadow);
    display: none;
    max-height: 260px;
    overflow: auto;
}

.custom-select.is-open .custom-select-menu {
    display: block;
}

.custom-select-option {
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--text);
    text-align: left;
    border-radius: 12px;
    padding: 11px 12px;
    cursor: pointer;
    transition: 0.2s ease;
}

.custom-select-option:hover,
.custom-select-option.is-active {
    background: rgba(95, 183, 255, 0.12);
}

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

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

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

.field label {
    font-weight: 600;
}

.field-span-2 {
    grid-column: span 2;
}

.field-span-3 {
    grid-column: span 3;
}

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

.table th,
.table td {
    padding: 14px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    text-align: left;
    vertical-align: top;
}

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

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 0.78rem;
    font-weight: 700;
}

.badge-success { background: rgba(57, 217, 138, 0.14); color: #8ef0bb; }
.badge-warning { background: rgba(255, 191, 105, 0.14); color: #ffd9a0; }
.badge-danger { background: rgba(255, 109, 125, 0.14); color: #ffd2d8; }
.badge-info { background: rgba(95, 183, 255, 0.14); color: #b6deff; }

.stack {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.flash {
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.flash-success { background: rgba(57, 217, 138, 0.12); border: 1px solid rgba(57, 217, 138, 0.18); }
.flash-error { background: rgba(255, 109, 125, 0.12); border: 1px solid rgba(255, 109, 125, 0.18); }

.flash-close {
    background: transparent;
    color: var(--text);
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
}

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

.login-card,
.standalone {
    width: min(100%, 460px);
    padding: 28px;
    border-radius: var(--radius-xl);
    background: var(--panel-strong);
}

.login-card form {
    display: grid;
    gap: 16px;
}

.login-logo {
    width: 72px;
    height: 72px;
    object-fit: contain;
    margin-bottom: 14px;
}

.empty-state {
    text-align: center;
    display: grid;
    gap: 14px;
    justify-items: center;
}

.empty-state h1 {
    margin: 0;
    font-size: 3rem;
}

.invoice-lines {
    display: grid;
    gap: 12px;
}

.line-item {
    display: grid;
    grid-template-columns: 2.2fr 0.7fr 0.7fr 0.8fr 0.9fr auto;
    gap: 10px;
    align-items: end;
    padding: 14px;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.06);
    background: rgba(255,255,255,0.02);
}

.totals-box {
    margin-left: auto;
    width: min(100%, 360px);
    display: grid;
    gap: 10px;
}

.totals-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.totals-row.is-strong {
    font-size: 1.12rem;
    font-weight: 700;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.split-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 20px;
}

.info-list {
    display: grid;
    gap: 14px;
}

.info-item {
    display: grid;
    gap: 4px;
}

.invoice-shell {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px;
    background: #ffffff;
    color: #0f172a;
    border-radius: 24px;
}

.invoice-print-grid {
    display: grid;
    grid-template-columns: 1.3fr 0.9fr;
    gap: 32px;
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}

.invoice-logo {
    max-width: 170px;
}

.invoice-box {
    padding: 18px;
    border-radius: 18px;
    background: #f4f8ff;
    border: 1px solid #d9e6ff;
}

.invoice-heading {
    margin: 0 0 10px;
    font-size: 2rem;
    letter-spacing: -0.04em;
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 28px;
}

.invoice-table th,
.invoice-table td {
    padding: 12px 10px;
    border-bottom: 1px solid #d9e1ec;
    text-align: left;
}

.invoice-table th {
    font-size: 0.78rem;
    text-transform: uppercase;
    color: #58708d;
}

.invoice-summary {
    margin-left: auto;
    margin-top: 28px;
    width: 320px;
}

.signature-stamp {
    max-width: 220px;
    opacity: 0.9;
}

.invoice-note {
    margin-top: 24px;
    padding: 18px;
    border-radius: 16px;
    background: #f8fafc;
}

.mobile-nav {
    display: none;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.03);
    padding: 0;
}

.mobile-nav span {
    display: block;
    width: 18px;
    height: 2px;
    margin: 4px auto;
    background: #fff;
}

@media (max-width: 1100px) {
    .metrics,
    .form-grid-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .split-layout,
    .invoice-print-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .admin-frame {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        inset: 16px auto 16px 16px;
        width: 280px;
        transform: translateX(-120%);
        transition: transform 0.2s ease;
        z-index: 20;
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .mobile-nav {
        display: block;
    }

    .topbar {
        align-items: flex-start;
    }

    .topbar-title {
        font-size: 1.6rem;
    }
}

@media (max-width: 760px) {
    .metrics,
    .form-grid,
    .form-grid-3,
    .line-item {
        grid-template-columns: 1fr;
    }

    .field-span-2,
    .field-span-3 {
        grid-column: auto;
    }

    .topbar {
        flex-direction: column;
    }
}
