:root {
    --bg: #f4f7fb;
    --panel: rgba(255, 255, 255, 0.92);
    --line: #e5e9f2;
    --text: #0f172a;
    --muted: #64748b;
    --accent: #111827;
    --accent-soft: #eef2ff;
    --shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius-md: 16px;
}

:root[data-theme="dark"] {
    --bg: #08111f;
    --panel: rgba(9, 18, 33, 0.84);
    --line: rgba(148, 163, 184, 0.18);
    --text: #e5eefb;
    --muted: #9fb0c8;
    --accent: #f8fafc;
    --accent-soft: rgba(30, 41, 59, 0.8);
    --shadow: 0 30px 80px rgba(2, 6, 23, 0.4);
}

* {
    box-sizing: border-box;
}

body {
    background:
        radial-gradient(circle at top left, rgba(226, 232, 240, 0.6), transparent 28%),
        radial-gradient(circle at right 20%, rgba(241, 245, 249, 0.85), transparent 26%),
        linear-gradient(180deg, #f8fafc 0%, #f3f6fb 100%);
    color: var(--text);
    font-family: "Instrument Sans", "Segoe UI", sans-serif;
    min-height: 100vh;
}

:root[data-theme="dark"] body {
    background:
        radial-gradient(circle at top left, rgba(59, 130, 246, 0.14), transparent 28%),
        radial-gradient(circle at right 20%, rgba(20, 184, 166, 0.12), transparent 24%),
        linear-gradient(180deg, #06101d 0%, #0b1526 100%);
}

.admin-body {
    margin: 0;
}

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

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

.sidebar-inner {
    min-width: 0;
}

.sidebar-toggle {
    display: none;
    margin-top: 18px;
}

:root[data-theme="dark"] .sidebar {
    background: rgba(8, 15, 29, 0.82);
    border-right-color: rgba(148, 163, 184, 0.08);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--text);
    text-decoration: none;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    color: var(--muted);
}

.brand-mark {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #fff;
    font-weight: 700;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    color: #334155;
}

:root[data-theme="dark"] .sidebar .nav-link {
    color: #c5d4e8;
}

.sidebar .nav-link.active,
.sidebar .nav-link:hover {
    background: #fff;
    color: var(--accent);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

:root[data-theme="dark"] .sidebar .nav-link.active,
:root[data-theme="dark"] .sidebar .nav-link:hover {
    background: rgba(15, 23, 42, 0.82);
    box-shadow: 0 18px 40px rgba(2, 6, 23, 0.32);
}

.sidebar-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding-top: 20px;
}

.sidebar-footer-mobile {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

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

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

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
}

.panel-card,
.metric-card,
.login-panel {
    border: 1px solid rgba(255, 255, 255, 0.6);
    background: var(--panel);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
    border-radius: var(--radius-xl);
}

.panel-card {
    padding: 24px;
}

.metric-card {
    padding: 24px;
}

.metric-card span {
    display: block;
    font-size: 0.88rem;
    color: var(--muted);
    margin-bottom: 10px;
}

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

.chart-card {
    position: relative;
    height: 320px;
}

.chart-card-sm {
    height: 300px;
}

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

.quick-action-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 148px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.6);
    color: var(--text);
    text-decoration: none;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.quick-action-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 28px rgba(15, 23, 42, 0.08);
    border-color: rgba(37, 99, 235, 0.22);
}

.quick-action-card i {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, #0f172a 0%, #274060 100%);
    color: #fff;
    font-size: 1.1rem;
}

.quick-action-card strong {
    font-size: 1rem;
}

