:root {
    --bg: #f3f7f4;
    --surface: #ffffff;
    --surface-soft: #f6faf7;
    --surface-strong: #e8f3ec;
    --text: #1a2b22;
    --muted: #66756c;
    --line: #dce8e0;
    --line-strong: #c5d6cb;
    --primary: #12a86a;
    --primary-rgb: 18, 168, 106;
    --primary-deep: #0d8a56;
    --primary-soft: #e8f8f0;
    --green: #12a86a;
    --red: #e25555;
    --red-soft: #fff5f5;
    --amber: #d08916;
    --amber-soft: #fff8e8;
    --violet: #6d7cff;
    --violet-soft: #eef0ff;
    --radius: 12px;
    --radius-sm: 10px;
    --sidebar-width: 248px;
    --shadow: 0 1px 2px rgba(26, 43, 34, .04), 0 8px 24px rgba(26, 43, 34, .05);
    --shadow-soft: 0 1px 2px rgba(26, 43, 34, .03);
    --btn-shadow: 0 1px 2px rgba(18, 168, 106, .08);
}

:root[data-theme="dark"] {
    --bg: #0a0f0c;
    --surface: #121916;
    --surface-soft: #17201c;
    --surface-strong: #1c2a23;
    --text: #eef5f0;
    --muted: #93a39a;
    --line: #27332d;
    --line-strong: #3a4a41;
    --primary: #3dd492;
    --primary-rgb: 61, 212, 146;
    --primary-deep: #6ee4ae;
    --primary-soft: rgba(61, 212, 146, .14);
    --green: #3dd492;
    --red: #ff8b8b;
    --red-soft: rgba(255, 139, 139, .14);
    --amber: #f0bd5d;
    --amber-soft: rgba(240, 189, 93, .14);
    --violet: #9aa5ff;
    --violet-soft: rgba(154, 165, 255, .14);
    --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 10px 28px rgba(0, 0, 0, .28);
    --shadow-soft: 0 1px 2px rgba(0, 0, 0, .2);
    --btn-shadow: 0 1px 2px rgba(61, 212, 146, .12);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    color: var(--text);
    background:
        radial-gradient(1200px 480px at 12% -8%, rgba(var(--primary-rgb), .08), transparent 58%),
        radial-gradient(900px 420px at 100% 0%, rgba(var(--primary-rgb), .05), transparent 52%),
        var(--bg);
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    letter-spacing: .01em;
    line-height: 1.55;
    -webkit-text-size-adjust: 100%;
}

a {
    color: inherit;
    text-decoration: none;
}

.icon,
svg.icon {
    display: block;
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
    overflow: visible;
}

.icon *,
svg.icon * {
    vector-effect: non-scaling-stroke;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    background: var(--bg);
}

.mobile-topbar,
.sidebar-backdrop {
    display: none;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 16px 14px;
    border-right: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 92%, var(--surface-soft));
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    gap: 18px;
    overflow-y: auto;
}

.brand {
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 8px 12px;
    border-bottom: 1px solid var(--line);
}

.brand-mark,
.login-brand-mark,
.stat-icon,
.quick-icon {
    display: grid;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--primary) 36%, var(--line));
    border-radius: var(--radius);
    background: var(--primary-soft);
    color: var(--primary);
}

.brand-mark {
    width: 36px;
    height: 36px;
}

.brand-mark .icon,
.login-brand-mark .icon {
    width: 22px;
    height: 22px;
    stroke-width: 2.1;
}

.brand-title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: .02em;
}

.brand-sub {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}

.nav {
    display: grid;
    gap: 8px;
}

.nav a,
.logout-button,
.theme-toggle,
.btn,
.mobile-menu-button {
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font: inherit;
    transition:
        border-color .18s ease,
        background-color .18s ease,
        color .18s ease,
        box-shadow .18s ease,
        transform .18s ease;
}

