:root {
  --bg: #eef1f4;
  --ink: #14201c;
  --muted: #4a5560;
  --line: #c5cdd6;
  --panel: #ffffff;
  --accent: #0f6b5c;
  --danger: #9b1c1c;
  --font-ui: "IBM Plex Sans", "Noto Sans TC", sans-serif;
  --font-zh: "Noto Sans TC", "IBM Plex Sans", sans-serif;
  --base: 18px;
  --tap: 44px;
  --radius: 12px;
}

html[data-font="sm"] { --base: 16px; }
html[data-font="md"] { --base: 18px; }
html[data-font="lg"] { --base: 22px; }

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font-zh);
  font-size: var(--base);
  line-height: 1.5;
  background: var(--bg);
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(180deg, #f7f9fb 0%, var(--bg) 55%, #e6ebf0 100%);
}

/* Body is full-bleed; only the inner .desk / .stage card is width-capped.
   (Never put class "desk" on <body> — it inherited the 720px phone column.) */
body.mode-user,
body.mode-admin,
body.login {
  width: 100%;
  max-width: none;
  margin: 0;
  background: var(--bg);
}

.desk,
.login-stage,
.stage {
  position: relative;
  z-index: 1;
  width: min(100%, 720px);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--line) 80%, transparent);
}

/* —— User layouts: phone (narrow stack) vs pad (wide tablet/PC) —— */
html[data-layout="phone"] body.mode-user > .desk,
html[data-layout="phone"] body.mode-user > .stage {
  width: min(100%, 720px);
}

/* Phone: compact chrome, thumb-first modes */
html[data-layout="phone"] body.mode-user .desk-chrome {
  padding-bottom: 0.15rem;
}
html[data-layout="phone"] body.mode-user .desk-top {
  padding: 0.55rem 0.85rem;
}
html[data-layout="phone"] body.mode-user .symbol-strip {
  padding: 0.35rem 0.85rem 0.45rem;
  gap: 0.35rem;
}
html[data-layout="phone"] body.mode-user .mode-seg {
  padding: 0.35rem 0.85rem 0.55rem;
  gap: 0.35rem;
}
html[data-layout="phone"] body.mode-user .mode-seg-btn {
  padding: 0.65rem 0.5rem;
  font-size: 0.92em;
}
html[data-layout="phone"] body.mode-user .status-part {
  margin: 0 0.85rem 0.45rem;
}
html[data-layout="phone"] body.mode-user .desk-panel {
  padding: 0.85rem 0.85rem 1.1rem;
}
html[data-layout="phone"] body.mode-user .chart-card {
  margin-bottom: 0.75rem;
}
html[data-layout="phone"] body.mode-user .news-list article {
  padding: 0.75rem 0;
}
html[data-layout="phone"] body.mode-user .desk-foot {
  padding: 0.65rem 0.85rem 1rem;
  font-size: 0.78em;
}

/*
 * Pad / tablet / PC: wide reading desk.
 * Charts always stack full-width (never two-up).
 * Research: memo | news side-by-side in landscape.
 */
html[data-layout="pad"] body.mode-user > .desk,
html[data-layout="pad"] body.mode-user > .stage {
  width: min(100% - 1.5rem, 1480px);
  margin-top: 0.65rem;
  margin-bottom: 0.65rem;
  min-height: calc(100dvh - 1.3rem);
  border-radius: calc(var(--radius) + 4px);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--line) 80%, transparent),
    0 10px 36px color-mix(in srgb, var(--ink) 7%, transparent);
}
html[data-layout="pad"] body.mode-user .desk-top {
  padding: 0.7rem 1.35rem;
}
html[data-layout="pad"] body.mode-user .app-nav {
  padding: 0.15rem 1.35rem 0.45rem;
  gap: 0.45rem;
  border-bottom: none;
}
html[data-layout="pad"] body.mode-user .desk-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem 1rem;
  padding: 0.35rem 1.35rem 0.75rem;
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
html[data-layout="pad"] body.mode-user .symbol-strip {
  flex: 1 1 auto;
  flex-direction: row;
  flex-wrap: wrap;
  overflow-x: visible;
  padding: 0;
  gap: 0.4rem;
  min-width: 0;
}
html[data-layout="pad"] body.mode-user .sym-chip {
  width: auto;
  border-radius: 999px;
  min-height: 2.35rem;
  padding: 0.35rem 0.85rem;
}
html[data-layout="pad"] body.mode-user .mode-seg {
  flex: 0 0 auto;
  flex-direction: row;
  max-width: none;
  width: auto;
  padding: 0.2rem;
  gap: 0.2rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 65%, #fff);
}
html[data-layout="pad"] body.mode-user .mode-seg-btn {
  flex: 0 0 auto;
  width: auto;
  min-width: 4.5rem;
  text-align: center;
  justify-content: center;
  padding: 0.5rem 0.95rem;
  font-size: 0.92em;
  border-width: 1px;
  border-radius: 9px;
  background: transparent;
  box-shadow: none;
}
html[data-layout="pad"] body.mode-user .mode-seg-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
}
html[data-layout="pad"] body.mode-user .status-part {
  margin: 0 1.35rem 0.65rem;
  font-size: 0.85em;
}
html[data-layout="pad"] body.mode-user .desk-panel {
  padding: 1.1rem 1.5rem 1.5rem;
  min-width: 0;
}
html[data-layout="pad"] body.mode-user .desk-foot {
  display: block;
  padding: 0.65rem 1.5rem 1rem;
  font-size: 0.8em;
}

