:root {
  --ink: #1c2732;
  --muted: #64717d;
  --line: #d6dde4;
  --line-strong: #b8c5d0;
  --canvas: #edf1f4;
  --surface: #ffffff;
  --sidebar: #202b36;
  --sidebar-hover: #2e3d4b;
  --primary: #0877c9;
  --primary-dark: #075e9f;
  --success: #147b68;
  --danger: #bf4450;
  --amber: #c87813;
  --shadow: 0 12px 28px rgba(23, 35, 46, 0.12);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  min-width: 320px;
  background: #cad3db;
  color: var(--ink);
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid #f3a438; outline-offset: 2px; }
svg { width: 18px; height: 18px; stroke-width: 1.9; }
.hidden { display: none !important; }

.desktop-shell {
  width: min(1480px, calc(100% - 32px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
  overflow: hidden;
  background: var(--canvas);
  border: 1px solid #aab6c1;
  box-shadow: 0 20px 50px rgba(20, 31, 42, 0.22);
}
.window-chrome {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: #17212a;
  color: #f2f5f7;
  border-bottom: 1px solid #0e151b;
}
.app-mark, .avatar {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  border-radius: 4px;
}
.app-name { font-size: 16px; font-weight: 800; letter-spacing: 0; }
.app-channel, .eyebrow, .page-kicker, .panel-heading span, .sidebar-caption {
  color: #8899a8;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}
.chrome-spacer { flex: 1; }
.service-status { display: inline-flex; align-items: center; gap: 7px; color: #c8d4dc; font-size: 12px; }
.service-status span { width: 8px; height: 8px; background: #35bc83; border-radius: 50%; }
.icon-button {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  color: inherit;
  background: transparent;
}
.icon-button:hover { background: rgba(255, 255, 255, 0.12); }
.icon-button.has-update { color: #ffd075; }

.app-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr) 270px; min-height: calc(100vh - 82px); }
.sidebar { display: flex; flex-direction: column; padding: 18px 12px 14px; color: #dae3e9; background: var(--sidebar); }
.nav-stack { display: grid; gap: 4px; }
.nav-item {
  width: 100%;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 4px;
  color: #c3d0d8;
  background: transparent;
  text-align: left;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { color: #fff; background: #0f71b7; border-color: #238ad2; }
.nav-item svg { flex: 0 0 auto; }
.sidebar-foot { margin-top: auto; padding: 16px 9px 2px; border-top: 1px solid #3a4a58; color: #a9b6c0; font-size: 12px; line-height: 1.75; }
.sidebar-caption { margin-bottom: 4px; }

.workspace-main { min-width: 0; padding: 30px; background: var(--canvas); }
.page-view { display: none; }
.page-view.active { display: block; }
.page-kicker { color: var(--primary); margin-bottom: 8px; }
.page-title-row, .library-topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
h1, h2, h3, h4, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: 26px; line-height: 1.24; letter-spacing: 0; }
h2 { margin-bottom: 0; font-size: 18px; line-height: 1.3; letter-spacing: 0; }
h3 { font-size: 18px; letter-spacing: 0; }
p { color: var(--muted); line-height: 1.6; }
.page-title-row > div > p, .library-topbar > div > p { margin-bottom: 0; }

.primary-button, .secondary-button, .text-button, .command-bar button, .side-actions button, .pager button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 4px;
  font-weight: 700;
  text-decoration: none;
}
.primary-button { padding: 0 14px; border: 1px solid var(--primary); color: #fff; background: var(--primary); }
.primary-button:hover { border-color: var(--primary-dark); background: var(--primary-dark); }
.secondary-button { padding: 0 13px; border: 1px solid var(--line-strong); color: #394957; background: #fff; }
.secondary-button:hover { background: #f5f8fa; }
.text-button { min-height: 28px; padding: 0; border: 0; color: var(--primary); background: transparent; }
.text-button:hover { color: var(--primary-dark); text-decoration: underline; }
.full-button { width: 100%; }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric { min-height: 112px; padding: 17px; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid #7d8d9b; }
.metric:nth-child(2) { border-top-color: var(--success); }
.metric:nth-child(3) { border-top-color: var(--amber); }
.metric span, .membership-status span { display: block; color: var(--muted); font-size: 12px; }
.metric b { display: block; margin: 8px 0 5px; font-size: 22px; line-height: 1; }
.metric small { color: #81909c; }
.metric-online { color: var(--success); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(260px, 0.85fr); gap: 18px; }
.surface-panel { border: 1px solid var(--line); background: var(--surface); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 17px 18px 15px; border-bottom: 1px solid var(--line); }
.panel-heading span { color: var(--primary); }
.panel-heading h2 { margin-top: 3px; }
.news-feed { min-height: 268px; }
.news-row { padding: 15px 18px; border-bottom: 1px solid #e7edf1; }
.news-row:last-child { border-bottom: 0; }
.news-row h4 { margin-bottom: 5px; font-size: 15px; }
.news-row p { margin-bottom: 5px; font-size: 13px; }
.news-row small { color: #88949e; }
.empty-state { padding: 24px 18px; color: var(--muted); text-align: left; }
.product-preview { display: grid; gap: 0; }
.product-preview-item { padding: 16px 18px; border-bottom: 1px solid #e7edf1; }
.product-preview-item:last-child { border-bottom: 0; }
.product-preview-item h4 { margin-bottom: 6px; font-size: 15px; }
.product-preview-item p { margin-bottom: 8px; font-size: 13px; }
.product-preview-item b { color: var(--success); font-size: 13px; }

.library-actions { display: flex; align-items: center; gap: 8px; }
.search-box { width: 190px; height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid var(--line-strong); background: #fff; }
.search-box svg { width: 16px; color: #6f7f8c; }
.search-box input { min-width: 0; width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; }
.library-panel { overflow: hidden; }
.table-wrap { overflow: auto; }
.acct-table { width: 100%; min-width: 700px; border-collapse: collapse; }
.acct-table th { height: 42px; padding: 0 12px; color: #586b7b; background: #f5f7f9; border-bottom: 1px solid var(--line); font-size: 12px; text-align: left; white-space: nowrap; }
.acct-table td { height: 46px; padding: 0 12px; border-bottom: 1px solid #e7edf1; white-space: nowrap; }
.acct-table tbody tr { cursor: pointer; }
.acct-table tbody tr:hover td { background: #f4f9fc; }
.acct-table tbody tr.selected td { color: #075d98; background: #dceef9; }
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 0 15px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); background: #fbfcfd; }
.pager { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.pager button { width: 30px; min-height: 30px; padding: 0; color: #40515f; border: 1px solid var(--line-strong); background: #fff; }
.pager button:hover { background: #eff5f9; }
.pager svg { width: 16px; }
.command-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.command-bar button, .side-actions button { padding: 0 11px; color: #40515f; border: 1px solid var(--line-strong); background: #fff; }
.command-bar button:hover, .side-actions button:hover { color: var(--primary-dark); border-color: #83b5d7; background: #f5faff; }
.command-bar svg, .side-actions svg { width: 16px; }

.announcement-list { display: grid; gap: 12px; }
.announcement-card { padding: 20px; border-left: 3px solid #7d8d9b; background: var(--surface); border-right: 1px solid var(--line); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.announcement-card.pinned { border-left-color: var(--primary); }
.announcement-card h2 { margin-bottom: 8px; }
.announcement-card p { margin-bottom: 10px; white-space: normal; }
.announcement-meta { color: #82909d; font-size: 12px; }
.product-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.product-card { min-height: 205px; display: flex; flex-direction: column; padding: 20px; border: 1px solid var(--line); background: var(--surface); }
.product-card h2 { margin-bottom: 10px; }
.product-card p { flex: 1; font-size: 13px; }
.product-card-footer { padding-top: 12px; border-top: 1px solid #e5ebef; }
.product-card-footer b { display: block; color: var(--success); margin-bottom: 5px; }
.product-card-footer small { color: #7b8995; }
.support-panel { display: flex; align-items: flex-start; gap: 18px; padding: 28px; }
.support-icon { width: 48px; height: 48px; display: grid; place-items: center; flex: 0 0 auto; color: #fff; background: var(--success); border-radius: 4px; }
.support-icon svg { width: 25px; height: 25px; }
.support-panel h2 { margin: 6px 0 8px; font-size: 23px; }

.identity-panel { padding: 22px 18px; border-left: 1px solid var(--line); background: #f9fbfc; }
.identity-state { min-height: 280px; }
.guest-avatar { width: 52px; height: 52px; margin-bottom: 18px; background: #607180; font-size: 20px; }
.identity-state .eyebrow { color: var(--primary); }
.identity-state h2 { margin: 5px 0 8px; font-size: 18px; }
.identity-state > p { margin-bottom: 20px; font-size: 13px; }
.identity-title { display: flex; align-items: center; gap: 12px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.identity-title .avatar { width: 42px; height: 42px; font-size: 17px; }
.identity-title p { margin: 3px 0 0; font-size: 12px; }
.membership-status { margin: 18px 0; padding: 13px; border-left: 3px solid var(--success); background: #eef8f5; }
.membership-status b { display: block; margin: 6px 0 4px; color: #126754; }
.membership-status small { display: block; color: #5b7d73; font-size: 12px; }
.side-actions { display: grid; gap: 8px; }
.side-actions button { width: 100%; justify-content: flex-start; }
.side-actions .danger-button { color: var(--danger); border-color: #e1b6bb; background: #fff8f8; }
.side-actions .danger-button:hover { color: #9e303a; border-color: #d69ca4; background: #fff0f1; }

.modal { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(15, 25, 34, 0.48); }
.modal-card { width: min(620px, 100%); max-height: min(760px, calc(100vh - 40px)); overflow: auto; background: #fff; border: 1px solid #aebbc5; box-shadow: var(--shadow); }
.modal-heading { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px 0 20px; border-bottom: 1px solid var(--line); background: #f6f8fa; }
.modal-heading h3 { margin: 0; }
.modal-heading .icon-button { color: #52616d; }
.modal-heading .icon-button:hover { background: #e7edf1; }
#modal-body { padding: 20px; }
#modal-body label { display: block; margin-bottom: 13px; color: #4a5a67; font-size: 13px; font-weight: 700; }
#modal-body input:not([type="checkbox"]), #modal-body textarea, #modal-body select { width: 100%; min-height: 36px; margin-top: 6px; padding: 7px 9px; color: var(--ink); border: 1px solid var(--line-strong); border-radius: 3px; background: #fff; }
#modal-body textarea { min-height: 104px; resize: vertical; }
#modal-body input[type="checkbox"] { width: auto; margin-right: 6px; accent-color: var(--primary); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: #f8fafb; }
.form-note, .hint { color: var(--muted); font-size: 12px; line-height: 1.55; }
.form-switch { margin-top: 12px; color: var(--primary); font-size: 13px; }
.form-switch button { padding: 0; border: 0; color: var(--primary); background: transparent; text-decoration: underline; }
.news-list, .product-list { display: grid; gap: 10px; }
.news-item, .product-preview-dialog { padding: 13px; border: 1px solid var(--line); background: #fbfcfd; }
.news-item h4, .product-preview-dialog h4 { margin-bottom: 6px; }
.news-item p, .product-preview-dialog p { margin-bottom: 7px; font-size: 13px; }
.news-item small, .product-preview-dialog small { color: var(--muted); }
.ops-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 18px; }
.ops-actions button { min-height: 38px; border: 1px solid #9fc5df; color: #0c618f; background: #f3faff; border-radius: 4px; font-weight: 700; }
.ops-actions button:hover { background: #e4f3fc; }
.admin-list { max-height: 190px; overflow: auto; padding: 10px; border: 1px solid var(--line); color: #52616d; background: #fbfcfd; font-family: Consolas, "Microsoft YaHei", monospace; font-size: 12px; line-height: 1.7; }
.code-list { max-height: 280px; overflow: auto; margin: 0; padding: 12px; color: #07577f; border: 1px solid #a8c9dc; background: #f3fbff; font-family: Consolas, monospace; line-height: 1.7; }
.toast { position: fixed; z-index: 30; right: 22px; bottom: 22px; max-width: min(360px, calc(100% - 44px)); padding: 10px 13px; color: #fff; background: #253543; box-shadow: 0 8px 18px rgba(0,0,0,0.2); }

@media (max-width: 1120px) {
  .desktop-shell { width: 100%; min-height: 100vh; margin: 0; border: 0; }
  .app-layout { grid-template-columns: 190px minmax(0, 1fr); }
  .identity-panel { display: none; }
}
@media (max-width: 780px) {
  .window-chrome { padding: 0 10px; }
  .app-channel, .service-status { display: none; }
  .app-layout { grid-template-columns: 1fr; min-height: auto; }
  .sidebar { display: block; padding: 8px; }
  .nav-stack { display: flex; overflow-x: auto; }
  .nav-item { min-width: max-content; width: auto; height: 36px; padding: 0 9px; }
  .sidebar-foot { display: none; }
  .workspace-main { padding: 20px 14px; }
  .page-title-row, .library-topbar { display: grid; }
  .page-title-row .primary-button { justify-self: start; }
  .metric-grid, .dashboard-grid, .product-grid { grid-template-columns: 1fr; }
  .library-actions { flex-wrap: wrap; }
  .search-box { width: min(100%, 260px); }
  .table-footer { align-items: flex-start; flex-direction: column; padding: 11px 15px; }
  .command-bar button { flex: 1 1 140px; }
}