.nav a,
.logout-button {
    width: 100%;
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 560;
}

.nav-icon {
    color: var(--muted);
}

.nav a:hover,
.logout-button:hover,
.theme-toggle:hover {
    border-color: color-mix(in srgb, var(--primary) 18%, var(--line));
    background: var(--surface-soft);
    color: var(--text);
}

.nav a.active {
    color: var(--primary-deep);
    font-weight: 680;
    border-color: color-mix(in srgb, var(--primary) 22%, transparent);
    background: linear-gradient(135deg, var(--primary-soft), color-mix(in srgb, var(--primary-soft) 40%, var(--surface)));
    box-shadow: var(--shadow-soft);
}

.nav a.active .nav-icon {
    color: var(--primary);
}

.sidebar-footer {
    margin-top: auto;
    display: grid;
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 13px;
}

.sidebar-user {
    display: grid;
    gap: 2px;
    min-width: 0;
    padding: 0 6px;
}

.sidebar-user strong,
.sidebar-user span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user strong {
    color: var(--text);
}

.theme-toggle,
.logout-button {
    justify-content: center;
    border-color: var(--line);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 14px;
    font-weight: 620;
}

.theme-toggle.login-theme-toggle {
    width: 42px;
    min-width: 42px;
    padding: 0;
}

.sidebar-footer .theme-toggle {
    width: 100%;
}

.main {
    min-width: 0;
    width: 100%;
    padding: 24px 28px 48px;
}

.topbar {
    min-height: 64px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin: -24px -28px 22px;
    padding: 14px 28px;
    border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
    background: color-mix(in srgb, var(--surface) 78%, transparent);
    backdrop-filter: blur(12px);
}

.page-title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: .01em;
}

.page-title::after {
    content: "";
    display: block;
    width: 28px;
    height: 3px;
    margin-top: 8px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 20%, transparent));
}

.page-desc {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
}

.user-pill {
    min-width: 168px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
    text-align: right;
}

.user-pill-icon {
    color: var(--primary);
    margin-left: auto;
    margin-bottom: 3px;
}

.user-pill strong,
.user-pill span {
    display: block;
}

.user-pill span {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.grid {
    display: grid;
    gap: 16px;
}

.stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.two-col {
    grid-template-columns: minmax(320px, 440px) minmax(0, 1fr);
    align-items: start;
}

.management-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
}

.product-portal-panel {
    margin-top: 18px;
}

.product-grid,
.product-module-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.product-card,
.module-card {
    position: relative;
    min-height: 176px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
    overflow: hidden;
    transition: border-color .18s ease, background-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.product-card-active:hover,
.module-card.active:hover {
    border-color: color-mix(in srgb, var(--primary) 40%, var(--line));
    background: color-mix(in srgb, var(--primary-soft) 28%, var(--surface));
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.product-card-line {
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--primary);
}

.product-card.disabled,
.module-card:not(.active) {
    color: var(--muted);
    background: var(--surface-soft);
}

.product-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.product-icon,
.module-icon,
.product-hero-mark {
    display: grid;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--primary) 34%, var(--line));
    border-radius: var(--radius);
    background: var(--primary-soft);
    color: var(--primary);
}

.product-icon,
.module-icon {
    width: 42px;
    height: 42px;
}

.product-icon .icon,
.module-icon .icon {
    width: 22px;
    height: 22px;
}

.product-card strong,
.module-card strong {
    margin-top: 4px;
    color: var(--text);
    font-size: 20px;
    line-height: 1.2;
}

.product-subtitle,
.product-desc,
.module-card span:not(.module-icon) {
    color: var(--muted);
    font-size: 13px;
}

.product-desc {
    min-height: 40px;
}

.product-action {
    margin-top: auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--primary-deep);
    font-weight: 640;
}

.product-action .icon {
    width: 15px;
    height: 15px;
}

.product-hero {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
    margin-bottom: 18px;
}

