:root {
    color-scheme: dark;
    --bg: #080710;
    --bg-2: #111129;
    --panel: rgba(24, 19, 42, .78);
    --panel-strong: rgba(32, 25, 55, .92);
    --line: rgba(153, 116, 255, .22);
    --line-hot: rgba(255, 209, 102, .68);
    --text: #fff8f0;
    --muted: #c7bad7;
    --soft: #8a7aa2;
    --violet: #7f63ff;
    --violet-2: #b589ff;
    --gold: #ffd166;
    --gold-2: #f0a85d;
    --green: #2ee59d;
    --red: #ff5f73;
    --shadow: 0 20px 64px rgba(0, 0, 0, .36);
    --glow: 0 0 24px rgba(127, 99, 255, .13);
}

* { box-sizing: border-box; }

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 18% 7%, rgba(127, 99, 255, .18), transparent 28%),
        radial-gradient(circle at 82% 14%, rgba(255, 209, 102, .10), transparent 24%),
        radial-gradient(circle at 76% 92%, rgba(46, 229, 157, .07), transparent 30%),
        linear-gradient(135deg, #090711 0%, #121027 48%, #191733 100%);
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
    background-size: 64px 64px;
    mask-image: linear-gradient(90deg, rgba(0,0,0,.6), rgba(0,0,0,.08));
}

a { color: inherit; }

svg {
    width: 1.18em;
    height: 1.18em;
    fill: currentColor;
    flex: 0 0 auto;
    vertical-align: -0.16em;
}

.icon-sprite { display: none; }

.app-loader {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    background: rgba(8, 7, 16, .72);
    opacity: 0;
    visibility: hidden;
    transition: opacity .22s ease, visibility .22s ease;
    backdrop-filter: blur(10px);
}

.app-loader.is-active {
    opacity: 1;
    visibility: visible;
}

.app-loader span {
    width: 52px;
    height: 52px;
    border-radius: 999px;
    border: 3px solid rgba(255,255,255,.12);
    border-top-color: var(--gold);
    animation: spin .8s linear infinite;
}

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

.sidebar {
    position: sticky;
    top: 0;
    min-height: 100vh;
    padding: 28px 20px;
    border-right: 1px solid var(--line);
    background:
        linear-gradient(180deg, rgba(22, 15, 41, .96), rgba(9, 7, 18, .86)),
        radial-gradient(circle at top left, rgba(127,99,255,.22), transparent 32%);
    box-shadow: 22px 0 80px rgba(0,0,0,.25);
}

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

.brand-mark {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 209, 102, .64);
    border-radius: 16px;
    color: #120d1f;
    background: linear-gradient(135deg, var(--gold), var(--gold-2));
    box-shadow: 0 0 22px rgba(255, 209, 102, .18);
    font-weight: 950;
}

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

.brand strong {
    letter-spacing: 0;
}

.brand small {
    margin-top: 3px;
    color: var(--muted);
}

.side-nav {
    display: grid;
    gap: 8px;
    margin-top: 46px;
}

.nav-label,
.eyebrow,
.db-label {
    color: #d7c1ff;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.side-nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 50px;
    border: 1px solid transparent;
    border-radius: 16px;
    padding: 0 14px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 850;
    transition: transform .16s ease, border-color .16s ease, background .16s ease, color .16s ease;
}

.side-nav a:hover,
.side-nav a.active {
    color: var(--text);
    border-color: rgba(255, 209, 102, .68);
    background: linear-gradient(135deg, rgba(255,209,102,.14), rgba(127,99,255,.12));
    transform: translateX(2px);
}

.side-nav a.active::before {
    content: "";
    position: absolute;
    left: -8px;
    width: 4px;
    height: 28px;
    border-radius: 999px;
    background: var(--gold);
    box-shadow: 0 0 14px rgba(255, 209, 102, .52);
}

.sidebar-card {
    margin-top: 44px;
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 18px;
    color: var(--muted);
    background: rgba(255,255,255,.045);
}

.sidebar-card strong {
    display: block;
    margin: 10px 0 6px;
    color: var(--text);
}

.pulse-dot {
    width: 12px;
    height: 12px;
    display: inline-block;
    border-radius: 999px;
    background: var(--green);
    box-shadow: 0 0 0 7px rgba(46, 229, 157, .08), 0 0 16px rgba(46, 229, 157, .52);
    animation: pulse 2.4s ease-in-out infinite;
}

.content-shell {
    min-width: 0;
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    gap: 20px;
    padding: 28px clamp(18px, 3vw, 44px);
}

.topbar,
.glass-panel,
.flash {
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--panel);
    box-shadow: var(--shadow), var(--glow);
    backdrop-filter: blur(18px);
}