/* Fallback: any wide viewport that is not explicitly phone uses a wide desk */
@media (min-width: 900px) {
  html:not([data-layout="phone"]) body.mode-user > .desk,
  html:not([data-layout="phone"]) body.mode-user > .stage {
    width: min(100% - 2rem, 1480px);
    margin-top: 0.65rem;
    margin-bottom: 0.65rem;
    min-height: calc(100dvh - 1.3rem);
    border-radius: calc(var(--radius) + 4px);
    box-shadow:
      0 0 0 1px color-mix(in srgb, var(--line) 80%, transparent),
      0 10px 36px color-mix(in srgb, var(--ink) 7%, transparent);
  }
}

/* Market: single-column chart stack (never two-up) */
html[data-layout="pad"] body.mode-user #panel-market.is-active {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
html[data-layout="pad"] body.mode-user .market-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.55rem 1rem;
}
html[data-layout="pad"] body.mode-user .market-toolbar .panel-caption {
  margin: 0;
  flex: 1 1 14rem;
  min-width: 0;
}
html[data-layout="pad"] body.mode-user .market-toolbar .chart-range {
  margin: 0;
  flex: 0 0 auto;
}
html[data-layout="pad"] body.mode-user .chart-stack {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
html[data-layout="pad"] body.mode-user .chart-card {
  min-width: 0;
  overflow: hidden;
  margin-bottom: 0;
}
html[data-layout="pad"] body.mode-user .chart-wrap {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}
html[data-layout="pad"] body.mode-user .chart-wrap-price {
  height: 340px;
  min-height: 280px;
}
html[data-layout="pad"] body.mode-user .chart-wrap-rsi {
  height: 170px;
  min-height: 150px;
}
html[data-layout="pad"] body.mode-user .chart-wrap-eps {
  height: 200px;
  min-height: 170px;
}
html[data-layout="pad"] body.mode-user .chart-stats {
  grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr));
  margin: 0;
}

/* Research: memo | news (reading panes) — not charts */
html[data-layout="pad"] body.mode-user #panel-research.is-active {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 1.1rem;
  align-items: stretch;
}
html[data-layout="pad"] body.mode-user #panel-research > .panel-caption {
  grid-column: 1 / -1;
  margin: 0 0 0.15rem;
}
html[data-layout="pad"] body.mode-user #panel-research > .research-subseg {
  display: none;
}
html[data-layout="pad"] body.mode-user #panel-research .research-subpanel {
  display: flex !important;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  background: #fff;
  min-width: 0;
  min-height: 18rem;
  max-height: min(74vh, 44rem);
  overflow: hidden;
}
html[data-layout="pad"] body.mode-user #research-memo::before,
html[data-layout="pad"] body.mode-user #research-news::before {
  content: "備忘";
  display: block;
  flex: 0 0 auto;
  font-weight: 700;
  font-size: 0.95em;
  margin: 0;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 70%, #fff);
}
html[data-layout="pad"] body.mode-user #research-news::before {
  content: "新聞";
}
html[data-layout="pad"] body.mode-user #research-memo .legal-details,
html[data-layout="pad"] body.mode-user #research-memo .memo-body,
html[data-layout="pad"] body.mode-user #research-memo .empty-copy,
html[data-layout="pad"] body.mode-user #research-news .panel-caption,
html[data-layout="pad"] body.mode-user #research-news .news-list,
html[data-layout="pad"] body.mode-user #research-news .empty-copy {
  padding-left: 1rem;
  padding-right: 1rem;
}
html[data-layout="pad"] body.mode-user #research-memo .memo-body,
html[data-layout="pad"] body.mode-user #research-news .news-list {
  flex: 1 1 auto;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 1rem;
  min-height: 0;
  min-width: 0;
}
html[data-layout="pad"] body.mode-user #research-memo .legal-details {
  margin: 0.55rem 1rem 0.35rem;
  padding: 0;
}

@media (min-width: 900px) {
  html[data-layout="pad"] body.mode-user > .desk,
  html[data-layout="pad"] body.mode-user > .stage {
    width: min(100% - 2rem, 1480px);
  }
  html[data-layout="pad"] body.mode-user .desk-panel {
    padding: 1.2rem 1.65rem 1.6rem;
  }
  html[data-layout="pad"] body.mode-user .chart-wrap-price {
    height: 380px;
    min-height: 300px;
  }
}

