:root {
    --bg: #f8f4ec;
    --bg-soft: #fffdf7;
    --ink: #1d2430;
    --muted: #687182;
    --line: #dbd4c6;
    --primary: #0f9a8c;
    --primary-ink: #fff;
    --accent: #ef8822;
    --danger: #cc3e2f;
    --panel-shadow: 0 14px 40px rgba(18, 34, 52, 0.12);
    --radius: 16px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    color: var(--ink);
    font-family: "Poppins", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
}

body {
    position: relative;
}

.bg-gradient {
    position: fixed;
    inset: 0;
    z-index: -2;
    background:
        radial-gradient(700px 360px at 4% 4%, rgba(239, 136, 34, 0.24), transparent 62%),
        radial-gradient(680px 360px at 96% 4%, rgba(15, 154, 140, 0.22), transparent 60%),
        linear-gradient(180deg, #fffefb 0%, #f8f4ec 100%);
}

.bg-grid {
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image:
        linear-gradient(rgba(23, 36, 54, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(23, 36, 54, 0.04) 1px, transparent 1px);
    background-size: 22px 22px;
    mask-image: radial-gradient(ellipse at center, #000 48%, transparent 86%);
    pointer-events: none;
}

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

.sidebar {
    border-right: 1px solid rgba(80, 100, 120, 0.24);
    backdrop-filter: blur(8px);
    background: rgba(252, 250, 244, 0.88);
    padding: 28px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.brand-tag {
    margin: 0 0 8px;
    font-size: 12px;
    letter-spacing: 0.24em;
    color: var(--accent);
    font-weight: 700;
}

.brand h1 {
    margin: 0;
    font-size: 22px;
    line-height: 1.24;
}

.brand-sub {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.menu {
    display: grid;
    gap: 8px;
}

.menu-item {
    border: 1px solid transparent;
    background: transparent;
    color: #203043;
    text-align: left;
    font-size: 14px;
    font-weight: 600;
    padding: 11px 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.menu-item:hover {
    transform: translateX(3px);
    background: rgba(15, 154, 140, 0.07);
}

.menu-item.is-active {
    border-color: rgba(15, 154, 140, 0.4);
    background: rgba(15, 154, 140, 0.12);
    color: #0a4a43;
}

.sidebar-foot {
    margin-top: auto;
    border-top: 1px dashed var(--line);
    padding-top: 14px;
    display: grid;
    gap: 8px;
}

.sidebar-foot p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}

.sidebar-foot code {
    font-size: 12px;
    color: #3b4250;
    background: rgba(18, 34, 52, 0.05);
    border: 1px solid rgba(18, 34, 52, 0.1);
    border-radius: 8px;
    padding: 6px 8px;
}

.sidebar-foot a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
}

.main {
    padding: 22px;
    display: grid;
    gap: 14px;
    align-content: start;
}

.topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: end;
}

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

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

input,
select,
textarea {
    border: 1px solid rgba(18, 34, 52, 0.16);
    border-radius: 11px;
    padding: 10px 12px;
    background: #fff;
    color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: rgba(15, 154, 140, 0.7);
    box-shadow: 0 0 0 3px rgba(15, 154, 140, 0.14);
}

.btn {
    border: 1px solid rgba(18, 34, 52, 0.18);
    background: #fff;
    color: #223247;
    border-radius: 11px;
    padding: 9px 13px;
    cursor: pointer;
    transition: transform 130ms ease, box-shadow 130ms ease, background 130ms ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(18, 34, 52, 0.1);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-ink);
}

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

.btn-ghost {
    background: transparent;
}

.token-state {
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    border: 1px solid transparent;
    height: fit-content;
}

.token-state-idle {
    color: #6f6a44;
    background: #fff9dc;
    border-color: #e8dd9b;
}

.token-state-ok {
    color: #0c5f56;
    background: #ddf7f3;
    border-color: #8ad8cf;
}

.token-state-error {
    color: #8e2f24;
    background: #ffe2dd;
    border-color: #f2a89d;
}

.notice-bar {
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 13px;
    border: 1px solid transparent;
}

.notice-info {
    background: #eaf6ff;
    color: #1c4d70;
    border-color: #c0def2;
}

.notice-ok {
    background: #ddf7f3;
    color: #0c5f56;
    border-color: #8ad8cf;
}

.notice-error {
    background: #ffe2dd;
    color: #8e2f24;
    border-color: #f2a89d;
}

.view {
    display: none;
    animation: fadeUp 200ms ease;
}

.view.is-active {
    display: grid;
    gap: 14px;
}

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

.view-head {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    align-items: center;
}

.view-head h2 {
    margin: 0;
    font-size: 24px;
}

.panel {
    background: var(--bg-soft);
    border: 1px solid rgba(21, 47, 70, 0.11);
    border-radius: var(--radius);
    box-shadow: var(--panel-shadow);
    padding: 14px;
    display: grid;
    gap: 10px;
}

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

.panel-head h3 {
    margin: 0;
    font-size: 16px;
}

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

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 10px;
}

.card {
    background: linear-gradient(140deg, rgba(255, 255, 255, 0.95), rgba(255, 250, 238, 0.96));
    border: 1px solid rgba(21, 47, 70, 0.11);
    border-radius: var(--radius);
    box-shadow: var(--panel-shadow);
    padding: 14px;
}

.card h4 {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
}

.card strong {
    margin-top: 6px;
    display: block;
    font-size: 27px;
    color: #16314a;
}

.card small {
    color: var(--muted);
    display: block;
    margin-top: 4px;
}

.toolbar {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) 190px 96px 110px;
    gap: 8px;
}

