:root {
  --bg: #f3efe6;
  --ink: #1b1f1c;
  --muted: #5c645d;
  --card: #fffdf8;
  --line: #d9d2c4;
  --line-strong: #c4bba9;
  --accent: #1f4d3a;
  --accent-2: #2e6b50;
  --up: #1a7a45;
  --down: #b42318;
  --ok-bg: #e6f4ea;
  --err-bg: #fdecea;
  --note-bg: #f4efe0;
  --shadow: 0 1px 0 rgba(27, 31, 28, 0.04), 0 8px 24px rgba(27, 31, 28, 0.05);
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 "Iowan Old Style", Palatino, "Palatino Linotype", "Times New Roman", serif;
}

body {
  min-height: 100vh;
}

code, input, button, table, .sym, .brand-mark {
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
}

.wrap {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
}

.wrap.narrow { width: min(560px, calc(100% - 32px)); }
.wrap.narrow-plus { width: min(720px, calc(100% - 32px)); }

.top {
  border-bottom: 1px solid var(--line);
  background: rgba(243, 239, 230, 0.9);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 2;
}

.top-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--accent);
  color: #f6f1e6;
  font-size: 13px;
  font-weight: 700;
}

.brand-mark .icon {
  width: 28px;
  height: 28px;
}

.brand strong { display: block; font-size: 1.05rem; }
.brand em {
  display: block;
  font-style: normal;
  color: var(--muted);
  font-size: 0.78rem;
}

main.wrap { padding: 22px 0 48px; }

.totals {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.totals > div {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.totals .k {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
}

.totals .k .icon {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

.totals strong {
  display: block;
  margin-top: 4px;
  font-size: 1.35rem;
  font-weight: 650;
}

.totals small {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.85rem;
  font-weight: 500;
}

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

.grid.two {
  grid-template-columns: 1fr 1fr;
  margin-top: 16px;
  align-items: start;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 18px 10px;
}

.card-head h1 {
  margin: 0 0 4px;
  font-size: 1.45rem;
}

.card-head p {
  margin: 0 0 14px;
  color: var(--muted);
}

.card-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-head-row p { margin-bottom: 14px; }

.csv-link {
  flex: 0 0 auto;
  margin-top: 4px;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
}

.csv-link:hover { text-decoration: underline; }

.stack-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.stack-form.cols label { flex: 1 1 120px; }
.stack-form label.wide { flex: 1 1 100%; }

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--muted);
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
}

.opt { color: #8a9186; }

input, button, .btn-quiet, select, textarea {
  font-size: 0.95rem;
}

input, select, textarea {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 0;
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
}

textarea { resize: vertical; width: 100%; }

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-2);
  outline-offset: 1px;
}

button, .btn-quiet {
  border: 0;
  border-radius: 8px;
  padding: 9px 14px;
  background: var(--accent);
  color: #f6f1e6;
  cursor: pointer;
  font-weight: 600;
}

button:hover, .btn-quiet:hover { background: var(--accent-2); }

.btn-quiet {
  display: inline-block;
  text-decoration: none;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--line-strong);
}

.btn-quiet:hover { background: var(--note-bg); color: var(--accent); }

.refresh button {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--line-strong);
  padding: 7px 12px;
}

.refresh button:hover { background: var(--note-bg); }

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon {
  display: block;
  flex: 0 0 auto;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

button.icon-btn .icon,
a.icon-btn .icon {
  width: 15px;
  height: 15px;
}

.mkt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.mkt-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #8a9186;
}

