/* OP Simulation Engine — styling echoes own-piece.com (MODEL-SPEC §12).
   Light theme, white bg, #658EFF primary, #244191 navy, blue gradient accents,
   Gilroy headings (Inter/system fallback), pill buttons (radius 9999px). */

:root {
  --op-primary: #658EFF;
  --op-primary-600: #4f78ec;
  --op-navy: #244191;
  --op-bg: #FFFFFF;
  --op-surface: #F3F4F6;
  --op-surface-2: #FAFBFF;
  --op-border: #E5E8F0;
  --op-text: #000000;
  --op-text-muted: #565656;
  --op-text-subtle: #9CA3AF;
  --op-good: #18a957;
  --op-warn: #e8a33d;
  --op-bad: #e2483d;
  --op-grad: linear-gradient(135deg, #244191 0%, #658EFF 55%, #9FB8FF 100%);
  --op-grad-soft: linear-gradient(135deg, rgba(101,142,255,0.10), rgba(159,184,255,0.04));
  --radius-pill: 9999px;
  --radius-card: 16px;
  --shadow: 0 1px 2px rgba(16,24,40,0.04), 0 8px 24px rgba(36,65,145,0.06);
  --font: "Gilroy", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--op-text);
  background: var(--op-bg);
  font-weight: 400;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-weight: 700; letter-spacing: -0.01em; margin: 0; }
a { color: var(--op-primary-600); }
.muted { color: var(--op-text-muted); }
.subtle { color: var(--op-text-subtle); }

/* ---- header ------------------------------------------------------------ */
.op-header {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 28px;
  background: #fff;
  border-bottom: 1px solid var(--op-border);
  position: sticky; top: 0; z-index: 50;
}
.op-header img.logo { height: 26px; width: auto; display: block; }
.op-header .wordmark { font-weight: 700; font-size: 18px; letter-spacing: -0.02em; }
.op-header .wordmark .sub { color: var(--op-text-subtle); font-weight: 600; }
.op-header nav { margin-left: auto; display: flex; gap: 22px; }
.op-header nav span { color: var(--op-text-muted); font-weight: 600; font-size: 14px; }

/* ---- hero -------------------------------------------------------------- */
.hero {
  /* MODEL-SPEC §12 hero gradient */
  background: linear-gradient(162.79deg, #C6D6FF 0%, #658EFF 100%);
  color: #16285c;
  padding: 30px 28px;
}
.hero h1 { font-size: 26px; }
.hero p { margin: 6px 0 0; opacity: 0.92; max-width: 760px; font-size: 14px; }

/* ---- layout ------------------------------------------------------------ */
.wrap { max-width: 1320px; margin: 0 auto; padding: 22px 28px 60px; }
.grid { display: grid; gap: 18px; }
.cols-2 { grid-template-columns: 360px 1fr; }
@media (max-width: 980px) { .cols-2 { grid-template-columns: 1fr; } }

.card {
  background: #fff;
  border: 1px solid var(--op-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card h2 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--op-navy); margin-bottom: 14px; }
.card h3 { font-size: 13px; color: var(--op-text-muted); margin: 14px 0 8px; text-transform: uppercase; letter-spacing: 0.03em; }

/* ---- controls ---------------------------------------------------------- */
.controls { position: sticky; top: 72px; align-self: start; }
.field { margin-bottom: 12px; }
.field label { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--op-text-muted); margin-bottom: 5px; font-weight: 600; }
.field label .val { color: var(--op-navy); font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--op-primary); }
input[type="number"], select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--op-border);
  border-radius: 10px; font-family: var(--font); font-size: 13px; color: var(--op-text);
  background: var(--op-surface-2);
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.section-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--op-primary-600); margin: 16px 0 8px; }
fieldset { border: none; padding: 0; margin: 0; }

/* odds table */
.odds-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.odds-table th { text-align: right; color: var(--op-text-subtle); font-weight: 600; padding: 3px 5px; font-size: 11px; }
.odds-table th:first-child { text-align: left; }
.odds-table td { padding: 2px 4px; }
.odds-table td:first-child { font-weight: 700; color: var(--op-navy); }
.odds-table input { padding: 4px 6px; font-size: 11.5px; text-align: right; border-radius: 7px; }
.odds-sum { font-size: 11px; margin-top: 4px; text-align: right; }
.odds-sum.bad { color: var(--op-bad); font-weight: 700; }
.odds-sum.ok { color: var(--op-good); }

/* ---- buttons (pill) ---------------------------------------------------- */
.btn {
  border: none; cursor: pointer; font-family: var(--font); font-weight: 700;
  border-radius: var(--radius-pill); padding: 11px 22px; font-size: 14px;
  transition: transform .05s ease, box-shadow .15s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--op-primary); color: #fff; box-shadow: 0 6px 18px rgba(101,142,255,0.35); }