.topbar {
    min-height: 74px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 16px 22px;
}

.topbar h1,
.page-head h2,
.hero-panel h2 {
    margin: 0;
    font-size: clamp(21px, 2.55vw, 33px);
    line-height: 1.12;
    letter-spacing: 0;
}

.top-actions,
.hero-actions,
.row-actions,
.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.version-pill,
.status-pill {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0 13px;
    color: var(--muted);
    background: rgba(255,255,255,.045);
    font-weight: 850;
}

.status-pill span {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--green);
    box-shadow: 0 0 14px rgba(46, 229, 157, .55);
}

.page-stage {
    display: grid;
    gap: 20px;
    animation: contentIn .14s cubic-bezier(.2, .8, .2, 1) both;
}

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

.hero-panel,
.db-card,
.page-head,
.form-card,
.table-card,
.notice {
    padding: 22px;
}

.hero-panel {
    position: relative;
    overflow: hidden;
}

.hero-panel::after {
    content: "";
    position: absolute;
    inset: auto -80px -110px auto;
    width: 230px;
    height: 230px;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(255,209,102,.12), transparent 62%);
}

.lead,
.page-head p,
.quick-card p,
.muted,
.help,
.note-text,
.db-card p,
.sidebar-card p {
    color: var(--muted);
    line-height: 1.6;
}

.lead {
    max-width: 760px;
    margin: 18px 0 0;
    font-size: 15px;
}

.hero-actions {
    margin-top: 22px;
}

.db-card {
    display: grid;
    align-content: center;
}

.db-card strong {
    display: block;
    margin: 12px 0;
    font-size: 20px;
}

.is-ready {
    border-color: rgba(46, 229, 157, .38);
}

.is-error {
    border-color: rgba(255, 95, 115, .40);
}

.quick-grid,
.detail-grid,
.form-grid {
    display: grid;
    gap: 16px;
}

.quick-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.detail-grid {
    grid-template-columns: minmax(0, 1fr) minmax(320px, .78fr);
}

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

.wide {
    grid-column: 1 / -1;
}

.quick-card,
.client-row,
.file-row {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: linear-gradient(145deg, rgba(255,255,255,.075), rgba(255,255,255,.035));
    box-shadow:
        0 18px 44px rgba(0,0,0,.28),
        inset 0 1px 0 rgba(255,255,255,.055);
    transition: border-color .18s cubic-bezier(.2,.8,.2,1), box-shadow .18s cubic-bezier(.2,.8,.2,1), background .18s cubic-bezier(.2,.8,.2,1), filter .18s cubic-bezier(.2,.8,.2,1);
}

.quick-card::after,
.client-row::after,
.file-row::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    background: linear-gradient(115deg, transparent 0%, rgba(255,255,255,.10) 42%, transparent 68%);
    transform: translateX(-18%);
    transition: opacity .18s ease, transform .28s cubic-bezier(.2,.8,.2,1);
}

.quick-card {
    min-height: 168px;
    padding: 20px;
    color: var(--text);
    text-decoration: none;
}

.quick-card:hover,
.client-row:hover,
.file-row:hover {
    border-color: rgba(255, 209, 102, .58);
    box-shadow:
        0 22px 58px rgba(0,0,0,.34),
        0 0 22px rgba(127, 99, 255, .12),
        inset 0 1px 0 rgba(255,255,255,.075);
    filter: brightness(1.025);
}

.quick-card:hover::after,
.client-row:hover::after,
.file-row:hover::after {
    opacity: 1;
    transform: translateX(18%);
}

.card-icon,
.empty-icon,
.avatar {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    color: #171021;
    background: linear-gradient(135deg, var(--gold), var(--gold-2));
    box-shadow: 0 0 18px rgba(255,209,102,.18);
    font-weight: 950;
}

.quick-card strong {
    display: block;
    margin: 16px 0 8px;
    font-size: 18px;
}

.page-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
}

.split {
    flex-wrap: wrap;
}

.form-card label {
    display: grid;
    gap: 9px;
    color: var(--text);
    font-weight: 850;
}

input,
textarea {
    width: 100%;
    border: 1px solid rgba(153, 116, 255, .28);
    border-radius: 16px;
    padding: 12px 14px;
    color: var(--text);
    background: rgba(10, 8, 20, .62);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
    font: inherit;
    transition: border-color .14s cubic-bezier(.2,.8,.2,1), box-shadow .14s cubic-bezier(.2,.8,.2,1), transform .14s cubic-bezier(.2,.8,.2,1);
}

input::placeholder,
textarea::placeholder {
    color: rgba(199, 186, 215, .58);
}

