:root {
    --bg: #f3f6fb;
    --panel: #ffffff;
    --panel-soft: #f8fbff;
    --line: #d8e2f0;
    --line-strong: #c4d2e6;
    --text: #132238;
    --muted: #64748b;
    --primary: #1f5eff;
    --primary-soft: #e9f0ff;
    --nav-bg: #0f172a;
    --nav-surface: #162033;
    --nav-text: #c2d1ea;
    --nav-text-strong: #f8fbff;
    --success-bg: #e8f7ee;
    --success-text: #166534;
    --warning-bg: #fff4db;
    --warning-text: #9a5b00;
    --danger-bg: #ffe5e5;
    --danger-text: #b42318;
    --neutral-bg: #ebf0f7;
    --neutral-text: #42526b;
    --shadow: 0 16px 44px rgba(15, 23, 42, 0.08);
    --shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.05);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
    background: linear-gradient(180deg, #eef4ff 0%, var(--bg) 100%);
    color: var(--text);
}

a {
    color: inherit;
}

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

.sidebar {
    background: linear-gradient(180deg, #0f172a 0%, #111c31 100%);
    color: var(--nav-text);
    padding: 28px 22px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.sidebar-logo,
.login-mark {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, #2d6dff 0%, #4fa0ff 100%);
    box-shadow: 0 12px 24px rgba(45, 109, 255, 0.35);
}

.sidebar-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--nav-text-strong);
}

.sidebar-subtitle {
    margin-top: 4px;
    font-size: 12px;
    color: #8fa4c7;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.sidebar-nav {
    display: grid;
    gap: 8px;
}

.sidebar-nav a {
    padding: 12px 14px;
    border-radius: 14px;
    text-decoration: none;
    color: var(--nav-text);
    transition: 0.18s ease;
}

.sidebar-nav a:hover {
    background: rgba(148, 163, 184, 0.12);
    color: var(--nav-text-strong);
}

.sidebar-nav a.active {
    background: rgba(31, 94, 255, 0.18);
    color: var(--nav-text-strong);
    box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.24);
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px;
    border-radius: 16px;
    background: rgba(148, 163, 184, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.14);
}

.admin-label {
    font-size: 12px;
    color: #8fa4c7;
}

.admin-name {
    margin-top: 8px;
    font-weight: 700;
    color: var(--nav-text-strong);
}

.workspace {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.workspace-topbar {
    padding: 28px 32px 0;
}

.workspace-title {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.workspace-subtitle {
    margin-top: 8px;
    max-width: 820px;
    color: var(--muted);
    line-height: 1.65;
}

.page {
    padding: 28px 32px 40px;
}

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

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

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

.stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 20px;
}

.dashboard-grid,
.licenses-top-grid {
    grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr);
    margin-bottom: 20px;
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-soft);
}

.card-emphasis {
    background: linear-gradient(180deg, #ffffff 0%, var(--panel-soft) 100%);
}

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

.section-head h3 {
    margin: 0;
    font-size: 18px;
}

.section-head p {
    margin: 8px 0 0;
}

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

.stat-card {
    padding: 20px 22px;
}

.stat-value {
    margin-top: 10px;
    font-size: 34px;
    font-weight: 800;
    letter-spacing: -0.04em;
}

.action-grid {
    display: grid;
    gap: 14px;
}

.action-tile {
    text-decoration: none;
    display: block;
    padding: 18px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.85);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.action-tile:hover {
    transform: translateY(-2px);
    border-color: #b7caf0;
    box-shadow: var(--shadow);
}

.action-title {
    font-weight: 700;
    margin-bottom: 8px;
}

.action-desc {
    color: var(--muted);
    line-height: 1.65;
}

label {
    display: block;
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 600;
    color: #344256;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 14px;
    color: var(--text);
    background: #fff;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

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

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #8fb2ff;
    box-shadow: 0 0 0 4px rgba(31, 94, 255, 0.12);
}

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

.filter-actions {
    display: flex;
    align-items: flex-end;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 16px;
    border: 0;
    border-radius: 12px;
    background: var(--primary);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
    box-shadow: 0 10px 18px rgba(31, 94, 255, 0.22);
}

.btn:hover {
    transform: translateY(-1px);
}

.btn.secondary {
    background: #eef3fb;
    color: #274060;
    box-shadow: none;
}

.btn.danger {
    background: #dc2626;
    box-shadow: 0 10px 18px rgba(220, 38, 38, 0.18);
}

.btn.success {
    background: #16a34a;
    box-shadow: 0 10px 18px rgba(22, 163, 74, 0.18);
}

.btn.copy {
    background: #edf5ff;
    color: #2153a2;
    box-shadow: none;
}

.btn.mini {
    min-height: 34px;
    padding: 0 12px;
    border-radius: 10px;
    font-size: 12px;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.45;
    transform: none;
    box-shadow: none;
}

.text-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
}

