:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --panel-2: #eef3f8;
  --line: #dbe3ec;
  --muted: #697785;
  --text: #17202a;
  --green: #148a5b;
  --red: #d43f3a;
  --gold: #b98518;
  --blue: #256ec6;
  --cyan: #168da1;
  --shadow: 0 14px 36px rgba(30, 45, 64, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 66px;
  padding: 0 28px;
  border-bottom: 1px solid rgba(23, 32, 42, 0.08);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  color: var(--text);
  background: transparent;
  font-weight: 800;
  font-size: 18px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(185, 133, 24, 0.38);
  border-radius: 8px;
  color: var(--gold);
  background: #fff7e6;
}

.desktop-nav {
  display: flex;
  gap: 4px;
  flex: 1;
}

.desktop-nav button,
.session-actions button,
.ghost-button,
.solid-button,
.icon-button,
.segmented button,
.tab-button {
  min-height: 38px;
  border-radius: 8px;
  color: var(--text);
  background: transparent;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.desktop-nav button,
.session-actions button,
.ghost-button,
.tab-button {
  padding: 0 12px;
}

.desktop-nav button:hover,
.session-actions button:hover,
.ghost-button:hover,
.tab-button:hover {
  background: rgba(37, 110, 198, 0.08);
}

.session-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.solid-button {
  padding: 0 14px;
  background: #1f6fc9;
  color: #ffffff;
  font-weight: 800;
}

.solid-button:hover {
  transform: translateY(-1px);
  background: #175da8;
}

.danger-button {
  background: rgba(239, 100, 97, 0.16);
  color: #b92c28;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}

.app-shell {
  width: min(1220px, calc(100vw - 36px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.section-band {
  padding: 24px 0;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 520px);
  gap: 28px;
  align-items: start;
}

.headline {
  padding: 18px 0 0;
}

.eyebrow {
  color: var(--gold);
  font-weight: 800;
  margin: 0 0 12px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 18px;
  font-size: clamp(38px, 7vw, 82px);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 16px;
  font-size: 26px;
}

h3 {
  margin-bottom: 10px;
  font-size: 18px;
}

.muted {
  color: var(--muted);
}

.lead {
  max-width: 680px;
  color: #465463;
  font-size: 18px;
  line-height: 1.7;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 18px 0;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.metric {
  display: grid;
  gap: 8px;
}

.metric strong {
  font-size: 30px;
}

.metric small {
  color: var(--muted);
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

.gold {
  color: var(--gold);
}

.stock-row,
.admin-row,
.log-row {
  display: grid;
  grid-template-columns: 96px minmax(130px, 1fr) 92px 96px 110px;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(23, 32, 42, 0.08);
}

.stock-row:last-child,
.admin-row:last-child,
.log-row:last-child {
  border-bottom: 0;
}

.stock-symbol {
  font-weight: 900;
  color: var(--gold);
}

.sparkline {
  width: 108px;
  height: 34px;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  align-items: start;
}

.stock-summary {
  display: grid;
  gap: 12px;
}

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

.price {
  font-size: 44px;
  line-height: 1;
  font-weight: 900;
}

.chart-card {
  overflow: hidden;
}

.chart-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f8fb;
}

.segmented button {
  min-width: 64px;
  padding: 0 10px;
  color: #536170;
}

.segmented button.active {
  background: var(--panel-2);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(215, 170, 72, 0.28);
}

.chart-wrap {
  position: relative;
  height: 430px;
  touch-action: pan-x pinch-zoom;
}

#stockChart {
  display: block;
  width: 100%;
  height: 100%;
}

.chart-tooltip {
  position: absolute;
  left: 16px;
  top: 16px;
  max-width: min(320px, calc(100% - 32px));
  padding: 10px 12px;
  border: 1px solid rgba(23, 32, 42, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  font-size: 12px;
  line-height: 1.55;
}

.chart-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.chart-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.notice {
  border-left: 3px solid var(--gold);
  padding: 10px 12px;
  background: rgba(185, 133, 24, 0.1);
  color: #806016;
}

.form {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: #52606f;
  font-size: 13px;
}

.field input,
.field select,
.field textarea,
.search-input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  background: #ffffff;
  color: var(--text);
  outline: none;
}

.field textarea {
  min-height: 88px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search-input:focus {
  border-color: rgba(215, 170, 72, 0.7);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.tab-button.active {
  background: var(--panel-2);
  box-shadow: inset 0 0 0 1px rgba(215, 170, 72, 0.32);
}

.admin-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
}

.admin-nav {
  position: sticky;
  top: 88px;
  align-self: start;
  display: grid;
  gap: 6px;
}

.admin-nav button {
  justify-content: start;
  text-align: left;
}

.table {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid rgba(23, 32, 42, 0.08);
  text-align: left;
  vertical-align: middle;
}

th {
  color: #52606f;
  font-size: 13px;
  background: #f4f7fa;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef3f8;
  color: #425161;
  font-size: 12px;
  white-space: nowrap;
}

.badge.good {
  background: rgba(47, 199, 134, 0.14);
  color: #14784f;
}

.badge.bad {
  background: rgba(239, 100, 97, 0.14);
  color: #b92c28;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 14px;
  border: 1px solid rgba(23, 32, 42, 0.12);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.empty {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 920px) {
  .topbar {
    flex-wrap: wrap;
    padding: 12px 18px;
  }

  .desktop-nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
  }

  .hero,
  .detail-layout,
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .grid.cols-3,
  .grid.cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-nav {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 24px, 1220px);
    padding-top: 18px;
  }

  .topbar {
    gap: 10px;
  }

  .brand {
    font-size: 16px;
  }

  .session-actions {
    margin-left: auto;
  }

  .grid.cols-2,
  .grid.cols-3,
  .grid.cols-4 {
    grid-template-columns: 1fr;
  }

  .stock-row {
    grid-template-columns: 72px minmax(96px, 1fr) 74px;
  }

  .stock-row > :nth-child(4),
  .stock-row > :nth-child(5) {
    display: none;
  }

  .summary-top {
    display: grid;
  }

  .chart-header {
    align-items: stretch;
  }

  .segmented {
    grid-auto-flow: row;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .chart-wrap {
    height: 360px;
  }
}
