:root {
    color-scheme: dark;
    --bg: #090a0c;
    --surface: #121418;
    --surface-raised: #181b20;
    --surface-soft: #20242a;
    --line: #2b3037;
    --line-strong: #3b424b;
    --text: #f4f4f2;
    --muted: #9aa0a9;
    --orange: #f59a18;
    --orange-strong: #ffad33;
    --orange-soft: rgba(245, 154, 24, .12);
    --green: #48c78e;
    --red: #ff6b6b;
    --blue: #70a7ff;
    --shadow: 0 18px 48px rgba(0, 0, 0, .28);
    --radius: 14px;
    --sidebar: 256px;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

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

body {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at 80% 0%, rgba(245, 154, 24, .06), transparent 26rem),
        linear-gradient(180deg, #0b0c0e, var(--bg));
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}

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

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

button {
    cursor: pointer;
}

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

.sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    width: var(--sidebar);
    height: 100vh;
    border-right: 1px solid var(--line);
    background: #0e1013;
}

.brand {
    display: flex;
    height: 112px;
    align-items: center;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
}

.brand img {
    display: block;
    width: 100%;
    height: auto;
}

.nav {
    display: grid;
    gap: 7px;
    padding: 18px 14px;
}

.nav-label {
    margin: 18px 10px 4px;
    color: #666d76;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .16em;
    text-transform: uppercase;
}

.nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 10px;
    color: #b8bdc4;
    font-weight: 650;
    transition: .18s ease;
}

.nav a:hover {
    border-color: var(--line);
    background: var(--surface-raised);
    color: var(--text);
}

.nav a.active {
    border-color: rgba(245, 154, 24, .28);
    background: var(--orange-soft);
    color: var(--orange-strong);
}

.nav-icon {
    display: grid;
    width: 22px;
    height: 22px;
    place-items: center;
    color: currentColor;
}

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

.main {
    min-width: 0;
    grid-column: 2;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    min-height: 72px;
    align-items: center;
    justify-content: space-between;
    padding: 14px clamp(20px, 3vw, 42px);
    border-bottom: 1px solid var(--line);
    background: #0a0b0d;
}