.quick-action-card span {
    color: var(--muted);
    line-height: 1.55;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

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

.stack-item,
.detail-list div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.stack-item:last-child,
.detail-list div:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.detail-list span {
    color: var(--muted);
}

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

.summary-row.total {
    font-size: 1.1rem;
    border-bottom: 0;
}

.invoice-summary-card {
    position: sticky;
    top: 28px;
}

.invoice-items-table textarea {
    min-width: 220px;
}

.invoice-frame {
    width: 100%;
    min-height: 1100px;
    border: 0;
    background: #fff;
}

.settings-logo-preview {
    max-width: 180px;
    max-height: 80px;
    object-fit: contain;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 8px;
    background: #fff;
}

.login-page {
    background:
        radial-gradient(circle at top left, rgba(158, 196, 255, 0.55), transparent 22%),
        radial-gradient(circle at 88% 16%, rgba(255, 223, 186, 0.35), transparent 20%),
        linear-gradient(135deg, #eef4ff 0%, #f8fbff 48%, #fff8ef 100%);
}

.login-panel {
    padding: 38px;
}

.login-shell {
    position: relative;
    overflow: hidden;
    min-height: 100vh;
}

.login-wrap {
    position: relative;
    z-index: 2;
}

.login-orb {
    position: absolute;
    border-radius: 999px;
    filter: blur(8px);
    opacity: 0.9;
    animation: floatOrb 14s ease-in-out infinite;
}

.login-orb-one {
    width: 340px;
    height: 340px;
    top: 8%;
    left: -90px;
    background: radial-gradient(circle at 30% 30%, rgba(106, 169, 255, 0.75), rgba(106, 169, 255, 0.05));
}

.login-orb-two {
    width: 300px;
    height: 300px;
    right: -60px;
    bottom: 10%;
    animation-delay: -5s;
    background: radial-gradient(circle at 40% 40%, rgba(255, 191, 122, 0.6), rgba(255, 191, 122, 0.04));
}

.login-story {
    position: relative;
    padding: 40px 24px;
    animation: slideUp 0.8s ease;
}

.login-story::before {
    content: "";
    position: absolute;
    inset: 24px 0 auto auto;
    width: 180px;
    height: 180px;
    border-radius: 32px;
    background:
        linear-gradient(135deg, rgba(15, 23, 42, 0.08), rgba(15, 23, 42, 0)),
        repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.5) 0 12px, rgba(255, 255, 255, 0.1) 12px 24px);
    transform: rotate(14deg);
}

.login-kicker {
    margin: 12px 0 10px;
    color: #47617d;
    font-size: 0.78rem;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    font-weight: 700;
}

.login-story h1 {
    max-width: 560px;
    font-size: clamp(2.8rem, 5vw, 4.8rem);
    line-height: 0.96;
    margin: 0 0 18px;
    letter-spacing: -0.05em;
}

.login-lead {
    max-width: 520px;
    font-size: 1.08rem;
    line-height: 1.8;
    color: #526277;
    margin-bottom: 28px;
}

.login-feature-grid {
    display: grid;
    gap: 16px;
    max-width: 540px;
}

.login-feature {
    display: grid;
    grid-template-columns: 52px 1fr;
    gap: 16px;
    padding: 18px 20px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.52);
    box-shadow: 0 20px 45px rgba(56, 74, 103, 0.08);
    backdrop-filter: blur(14px);
}

.login-feature span {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: linear-gradient(135deg, #0f172a 0%, #23324b 100%);
    color: #fff;
    font-size: 1.15rem;
}

.login-feature strong {
    display: block;
    margin-bottom: 4px;
    font-size: 1rem;
}

.login-feature p {
    margin: 0;
    color: #607286;
    line-height: 1.6;
}

.login-panel-animated {
    animation: slideUp 0.9s ease;
}

.login-panel-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.login-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.88);
    color: var(--accent);
    font-weight: 700;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.login-panel-mark {
    width: 50px;
    height: 50px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: linear-gradient(135deg, #101828 0%, #314158 100%);
    color: #fff;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.login-panel h2 {
    margin: 0 0 8px;
    font-size: 2.2rem;
    letter-spacing: -0.04em;
}

.login-panel-copy {
    margin-bottom: 24px;
    color: #607286;
    line-height: 1.7;
}

.login-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    padding: 10px 14px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
    color: var(--accent);
    font-weight: 600;
}

.login-help {
    margin-top: 18px;
    color: var(--muted);
    font-size: 0.9rem;
}

.input-icon {
    position: relative;
}

.input-icon i {
    position: absolute;
    top: 50%;
    left: 18px;
    transform: translateY(-50%);
    color: #7c8da3;
    font-size: 1rem;
    pointer-events: none;
}

.input-icon .form-control {
    padding-left: 48px;
    min-height: 62px;
    border-radius: 18px;
    border-color: #d9e4f2;
    background: rgba(255, 255, 255, 0.88);
}

.input-icon .form-control:focus {
    border-color: #7ba6e8;
    box-shadow: 0 0 0 0.25rem rgba(123, 166, 232, 0.18);
}