.toolbar-wide {
    grid-template-columns: repeat(7, minmax(140px, 1fr));
}

.form-grid {
    display: grid;
    gap: 8px;
}

.form-grid h4 {
    margin: 0;
}

.form-inline {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(140px, 1fr) minmax(150px, 1fr) minmax(150px, 1fr) auto;
    gap: 8px;
}

.table-wrap {
    overflow: auto;
    border: 1px solid rgba(21, 47, 70, 0.11);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--panel-shadow);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 980px;
}

thead th {
    text-align: left;
    font-size: 12px;
    letter-spacing: 0.05em;
    color: #465b72;
    border-bottom: 1px solid #e4eaf2;
    padding: 11px 12px;
    background: #f9fbfd;
}

tbody td {
    padding: 11px 12px;
    border-bottom: 1px solid #edf1f5;
    font-size: 13px;
    vertical-align: top;
}

tbody tr:hover {
    background: #f7fbff;
}

.action-group {
    display: flex;
    gap: 6px;
}

.mini-btn {
    border: 1px solid rgba(18, 34, 52, 0.16);
    background: #fff;
    border-radius: 8px;
    padding: 5px 8px;
    font-size: 12px;
    cursor: pointer;
}

.mini-btn.danger {
    border-color: #e58f83;
    color: #8e2f24;
}

.pagination {
    font-size: 13px;
    color: var(--muted);
}

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

.json-box,
.log-box {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    background: #111a26;
    color: #d3e1f0;
    border-radius: 12px;
    padding: 11px;
    min-height: 140px;
    max-height: 420px;
    overflow: auto;
    font-family: "IBM Plex Mono", "Consolas", "Courier New", monospace;
    font-size: 12px;
    line-height: 1.55;
}

.playground {
    display: grid;
    grid-template-columns: 120px 1fr auto auto;
    gap: 8px;
}

.playground textarea {
    grid-column: 1 / -1;
    min-height: 150px;
    font-family: "IBM Plex Mono", "Consolas", "Courier New", monospace;
}

.muted {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #32475f;
}

.modal.hidden,
.hidden {
    display: none;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 20;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(12, 24, 36, 0.45);
}

.modal-card {
    position: relative;
    z-index: 1;
    margin: 4vh auto;
    width: min(1060px, calc(100vw - 30px));
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 18px 50px rgba(8, 14, 24, 0.45);
    border: 1px solid rgba(25, 37, 55, 0.16);
    display: grid;
    gap: 10px;
    padding: 12px;
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-head h3 {
    margin: 0;
}

@media (max-width: 1180px) {
    .toolbar,
    .toolbar-wide,
    .form-inline,
    .playground {
        grid-template-columns: 1fr;
    }
}

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

    .sidebar {
        border-right: none;
        border-bottom: 1px solid rgba(80, 100, 120, 0.22);
    }

    .two-col,
    .auth-head {
        grid-template-columns: 1fr;
        display: grid;
    }

    .auth-head {
        gap: 8px;
    }
}