html[data-layout="pad"] body.mode-user .ask-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  align-items: end;
}
html[data-layout="pad"] body.mode-user .panel-ask.is-active {
  max-width: none;
}
html[data-layout="pad"] body.mode-user .ask-compose {
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: color-mix(in srgb, var(--panel) 94%, #e8f0ed);
  border-top: 1px solid var(--line);
  margin: 0.75rem -1.5rem -0.5rem;
  padding: 0.85rem 1.5rem 1rem;
}

@media (orientation: portrait) {
  html[data-layout="pad"] body.mode-user .desk-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  html[data-layout="pad"] body.mode-user .mode-seg {
    width: 100%;
    justify-content: stretch;
  }
  html[data-layout="pad"] body.mode-user .mode-seg-btn {
    flex: 1 1 0;
  }
  html[data-layout="pad"] body.mode-user #panel-research.is-active {
    grid-template-columns: 1fr;
  }
  html[data-layout="pad"] body.mode-user #panel-research .research-subpanel {
    max-height: none;
  }
  html[data-layout="pad"] body.mode-user .ask-controls {
    grid-template-columns: 1fr;
  }
}

/* Phone: toolbar stacks naturally */
.desk-toolbar {
  display: contents;
}
html[data-layout="phone"] body.mode-user .desk-toolbar {
  display: contents;
}
.market-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 0.15rem;
}
.chart-stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.layout-row .layout-btn {
  min-height: var(--tap);
  min-width: auto;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  font-size: 0.88em;
  cursor: pointer;
}
.layout-row .layout-btn.is-active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}


.desk-chrome {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--panel) 94%, #e8f0ed);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--line) 55%, transparent);
}

.app-nav {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  padding: 0.15rem 1rem 0.55rem;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.app-nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.35rem;
  padding: 0.25rem 0.7rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88em;
  font-weight: 600;
}
.app-nav-link:hover,
.app-nav-link:focus-visible {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  outline: none;
}
.app-nav-link.is-current {
  color: var(--ink);
  border-color: var(--ink);
  background: color-mix(in srgb, var(--bg) 55%, #fff);
}
.stage-head .app-nav {
  padding-left: 0;
  padding-right: 0;
  margin: 0.65rem 0 0;
  border-bottom: none;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.btn-settings:focus-visible,
.btn-primary:focus-visible,
.btn-ghost:focus-visible,
.sec-btn:focus-visible,
.mode-seg-btn:focus-visible,
.research-subseg-btn:focus-visible,
.sym-chip:focus-visible,
.font-btn:focus-visible {
  outline: 2px solid var(--accent, #0f6b5c);
  outline-offset: 2px;
}
.md-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0.35rem 0 0.75rem;
}

.desk-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
}

.brand {
  font-weight: 700;
  font-size: 1.2em;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.desk-top-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.credit-meter {
  color: var(--muted);
  font-size: 0.85em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  border: 1px solid transparent;
}
.credit-meter.is-low {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
  background: color-mix(in srgb, var(--danger) 8%, #fff);
  font-weight: 600;
}

.btn-settings,
.btn-primary,
.btn-ghost,
.sec-btn,
.mode-seg-btn,
.research-subseg-btn,
.sym-chip,
.font-btn {
  min-height: var(--tap);
  min-width: var(--tap);
  font: inherit;
  border-radius: var(--radius);
  cursor: pointer;
}

.btn-settings,
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.45rem 0.9rem;
  font-weight: 600;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0.45rem 0.9rem;
}

.symbol-strip,
.section-strip,
.mode-seg {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding: 0.45rem 1rem 0.65rem;
  background: transparent;
}

.mode-seg {
  padding-top: 0.15rem;
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  gap: 0.25rem;
}

.status-part {
  margin: 0 1rem 0.5rem;
  font-size: 0.85em;
  color: var(--muted);
}
.status-part summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
}
.status-part-body {
  margin: 0.35rem 0 0;
  line-height: 1.45;
}

.section-strip {
  padding-top: 0.15rem;
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

.sym-chip {
  flex: 0 0 auto;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.88em;
  border-radius: 999px;
}

.mode-seg-btn {
  flex: 1 1 0;
  min-width: 5.5rem;
  padding: 0.55rem 0.75rem;
  border: 2px solid color-mix(in srgb, var(--accent) 25%, var(--line));
  background: color-mix(in srgb, var(--panel) 88%, #e8f0ed);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.95em;
  border-radius: 10px;
  letter-spacing: 0.01em;
}

.research-subseg {
  display: flex;
  gap: 0.35rem;
  margin: 0 0 0.75rem;
  flex-wrap: wrap;
}
.research-subseg-btn {
  flex: 0 0 auto;
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88em;
  border-radius: 8px;
}
.research-subpanel {
  display: none;
}
.research-subpanel.is-active {
  display: block;
}

.sec-btn {
  flex: 0 0 auto;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.95em;
  border-radius: 8px;
}

.sym-chip.is-active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--ink) 25%, transparent);
}

.mode-seg-btn.is-active,
.sec-btn.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--accent) 30%, transparent);
}

.research-subseg-btn.is-active {
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}

