:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #eef2f5;
  --ink: #17202a;
  --muted: #65717d;
  --line: #dce2e8;
  --brand: #00696c;
  --brand-ink: #ffffff;
  --success: #1f7a4d;
  --warning: #9a6300;
  --danger: #b3261e;
  --radius: 18px;
  --shadow: 0 18px 48px rgb(0 0 0 / 10%);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 32px; background: #e7eff0; }
.login-card { width: min(430px, 100%); padding: 42px; border: 1px solid var(--line); border-radius: 28px; background: var(--surface); box-shadow: var(--shadow); }
.brand-mark { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 16px; background: var(--brand); color: white; font-size: 28px; font-weight: 800; }
.brand-mark.small { width: 40px; height: 40px; border-radius: 12px; font-size: 21px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(24px, 3vw, 34px); letter-spacing: -.03em; }
h2 { margin-bottom: 18px; font-size: 20px; }
.muted { color: var(--muted); line-height: 1.6; }
.stack { display: grid; gap: 16px; margin-top: 28px; }
.stack.compact { margin-top: 18px; }
label { display: grid; gap: 8px; color: #394651; font-size: 13px; font-weight: 650; }
input, select, textarea { width: 100%; min-height: 44px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); outline: none; }
input:focus, select:focus, textarea:focus, button:focus-visible { border-color: var(--brand); box-shadow: 0 0 0 3px rgb(0 105 108 / 16%); outline: none; }
.primary, .secondary { min-height: 42px; padding: 0 17px; border-radius: 12px; font-weight: 750; }
.primary { border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink); }
.secondary { border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.text-button { border: 0; background: transparent; color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.form-error { min-height: 20px; margin: 0; color: var(--danger); font-size: 13px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 236px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 24px 16px; border-right: 1px solid #25323b; background: #18242c; color: #f6fbff; }
.brand-row { display: flex; align-items: center; gap: 12px; padding: 0 8px 30px; }
.brand-row div:last-child { display: grid; gap: 2px; }
.brand-row span { color: #afbcc5; font-size: 12px; }
nav { display: grid; gap: 7px; }
.nav-item { min-height: 44px; padding: 0 14px; border: 0; border-radius: 12px; background: transparent; color: #cbd5db; text-align: left; font-weight: 650; }
.nav-item:hover { background: #22323d; color: white; }
.nav-item.active { background: #d1eeee; color: #073c3e; }
.nav-badge { float: right; min-width: 20px; margin-left: 6px; padding: 2px 6px; border-radius: 999px; background: #d54b3e; color: white; font-size: 11px; text-align: center; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 14px 8px 0; border-top: 1px solid #33434e; color: #b9c6ce; font-size: 12px; }
.sidebar-foot .text-button { margin-left: auto; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; }

.workspace { width: 100%; max-width: 1480px; margin: 0 auto; padding: 30px 38px 54px; }
.topbar { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.summary-card, .panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 6px 18px rgb(0 0 0 / 5%); }
.summary-card { min-height: 130px; padding: 20px; }
.summary-card span { color: var(--muted); font-size: 13px; }
.summary-card strong { display: block; margin-top: 19px; font-size: 32px; letter-spacing: -.04em; }
.panel { padding: 24px; }
.split-panel { display: grid; grid-template-columns: minmax(180px, .7fr) minmax(460px, 1.3fr); gap: 32px; align-items: start; }
.workflow { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin: 0; padding: 0; list-style: none; }
.workflow li { display: flex; gap: 12px; min-height: 100px; padding: 14px; border: 1px solid var(--line); }
.workflow li:nth-child(1) { border-radius: 14px 0 0 0; }
.workflow li:nth-child(2) { border-radius: 0 14px 0 0; border-left: 0; }
.workflow li:nth-child(3) { border-radius: 0 0 0 14px; border-top: 0; }
.workflow li:nth-child(4) { border-radius: 0 0 14px 0; border-top: 0; border-left: 0; }
.workflow li > span { flex: 0 0 28px; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-soft); color: var(--brand); font-weight: 800; }
.workflow p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 12px; }
.panel-heading h2 { margin-bottom: 0; }
.panel-heading input { max-width: 260px; }
.table-panel { padding: 0; overflow: hidden; }
.table-panel .panel-heading { padding: 24px 24px 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 14px 18px; border-top: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { background: #f8fafb; color: var(--muted); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
td:last-child { text-align: right; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 9px; border-radius: 999px; background: var(--surface-soft); color: var(--muted); font-size: 11px; font-weight: 750; }
.badge.active { background: #dff4e8; color: var(--success); }
.badge.pending { background: #fff0ce; color: var(--warning); }
.badge.disabled, .badge.suspended, .badge.expired { background: #fbe4e2; color: var(--danger); }
.row-button { min-height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.row-button.confirm { border-color: var(--brand); background: var(--brand); color: var(--brand-ink); }
.row-button.danger-text { color: var(--danger); }
.row-button:disabled { cursor: not-allowed; opacity: .6; }
.row-actions { display: flex; justify-content: flex-end; gap: 7px; }
.subscription-layout { display: grid; grid-template-columns: minmax(320px, .8fr) minmax(420px, 1.2fr); gap: 18px; margin-bottom: 18px; }
.announcement-layout { display: grid; grid-template-columns: minmax(420px, 1.15fr) minmax(300px, .85fr); gap: 18px; align-items: start; }
.announcement-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.announcement-status h3 { margin: 22px 0 8px; font-size: 20px; }
.announcement-status p { line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.announcement-status small { color: var(--muted); }
.subscription-add-panel h2, .subscription-rules h2 { margin-bottom: 8px; }
.subscription-add-panel .muted { margin-bottom: 0; }
.subscription-rules p { max-width: 68ch; color: var(--muted); line-height: 1.65; }
.subscription-rules dl { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 22px 0 0; }
.subscription-rules dl div { padding: 14px; border-radius: 12px; background: var(--surface-soft); }
.subscription-rules dt { color: var(--muted); font-size: 11px; }
.subscription-rules dd { margin: 5px 0 0; font-weight: 700; }
.subscription-table-panel .panel-heading p { margin: 5px 0 0; }
.revision-label { flex: 0 0 auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.masked-url, .failure-count { display: block; max-width: 320px; margin-top: 5px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.failure-count { color: var(--danger); }
.active-source { display: inline-flex; min-height: 34px; align-items: center; padding: 0 12px; border-radius: 9px; background: #dff4e8; color: var(--success); font-size: 12px; font-weight: 750; }
.subscription-actions { min-width: 330px; flex-wrap: wrap; }
.two-column { display: grid; grid-template-columns: minmax(300px, .8fr) minmax(500px, 1.2fr); gap: 18px; align-items: start; }
.support-layout { display: grid; grid-template-columns: minmax(280px, .72fr) minmax(480px, 1.28fr); gap: 18px; height: min(720px, calc(100vh - 150px)); }
.support-list-panel, .support-chat-panel { min-height: 0; padding: 0; overflow: hidden; }
.support-thread-list { height: calc(100% - 86px); overflow-y: auto; padding: 0 12px 14px; }
.support-thread { width: 100%; padding: 14px; border: 1px solid transparent; border-radius: 14px; background: transparent; color: var(--ink); text-align: left; }
.support-thread:hover { background: var(--surface-soft); }
.support-thread.active { border-color: #9dcfd0; background: #e4f3f3; }
.support-thread > span { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.support-thread b { min-width: 22px; padding: 3px 6px; border-radius: 999px; background: var(--danger); color: white; font-size: 11px; text-align: center; }
.support-thread small { display: block; margin-top: 5px; color: var(--muted); }
.support-thread p { margin: 8px 0 0; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.support-chat-panel { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.support-chat-heading { padding: 24px 24px 12px; border-bottom: 1px solid var(--line); }
.support-chat-heading h2 { margin-bottom: 4px; }
.support-chat-heading p { margin-bottom: 0; }
.support-messages { overflow-y: auto; padding: 22px; background: #f8fafb; }
.support-message { width: fit-content; max-width: min(76%, 620px); margin: 0 0 14px; padding: 11px 14px; border-radius: 14px; background: white; box-shadow: 0 3px 12px rgb(0 0 0 / 5%); }
.support-message.admin { margin-left: auto; background: #dff2f2; }
.support-message span { color: var(--muted); font-size: 11px; }
.support-message p { margin: 6px 0 0; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.support-reply { padding: 16px 20px 20px; border-top: 1px solid var(--line); }
.support-reply > div { display: flex; align-items: flex-end; gap: 10px; }
.support-reply textarea { resize: vertical; }
.support-reply button { flex: 0 0 auto; height: 44px; }
.invite-result { display: grid; gap: 10px; margin-top: 20px; padding: 16px; border-radius: 14px; background: #e9f5f5; }
.invite-result span { color: var(--muted); font-size: 12px; }
.invite-result code { overflow-wrap: anywhere; color: #064e50; font-size: 16px; font-weight: 800; }

dialog { width: min(560px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: rgb(17 30 39 / 56%); }
.dialog-close { position: absolute; top: 12px; right: 14px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--surface-soft); font-size: 22px; }
.dialog-body { padding: 30px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0; }
.detail-grid div { padding: 12px; border-radius: 12px; background: var(--surface-soft); }
.detail-grid span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.action-group { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--line); }
.action-group form { display: grid; gap: 10px; }
.delete-account { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.delete-account p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.delete-account .danger { flex: 0 0 auto; min-height: 40px; padding: 0 16px; border: 1px solid var(--danger); border-radius: 10px; background: var(--surface); color: var(--danger); font-weight: 700; }
.delete-account .danger:hover { background: #fbe4e2; }
.delete-account .danger:focus-visible { outline: 3px solid var(--danger); outline-offset: 2px; }
.delete-account .danger:disabled { cursor: wait; opacity: .6; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: 360px; padding: 13px 16px; border-radius: 12px; background: #17252d; color: white; box-shadow: var(--shadow); transform: translateY(20px); opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.empty { padding: 42px 20px; color: var(--muted); text-align: center !important; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 76px minmax(0, 1fr); }
  .sidebar { padding-inline: 10px; }
  .brand-row { justify-content: center; padding-inline: 0; }
  .brand-row div:last-child, .nav-item, .sidebar-foot span, .sidebar-foot .text-button { font-size: 0; }
  .nav-item { padding: 0; text-align: center; }
  .nav-item::first-letter { font-size: 16px; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .split-panel, .two-column, .subscription-layout, .announcement-layout { grid-template-columns: 1fr; }
  .support-layout { grid-template-columns: minmax(220px, .65fr) minmax(380px, 1.35fr); }
}

@media (max-width: 620px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 3; top: auto; bottom: 0; width: 100%; height: 116px; flex-direction: row; align-items: center; padding: 8px; border: 0; }
  .brand-row, .sidebar-foot { display: none; }
  nav { width: 100%; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .nav-item { min-height: 50px; font-size: 12px; text-align: center; }
  .nav-item::first-letter { font-size: inherit; }
  .workspace { padding: 24px 16px 142px; }
  .topbar { align-items: center; }
  .summary-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .summary-card { min-height: 110px; padding: 16px; }
  .split-panel { padding: 18px; }
  .workflow { grid-template-columns: 1fr; }
  .workflow li, .workflow li:nth-child(n) { border: 1px solid var(--line); border-bottom: 0; border-radius: 0; }
  .workflow li:first-child { border-radius: 12px 12px 0 0; }
  .workflow li:last-child { border-bottom: 1px solid var(--line); border-radius: 0 0 12px 12px; }
  .detail-grid, .action-group { grid-template-columns: 1fr; }
  .support-layout { display: block; height: auto; }
  .support-list-panel { height: 280px; margin-bottom: 12px; }
  .support-chat-panel { height: 560px; }
  .subscription-rules dl { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
