:root {
    --ink: #1f2722;
    --muted: #68716b;
    --canvas: #f3f4ef;
    --surface: #ffffff;
    --line: #dfe2da;
    --accent: #176e5a;
    --accent-strong: #0f5847;
    --accent-soft: #e7f2ed;
    --warm: #b96228;
    --warm-soft: #fff3e5;
    --danger: #a63e3e;
    --sidebar: #17201b;
    --sidebar-line: #2b3730;
    --shadow: 0 10px 30px rgba(27, 40, 32, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    background: var(--canvas);
    color: var(--ink);
    font-family: "Microsoft YaHei UI", "PingFang SC", "Segoe UI", sans-serif;
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

[hidden] {
    display: none !important;
}

code,
.mono {
    font-family: "Cascadia Mono", "Consolas", monospace;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: #edf0ea;
}

.login-panel {
    width: min(430px, 100%);
    padding: 36px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.brand-mark {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 21px;
    font-weight: 700;
}

.brand-mark.small {
    width: 38px;
    height: 38px;
    font-size: 17px;
}

.eyebrow {
    margin: 18px 0 5px;
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.login-panel h1,
.topbar h1,
.workspace-section h2 {
    margin: 0;
    letter-spacing: 0;
}

.login-panel h1 {
    font-size: 28px;
}

.login-copy {
    margin: 10px 0 12px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.7;
}

.login-version {
    margin: 0 0 24px;
    color: #68766e;
    font-size: 12px;
}

.login-version strong {
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.login-panel label,
.field label,
.field-label {
    display: block;
    margin-bottom: 8px;
    color: #414b45;
    font-size: 12px;
    font-weight: 700;
}

.login-panel input,
.field input,
.field textarea,
.compact-form input {
    width: 100%;
    border: 1px solid #cfd5cc;
    border-radius: 7px;
    background: #fff;
    color: var(--ink);
    outline: none;
    transition: border-color 140ms ease, box-shadow 140ms ease;
}

.login-panel input,
.field input,
.compact-form input {
    height: 42px;
    padding: 0 12px;
}

.field textarea {
    min-height: 96px;
    padding: 11px 12px;
    resize: vertical;
    line-height: 1.65;
}

.login-panel input:focus,
.field input:focus,
.field textarea:focus,
.compact-form input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(23, 110, 90, 0.12);
}

.button {
    min-height: 38px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 700;
}

.button.primary {
    background: var(--accent);
    color: #fff;
}

.button.primary:hover {
    background: var(--accent-strong);
}

.button.secondary {
    background: var(--surface);
    border-color: var(--line);
    color: var(--ink);
}

.button.secondary:hover {
    background: #f8f9f6;
}

.button.danger {
    background: #fff7f5;
    border-color: #e6c2ba;
    color: var(--danger);
}

.button.danger:hover {
    background: #fcebe7;
}

.button.quiet {
    background: transparent;
    border-color: #405047;
    color: #d8e1dc;
}

.button.quiet:hover {
    background: #243129;
}

.button.full {
    width: 100%;
}

.login-panel .button {
    width: 100%;
    margin-top: 18px;
}

.form-error {
    min-height: 20px;
    margin: 10px 0 0;
    color: var(--danger);
    font-size: 12px;
}

.login-foot {
    margin: 22px 0 0;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.65;
}

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

.sidebar {
    min-height: 100vh;
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    max-height: 100vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    background: var(--sidebar);
    color: #eef4f0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 8px 24px;
    border-bottom: 1px solid var(--sidebar-line);
}

.sidebar-brand strong,
.sidebar-brand span {
    display: block;
}

.sidebar-brand strong {
    font-size: 14px;
}

.sidebar-brand span {
    margin-top: 4px;
    color: #849188;
    font-size: 10px;
}

.nav-list {
    display: grid;
    gap: 5px;
    margin: 24px 0;
}

.nav-link {
    display: block;
    padding: 11px 12px;
    border-radius: 6px;
    color: #aebbb3;
    text-decoration: none;
    font-size: 12px;
}

.nav-link:hover,
.nav-link.active {
    background: #25342c;
    color: #f4faf6;
}

.sidebar-status {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 8px;
    border-top: 1px solid var(--sidebar-line);
}

.sidebar-status strong,
.sidebar-status span {
    display: block;
}

.sidebar-status strong {
    font-size: 11px;
}

.sidebar-status span {
    margin-top: 3px;
    color: #7e8c83;
    font-size: 10px;
}

.sidebar-version {
    color: #9aaea1 !important;
    font-variant-numeric: tabular-nums;
}

.status-dot {
    width: 8px;
    height: 8px;
    flex: 0 0 8px;
    border-radius: 50%;
    background: #57cfa1;
    box-shadow: 0 0 0 4px rgba(87, 207, 161, 0.12);
}

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

.topbar {
    min-height: 94px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 20px 32px;
    border-bottom: 1px solid var(--line);
    background: rgba(250, 251, 248, 0.94);
}

.topbar .eyebrow {
    margin: 0 0 4px;
}

.topbar h1 {
    font-size: 22px;
}

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

.version-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border: 1px solid #cbd7cf;
    border-radius: 6px;
    background: #f2f7f4;
    color: #42604f;
    font-size: 11px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.server-time {
    color: var(--muted);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.content {
    max-width: 1080px;
    padding: 0 32px 60px;
}

.workspace-section {
    padding: 32px 0;
    border-bottom: 1px solid var(--line);
    scroll-margin-top: 16px;
}

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

.section-heading .eyebrow {
    margin: 0 0 5px;
}

.workspace-section h2 {
    font-size: 20px;
}

.section-heading p:not(.eyebrow) {
    max-width: 650px;
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.65;
}

.switch-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 11px;
    cursor: pointer;
}

.switch-row.warning {
    color: var(--warm);
}

.switch-row input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    opacity: 0;
    pointer-events: none;
}

.switch {
    width: 42px;
    height: 24px;
    position: relative;
    border-radius: 999px;
    background: #c9cec8;
    transition: background 140ms ease;
}

.switch::after {
    content: "";
    width: 18px;
    height: 18px;
    position: absolute;
    top: 3px;
    left: 3px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    transition: transform 140ms ease;
}

.switch-row input:checked + .switch {
    background: var(--accent);
}

.switch-row.warning input:checked + .switch {
    background: var(--warm);
}

.switch-row input:checked + .switch::after {
    transform: translateX(18px);
}

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

.field {
    min-width: 0;
}

.field.span-2 {
    grid-column: span 2;
}

.field small {
    display: block;
    margin-top: 7px;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.5;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--muted);
    font-size: 11px;
}

.check-row span {
    line-height: 1.5;
}

.check-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    min-height: 16px;
    flex: 0 0 auto;
    margin: 0;
    padding: 0;
}

.range-row {
    height: 42px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.range-row input {
    min-width: 0;
    height: 24px;
    padding: 0;
    accent-color: var(--accent);
}

.range-row output {
    width: 42px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    text-align: right;
}

.marquee-preview {
    height: 42px;
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr);
    align-items: center;
    overflow: hidden;
    border: 1px solid #ebdcc2;
    border-radius: 7px;
    background: var(--warm-soft);
}

.marquee-label {
    padding-left: 14px;
    color: #8a5a24;
    font-size: 11px;
    font-weight: 700;
}

.marquee-window {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
}

.marquee-track {
    display: inline-block;
    color: #6b4a24;
    font-size: 12px;
    white-space: nowrap;
    will-change: transform;
}

@keyframes marquee {
    from { transform: translateX(100%); }
    to { transform: translateX(-120%); }
}

.policy-note {
    margin-top: 20px;
    padding: 12px 14px;
    border-left: 3px solid var(--warm);
    background: var(--warm-soft);
    color: #73502b;
    font-size: 11px;
    line-height: 1.65;
}

.section-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    margin-top: 22px;
}