.product-hero-mark {
    width: 64px;
    height: 64px;
}

.product-hero-mark .icon {
    width: 34px;
    height: 34px;
}

.product-hero h3 {
    margin: 2px 0 6px;
    font-size: 28px;
    line-height: 1.12;
}

.product-hero p {
    margin: 0;
    color: var(--muted);
}

.product-hero-kicker {
    color: var(--primary-deep);
    font-size: 13px;
    font-weight: 680;
}

.huanqi-stats,
.product-module-grid,
.huanqi-data-grid,
.huanqi-dashboard-grid {
    margin-top: 18px;
}

.huanqi-dashboard-grid {
    display: grid;
    grid-template-columns: minmax(360px, 720px) minmax(240px, 300px);
    gap: 16px;
    align-items: stretch;
    justify-content: start;
}

.huanqi-chart-panel,
.huanqi-live-panel {
    min-height: 218px;
}

.line-chart {
    display: block;
    width: min(100%, 640px);
    height: auto;
    aspect-ratio: 520 / 148;
    margin: 12px auto 0;
    overflow: hidden;
}

.chart-grid {
    stroke: var(--line);
    stroke-width: 1;
    stroke-dasharray: 4 8;
}

.chart-axis {
    fill: var(--muted);
    font-family: inherit;
    font-size: 9px;
}

.chart-area {
    display: none;
}

.chart-line {
    fill: none;
    stroke: var(--primary);
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chart-dot {
    fill: var(--surface);
    stroke: var(--primary);
    stroke-width: 1.7;
}

.huanqi-live-panel {
    display: flex;
    flex-direction: column;
}

.live-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 0 5px var(--primary-soft);
}

.live-number {
    margin-top: 18px;
    color: var(--primary-deep);
    font-size: 68px;
    line-height: 1;
    font-weight: 720;
}

.live-label {
    margin-top: 8px;
    color: var(--text);
    font-size: 18px;
    font-weight: 680;
}

.live-meta {
    margin-top: auto;
    display: grid;
    gap: 10px;
    padding-top: 28px;
}

.live-meta span {
    min-height: 38px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius);
    color: var(--muted);
    background: var(--surface-soft);
    font-size: 13px;
    font-weight: 640;
}

.huanqi-subnav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 18px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-soft);
    box-shadow: var(--shadow-soft);
}

.huanqi-subnav a {
    position: relative;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: 10px;
    color: var(--muted);
    font-weight: 560;
    background: transparent;
}

.huanqi-subnav a:hover {
    color: var(--text);
    background: color-mix(in srgb, var(--surface) 72%, transparent);
}

.huanqi-subnav a.active {
    color: var(--primary-deep);
    font-weight: 680;
    border-color: color-mix(in srgb, var(--line) 80%, transparent);
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(26, 43, 34, .04), 0 4px 12px rgba(26, 43, 34, .05);
}

.huanqi-subnav a.active::after {
    display: none;
}

.huanqi-subnav .icon {
    width: 16px;
    height: 16px;
}

.huanqi-subnav a.active .icon {
    color: var(--primary);
}

.huanqi-management-panel {
    margin-top: 18px;
}

.huanqi-toolbar {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) auto auto minmax(160px, auto);
    align-items: end;
    gap: 10px;
    margin-bottom: 16px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface-soft) 88%, var(--surface));
}

.huanqi-toolbar .form-row {
    min-width: 0;
}

.release-filter-toolbar {
    grid-template-columns: minmax(220px, 300px) minmax(260px, 1fr) auto minmax(190px, auto);
}

.release-filter-toolbar .actions {
    align-self: end;
    flex-wrap: nowrap;
}