.topbar-title {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.signal {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 4px rgba(72, 199, 142, .12);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-copy {
    display: grid;
    text-align: right;
}

.user-copy strong {
    font-size: 13px;
}

.user-copy span {
    color: var(--muted);
    font-size: 11px;
}

.content {
    width: min(1480px, 100%);
    margin: 0 auto;
    padding: 34px clamp(20px, 3vw, 44px) 64px;
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--orange);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .15em;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 5px;
    font-size: clamp(27px, 3vw, 38px);
    line-height: 1.08;
    letter-spacing: -.035em;
}

h2 {
    margin-bottom: 16px;
    font-size: 19px;
    letter-spacing: -.02em;
}

h3 {
    font-size: 15px;
}

.subtitle {
    max-width: 720px;
    margin-bottom: 0;
    color: var(--muted);
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 15px;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    background: var(--surface-raised);
    color: var(--text);
    font-weight: 750;
    transition: .18s ease;
}

.button:hover {
    border-color: #59616c;
    transform: translateY(-1px);
}

.button-primary {
    border-color: var(--orange);
    background: var(--orange);
    color: #17120b;
}

.button-primary:hover {
    border-color: var(--orange-strong);
    background: var(--orange-strong);
}

.button-ghost {
    background: transparent;
}

.button-danger {
    border-color: rgba(255, 107, 107, .35);
    background: rgba(255, 107, 107, .08);
    color: #ff9898;
}

.button-small {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 12px;
}

.icon-button {
    width: 40px;
    height: 40px;
    padding: 0;
}

.mobile-menu {
    display: none;
}

.grid {
    display: grid;
    gap: 18px;
}

.metrics {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    margin-bottom: 24px;
}

.metric {
    position: relative;
    min-height: 138px;
    overflow: hidden;
    padding: 21px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: linear-gradient(145deg, var(--surface-raised), var(--surface));
    box-shadow: var(--shadow);
}

.metric::after {
    position: absolute;
    right: -24px;
    bottom: -38px;
    width: 100px;
    height: 100px;
    border: 1px solid rgba(245, 154, 24, .13);
    border-radius: 50%;
    content: "";
}

.metric-label {
    display: block;
    min-height: 42px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.metric-value {
    display: block;
    margin-top: 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: clamp(24px, 2.2vw, 33px);
    font-weight: 800;
    letter-spacing: -.05em;
}

.metric-accent .metric-value {
    color: var(--orange);
}

.panel {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.panel-header {
    display: flex;
    min-height: 66px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}

.panel-header h2,
.panel-header p {
    margin-bottom: 0;
}

.panel-body {
    padding: 22px;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th,
td {
    padding: 15px 18px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

th {
    color: #7f858e;
    font-size: 10px;
    font-weight: 850;
    letter-spacing: .11em;
    text-transform: uppercase;
}

td {
    color: #d8dadd;
}

tbody tr {
    transition: background .16s ease;
}

tbody tr:hover {
    background: rgba(255, 255, 255, .018);
}

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

.table-link {
    font-weight: 780;
}

.table-link:hover {
    color: var(--orange);
}

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

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.nowrap {
    white-space: nowrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--surface-soft);
    color: #c4c8ce;
    font-size: 11px;
    font-weight: 780;
    white-space: nowrap;
}

.badge::before {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    content: "";
}

.badge-orange {
    border-color: rgba(245, 154, 24, .28);
    background: rgba(245, 154, 24, .09);
    color: var(--orange);
}

.badge-green {
    border-color: rgba(72, 199, 142, .25);
    background: rgba(72, 199, 142, .08);
    color: var(--green);
}

.badge-blue {
    border-color: rgba(112, 167, 255, .28);
    background: rgba(112, 167, 255, .08);
    color: var(--blue);
}

.badge-red {
    border-color: rgba(255, 107, 107, .28);
    background: rgba(255, 107, 107, .08);
    color: var(--red);
}

.filters {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 18px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(18, 20, 24, .72);
}

.filters .field {
    min-width: 180px;
    margin: 0;
}

.filters .field-grow {
    flex: 1;
}

.field {
    display: grid;
    gap: 7px;
    margin-bottom: 17px;
}

.field label,
.field-label {
    color: #b8bdc4;
    font-size: 12px;
    font-weight: 750;
}

.field-help {
    color: #737a84;
    font-size: 11px;
}

input,
select,
textarea {
    width: 100%;
    min-height: 43px;
    padding: 9px 11px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    outline: none;
    background: #0e1013;
    color: var(--text);
    transition: .16s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(245, 154, 24, .12);
}

textarea {
    min-height: 100px;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: #5f656d;
}

input[type="checkbox"] {
    width: 18px;
    min-height: 18px;
    accent-color: var(--orange);
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 42px;
    color: #c8cbd0;
    font-size: 13px;
    font-weight: 650;
}

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

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

.form-section {
    padding: 22px;
    border-bottom: 1px solid var(--line);
}

.form-section:last-child {
    border-bottom: 0;
}

.section-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
}

.section-number {
    display: grid;
    width: 26px;
    height: 26px;
    place-items: center;
    border: 1px solid rgba(245, 154, 24, .4);
    border-radius: 6px;
    background: var(--orange-soft);
    color: var(--orange);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    font-weight: 800;
}

.section-heading h2 {
    margin: 0;
    font-size: 16px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px 22px;
    background: #0f1114;
}

.flash {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    padding: 13px 16px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: var(--surface-raised);
}

.flash-success {
    border-color: rgba(72, 199, 142, .35);
    color: #8fe0bb;
}

.flash-error {
    border-color: rgba(255, 107, 107, .38);
    color: #ff9f9f;
}

.error-list {
    margin: 5px 0 0;
    padding-left: 18px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--line);
}

.detail {
    min-height: 82px;
    padding: 15px;
    background: var(--surface);
}

.detail span {
    display: block;
    margin-bottom: 6px;
    color: #767d86;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.detail strong {
    color: #e0e2e5;
    font-weight: 690;
    overflow-wrap: anywhere;
}

.empty {
    padding: 54px 24px;
    text-align: center;
}

.empty-mark {
    display: grid;
    width: 52px;
    height: 52px;
    margin: 0 auto 15px;
    place-items: center;
    border: 1px solid var(--line-strong);
    border-radius: 13px;
    background: var(--surface-raised);
    color: var(--orange);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 18px;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 18px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
}

.auth-page {
    display: grid;
    min-height: 100vh;
    grid-template-columns: minmax(300px, 1fr) minmax(420px, 520px);
}

.auth-visual {
    position: relative;
    display: flex;
    overflow: hidden;
    align-items: flex-end;
    padding: clamp(40px, 7vw, 90px);
    border-right: 1px solid var(--line);
    background:
        linear-gradient(140deg, rgba(245, 154, 24, .08), transparent 38%),
        repeating-linear-gradient(90deg, transparent 0 79px, rgba(255, 255, 255, .018) 80px),
        repeating-linear-gradient(0deg, transparent 0 79px, rgba(255, 255, 255, .018) 80px),
        #0b0c0e;
}

.auth-visual::after {
    position: absolute;
    top: 18%;
    right: 10%;
    width: min(38vw, 560px);
    height: min(38vw, 560px);
    border: 1px solid rgba(245, 154, 24, .13);
    border-radius: 50%;
    box-shadow:
        0 0 0 50px rgba(245, 154, 24, .025),
        0 0 0 100px rgba(245, 154, 24, .015);
    content: "";
}

.auth-visual-content {
    position: relative;
    z-index: 1;
    max-width: 660px;
}

.auth-logo {
    width: min(480px, 80%);
    margin-bottom: 48px;
}

.auth-visual h1 {
    max-width: 620px;
    font-size: clamp(36px, 5vw, 72px);
    text-transform: uppercase;
}

.auth-visual h1 span {
    color: var(--orange);
}

.auth-panel {
    display: grid;
    place-items: center;
    padding: 42px;
    background: #0d0f12;
}

.auth-card {
    width: 100%;
    max-width: 390px;
}

.auth-card h2 {
    margin-bottom: 7px;
    font-size: 27px;
}

.auth-card .subtitle {
    margin-bottom: 28px;
}

.auth-actions {
    display: grid;
    gap: 12px;
    margin-top: 22px;
}

.auth-actions .button {
    width: 100%;
}

.auth-link {
    color: var(--orange);
    font-size: 12px;
    font-weight: 700;
}

.security-grid {
    grid-template-columns: minmax(0, 1fr) minmax(280px, .8fr);
}

.qr-code {
    display: inline-grid;
    padding: 14px;
    border-radius: 10px;
    background: #fff;
}

.qr-code svg {
    display: block;
    width: 210px;
    height: 210px;
}

.recovery-codes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 0;
    list-style: none;
}

.recovery-codes li {
    padding: 9px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #0d0f12;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
}

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

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

@media (max-width: 860px) {
    :root {
        --sidebar: 280px;
    }

    .app-shell {
        display: block;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        transform: translateX(-100%);
        box-shadow: 20px 0 50px rgba(0, 0, 0, .45);
        transition: transform .22s ease;
    }

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

    .main {
        width: 100%;
    }

    .mobile-menu {
        display: inline-flex;
    }

    .topbar-title {
        display: none;
    }

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

    .auth-page {
        grid-template-columns: 1fr;
    }

    .auth-visual {
        display: none;
    }

    .auth-panel {
        min-height: 100vh;
    }
}

@media (max-width: 620px) {
    .content {
        padding-top: 24px;
    }

    .user-copy {
        display: none;
    }

    .page-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .toolbar .button {
        flex: 1;
    }

    .metrics,
    .form-grid,
    .form-grid-3,
    .detail-grid,
    .security-grid {
        grid-template-columns: 1fr;
    }

    .metric {
        min-height: 112px;
    }

    .filters {
        align-items: stretch;
        flex-direction: column;
    }

    .filters .field {
        width: 100%;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions .button {
        width: 100%;
    }

    .auth-panel {
        padding: 26px 20px;
    }

    th,
    td {
        padding: 12px;
    }
}
