:root,
html[data-theme="dark"] {
    --bg: #0b0f14;
    --bg-2: #101722;
    --panel: #141c27;
    --panel-2: #182232;
    --line: #263244;
    --line-soft: #1f2a3a;
    --text: #e7edf5;
    --muted: #8fa1b6;
    --muted-2: #697b91;
    --accent: #3dd7ff;
    --accent-2: #1fa9d5;
    --danger: #ff5f6d;
    --success: #32d583;
    --warning: #fdb022;
    --info: #7c8cff;
    --shadow: 0 18px 60px rgba(0,0,0,.32);
    --field: #0f1621;
}

html[data-theme="light"] {
    --bg: #eef1f4;
    --bg-2: #e1e6eb;
    --panel: #ffffff;
    --panel-2: #f6f8fa;
    --line: #cfd8e3;
    --line-soft: #e2e8ef;
    --text: #121822;
    --muted: #627084;
    --muted-2: #7d8a99;
    --accent: #006d91;
    --accent-2: #004c68;
    --danger: #b42335;
    --success: #027a48;
    --warning: #b54708;
    --info: #3347d6;
    --shadow: 0 18px 45px rgba(15, 23, 42, .10);
    --field: #ffffff;
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 25% -10%, rgba(61,215,255,.12), transparent 32%),
        linear-gradient(180deg, var(--bg), var(--bg-2));
    color: var(--text);
    font-family: "Segoe UI", Arial, Helvetica, sans-serif;
    font-size: 14px;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--text);
}

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

.sidebar {
    border-right: 1px solid var(--line);
    background: rgba(13, 18, 25, .78);
    backdrop-filter: blur(16px);
    padding: 22px 18px;
    position: sticky;
    top: 0;
    height: 100vh;
}

html[data-theme="light"] .sidebar {
    background: rgba(255,255,255,.86);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--line-soft);
}

.brand-mark {
    width: 42px;
    height: 42px;
    border: 1px solid var(--accent);
    display: grid;
    place-items: center;
    color: var(--accent);
    font-weight: 800;
    letter-spacing: .08em;
    background: linear-gradient(135deg, rgba(61,215,255,.12), transparent);
}

.brand-title {
    font-weight: 800;
    letter-spacing: .03em;
    line-height: 1.1;
}

.brand-subtitle {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.nav-block {
    margin-top: 22px;
}

.nav-label {
    color: var(--muted-2);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .12em;
    margin: 0 0 10px;
}

.nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    padding: 11px 12px;
    border-left: 2px solid transparent;
    margin-bottom: 4px;
    background: transparent;
}

.nav-link:hover,
.nav-link.active {
    color: var(--text);
    background: rgba(61,215,255,.08);
    border-left-color: var(--accent);
}

.nav-link small {
    color: var(--muted-2);
}

.sidebar-bottom {
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: 18px;
    color: var(--muted);
    font-size: 12px;
}