.mkt-open .mkt-dot { background: var(--up); }
.mkt-pre .mkt-dot, .mkt-post .mkt-dot { background: #c9a227; }
.mkt-holiday .mkt-dot { background: var(--down); }

.mkt-time {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.auth-form button {
  align-self: flex-start;
  margin-top: 4px;
}

.table-wrap { overflow-x: auto; margin: 0 -6px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
}

th, td {
  text-align: left;
  padding: 10px 8px;
  border-top: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.num { text-align: right; font-variant-numeric: tabular-nums; }
.hist { width: 110px; }
.range-col { width: 130px; }

.range-track {
  display: block;
  position: relative;
  height: 6px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--down), #c9a227, var(--up));
  opacity: 0.85;
}

.range-mark {
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--card);
  transform: translateY(-50%);
  box-shadow: 0 0 0 1px rgba(27, 31, 28, 0.2);
}

.mix {
  margin: 4px 0 18px;
}

.mix-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.mix-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.mix-name,
.mix-under {
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  font-size: 0.72rem;
  line-height: 1.2;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.mix-under {
  display: none;
  color: var(--muted);
  font-weight: 600;
}

.mix-col.thin .mix-under { display: block; }

.mix-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  min-height: 32px;
  border-radius: 8px;
  color: #f6f1e6;
  text-decoration: none;
  padding: 0 6px;
  box-sizing: border-box;
}

.mix-seg:hover { filter: brightness(1.08); }

.mix-in {
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
}

.mix-col.thin .mix-in { display: none; }

.card-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

dialog.modal {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  width: min(440px, calc(100% - 32px));
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow);
}

dialog.modal::backdrop {
  background: rgba(27, 31, 28, 0.45);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 0;
}

.modal-head h2 {
  margin: 0;
  font-size: 1.25rem;
}

dialog.modal .auth-form {
  padding: 8px 18px 18px;
  margin-bottom: 0;
}

dialog.modal .hint { margin: 0 0 10px; }