.admin-nav-link.is-current {
  border-color: var(--ink);
  background: color-mix(in srgb, var(--bg) 55%, #fff);
}
.mode-user .btn-admin-enter {
  font-size: 0.88em;
  padding: 0.35rem 0.7rem;
}

.desk-panel {
  flex: 1;
  padding: 1rem 1rem 1.25rem;
  min-height: 40vh;
}

.panel-section { display: none; }
.panel-section.is-active {
  display: block;
}
.panel-section.panel-ask.is-active {
  display: flex;
}
@media (prefers-reduced-motion: no-preference) {
  .panel-section.is-active {
    animation: fadeIn 120ms ease;
  }
}
@keyframes fadeIn {
  from { opacity: 0.35; }
  to { opacity: 1; }
}

.panel-caption {
  color: var(--muted);
  margin: 0 0 0.75rem;
  font-size: 0.88em;
}
.freshness-line.is-stale,
.panel-caption.is-stale,
.news-meta-line time.is-stale {
  color: #9a3412;
  font-weight: 600;
}

.chart-range {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.85rem;
}
.range-btn {
  min-height: 2.5rem;
  min-width: 3.4rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 0.88em;
  cursor: pointer;
}
.range-btn.is-active {
  background: var(--ink);
  color: #f7faf9;
  border-color: var(--ink);
}
.range-btn:focus-visible {
  outline: 2px solid var(--accent, #0f6b5c);
  outline-offset: 2px;
}

.chart-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr));
  gap: 0.4rem;
  margin: 0 0 0.85rem;
}
.chart-stat {
  background: linear-gradient(165deg, #f7faf9 0%, #eef5f3 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  min-height: 2.8rem;
}
.chart-stat .k {
  display: block;
  color: var(--muted);
  font-size: 0.72em;
  letter-spacing: 0.02em;
}
.chart-stat .v {
  display: block;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-top: 0.15rem;
}
.chart-stat .v.up { color: #9b1c1c; }
.chart-stat .v.down { color: #0f6b5c; }

.chart-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 0.85rem 0.55rem;
  margin-bottom: 0.9rem;
  box-shadow: 0 1px 0 rgba(20, 32, 28, 0.04);
}
.chart-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}
.chart-title {
  margin: 0;
  font-size: 0.95em;
  font-weight: 600;
}
.chart-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.75em;
}

.chart-wrap {
  position: relative;
  width: 100%;
  margin-bottom: 0.25rem;
  min-height: 140px;
}
.chart-wrap-price { min-height: 220px; height: 240px; }
.chart-wrap-rsi { min-height: 140px; height: 150px; }
.chart-wrap-eps { min-height: 160px; height: 180px; }

.empty-copy {
  color: var(--muted);
  margin: 1.25rem 0;
  padding: 1rem 1.05rem;
  border: 1px dashed color-mix(in srgb, var(--line) 90%, var(--muted));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg) 80%, #fff);
  font-size: 0.92em;
  line-height: 1.45;
  text-align: center;
}
.hidden { display: none !important; }

.news-list article {
  padding: 0.95rem 0;
  border-bottom: 1px solid var(--line);
}
.news-list h3 {
  margin: 0 0 0.35rem;
  font-size: 1.02em;
  line-height: 1.35;
}
.news-list h3 a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  text-decoration-color: color-mix(in srgb, var(--muted) 55%, transparent);
}
.news-list h3 a:hover {
  text-decoration-color: currentColor;
}
.news-abstract {
  margin: 0.35rem 0 0.25rem;
  line-height: 1.45;
  color: var(--ink);
  font-size: 0.95em;
}
.news-published {
  margin: 0.2rem 0 0.2rem;
  font-size: 0.88em;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 600;
}
.news-published-label {
  margin-right: 0.35rem;
  color: var(--muted);
  font-weight: 500;
}
.news-published-age {
  margin-left: 0.25rem;
  color: var(--muted);
  font-weight: 500;
}
.news-published.is-stale,
.news-published.is-stale .news-published-age {
  color: #9a3412;
}
.news-published-missing {
  color: var(--muted);
  font-weight: 500;
  font-style: italic;
}
.news-meta-line {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.82em;
}
.news-meta-line {
  color: var(--muted);
  font-size: 0.85em;
  margin: 0 0 0.35rem;
}
.news-atoms {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
}