.btn-primary:hover { background: var(--op-primary-600); }
.btn-ghost { background: var(--op-surface); color: var(--op-navy); }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 10px; margin-top: 6px; }
.preset-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.pill {
  border: 1px solid var(--op-border); background: #fff; color: var(--op-text-muted);
  border-radius: var(--radius-pill); padding: 6px 14px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.pill.active { background: var(--op-grad-soft); border-color: var(--op-primary); color: var(--op-navy); }

/* ---- progress ---------------------------------------------------------- */
.progress { height: 8px; background: var(--op-surface); border-radius: var(--radius-pill); overflow: hidden; margin-top: 12px; display: none; }
.progress.show { display: block; }
.progress > div { height: 100%; width: 0%; background: var(--op-grad); transition: width .1s linear; }
.progress-label { font-size: 11.5px; color: var(--op-text-subtle); margin-top: 5px; min-height: 14px; }

/* ---- dashboard --------------------------------------------------------- */
.answers { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
@media (max-width: 1100px) { .answers { grid-template-columns: repeat(2, 1fr); } }
.answer {
  background: var(--op-grad-soft); border: 1px solid var(--op-border);
  border-radius: var(--radius-card); padding: 14px;
}
.answer .q { font-size: 11.5px; font-weight: 700; color: var(--op-primary-600); text-transform: uppercase; letter-spacing: 0.03em; min-height: 28px; }
.answer .verdict { font-size: 20px; font-weight: 700; margin: 6px 0 2px; }
.answer .verdict.good { color: var(--op-good); }
.answer .verdict.warn { color: var(--op-warn); }
.answer .verdict.bad { color: var(--op-bad); }
.answer .detail { font-size: 12px; color: var(--op-text-muted); }
.answer .detail b { color: var(--op-navy); }
.answer .caveat {
  margin-top: 8px;
  padding: 7px 9px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--op-navy);
  background: var(--op-grad-soft);
  border-left: 3px solid var(--op-warn);
  border-radius: 6px;
}

.kpis { display: flex; flex-wrap: wrap; gap: 22px; }
.kpi .v { font-size: 22px; font-weight: 700; color: var(--op-navy); font-variant-numeric: tabular-nums; }
.kpi .k { font-size: 11.5px; color: var(--op-text-subtle); text-transform: uppercase; letter-spacing: 0.04em; }

/* heat map */
.heat { display: grid; grid-template-columns: repeat(8, 1fr); gap: 10px; }
@media (max-width: 700px) { .heat { grid-template-columns: repeat(4, 1fr); } }
.heat .cell { border-radius: 12px; padding: 10px; color: #fff; text-align: center; position: relative; min-height: 78px; display: flex; flex-direction: column; justify-content: space-between; }
.heat .cell .cn { font-weight: 700; font-size: 13px; }
.heat .cell .cq { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.heat .cell .cp { font-size: 10.5px; opacity: 0.9; }

.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-box { min-height: 240px; }

/* ledger trace */
.ledger { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; max-height: 360px; overflow: auto; border: 1px solid var(--op-border); border-radius: 12px; }
.ledger table { width: 100%; border-collapse: collapse; }
.ledger th { position: sticky; top: 0; background: var(--op-surface); text-align: left; padding: 7px 10px; font-size: 11px; color: var(--op-text-muted); border-bottom: 1px solid var(--op-border); }
.ledger td { padding: 5px 10px; border-bottom: 1px solid #f1f3f8; white-space: nowrap; }
.ledger tr:hover td { background: var(--op-surface-2); }
.tag { display: inline-block; padding: 1px 8px; border-radius: var(--radius-pill); font-size: 10.5px; font-weight: 700; }
.tag.dep { background: #eef2ff; color: #4f78ec; }
.tag.buy { background: #fdeeee; color: #c0392b; }
.tag.rev { background: #eafaf0; color: #18a957; }
.tag.in  { background: #fff3e0; color: #b9791f; }
.tag.keep{ background: #f3e8ff; color: #7c3aed; }
.tag.rs  { background: #e6f6ff; color: #2477b5; }
.tag.brk { background: #2b2b2b; color: #fff; }

.bottleneck-list { list-style: none; padding: 0; margin: 0; }
.bottleneck-list li { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid #f1f3f8; font-size: 13px; }
.bottleneck-list li b { color: var(--op-navy); }
.bottleneck-list li .d { color: var(--op-text-muted); }
.bottleneck-list li.alert b { color: var(--op-bad); }

.hidden { display: none; }
.empty-state { text-align: center; color: var(--op-text-subtle); padding: 50px 20px; }
.foot { text-align: center; color: var(--op-text-subtle); font-size: 12px; margin-top: 36px; }
.spacer { height: 18px; }
.banner { border-radius: 12px; padding: 12px 16px; font-size: 13px; font-weight: 600; margin-bottom: 14px; }
.banner.ok { background: #eafaf0; color: #14803f; }
.banner.bad { background: #fdeeee; color: #b3271e; }