.session-kick-field {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.session-kick-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
}

.session-filter-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
}

.active-session-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.session-empty {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.active-session-list {
    display: grid;
    gap: 8px;
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
}

.active-session-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #f9faf7;
}

.session-account {
    font-family: "Cascadia Mono", "Consolas", monospace;
    font-size: 13px;
    font-weight: 700;
}

.session-meta {
    margin-top: 3px;
    color: var(--muted);
    font-size: 11px;
}

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

.session-actions .button {
    min-height: 30px;
    padding: 5px 9px;
    font-size: 11px;
}

.saved-text {
    color: var(--muted);
    font-size: 11px;
}

.count-badge {
    flex: 0 0 auto;
    padding: 6px 9px;
    border-radius: 5px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
}

.entitlement-panel {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcf9;
}

.entitlement-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.entitlement-heading strong {
    display: block;
    font-size: 14px;
}

.entitlement-heading small {
    display: block;
    margin-top: 4px;
}

.entitlement-defaults {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
}

.compact-field {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 11px;
}

.compact-field input {
    width: 130px;
}

.entitlement-entry {
    display: grid;
    grid-template-columns: minmax(120px, 0.55fr) minmax(120px, 0.55fr) minmax(180px, 1.4fr) auto;
    gap: 10px;
    margin-top: 14px;
}

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

.entitlement-bulk {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.entitlement-bulk label {
    color: var(--muted);
    font-size: 12px;
}

.entitlement-bulk input {
    width: 170px;
}

.entitlement-filter {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
}

.entitlement-filter label {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.entitlement-filter input {
    min-width: 0;
    flex: 1 1 auto;
}

.entitlement-table-wrap {
    max-height: 440px;
    width: 100%;
    min-width: 0;
    margin-top: 16px;
    overflow: auto;
    contain: inline-size;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
}

.entitlement-table {
    width: 100%;
    min-width: 1120px;
    border-collapse: collapse;
    font-size: 12px;
}

.group-entitlement-table {
    min-width: 720px;
}

.workspace-section {
    overflow-x: clip;
}

.entitlement-table th,
.entitlement-table td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}

.entitlement-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f3f5ef;
    color: #4f5847;
    font-size: 11px;
}