.login-submit {
    min-height: 60px;
    border-radius: 18px;
    background: linear-gradient(135deg, #101828 0%, #1f314d 100%);
    border: 0;
    box-shadow: 0 18px 34px rgba(16, 24, 40, 0.18);
}

@keyframes floatOrb {
    0%, 100% {
        transform: translate3d(0, 0, 0);
    }
    50% {
        transform: translate3d(0, -18px, 0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(22px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.table > :not(caption) > * > * {
    padding: 1rem 0.9rem;
}

.table thead th {
    border-bottom-width: 1px;
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

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

.btn {
    border-radius: 14px;
    font-weight: 600;
}

:root[data-theme="dark"] .btn-outline-dark {
    border-color: rgba(191, 219, 254, 0.22);
    color: #dbeafe;
}

:root[data-theme="dark"] .btn-light {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.08);
    color: #eff6ff;
}

.form-control,
.form-select {
    border-radius: 14px;
    border-color: #d8e0ec;
    padding: 0.82rem 0.95rem;
    box-shadow: none;
}

.form-control:focus,
.form-select:focus {
    border-color: #94a3b8;
    box-shadow: 0 0 0 0.2rem rgba(148, 163, 184, 0.18);
}

:root[data-theme="dark"] .form-control,
:root[data-theme="dark"] .form-select {
    background: rgba(8, 15, 29, 0.62);
    border-color: rgba(148, 163, 184, 0.18);
    color: #e5eefb;
}

:root[data-theme="dark"] .form-control::placeholder {
    color: #8da0b9;
}

:root[data-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text);
    --bs-table-border-color: var(--line);
}

:root[data-theme="dark"] .text-secondary {
    color: #97a9c3 !important;
}

:root[data-theme="dark"] .alert {
    color: inherit;
}

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

    .sidebar {
        position: relative;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid rgba(15, 23, 42, 0.05);
        padding: 18px;
    }

    .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        gap: 8px;
    }

    .sidebar-collapse {
        padding-top: 6px;
    }

    .sidebar > .sidebar-footer {
        display: none;
    }

    .content-topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
    }

    .content-topbar > div:last-child {
        width: 100%;
        flex-wrap: wrap;
    }

    .content-topbar > div:last-child .btn {
        flex: 1 1 calc(50% - 8px);
    }

    .quick-actions-grid {
        grid-template-columns: 1fr;
    }

    .invoice-summary-card {
        position: static;
    }

    .panel-card,
    .metric-card {
        padding: 20px;
    }

    .panel-head form,
    .panel-head .d-flex,
    .panel-head .row {
        width: 100%;
    }

    .panel-head .form-control,
    .panel-head .form-select,
    .panel-head .btn {
        width: 100%;
    }

    .login-story {
        padding: 24px 0 0;
    }

    .login-story::before {
        display: none;
    }

    .login-story h1 {
        font-size: 2.8rem;
    }
}

@media (max-width: 767.98px) {
    .content-area {
        padding: 18px;
    }

    .content-topbar {
        gap: 14px;
    }

    .content-topbar > div:last-child {
        width: 100%;
        flex-wrap: wrap;
    }

    .content-topbar > div:last-child .btn {
        flex: 1 1 100%;
    }

    .sidebar {
        padding: 14px;
    }

    .brand {
        gap: 10px;
    }

    .brand-mark {
        width: 42px;
        height: 42px;
        border-radius: 14px;
    }

    .panel-card,
    .metric-card {
        padding: 18px;
        border-radius: 22px;
    }

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

    .panel-head {
        gap: 12px;
        margin-bottom: 14px;
    }

    .stack-item,
    .detail-list div,
    .summary-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-control,
    .form-select {
        padding: 0.78rem 0.9rem;
    }

    .quick-action-card {
        min-height: auto;
    }

    .table-mobile-cards thead {
        display: none;
    }

    .table-mobile-cards,
    .table-mobile-cards tbody,
    .table-mobile-cards tr,
    .table-mobile-cards td {
        display: block;
        width: 100%;
    }

    .table-mobile-cards tr {
        padding: 14px 0;
        border-bottom: 1px solid var(--line);
    }

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

    .table-mobile-cards td {
        border: 0;
        padding: 0.45rem 0;
        text-align: left !important;
    }

    .table-mobile-cards td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 0.2rem;
        color: var(--muted);
        font-size: 0.72rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.08em;
    }

    .chart-card,
    .chart-card-sm {
        height: 260px;
    }

    .invoice-frame {
        min-height: 780px;
    }

    .login-panel {
        padding: 24px;
    }

    .login-feature {
        grid-template-columns: 1fr;
    }

    .login-feature span {
        width: 44px;
        height: 44px;
        border-radius: 14px;
    }
}

@media print {
    .sidebar,
    .content-topbar,
    .alert,
    .btn,
    .panel-card:not(.invoice-preview) {
        display: none !important;
    }

    .content-area {
        padding: 0;
    }
}