.text-link:hover {
    text-decoration: underline;
}

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

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    padding: 13px 14px;
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: #f7faff;
    border-bottom: 1px solid var(--line);
}

tbody td {
    padding: 15px 14px;
    border-bottom: 1px solid #edf2f8;
    vertical-align: top;
}

tbody tr:hover {
    background: #fbfdff;
}

.pagination {
    margin-top: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge.ready {
    background: #e8f0ff;
    color: #2453a6;
}

.badge.active,
.badge.success {
    background: var(--success-bg);
    color: var(--success-text);
}

.badge.used,
.badge.warning {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.badge.disabled,
.badge.danger {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.badge.trial,
.badge.expired,
.badge.neutral {
    background: var(--neutral-bg);
    color: var(--neutral-text);
}

.badge.audit {
    text-transform: none;
}

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

.event-item {
    padding: 16px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: #fbfdff;
}

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

.event-title {
    margin-top: 12px;
    font-weight: 700;
}

.event-desc {
    margin-top: 8px;
    color: var(--muted);
    line-height: 1.6;
    word-break: break-word;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.edit-row td {
    padding: 0;
    background: #f7faff;
}

.inline-edit-panel {
    display: grid;
    gap: 18px;
    padding: 20px;
    border-top: 1px solid var(--line);
}

.code-block {
    display: inline-block;
    max-width: 420px;
    white-space: pre-wrap;
    word-break: break-word;
    padding: 8px 10px;
    border-radius: 12px;
    background: #f3f7fd;
    color: #23364f;
}

code {
    font-family: "Consolas", "Courier New", monospace;
    background: #f3f7fd;
    border-radius: 10px;
    padding: 6px 8px;
}

.tiny {
    font-size: 12px;
}

.error {
    min-height: 20px;
    color: var(--danger-text);
    font-size: 13px;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 36px 20px;
}

.login-wrap {
    width: min(100%, 980px);
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(320px, 420px);
    gap: 28px;
    align-items: stretch;
}

.login-hero,
.login-card {
    box-shadow: var(--shadow);
}

.login-hero {
    background: linear-gradient(135deg, #0f172a 0%, #1f3f8d 100%);
    color: #fff;
    border-radius: 28px;
    padding: 34px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-hero h1 {
    margin: 20px 0 14px;
    font-size: 34px;
    line-height: 1.15;
}

.login-hero p {
    margin: 0;
    color: #d9e5ff;
    line-height: 1.75;
}

.login-card {
    padding: 28px;
    border-radius: 28px;
}

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

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

    .sidebar {
        gap: 18px;
    }

    .workspace-topbar,
    .page {
        padding-left: 20px;
        padding-right: 20px;
    }

    .grid-2,
    .grid-3,
    .stat-grid,
    .dashboard-grid,
    .licenses-top-grid,
    .login-wrap {
        grid-template-columns: 1fr;
    }

    .pagination,
    .section-head,
    .event-top {
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-actions {
        align-items: stretch;
    }
}