.huanqi-toolbar-meta {
    align-self: center;
    justify-self: end;
    font-size: 13px;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 12px 0;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.pagination .actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.module-card {
    min-height: 168px;
}

.module-card em {
    margin-top: auto;
    color: var(--primary-deep);
    font-style: normal;
    font-weight: 680;
}

.module-card:not(.active) em {
    color: var(--muted);
}

.message-list {
    display: grid;
    gap: 10px;
}

.message-row {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.message-route {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.message-route .icon {
    width: 14px;
    height: 14px;
    color: var(--primary);
}

.message-row p {
    margin: 8px 0 6px;
    word-break: break-word;
}

.message-route.compact {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.message-content-preview {
    margin-top: 8px;
    max-width: 520px;
    word-break: break-word;
}

.resource-cover-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    max-width: 560px;
}

.resource-cover-row .mono {
    min-width: 0;
    word-break: break-all;
}

.resource-cover-thumb {
    width: 56px;
    height: 40px;
    flex: 0 0 56px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    object-fit: cover;
}

.group-cell .avatar-thumb {
    border-radius: var(--radius);
}

.group-member-preview {
    margin-top: 8px;
    max-width: 340px;
    font-size: 13px;
    word-break: break-word;
}

.group-member-editor {
    display: grid;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.group-member-editor-head,
.group-member-editor-row {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr) 132px;
    gap: 10px;
    align-items: center;
}

.group-member-editor-head {
    color: var(--muted);
    font-size: 12px;
    font-weight: 720;
}

.group-member-editor-row {
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.group-member-keep {
    justify-content: center;
}

.member-role-fixed {
    display: flex;
    align-items: center;
}

.empty.compact {
    padding: 16px;
    text-align: left;
}

.huanqi-mini-list {
    display: grid;
    gap: 10px;
}

.huanqi-user-line,
.user-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.huanqi-user-line {
    justify-content: space-between;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.huanqi-user-line > div {
    min-width: 0;
}

.user-main {
    min-width: 0;
}

.avatar-thumb {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border: 1px solid color-mix(in srgb, var(--primary) 34%, var(--line));
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary-deep);
    object-fit: cover;
}

img.avatar-thumb {
    display: block;
}

.avatar-thumb.large {
    width: 54px;
    height: 54px;
    flex-basis: 54px;
}

.avatar-fallback {
    display: grid;
    place-items: center;
    font-weight: 720;
}

.social-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.social-metrics span {
    padding: 4px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    background: var(--surface);
    font-size: 12px;
    font-weight: 640;
}

.icon-btn {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    transition: border-color .18s ease, background-color .18s ease, color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.icon-btn.small {
    width: 28px;
    height: 28px;
}

.icon-btn .icon {
    width: 15px;
    height: 15px;
}

.icon-btn:hover:not(:disabled),
.icon-btn.is-copied {
    border-color: color-mix(in srgb, var(--primary) 36%, var(--line));
    background: var(--primary-soft);
    color: var(--primary-deep);
    box-shadow: var(--btn-shadow);
    transform: translateY(-1px);
}

.icon-btn:disabled {
    opacity: .42;
    cursor: not-allowed;
}

.token-cell {
    margin-top: 4px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.token-main {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.token-mask {
    color: var(--text);
    font-size: 13px;
    white-space: nowrap;
}

.token-actions,
.token-modal-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.token-expire {
    margin-top: 2px;
    font-size: 12px;
}

.token-modal-dialog {
    width: min(760px, 100%);
}

.token-modal-header {
    align-items: center;
}

.token-modal-body {
    display: grid;
    gap: 14px;
}

.token-modal-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.token-modal-meta div {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.token-modal-meta span,
.token-modal-meta strong {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.token-modal-meta span {
    color: var(--muted);
    font-size: 12px;
}

.token-modal-meta strong {
    margin-top: 3px;
}

.token-raw {
    display: block;
    min-height: 76px;
    padding: 14px;
    border: 1px solid color-mix(in srgb, var(--primary) 24%, var(--line));
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--primary-soft) 32%, var(--surface));
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-all;
}

.token-modal-note {
    margin: 0;
    font-size: 13px;
}

.modal-user-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.modal-user-preview div {
    display: grid;
    gap: 2px;
}

.modal-user-preview span {
    color: var(--muted);
    font-size: 13px;
}

.resource-placeholder {
    margin-top: 18px;
}

.resource-lines {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.resource-lines div {
    min-height: 120px;
    display: grid;
    align-content: start;
    gap: 8px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.resource-lines strong {
    color: var(--text);
    font-size: 16px;
}

.resource-lines span {
    color: var(--muted);
    font-size: 13px;
}

.management-panel-wide {
    min-height: 280px;
}

.panel,
.stat,
.login-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
}

.panel {
    padding: 20px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin: -2px -2px 16px;
    padding: 0 0 14px;
    border-bottom: 1px solid color-mix(in srgb, var(--line) 86%, transparent);
}

.panel-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.panel-title {
    margin: 0;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-size: 16px;
    font-weight: 680;
}

.panel-title .icon {
    color: var(--primary);
}

.stat {
    min-height: 96px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.stat:hover {
    border-color: color-mix(in srgb, var(--primary) 24%, var(--line));
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
}

.stat-icon .icon {
    width: 20px;
    height: 20px;
}

.stat-label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 560;
}

.stat-value {
    margin-top: 3px;
    font-size: 28px;
    line-height: 1.1;
    font-weight: 720;
    letter-spacing: -.02em;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
}

th,
td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
    font-size: 14px;
}

th {
    color: var(--muted);
    font-weight: 640;
    background: var(--surface-soft);
}

tbody tr:hover {
    background: var(--surface-soft);
}

.select-col {
    width: 44px;
    text-align: center;
    vertical-align: middle;
}

.select-col input[type="checkbox"] {
    margin: 0 auto;
}

.batch-form {
    margin: 0;
}

.batch-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    padding: 0;
    border: 0;
    background: transparent;
}

.batch-title {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 680;
    background: var(--surface-soft);
}

.batch-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.batch-actions select {
    width: 88px;
    min-height: 32px;
    padding: 0 24px 0 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    font-size: 13px;
    font-weight: 760;
}

.batch-actions .btn {
    min-height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    color: var(--primary-deep);
    border-color: color-mix(in srgb, var(--primary) 28%, var(--line));
    background: color-mix(in srgb, var(--primary-soft) 70%, var(--surface));
    font-weight: 620;
}

.batch-actions .btn .icon {
    width: 14px;
    height: 14px;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.actions form {
    margin: 0;
}

.form-grid {
    display: grid;
    gap: 14px;
}

.form-row {
    display: grid;
    gap: 7px;
}

.form-row.full {
    grid-column: 1 / -1;
}

label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 620;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--text);
    background: var(--surface);
    outline: none;
    font: inherit;
    transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: color-mix(in srgb, var(--primary) 55%, var(--line));
    background: color-mix(in srgb, var(--surface) 92%, var(--primary-soft));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);
}

textarea {
    min-height: 118px;
    resize: vertical;
}

input[type="checkbox"] {
    width: 18px;
    min-height: 18px;
    accent-color: var(--primary);
}

.check-row,
.permission-grid label {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--text);
    font-weight: 700;
}

.permission-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.btn {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-weight: 620;
    letter-spacing: .01em;
    box-shadow: var(--shadow-soft);
}

.btn:hover {
    border-color: color-mix(in srgb, var(--primary) 28%, var(--line));
    background: color-mix(in srgb, var(--surface-soft) 70%, var(--surface));
    color: var(--primary-deep);
    box-shadow: var(--btn-shadow);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.btn .icon,
.logout-button .icon,
.theme-toggle .icon,
.mobile-menu-button .icon {
    width: 15px;
    height: 15px;
}

.btn.primary {
    color: #ffffff;
    border-color: transparent;
    background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 92%, #ffffff), var(--primary-deep));
    box-shadow: 0 1px 2px rgba(var(--primary-rgb), .18), 0 8px 18px rgba(var(--primary-rgb), .16);
}

.btn.primary:hover {
    color: #ffffff;
    border-color: transparent;
    background: linear-gradient(180deg, var(--primary), color-mix(in srgb, var(--primary-deep) 88%, #000000));
    box-shadow: 0 2px 6px rgba(var(--primary-rgb), .22), 0 10px 22px rgba(var(--primary-rgb), .18);
}

.btn.danger {
    color: var(--red);
    border-color: color-mix(in srgb, var(--red) 28%, var(--line));
    background: var(--red-soft);
    box-shadow: none;
}

.btn.danger:hover {
    color: #ffffff;
    border-color: transparent;
    background: linear-gradient(180deg, color-mix(in srgb, var(--red) 88%, #ffffff), var(--red));
    box-shadow: 0 6px 16px rgba(226, 85, 85, .18);
}

.btn.small {
    min-height: 32px;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 600;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    min-height: 24px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-soft);
    font-size: 12px;
    font-weight: 620;
    line-height: 1;
    white-space: nowrap;
    word-break: keep-all;
}

.badge.green {
    color: var(--green);
    border-color: color-mix(in srgb, var(--green) 42%, var(--line));
    background: var(--primary-soft);
}

.badge.red {
    color: var(--red);
    border-color: color-mix(in srgb, var(--red) 42%, var(--line));
    background: var(--red-soft);
}

.badge.amber {
    color: var(--amber);
    border-color: color-mix(in srgb, var(--amber) 42%, var(--line));
    background: var(--amber-soft);
}

.muted {
    color: var(--muted);
}

.mono {
    font-family: Consolas, "SFMono-Regular", Menlo, monospace;
    word-break: break-all;
}

.api-sample {
    margin: 0;
    white-space: pre-wrap;
}

.flash {
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--primary-soft) 40%, var(--surface));
    box-shadow: var(--shadow-soft);
    font-weight: 600;
}

.flash.success {
    color: var(--green);
}

.flash.error {
    color: var(--red);
    border-left-color: var(--red);
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(900px 420px at 20% 0%, rgba(var(--primary-rgb), .12), transparent 55%),
        radial-gradient(700px 360px at 90% 20%, rgba(var(--primary-rgb), .08), transparent 50%),
        var(--bg);
}

.login-shell {
    width: min(420px, 100%);
}

.login-card {
    padding: 32px;
    box-shadow: var(--shadow);
}

.login-card h1 {
    margin: 0 0 5px;
    font-size: 26px;
    font-weight: 720;
}

.login-card p {
    margin: 0 0 22px;
    color: var(--muted);
    font-weight: 500;
}

.login-card .btn.primary {
    width: 100%;
    min-height: 44px;
}

.login-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.login-brand-mark {
    width: 46px;
    height: 46px;
}

.empty {
    padding: 28px;
    color: var(--muted);
    text-align: center;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

body.modal-open {
    overflow: hidden;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 7vh 16px 32px;
}

.modal.is-open {
    display: flex;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
}

.modal-dialog {
    position: relative;
    z-index: 1;
    width: min(560px, 100%);
    max-height: 86vh;
    overflow: auto;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: 0 24px 72px rgba(0, 0, 0, .22);
}

.modal-dialog-wide {
    width: min(720px, 100%);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: -2px 0 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.modal-close {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    transition: border-color .18s ease, background-color .18s ease, color .18s ease, transform .18s ease;
}

.modal-close:hover {
    border-color: color-mix(in srgb, var(--primary) 28%, var(--line));
    color: var(--primary-deep);
    background: var(--primary-soft);
    transform: translateY(-1px);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 4px;
}

.mail-template-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr);
    gap: 14px;
    align-items: start;
}

.mail-template-form,
.mail-template-preview {
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.mail-template-form textarea {
    min-height: 230px;
}

.mail-template-preview {
    display: grid;
    gap: 12px;
}

.mail-template-preview-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.mail-template-preview-head strong {
    font-size: 16px;
}

.mail-template-preview-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.mail-template-preview-meta div {
    min-width: 0;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.mail-template-preview-meta span,
.mail-template-preview-meta strong {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mail-template-preview-meta span {
    color: var(--muted);
    font-size: 12px;
}

.mail-template-preview-body {
    min-height: 230px;
    margin: 0;
    padding: 12px;
    border: 1px solid color-mix(in srgb, var(--primary) 20%, var(--line));
    border-radius: var(--radius);
    background: var(--surface);
}

.storage-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.12fr) minmax(300px, .88fr);
    gap: 14px;
    align-items: start;
}

.storage-project-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.storage-project-tab {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
    color: var(--text);
}

.storage-project-tab:hover,
.storage-project-tab.active {
    border-color: color-mix(in srgb, var(--primary) 46%, var(--line));
    background: color-mix(in srgb, var(--primary-soft) 38%, var(--surface));
}

.storage-project-tab.active {
    box-shadow: inset 3px 0 0 var(--primary);
}

.storage-project-icon {
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--primary) 34%, var(--line));
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--primary);
}

.storage-project-icon .icon {
    width: 20px;
    height: 20px;
}

.storage-project-main {
    min-width: 0;
    display: grid;
    gap: 3px;
}

.storage-project-main strong,
.storage-project-main small,
.storage-project-main code {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.storage-project-main strong {
    font-size: 15px;
}

.storage-project-main small {
    color: var(--muted);
    font-size: 12px;
}

.storage-project-main code {
    color: var(--primary-deep);
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.storage-form,
.storage-summary {
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.storage-summary {
    display: grid;
    gap: 12px;
}

.storage-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid color-mix(in srgb, var(--primary) 24%, var(--line));
    border-radius: var(--radius);
    background: var(--surface);
}

.storage-card-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--primary) 36%, var(--line));
    border-radius: var(--radius);
    background: var(--primary-soft);
    color: var(--primary);
}

.storage-card span,
.storage-card strong {
    display: block;
}

.storage-card span {
    color: var(--muted);
    font-size: 12px;
}

.storage-card strong {
    margin-top: 2px;
    font-size: 17px;
}

.storage-paths {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.storage-paths code {
    display: block;
    min-width: 0;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-soft);
    color: var(--text);
    overflow-wrap: anywhere;
    line-height: 1.45;
}

.storage-note {
    margin: 0;
}

@media (max-width: 1180px) {
    .stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .two-col {
        grid-template-columns: 1fr;
    }

    .huanqi-dashboard-grid {
        grid-template-columns: 1fr;
    }

    .product-grid,
    .product-module-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .storage-project-tabs {
        grid-template-columns: 1fr;
    }

    .resource-lines {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 820px) {
    body.sidebar-open {
        overflow: hidden;
    }

    .app-shell {
        display: block;
        padding-top: 56px;
    }

    .mobile-topbar {
        position: fixed;
        inset: 0 0 auto 0;
        z-index: 40;
        height: 56px;
        display: flex;
        align-items: center;
        gap: 12px;
        padding: max(8px, env(safe-area-inset-top)) 14px 8px;
        border-bottom: 1px solid var(--line);
        background: var(--surface);
        font-weight: 680;
    }

    .mobile-menu-button {
        width: 38px;
        height: 38px;
        display: grid;
        place-items: center;
        border-color: var(--line);
        background: var(--surface-soft);
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 30;
        display: block;
        background: rgba(0, 0, 0, .46);
        opacity: 0;
        pointer-events: none;
        transition: opacity .18s ease;
    }

    body.sidebar-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 50;
        width: min(82vw, 300px);
        height: 100dvh;
        padding: max(14px, env(safe-area-inset-top)) 12px 14px;
        border-right: 1px solid var(--line);
        transform: translateX(-104%);
        transition: transform .2s ease;
        box-shadow: 16px 0 36px rgba(0, 0, 0, .18);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .nav {
        grid-template-columns: 1fr;
    }

    .nav a {
        min-height: 44px;
    }

    .main {
        padding: 18px 14px 32px;
    }

    .huanqi-subnav {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .huanqi-subnav::-webkit-scrollbar {
        display: none;
    }

    .huanqi-subnav a {
        flex: 0 0 auto;
    }

    .huanqi-toolbar {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .huanqi-toolbar .btn {
        width: 100%;
    }

    .huanqi-toolbar-meta {
        justify-self: start;
    }

    .pagination {
        align-items: stretch;
        flex-direction: column;
    }

    .pagination .actions {
        justify-content: stretch;
    }

    .pagination .btn {
        flex: 1 1 0;
    }

    .topbar {
        display: grid;
        align-items: start;
        margin: 0 0 18px;
        padding: 0 0 16px;
        border-bottom: 1px solid var(--line);
        background: transparent;
    }

    .page-title {
        font-size: 22px;
    }

    .page-desc {
        font-size: 13px;
    }

    .user-pill {
        width: 100%;
        min-width: 0;
        text-align: left;
    }

    .user-pill-icon {
        margin-left: 0;
    }

    .stats,
    .two-col,
    .huanqi-dashboard-grid,
    .product-grid,
    .product-module-grid,
    .resource-lines,
    .storage-project-tabs,
    .mail-template-layout,
    .storage-layout,
    .mail-template-preview-meta {
        grid-template-columns: 1fr;
    }

    .product-hero {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .token-modal-meta {
        grid-template-columns: 1fr;
    }

    .product-hero .btn {
        width: 100%;
    }
}

@media (max-width: 760px) {
    .table-wrap {
        overflow: visible;
    }

    table {
        min-width: 0;
        border-collapse: separate;
        border-spacing: 0;
    }

    thead {
        display: none;
    }

    tbody,
    tr,
    td {
        display: block;
        width: 100%;
    }

    tr {
        margin-bottom: 14px;
        padding: 12px;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        background: var(--surface);
    }

    td {
        display: grid;
        grid-template-columns: minmax(82px, 34%) minmax(0, 1fr);
        gap: 10px;
        align-items: start;
        padding: 8px 0;
        border-bottom: 1px solid var(--line);
        overflow-wrap: anywhere;
    }

    td:last-child {
        border-bottom: 0;
    }

    td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 12px;
        font-weight: 640;
    }

    td[data-label="操作"] {
        display: block;
        padding-top: 12px;
    }

    td[data-label="操作"]::before {
        display: block;
        margin-bottom: 8px;
    }

    td.select-col {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        text-align: left;
    }

    td.select-col::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 12px;
        font-weight: 640;
    }

    .batch-toolbar {
        width: 100%;
        justify-content: space-between;
    }

    .batch-actions {
        flex: 1;
        justify-content: flex-end;
        min-width: 0;
    }

    .batch-actions select {
        width: min(42vw, 112px);
    }

    .actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .actions .btn,
    .actions button {
        width: 100%;
    }

    .group-member-editor-head {
        display: none;
    }

    .group-member-editor-row {
        grid-template-columns: 42px minmax(0, 1fr);
    }

    .group-member-editor-row select,
    .member-role-fixed {
        grid-column: 2;
    }
}

@media (max-width: 520px) {
    .panel {
        padding: 14px;
    }

    .stat {
        min-height: 84px;
    }

    .stat-value {
        font-size: 25px;
    }

    .btn.small {
        min-height: 42px;
    }

    .permission-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 420px) {
    td {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .actions {
        grid-template-columns: 1fr;
    }

    .login-card {
        padding: 22px;
    }

    .login-title-row {
        display: grid;
    }
}