.memo-body {
  font-family: inherit;
  margin: 0.5rem 0 0;
  font-size: 1em;
  line-height: 1.55;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.memo-body img,
.memo-body svg {
  max-width: 100%;
  height: auto;
}

.md-body h1,
.md-body h2,
.md-body h3,
.chat-bubble h1,
.chat-bubble h2,
.chat-bubble h3 {
  margin: 0.85em 0 0.35em;
  line-height: 1.3;
  font-size: 1.05em;
}
.md-body h1 { font-size: 1.2em; }
.md-body p,
.chat-bubble p {
  margin: 0.45em 0;
}
.md-body ul,
.md-body ol,
.chat-bubble ul,
.chat-bubble ol {
  margin: 0.45em 0;
  padding-left: 1.25rem;
}
.md-body code,
.chat-bubble code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: color-mix(in srgb, var(--bg) 80%, var(--line));
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
.md-body pre,
.chat-bubble pre {
  overflow-x: auto;
  padding: 0.75rem;
  background: color-mix(in srgb, var(--bg) 80%, var(--line));
  border-radius: var(--radius);
  white-space: pre-wrap;
}
.md-body pre code,
.chat-bubble pre code {
  background: transparent;
  padding: 0;
}
.md-body a,
.chat-bubble a {
  color: var(--accent);
}
.md-body .md-table-wrap,
.md-body table,
.chat-bubble .md-table-wrap {
  margin: 0.65rem 0;
}

.ask-controls {
  display: grid;
  gap: 0.75rem;
  margin: 0.75rem 0 1rem;
}
.panel-ask {
  display: none;
  flex-direction: column;
  min-height: calc(100dvh - 12rem);
}
.panel-ask.is-active {
  display: flex;
}
.panel-ask .chat-log {
  flex: 1;
  min-height: 12rem;
  margin-bottom: 0.75rem;
}
.ask-compose {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin: 0 -1rem -0.25rem;
  padding: 0.75rem 1rem calc(0.85rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 94%, #e8f0ed);
  box-shadow: 0 -6px 16px color-mix(in srgb, var(--ink) 6%, transparent);
}
.field {
  display: grid;
  gap: 0.3rem;
  font-weight: 600;
}
.field-hint {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.82em;
  line-height: 1.35;
}
.big-select,
#chat-input,
#wl-instrument {
  font: inherit;
  min-height: var(--tap);
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  width: 100%;
}

.chat-log {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 1rem;
  max-height: min(42vh, 420px);
  overflow: auto;
}
.chat-bubble {
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
}
.chat-bubble.user { border-left: 4px solid var(--accent); }
.chat-bubble.assistant { border-left: 4px solid var(--ink); }
.chat-bubble .md-table-wrap {
  overflow-x: auto;
  margin-top: 0.5rem;
}
.chat-bubble table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.92em;
}
.chat-bubble th,
.chat-bubble td {
  border: 1.5px solid var(--ink);
  padding: 0.35rem 0.5rem;
  text-align: left;
}

.chat-form {
  display: grid;
  gap: 0.65rem;
}
.chat-error {
  color: var(--danger);
  min-height: 1.2em;
}

.desk-foot {
  padding: 0.55rem 1rem calc(0.65rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 0.78em;
  line-height: 1.4;
}
.legal-foot {
  margin: 0 0 0.25rem;
  color: var(--muted);
}
.legal-details {
  margin: 0 0 0.75rem;
  font-size: 0.88em;
  color: var(--muted);
}
.legal-details summary {
  cursor: pointer;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  font-weight: 600;
  color: var(--muted);
}
.legal-disclaimer {
  margin: 0.4rem 0 0;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  background: var(--bg);
  color: var(--ink);
  font-size: 0.95em;
  line-height: 1.45;
  font-weight: 400;
}

.settings-sheet {
  border: none;
  border-radius: 16px 16px 0 0;
  width: min(100vw, 720px);
  max-width: 100%;
  margin: auto auto 0;
  padding: 0;
  max-height: 92dvh;
}
.settings-sheet::backdrop {
  background: color-mix(in srgb, var(--ink) 40%, transparent);
}
.settings-inner {
  padding: 1rem 1rem 1.5rem;
  overflow: auto;
  max-height: 92dvh;
}
.settings-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.settings-head h2 { margin: 0; font-size: 1.15em; }
.settings-email { color: var(--muted); }
.settings-admin {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: color-mix(in srgb, var(--accent) 5%, #fff);
}
.settings-admin-lead {
  margin: 0 0 0.75rem;
}
.settings-admin-link {
  width: 100%;
}
fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 1rem 0;
  padding: 0.85rem;
}
.font-row, .admin-row, .wl-add {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.font-btn.is-active {
  background: var(--accent);
  color: #fff;
  border: none;
}
.wl-list {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
}
.wl-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
  min-height: var(--tap);
}
.note { color: var(--muted); font-size: 0.9em; }

/* Login */
.login-stage {
  padding: 2.75rem 1.35rem 2.25rem;
  justify-content: center;
  min-height: 100dvh;
}
.brand-mark {
  font-weight: 700;
  font-size: 1.95rem;
  margin: 0 0 0.85rem;
  letter-spacing: -0.03em;
}
.login-headline {
  font-size: 1.22rem;
  margin: 0 0 0.55rem;
  font-weight: 700;
  line-height: 1.35;
}
.lede {
  color: var(--muted);
  margin: 0 0 1rem;
  font-size: 0.95em;
}
.login-actions {
  margin-top: 1.5rem;
  display: grid;
  gap: 1rem;
}
.auth-https-hint {
  color: var(--danger);
  padding: 0.75rem 0.85rem;
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--danger) 6%, #fff);
  font-size: 0.92em;
  line-height: 1.45;
}
.auth-https-hint a {
  color: var(--accent);
  font-weight: 600;
}
.shell { max-width: 720px; margin: 0 auto; padding: 1rem; position: relative; z-index: 1; }
.top { display: none; }