.main {
    min-width: 0;
    padding: 24px;
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.page-kicker {
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: .16em;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 7px;
}

h1, h2, h3 {
    margin: 0;
    line-height: 1.15;
}

h1 {
    font-size: 28px;
    letter-spacing: -.03em;
}

h2 {
    font-size: 18px;
}

.subline {
    color: var(--muted);
    margin: 8px 0 0;
    line-height: 1.5;
}

.userbar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.user-chip {
    border: 1px solid var(--line);
    background: var(--panel);
    padding: 9px 11px;
    color: var(--muted);
    white-space: nowrap;
}

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

.grid.stats {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    margin-bottom: 18px;
}

.grid.two {
    grid-template-columns: minmax(0, 1.45fr) minmax(340px, .65fr);
    align-items: start;
}

.card {
    background: rgba(20, 28, 39, .88);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

html[data-theme="light"] .card {
    background: rgba(255,255,255,.92);
}

.card-head {
    padding: 16px 18px;
    border-bottom: 1px solid var(--line-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-title {
    font-weight: 800;
    letter-spacing: .02em;
}

.card-body {
    padding: 18px;
}

.card-footer {
    padding: 16px 18px;
    border-top: 1px solid var(--line-soft);
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.stat-card {
    padding: 16px;
    border: 1px solid var(--line);
    background: var(--panel);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: "";
    position: absolute;
    right: -20px;
    top: -36px;
    width: 88px;
    height: 88px;
    border: 1px solid rgba(61,215,255,.24);
    transform: rotate(20deg);
}

.stat-label {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.stat-value {
    font-size: 31px;
    font-weight: 800;
    margin-top: 8px;
}

.toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: end;
    margin-bottom: 16px;
}

.toolbar .field {
    margin: 0;
}

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

table.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}

.data-table th,
.data-table td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
    text-align: left;
}

.data-table th {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .10em;
    background: rgba(255,255,255,.02);
    font-weight: 700;
}

html[data-theme="light"] .data-table th {
    background: #f4f7fa;
}

.data-table tr:hover td {
    background: rgba(61,215,255,.035);
}

.text-right {
    text-align: right !important;
}

.nowrap {
    white-space: nowrap;
}

.small,
small {
    font-size: 12px;
    color: var(--muted);
}

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

.strong {
    font-weight: 800;
}

.stack {
    display: grid;
    gap: 12px;
}

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

.col-12 { grid-column: span 12; }
.col-8 { grid-column: span 8; }
.col-6 { grid-column: span 6; }
.col-4 { grid-column: span 4; }
.col-3 { grid-column: span 3; }
.col-2 { grid-column: span 2; }

.field {
    margin-bottom: 14px;
}

label {
    display: block;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 7px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--field);
    color: var(--text);
    padding: 11px 12px;
    outline: none;
    border-radius: 0;
    font: inherit;
}

textarea {
    resize: vertical;
    line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: inset 3px 0 0 var(--accent);
}

.form-hint {
    color: var(--muted-2);
    font-size: 12px;
    margin-top: 7px;
    line-height: 1.45;
}

.btn,
button.btn,
a.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    padding: 9px 13px;
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--text);
    font-weight: 700;
    letter-spacing: .015em;
    cursor: pointer;
    border-radius: 0;
    font: inherit;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover {
    border-color: var(--accent);
    color: var(--text);
}

.btn-sm {
    min-height: 31px;
    padding: 6px 9px;
    font-size: 12px;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #061018;
}

.btn-primary:hover {
    background: var(--accent-2);
    border-color: var(--accent-2);
    color: #fff;
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: #04150d;
}

.btn-warning {
    background: var(--warning);
    border-color: var(--warning);
    color: #1e1200;
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.btn-ghost {
    background: transparent;
}

.btn-full {
    width: 100%;
}

.btn[disabled],
button:disabled {
    opacity: .54;
    cursor: not-allowed;
}

.inline-form {
    display: inline-flex;
    margin: 0;
    vertical-align: middle;
}

.actions {
    display: flex;
    gap: 7px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--line);
    padding: 5px 8px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    background: var(--panel-2);
}

.status::before {
    content: "";
    width: 7px;
    height: 7px;
    background: currentColor;
}

.status-success { color: var(--success); }
.status-warning { color: var(--warning); }
.status-danger { color: var(--danger); }
.status-info { color: var(--info); }
.status-primary { color: var(--accent); }
.status-dark { color: var(--muted); }
.status-secondary { color: var(--muted); }

.alert {
    border: 1px solid var(--line);
    background: var(--panel);
    padding: 12px 14px;
    margin-bottom: 16px;
    color: var(--text);
}

.alert-success {
    border-left: 4px solid var(--success);
}

.alert-danger {
    border-left: 4px solid var(--danger);
}

.alert-info {
    border-left: 4px solid var(--accent);
}

.log-list {
    display: grid;
    gap: 10px;
}

.log-item {
    border: 1px solid var(--line-soft);
    padding: 12px;
    background: rgba(255,255,255,.02);
}

.log-top {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
}

.hr {
    height: 1px;
    background: var(--line-soft);
    margin: 20px 0;
}

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

.login-card {
    width: 100%;
    max-width: 430px;
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.login-head {
    padding: 24px;
    border-bottom: 1px solid var(--line-soft);
}

.login-body {
    padding: 24px;
}

.login-title {
    font-size: 25px;
    font-weight: 800;
}

.theme-toggle {
    width: 38px;
    min-width: 38px;
    padding: 0;
}

.empty {
    padding: 28px;
    color: var(--muted);
    text-align: center;
}

.preview-box {
    border: 1px solid var(--line-soft);
    background: var(--field);
    padding: 14px;
    white-space: pre-wrap;
    line-height: 1.5;
    max-height: 420px;
    overflow: auto;
}

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

    .sidebar {
        position: relative;
        height: auto;
        display: block;
    }

    .sidebar-bottom {
        position: static;
        margin-top: 16px;
    }

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

    .topbar {
        display: block;
    }

    .userbar {
        margin-top: 14px;
        justify-content: flex-start;
    }
}

@media (max-width: 720px) {
    .main {
        padding: 16px;
    }

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

    .col-12,
    .col-8,
    .col-6,
    .col-4,
    .col-3,
    .col-2 {
        grid-column: auto;
    }

    .card-head,
    .card-footer {
        display: block;
    }

    .card-head .actions,
    .card-footer .actions {
        margin-top: 12px;
        justify-content: flex-start;
    }
}

.checkline {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    color: var(--text);
    text-transform: none;
    letter-spacing: 0;
    line-height: 1.45;
}

.checkline input {
    width: auto;
    margin-top: 2px;
}

.data-table.compact th,
.data-table.compact td {
    padding: 8px 10px;
    font-size: 13px;
}


.row-actions {
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: nowrap;
}

@media (max-width: 980px) {
    .row-actions {
        flex-wrap: wrap;
    }
}