input:focus,
textarea:focus {
    border-color: rgba(255, 209, 102, .72);
    box-shadow: 0 0 0 3px rgba(255, 209, 102, .08), 0 0 18px rgba(127, 99, 255, .12);
    outline: 0;
    transform: translateY(-1px);
}

input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-picker {
    position: relative;
}

.file-picker em {
    min-height: 50px;
    display: flex;
    align-items: center;
    border: 1px dashed rgba(255, 209, 102, .42);
    border-radius: 16px;
    padding: 0 16px;
    color: var(--muted);
    background: rgba(255,255,255,.045);
    font-style: normal;
    transition: border-color .16s cubic-bezier(.2,.8,.2,1), background .16s cubic-bezier(.2,.8,.2,1);
}

.file-picker:hover em {
    border-color: rgba(255, 209, 102, .76);
    background: rgba(255, 209, 102, .08);
}

.button {
    position: relative;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0 18px;
    cursor: pointer;
    color: var(--text);
    font: inherit;
    font-weight: 950;
    text-decoration: none;
    overflow: hidden;
    transform: translateZ(0);
    transition: transform .14s cubic-bezier(.2,.8,.2,1), box-shadow .14s cubic-bezier(.2,.8,.2,1), border-color .14s cubic-bezier(.2,.8,.2,1), background .14s cubic-bezier(.2,.8,.2,1);
}

.button:hover {
    border-color: rgba(255, 209, 102, .48);
    box-shadow: 0 0 0 1px rgba(255, 209, 102, .10), 0 12px 28px rgba(0,0,0,.18);
}

.button:active {
    transform: translateY(1px) scale(.985);
    box-shadow: inset 0 2px 10px rgba(0,0,0,.28);
}

.button.primary {
    color: #170f20;
    background: linear-gradient(135deg, var(--gold), var(--gold-2));
    box-shadow: 0 12px 26px rgba(255, 209, 102, .16);
}

.button.soft {
    color: var(--text);
    border-color: rgba(127, 99, 255, .38);
    background: rgba(127, 99, 255, .16);
}

.button.ghost {
    color: var(--text);
    border-color: rgba(255,255,255,.12);
    background: rgba(255,255,255,.055);
}

.button.danger {
    color: #fff;
    background: linear-gradient(135deg, #ff6478, #b8324a);
}

.button.is-loading {
    pointer-events: none;
    opacity: .78;
}

.ripple {
    position: absolute;
    border-radius: 999px;
    background: rgba(255,255,255,.34);
    transform: scale(0);
    animation: ripple .55s ease-out;
    pointer-events: none;
}

.client-list,
.file-list {
    display: grid;
    gap: 13px;
}

.client-row,
.file-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px;
}

.row-main {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 13px;
}

.row-main strong,
.row-main span {
    display: block;
}

.row-main span,
.client-row span,
.file-row span {
    color: var(--muted);
}

.avatar.file {
    color: var(--text);
    background: linear-gradient(135deg, rgba(127,99,255,.8), rgba(181,137,255,.7));
}

.empty {
    display: grid;
    justify-items: center;
    gap: 12px;
    padding: 42px 20px;
    text-align: center;
}

.empty strong {
    font-size: 22px;
}

.flash,
.notice {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 18px;
}

.success {
    border-color: rgba(46, 229, 157, .34);
    color: #d9fff0;
    background: rgba(46, 229, 157, .08);
}

.error {
    border-color: rgba(255, 95, 115, .38);
    color: #ffd9df;
    background: rgba(255, 95, 115, .09);
}

.footer {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    color: var(--soft);
    font-size: 14px;
}

[data-reveal] {
    opacity: 0;
    transform: translateY(3px);
    transition: opacity .14s cubic-bezier(.2,.8,.2,1), transform .14s cubic-bezier(.2,.8,.2,1);
}

[data-reveal].is-visible {
    opacity: 1;
    transform: translateY(0);
}

@keyframes contentIn {
    from { opacity: .96; transform: translateY(2px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    50% { transform: scale(.9); box-shadow: 0 0 0 9px rgba(46, 229, 157, .05), 0 0 18px rgba(46, 229, 157, .62); }
}

@keyframes ripple {
    to { transform: scale(3.4); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }
}

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

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

    .side-nav {
        margin-top: 24px;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .nav-label,
    .sidebar-card {
        display: none;
    }

    .hero-grid,
    .quick-grid,
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 680px) {
    .content-shell {
        padding: 16px 12px 24px;
        gap: 16px;
    }

    .topbar,
    .page-head,
    .client-row,
    .file-row,
    .footer {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar h1,
    .page-head h2,
    .hero-panel h2 {
        font-size: 25px;
    }

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

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

    .row-actions,
    .form-actions,
    .hero-actions,
    .top-actions {
        justify-content: flex-start;
    }

    .button {
        width: 100%;
    }
}