/* Watchlist / Analyse pages */
.stage { padding: 1.25rem 1.25rem 2rem; gap: 1rem; }
.stage-head { margin: 0; }
.stage-head h1 { margin: 0.35rem 0 0.35rem; font-size: 1.45rem; }
.stage-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.75rem 0 0;
  font-size: 0.95em;
}
.stage-nav a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.stage-nav a[aria-current="page"] {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}
.brand-mark a { color: inherit; text-decoration: none; }
.compose {
  display: grid;
  gap: 0.75rem;
  padding: 1rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.field { display: grid; gap: 0.35rem; }
.field input,
.field select,
.big-select {
  min-height: var(--tap);
  font: inherit;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--tap);
}
.symbol-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.35rem;
}
.symbol-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--tap);
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--line);
}
.symbol-list .symbol {
  flex: 1 1 auto;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
}
.symbol-list .inline { margin: 0; }
.empty { color: var(--muted); }
.error { color: var(--danger); margin: 0; }
.memo-sheet {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  background: #fafbfc;
}
.memo-kicker {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.9em;
}
.memo-sheet .memo-body {
  margin: 0;
  font-family: var(--font-zh);
  font-size: 0.95em;
}
.logout-form { margin-top: auto; padding-top: 1rem; }

/* Admin console */
.admin-crew-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}
.admin-crew-head h2 { margin: 0; }
.admin-crew-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.admin-crew-status {
  font-size: 0.85rem;
  color: var(--muted, #4a5560);
}
.admin-crew-status.is-up { color: var(--accent, #0f6b5c); font-weight: 600; }
.admin-crew-status.is-down { color: #9b2c2c; font-weight: 600; }
.admin-crew-status.is-idle { color: var(--muted, #4a5560); font-weight: 600; }
.admin-crew-roles {
  list-style: none;
  margin: 0 0 0.85rem;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}
.admin-crew-role {
  margin: 0;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  font-size: 0.88rem;
  line-height: 1.4;
  background: color-mix(in srgb, var(--bg) 85%, #fff);
}
.admin-crew-role.is-active {
  border-color: color-mix(in srgb, var(--accent, #0f6b5c) 55%, var(--line));
  background: color-mix(in srgb, var(--accent, #0f6b5c) 8%, #fff);
}
.admin-crew-role code {
  font-size: 0.8em;
  color: var(--muted, #4a5560);
}
.admin-pill-wl {
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.78rem;
}
.admin-pill-wl-ok { color: #0f6b5c; }
.admin-pill-wl-needs_engine { color: #9b2c2c; }
.admin-pill-wl-collecting { color: #b45309; }
.admin-pill-wl-no_memo,
.admin-pill-wl-no_series,
.admin-pill-wl-memo_stale,
.admin-pill-wl-series_stale { color: #4a5560; }
.admin-crew-meta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
  gap: 0.4rem 0.9rem;
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 70%, #fff);
  font-size: 0.88rem;
}
.admin-crew-meta dt {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted, #4a5560);
}
.admin-crew-meta dd { margin: 0.15rem 0 0; font-variant-numeric: tabular-nums; }
.admin-crew-sub {
  margin: 1rem 0 0.45rem;
  font-size: 0.95em;
  font-weight: 600;
}
.admin-crew-sub code {
  font-size: 0.75em;
  font-weight: 400;
  color: var(--muted, #4a5560);
}
.admin-crew-log {
  margin: 0;
  max-height: 22rem;
  overflow: auto;
  padding: 0.75rem 0.9rem;
  font-size: 0.78rem;
  line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: linear-gradient(180deg, #f3f6f4 0%, #e8eeeb 100%);
  border: 1px solid rgba(20, 32, 28, 0.12);
  color: #14201c;
  white-space: pre-wrap;
  word-break: break-word;
}
.desk.admin-shell {
  width: min(100%, 1200px);
  box-shadow: none;
  background: transparent;
}
body.mode-admin {
  background:
    radial-gradient(1200px 480px at 12% -10%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 55%),
    radial-gradient(900px 420px at 100% 0%, color-mix(in srgb, #1a4a40 8%, transparent), transparent 50%),
    var(--bg);
}
body.mode-admin .desk.admin-shell {
  min-height: 100dvh;
}
.admin-top {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--panel) 94%, #e8f0ed);
  border: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  margin: 0.75rem 0.75rem 0;
  padding-left: 1.1rem;
  padding-right: 1.1rem;
}
.admin-console {
  display: flex;
  flex-direction: column;
  flex: 1;
  margin: 0 0.75rem 0.75rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  min-height: 0;
}
.admin-page-head {
  margin-bottom: 1rem;
}
.admin-nav {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 92%, #e8f0ed);
  backdrop-filter: blur(6px);
}
.admin-nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9em;
  font-weight: 600;
  background: var(--panel);
}
.admin-nav-link:hover,
.admin-nav-link:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}
.admin-panel {
  padding: 1.1rem 1.25rem 2rem;
}
.admin-title { margin: 0 0 0.35rem; font-size: 1.35em; }
.admin-section {
  margin: 1.75rem 0;
  scroll-margin-top: 5rem;
}
.admin-section h2 { margin: 0 0 0.75rem; font-size: 1.12em; }

.admin-ops-dock {
  position: sticky;
  top: 4.35rem;
  z-index: 12;
  margin: 0.75rem 0 1rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel) 88%, #dfe8e4);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--line) 50%, transparent);
}
.admin-job-banner {
  margin: 0 0 0.45rem;
  min-height: 1.25em;
}
.admin-job-banner.is-busy {
  color: var(--accent);
  font-weight: 600;
}
.admin-job-banner.is-ok {
  color: var(--accent);
}
.admin-job-banner.is-err {
  color: #a33;
}
.admin-wl-ops {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
  margin: 0;
}
.admin-ops-inst {
  min-width: 10rem;
}
.admin-ops-inst input {
  min-width: 9.5rem;
  font-size: 1rem;
}
.admin-wl-ops .btn-ghost,
.admin-wl-row-ops .btn-ghost {
  min-height: 2.5rem;
  padding: 0.4rem 0.85rem;
}
.admin-table-scroll {
  max-height: min(62vh, 36rem);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.admin-table-scroll .admin-table {
  margin: 0;
}
.admin-table-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  box-shadow: 0 1px 0 var(--ink);
}
.admin-wl-row-ops {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
}

/* iPad landscape / desktop: left rail + wide work surface */
@media (min-width: 900px) {
  .desk.admin-shell {
    width: min(100% - 1.5rem, 1280px);
  }
  .admin-console {
    display: grid;
    grid-template-columns: 11.5rem minmax(0, 1fr);
    align-items: stretch;
  }
  .admin-nav {
    position: sticky;
    top: 0;
    align-self: start;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0.4rem;
    min-height: calc(100dvh - 4.5rem);
    padding: 1rem 0.75rem;
    border-bottom: none;
    border-right: 1px solid var(--line);
  }
  .admin-nav-link {
    width: 100%;
    justify-content: flex-start;
  }
  .admin-panel {
    padding: 1.25rem 1.5rem 2.5rem;
  }
  .admin-ops-dock {
    top: 4.35rem;
  }
  .admin-section {
    scroll-margin-top: 1rem;
  }
  .admin-chart-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 1100px) {
  .desk.admin-shell {
    width: min(100% - 2rem, 1360px);
  }
  .admin-console {
    grid-template-columns: 12.5rem minmax(0, 1fr);
  }
}
.admin-form {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 0.5rem;
}
.admin-form-row {
  align-items: end;
}
@media (min-width: 720px) {
  .admin-form-row {
    grid-template-columns: minmax(10rem, 1.4fr) minmax(6rem, 0.55fr) minmax(7rem, 1fr) auto;
  }
  .admin-form-row .field-amount { max-width: 8rem; }
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92em;
}
.admin-table th,
.admin-table td {
  border: 1.5px solid var(--ink);
  padding: 0.4rem 0.5rem;
  text-align: left;
  vertical-align: middle;
}
.admin-table th { background: var(--bg); }
.admin-table tr.is-selected {
  background: color-mix(in srgb, var(--accent) 10%, #fff);
}
a.btn-primary,
a.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.admin-class-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 1rem 0 1.25rem;
}
.admin-class-card {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 1.5px solid var(--ink);
  padding: 0.85rem 1rem;
  background: var(--panel, #fff);
  border-radius: 0;
}
.admin-class-card[data-class="limited"] {
  border-left: 4px solid #0f6b5c;
}
.admin-class-card[data-class="unlimited"] {
  border-left: 4px solid #b45309;
}
.admin-class-card.is-active,
.admin-class-card[aria-pressed="true"] {
  box-shadow: inset 0 0 0 2px var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, #fff);
}
.admin-class-card[data-class="unlimited"].is-active,
.admin-class-card[data-class="unlimited"][aria-pressed="true"] {
  box-shadow: inset 0 0 0 2px #b45309;
  background: color-mix(in srgb, #b45309 7%, #fff);
}
.admin-class-label {
  margin: 0;
  font-size: 1.05em;
  letter-spacing: 0.02em;
}
.admin-class-desc {
  margin: 0.2rem 0 0.75rem;
  color: var(--muted);
  font-size: 0.85em;
}
.admin-class-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 0;
}
.admin-class-stats dt {
  margin: 0;
  font-size: 0.72em;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.admin-class-stats dd {
  margin: 0.15rem 0 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.admin-class-roll {
  margin: 0.75rem 0 0;
  padding-top: 0.55rem;
  border-top: 1px solid var(--line);
  font-size: 0.78em;
  color: var(--muted);
  line-height: 1.45;
}
.admin-class-roll strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.admin-lanes {
  display: grid;
  gap: 0.85rem;
  margin: 0 0 1.25rem;
}
@media (min-width: 1100px) {
  .admin-accounts .admin-lanes {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}
.admin-lane {
  border: 1.5px solid var(--ink);
  padding: 0.9rem 1rem 1rem;
  background: linear-gradient(180deg, #fbfcfd 0%, #fff 40%);
}
.admin-lane[data-lane="limited"] {
  border-top: 3px solid #0f6b5c;
}
.admin-lane[data-lane="unlimited"] {
  border-top: 3px solid #b45309;
}
.admin-lane-head h3 {
  margin: 0 0 0.55rem;
  font-size: 1em;
}
.admin-form-limited {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 0.5rem;
}
.admin-form-limited-row {
  display: grid;
  gap: 0.65rem;
  align-items: end;
}
@media (min-width: 640px) {
  .admin-form-limited-row {
    grid-template-columns: minmax(6.5rem, 0.55fr) minmax(8rem, 1fr) auto;
  }
  .admin-form-limited-row .field-amount {
    max-width: 8.5rem;
  }
  .admin-form-limited-row .btn-primary {
    justify-self: start;
    min-width: 8.5rem;
  }
}
.admin-form-unlimited {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: flex-end;
  margin-bottom: 0.5rem;
}
.admin-form-unlimited .field {
  flex: 1 1 12rem;
  min-width: 10rem;
}
.admin-form-unlimited .btn-primary {
  flex-shrink: 0;
}
.admin-lane .wl-list li {
  flex-wrap: nowrap;
  gap: 0.5rem;
}
.admin-lane .wl-list li > span:first-child {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-lane .wl-list .btn-ghost {
  flex-shrink: 0;
  min-width: auto;
  min-height: 2.25rem;
  padding: 0.3rem 0.65rem;
  font-size: 0.85em;
}
.admin-accounts-table-wrap,
.admin-ledger-table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.admin-accounts-table-wrap {
  max-height: min(52vh, 28rem);
}
.admin-ledger-table-wrap {
  max-height: min(48vh, 24rem);
}
.admin-accounts-table {
  min-width: 52rem;
}
.admin-ledger-table {
  min-width: 44rem;
}
.admin-accounts-table .col-email {
  min-width: 11rem;
  max-width: 18rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-accounts-table .col-class {
  width: 5.5rem;
  white-space: nowrap;
}
.admin-accounts-table .col-date,
.admin-ledger-table .col-date {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-size: 0.9em;
}
.admin-accounts-table .col-money,
.admin-ledger-table .col-money {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.admin-accounts-table .col-action {
  width: 5.25rem;
  text-align: center;
  white-space: nowrap;
}
.admin-accounts-table .admin-ledger-btn {
  min-width: auto;
  min-height: 2.25rem;
  padding: 0.3rem 0.65rem;
  font-size: 0.85em;
}
.admin-ledger-table .col-kind {
  white-space: nowrap;
}
.admin-ledger-table .col-model {
  min-width: 7rem;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-ledger-table .col-reason {
  min-width: 8rem;
}
.admin-steps {
  margin: 0 0 0.9rem;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: 0.85em;
  line-height: 1.45;
}
.admin-steps code {
  font-size: 0.92em;
}
.admin-steps a {
  color: var(--accent);
}
.admin-msg {
  min-height: 1.25em;
  margin: 0.25rem 0 0;
}
.admin-msg.is-ok {
  color: var(--accent);
  font-weight: 600;
}
.admin-msg.is-err {
  color: var(--danger);
  font-weight: 600;
}
.admin-subhead {
  margin: 1rem 0 0.45rem;
  font-size: 0.92em;
  font-weight: 600;
}
.admin-source-tag {
  margin-left: 0.35rem;
  font-size: 0.72em;
  color: var(--muted);
  font-weight: 500;
}
.admin-pill {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--ink);
  font-size: 0.72em;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: lowercase;
  vertical-align: middle;
  background: rgba(15, 107, 92, 0.1);
}
.admin-pill-unlim {
  background: rgba(180, 83, 9, 0.12);
}
.admin-pill-kind {
  margin-left: 0;
  background: color-mix(in srgb, var(--ink) 6%, #fff);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-transform: none;
  letter-spacing: 0;
}
.admin-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 0.75rem;
}
.admin-chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}
.admin-chart-wide {
  grid-column: 1 / -1;
}
.admin-chart-card {
  margin: 0;
}
.admin-chart-card .chart-title {
  font-size: 0.95em;
}
.chart-wrap-admin {
  min-height: 168px;
  height: 188px;
}
.chart-wrap-admin-wide {
  min-height: 148px;
  height: 168px;
}

/* OpenClaw dock */
.dock-shell .dock-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 0.85rem;
}
.dock-kicker {
  margin: 0 0 0.25rem;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted, #4a5560);
}
.dock-summary {
  margin-bottom: 1rem;
}
.dock-table tbody tr {
  cursor: pointer;
}
.dock-table tbody tr:hover {
  background: color-mix(in srgb, var(--accent, #0f6b5c) 6%, #fff);
}
.dock-prompt {
  margin: 1.25rem 0 0.5rem;
  border: 1px solid var(--line);
  padding: 0.55rem 0.75rem 0.75rem;
  background: color-mix(in srgb, var(--bg) 80%, #fff);
}
.dock-prompt summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 0.45rem;
}
.dock-prompt .admin-crew-log {
  max-height: 16rem;
}
.dock-summary-cell {
  min-width: 16rem;
  max-width: 36rem;
}
.dock-summary-text {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
  font-size: 0.9em;
}
.settings-admin-lead {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

@media (max-width: 720px) {
  .admin-class-cards,
  .admin-chart-grid {
    grid-template-columns: 1fr;
  }
  .admin-chart-wide { grid-column: auto; }
  .admin-class-stats { grid-template-columns: 1fr 1fr 1fr; }
}

@media (max-width: 480px) {
  .desk-top-right .credit-meter {
    max-width: 5.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