.sym {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.sub {
  color: var(--muted);
  font-size: 0.78rem;
}

.actions {
  white-space: nowrap;
  text-align: right;
}

.actions form { display: inline; }

a, .linkish {
  color: var(--accent);
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  padding: 16px;
  margin: 8px 0 16px;
  background: #faf7ef;
}

.empty p { margin: 0; color: var(--muted); }

.banner {
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0 0 12px;
}

.banner-ok { background: var(--ok-bg); color: #14532d; }
.banner-error { background: var(--err-bg); color: #7f1d1d; }
.banner-notice { background: var(--note-bg); color: #5b4a1f; }

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

.spark { display: block; }
.spark polyline { stroke-width: 1.6; fill: none; }
.spark circle { stroke: none; }
.spark-up polyline { stroke: var(--up); }
.spark-up circle { fill: var(--up); }
.spark-down polyline { stroke: var(--down); }
.spark-down circle { fill: var(--down); }
.spark-flat polyline { stroke: #7a8478; }
.spark-flat circle { fill: #7a8478; }

.chart-card { padding-bottom: 18px; }
.chart-wrap { margin: 4px 0 8px; }
.area-chart { display: block; width: 100%; height: auto; max-height: 220px; }
.area-chart .chart-line { fill: none; stroke-width: 2; }
.area-chart .chart-dot { stroke: none; }
.chart-up .chart-line { stroke: var(--up); }
.chart-up .chart-dot { fill: var(--up); }
.chart-up .chart-fill { fill: var(--up); opacity: 0.12; }
.chart-down .chart-line { stroke: var(--down); }
.chart-down .chart-dot { fill: var(--down); }
.chart-down .chart-fill { fill: var(--down); opacity: 0.1; }
.chart-flat .chart-line { stroke: #7a8478; }
.chart-flat .chart-dot { fill: #7a8478; }
.chart-flat .chart-fill { fill: #7a8478; opacity: 0.1; }
.chart-axis { fill: var(--muted); font-size: 11px; font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif; }
.range-wide { margin: 8px 0 4px; }

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
}
.nav-link:hover { background: var(--note-bg); }

.banner-alert {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: #f4efe0;
  color: #5b4a1f;
}
.banner-alert p { margin: 0; }
.banner-approach {
  background: #f4efe0;
  color: #5b4a1f;
  border-left: 4px solid #c4a035;
}

.pill-approach,
.pill-hit {
  display: inline-block;
  margin-top: 4px;
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-radius: 4px;
  padding: 2px 6px;
}
.pill-approach { background: #f4efe0; color: #5b4a1f; }
.pill-hit { background: var(--err-bg); color: #7f1d1d; }

.plain-list li.approach { background: #faf6ea; margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: 8px; }
.plain-list li.hit { background: #fdecea; margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: 8px; }

.plain-list, .note-list { list-style: none; padding: 0; margin: 8px 0 12px; }
.plain-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 0.92rem;
}
.note-list li { padding: 10px 0; border-top: 1px solid var(--line); }
.note-scroll {
  max-height: 22rem;
  overflow-y: auto;
  margin: 8px 0 10px;
  padding-right: 8px;
  border-top: 1px solid var(--line);
}
.note-scroll .note-list { margin: 0; }
.note-scroll .note-list li:first-child { border-top: 0; }
.note-meta { color: var(--muted); font-size: 0.78rem; font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif; margin-bottom: 4px; }
.note-body { margin: 6px 0 8px; white-space: pre-wrap; }
.note-title { margin: 4px 0 8px; font-size: 1.15rem; }
.badge {
  display: inline-block;
  background: var(--accent);
  color: #f6f1e6;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 4px;
  padding: 1px 6px;
  margin-right: 6px;
}

.sym a { color: inherit; text-decoration: none; }
.sym a:hover { color: var(--accent); text-decoration: underline; }

.docs-card { padding-bottom: 28px; }
.docs-lead {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.95rem;
}
.docs-body h1 { font-size: 1.6rem; margin: 0 0 12px; }
.docs-body h2 { font-size: 1.2rem; margin: 22px 0 8px; }
.docs-body h3 { font-size: 1.05rem; margin: 16px 0 6px; }
.docs-body p { margin: 0 0 10px; }
.docs-body ul, .docs-body ol { margin: 0 0 12px; padding-left: 1.2em; }
.docs-body li { margin: 0 0 4px; }
.docs-body code {
  font-size: 0.86em;
  background: var(--note-bg);
  padding: 1px 5px;
  border-radius: 4px;
}
.docs-body pre {
  background: #1b1f1c;
  color: #f6f1e6;
  padding: 12px 14px;
  border-radius: 10px;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.45;
  font-family: "IBM Plex Sans", "Segoe UI", ui-monospace, monospace;
}
.docs-body pre code { background: none; color: inherit; padding: 0; }
.docs-body table { font-size: 0.9rem; }
.docs-body th, .docs-body td { vertical-align: top; }

.lots-inline { margin-top: 8px; }
.lots-inline summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.78rem;
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
}

div.dt-container {
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
}
div.dt-container .dt-search {
  float: none;
  text-align: left;
  margin: 0 0 12px;
}
div.dt-container .dt-search input {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 10px;
  margin-left: 0;
  width: min(280px, 100%);
}
div.dt-container .dt-info {
  color: var(--muted);
  font-size: 0.82rem;
  padding: 8px 0 4px;
}
div.dt-container .dt-layout-row {
  display: block;
}
table.dataTable thead > tr > th {
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
table.dataTable.stripe tbody tr.even,
table.dataTable.display tbody tr.even,
table.dataTable tbody tr {
  background: transparent;
}
table.dataTable tbody tr:hover {
  background: #faf7ef;
}
table.dataTable.hover tbody tr:hover {
  background: #faf7ef;
}

.lot-detail td { background: #faf7ef; }
.nested { width: 100%; }
.nested td { border-top: 1px dashed var(--line); }

.hint, .crumb { color: var(--muted); font-size: 0.9rem; }
.form-actions { display: flex; gap: 10px; align-items: center; }

.foot {
  border-top: 1px solid var(--line);
  padding: 20px 0 32px;
  color: var(--muted);
  font-size: 0.85rem;
}

.foot p { margin: 0 0 6px; }

@media (max-width: 900px) {
  .totals { grid-template-columns: 1fr 1fr; }
  .mkt-time { display: none; }
  .grid.two { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .mix-name { font-size: 0.66rem; }
  .mix-in, .mix-under { font-size: 0.66rem; }
  .brand-mark { width: 44px; height: 44px; }
  .brand-mark .icon { width: 24px; height: 24px; }
  html, body { font-size: 16px; }
  .totals { grid-template-columns: 1fr; }
  .totals strong { font-size: 1.2rem; }
  .brand em { display: none; }
  th.hist, td.hist, th.range-col, td.range-col { display: none; }
  .stack-form button.icon-btn { width: 100%; justify-content: center; }
  .mkt-time { display: none; }
  .top-actions .refresh .icon-btn,
  .top-actions .nav-link { padding: 7px 9px; font-size: 0; gap: 0; }
  .top-actions .refresh .icon,
  .top-actions .nav-link .icon { width: 16px; height: 16px; }
}