.entitlement-table tr:last-child td {
    border-bottom: 0;
}

.entitlement-table tbody tr:hover {
    background: #fafbf7;
}

.entitlement-qq {
    font-family: "Cascadia Mono", "Consolas", monospace;
    font-weight: 700;
}

.entitlement-note {
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.entitlement-status {
    display: inline-flex;
    padding: 3px 7px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
}

.entitlement-status.active {
    background: #e8f5e8;
    color: #276c35;
}

.entitlement-status.expired {
    background: #fff0dd;
    color: #8b5315;
}

.entitlement-status.disabled {
    background: #eceff1;
    color: #5f676c;
}

.entitlement-row-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.entitlement-row-days {
    width: 96px;
    min-height: 30px;
    padding: 4px 6px;
}

.entitlement-table:not(.group-entitlement-table) th:last-child,
.entitlement-table:not(.group-entitlement-table) td:last-child {
    width: 340px;
    min-width: 340px;
}

@media (min-width: 621px) {
    .entitlement-table:not(.group-entitlement-table) th:last-child,
    .entitlement-table:not(.group-entitlement-table) td:last-child {
        position: sticky;
        right: 0;
        z-index: 2;
        background: #fff;
        box-shadow: -8px 0 12px rgba(35, 42, 36, 0.08);
    }

    .entitlement-table:not(.group-entitlement-table) th:last-child {
        z-index: 3;
        background: #f3f5ef;
    }

    .entitlement-table:not(.group-entitlement-table) tbody tr:hover td:last-child {
        background: #fafbf7;
    }
}

.button.tiny {
    min-height: 30px;
    padding: 5px 8px;
    font-size: 11px;
}

.account-layout {
    display: grid;
    grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.4fr);
    gap: 30px;
}

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

.subsection-title {
    margin: 0 0 12px;
    font-size: 13px;
}

.user-list {
    display: grid;
    gap: 1px;
    margin: 0;
    padding: 1px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--line);
    list-style: none;
}

.user-row {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    background: var(--surface);
}

.user-name {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    font-size: 12px;
    font-weight: 600;
}

.current-badge {
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 9px;
    font-weight: 700;
}

.delete-user {
    border: 0;
    background: transparent;
    color: var(--danger);
    font-size: 11px;
}

.compact-form {
    display: grid;
    align-content: start;
    gap: 8px;
}

.compact-form label {
    margin-top: 4px;
    color: #414b45;
    font-size: 11px;
    font-weight: 700;
}

.compact-form .button {
    margin-top: 10px;
}

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

.status-grid div {
    min-width: 0;
    padding: 18px;
    background: var(--surface);
}

.status-grid dt {
    color: var(--muted);
    font-size: 10px;
}

.status-grid dd {
    margin: 7px 0 0;
    overflow-wrap: anywhere;
    font-size: 12px;
    font-weight: 600;
}

.toast {
    min-height: 0;
    position: fixed;
    z-index: 20;
    top: 18px;
    right: 20px;
    max-width: min(420px, calc(100vw - 40px));
    padding: 0;
    border-radius: 7px;
    background: #23342b;
    color: #fff;
    font-size: 12px;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 160ms ease, transform 160ms ease, padding 160ms ease;
    pointer-events: none;
}

.toast.visible {
    padding: 12px 15px;
    opacity: 1;
    transform: translateY(0);
}

.toast.error {
    background: #8e3838;
}

@media (max-width: 820px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        min-height: auto;
        position: static;
        align-self: auto;
        height: auto;
        max-height: none;
        overflow-y: visible;
        padding: 14px;
    }

    .sidebar-brand {
        padding-bottom: 14px;
    }

    .nav-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        margin: 14px 0;
    }

    .nav-link {
        text-align: center;
    }

    .sidebar-status {
        display: none;
    }

    .sidebar .button {
        margin-top: 4px;
    }

    .topbar {
        min-height: auto;
        padding: 18px 20px;
    }

    .content {
        padding: 0 20px 40px;
    }

    .section-heading {
        display: block;
    }

    .switch-row {
        margin-top: 16px;
    }
}

@media (max-width: 620px) {
    .login-panel {
        padding: 28px 22px;
    }

    .topbar {
        display: block;
    }

    .topbar-actions {
        margin-top: 14px;
        justify-content: space-between;
    }

    .form-grid,
    .status-grid,
    .account-layout,
    .account-forms {
        grid-template-columns: 1fr;
    }

    .field.span-2 {
        grid-column: span 1;
    }

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

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

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

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

    .entitlement-heading,
    .entitlement-defaults,
    .entitlement-bulk,
    .entitlement-filter {
        align-items: stretch;
        flex-direction: column;
    }

    .entitlement-entry {
        grid-template-columns: 1fr;
    }

    .entitlement-panel,
    .entitlement-table-wrap,
    .entitlement-entry-actions {
        min-width: 0;
        max-width: 100%;
    }

    .entitlement-entry-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .compact-field input,
    .entitlement-bulk input,
    .entitlement-entry-actions .button {
        width: 100%;
    }

    .session-actions {
        justify-content: flex-start;
    }
}
