:root {
  --page: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --line: #e3e6eb;
  --line-strong: #cdd3dc;
  --text: #161a22;
  --muted: #667085;
  --faint: #98a2b3;
  --brand: #1f5fbf;
  --brand-soft: #edf4ff;
  --up: #c62f2f;
  --down: #087354;
  --warn: #a15c07;
  --bad: #b42318;
  --good: #137a4f;
  --radius: 8px;
  --shadow: 0 8px 28px rgba(18, 25, 38, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  line-height: 1.5;
}

.login-page {
  display: grid;
  place-items: center;
}

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

button {
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  border-radius: 6px;
  padding: 8px 13px;
  cursor: pointer;
}

button.secondary {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

button.compact {
  padding: 5px 9px;
  font-size: 12px;
}

button.danger {
  border-color: #f1c7c4;
  background: #fff5f4;
  color: var(--bad);
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.quote-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted var(--line-strong);
}

.quote-link:hover {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.topbar, .layout {
  max-width: 1220px;
  margin: 0 auto;
  padding-left: 28px;
  padding-right: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  padding-top: 26px;
  padding-bottom: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 31px;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 2px;
  font-size: 18px;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 6px;
  font-size: 15px;
}

.top-actions, .row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.sync-status, .count-pill {
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
}

.layout { padding-bottom: 56px; }

.summary-grid {
  display: grid;
  grid-template-columns: 2fr repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.summary-card, .section, .two-column > article, .tool-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.summary-card { padding: 16px 18px; }

.summary-card span, .decision-stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.summary-card strong {
  display: block;
  margin-top: 8px;
  font-size: 25px;
  line-height: 1.1;
}

.summary-card.hero strong { font-size: 38px; }

.summary-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.view-tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px;
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow);
}

.view-tabs button {
  flex: 0 0 auto;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.view-tabs button.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.section {
  padding: 17px;
  margin-bottom: 14px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 13px;
}

.section-head p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  gap: 14px;
}

.highlight-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.compact-list {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.highlight, .watch-card, .record-item, .provider-item {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 7px;
  padding: 13px;
}

.highlight strong, .symbol-cell strong, .record-item strong {
  display: block;
}

.highlight p, .watch-card p, .record-item p, .tool-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.todo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.todo-card {
  display: grid;
  gap: 10px;
  min-height: 96px;
  text-align: left;
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--text);
}

.todo-card span {
  color: var(--muted);
  font-size: 13px;
}

.todo-card strong {
  font-size: 32px;
  line-height: 1;
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}

th {
  color: var(--faint);
  font-size: 11px;
  font-weight: 700;
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  white-space: nowrap;
}

td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  vertical-align: middle;
}

tbody tr:hover { background: #fbfcfe; }

.symbol-cell small {
  display: block;
  color: var(--muted);
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  border-radius: 999px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.pill.good { color: var(--good); background: #eefaf3; border-color: #cfe8d8; }
.pill.warn { color: var(--warn); background: #fff7e8; border-color: #ecd8aa; }
.pill.bad { color: var(--bad); background: #fff0ee; border-color: #efcbc6; }

.segmented {
  display: flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 999px;
  flex-wrap: wrap;
}

.segmented button {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
}

.segmented button.active {
  color: var(--text);
  background: #fff;
  box-shadow: 0 1px 5px rgba(0,0,0,.06);
}

.watch-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.watch-head, .watch-actions, .record-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.watch-actions {
  align-items: center;
  margin-top: 12px;
  flex-wrap: wrap;
}

.decision-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.decision-stat {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.decision-stat strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.technical-entry-box {
  margin-top: 12px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.technical-entry-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}

.technical-entry-box p {
  margin-bottom: 0;
}

.tech-signal-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.record-list {
  display: grid;
  gap: 8px;
}

.transaction-list {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.two-column > article { padding: 17px; }

.maintenance-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.tool-card { padding: 14px; }

.provider-list {
  display: grid;
  gap: 8px;
}

.provider-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  box-shadow: none;
}

.provider-item small {
  grid-column: 1 / -1;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #1d2430;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .18s ease, transform .18s ease;
  z-index: 20;
}

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

.drawer {
  width: min(760px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(0,0,0,.24);
}

.compact-drawer { width: min(520px, calc(100vw - 28px)); }

.drawer::backdrop { background: rgba(18, 25, 38, .34); }

.drawer form { padding: 18px; }

.drawer-head, .drawer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.drawer-actions {
  margin-top: 16px;
  justify-content: flex-end;
}

.icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.inline-settings {
  max-width: 820px;
  margin-top: 0;
}

.form-submit {
  display: flex;
  align-items: end;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

label.wide { grid-column: 1 / -1; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
}

textarea { resize: vertical; }

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

.login-screen {
  width: min(420px, calc(100vw - 32px));
}

.login-panel {
  display: grid;
  gap: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  font-size: 28px;
}

.login-error {
  min-height: 20px;
  color: var(--bad);
  font-size: 13px;
}

.skeleton-block {
  min-height: 90px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, #eef1f5, #f8fafc, #eef1f5);
  background-size: 200% 100%;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

@media (max-width: 920px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .summary-grid,
  .highlight-list,
  .watch-grid,
  .two-column,
  .overview-grid,
  .maintenance-grid {
    grid-template-columns: 1fr;
  }

  .summary-card.hero strong { font-size: 34px; }
}

@media (max-width: 600px) {
  .topbar, .layout {
    padding-left: 14px;
    padding-right: 14px;
  }

  h1 { font-size: 28px; }

  .summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .summary-card.hero {
    grid-column: 1 / -1;
  }

  .form-grid,
  .todo-grid {
    grid-template-columns: 1fr;
  }

  .section-head {
    flex-direction: column;
  }
}
