:root {
  color-scheme: dark;
  --bg: #0b0d0f;
  --panel: #101315;
  --panel-strong: #141719;
  --surface: #0d1012;
  --border: #272c30;
  --border-soft: #1d2226;
  --text: #f2f3f4;
  --muted: #8f989f;
  --muted-strong: #b9c0c5;
  --accent: #dba351;
  --accent-hover: #e4b368;
  --success: #8fb99a;
  --danger: #c96f6f;
  --chart: #74b47d;
  --radius: 5px;
  --content: 1240px;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 82% -18%, rgba(219, 163, 81, 0.08), transparent 34%),
    var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
h1, h2, h3, p { margin-top: 0; }

.site-header {
  min-height: 72px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(11, 13, 15, 0.92);
}

.header-inner,
main {
  width: min(calc(100% - 40px), var(--content));
  margin: 0 auto;
}

.header-inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand { display: flex; align-items: baseline; gap: 12px; }
.brand-mark { font-size: 14px; font-weight: 760; letter-spacing: 0.2em; }
.brand-product,
.header-status {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

main { padding: 50px 0 88px; }
.eyebrow {
  margin-bottom: 11px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  max-width: 820px;
  margin-bottom: 13px;
  font-size: clamp(36px, 5vw, 56px);
  font-weight: 520;
  letter-spacing: -0.045em;
  line-height: 1.03;
}

.lead {
  max-width: 740px;
  margin-bottom: 36px;
  color: var(--muted-strong);
  font-size: 15px;
  line-height: 1.7;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}

.access-panel { max-width: 560px; padding: 30px; }
.panel-heading,
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}
.panel-heading { margin-bottom: 23px; }
.panel-heading h2,
.section-heading h2 {
  margin-bottom: 6px;
  font-size: 22px;
  font-weight: 580;
  letter-spacing: -0.025em;
}
.panel-heading p,
.section-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}
.section-heading.compact { margin-bottom: 16px; }
.section-heading.compact h2 { font-size: 18px; }

.step-mark {
  flex: 0 0 auto;
  min-width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
}

.field { display: grid; gap: 8px; }
.field + .field { margin-top: 16px; }
label { color: var(--muted-strong); font-size: 12px; font-weight: 580; }
input,
select {
  width: 100%;
  height: 45px;
  border: 1px solid var(--border);
  border-radius: 3px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  padding: 0 13px;
}
input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(219, 163, 81, 0.1);
}
.field-note { color: var(--muted); font-size: 11px; line-height: 1.5; }
.form-message {
  min-height: 18px;
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 11px;
  line-height: 1.5;
}
.form-message.is-success { color: var(--success); }

.primary-button,
.secondary-button,
.icon-button {
  border-radius: 3px;
  font-weight: 680;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}
.primary-button,
.secondary-button {
  min-height: 43px;
  padding: 0 17px;
}
.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #15110b;
}
.primary-button:hover:not(:disabled) {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}
.secondary-button {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted-strong);
}
.secondary-button:hover:not(:disabled) { border-color: #454c52; color: var(--text); }
.access-button { min-width: 150px; margin-top: 22px; }

.workspace-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
}
.workspace-header h1 { margin-bottom: 8px; font-size: clamp(34px, 4.6vw, 52px); }
.workspace-header p { max-width: 720px; margin-bottom: 0; color: var(--muted); line-height: 1.6; }
.workspace-actions { display: flex; align-items: center; gap: 14px; }
.update-label { max-width: 360px; color: var(--muted); font-size: 11px; line-height: 1.45; text-align: right; white-space: normal; }

.summary-panel { padding: 26px; margin-bottom: 20px; background: var(--panel-strong); }
.status-badge {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  padding: 6px 9px;
  color: var(--muted-strong);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.status-badge.is-active { border-color: #3b5542; color: var(--success); }
.status-badge.is-stopped { border-color: #664343; color: var(--danger); }
.status-badge.is-completed { border-color: #4b4d51; color: var(--muted-strong); }

.summary-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin: 22px 0 18px;
}
.metric-card,
.detail-metrics article {
  border: 1px solid var(--border-soft);
  background: var(--surface);
  padding: 14px;
}
.metric-card { min-height: 91px; }
.metric-card span,
.detail-metrics span,
.strategy-preview span {
  display: block;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.metric-card strong {
  display: block;
  margin-top: 12px;
  font-size: 20px;
  font-weight: 590;
  letter-spacing: -0.025em;
}

.chart-card {
  border: 1px solid var(--border-soft);
  background: #0e1113;
}
.chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 16px 0;
}
.chart-header h3 { margin-bottom: 4px; font-size: 14px; font-weight: 630; }
.chart-header p,
.chart-header > span { margin-bottom: 0; color: var(--muted); font-size: 10px; }
.chart-stage { min-height: 286px; padding: 12px 12px 10px; }
.chart-stage.small { min-height: 240px; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-grid-line { stroke: #23292d; stroke-width: 1; }
.chart-line { fill: none; stroke: var(--chart); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart-reference-line { fill: none; stroke: #6e767b; stroke-width: 1.6; stroke-dasharray: 7 6; stroke-linecap: round; stroke-linejoin: round; }
.chart-area { fill: url(#qud-chart-fill); }
.chart-point { fill: #0e1113; stroke: var(--chart); stroke-width: 2; }
.chart-reference-point { fill: #0e1113; stroke: #6e767b; stroke-width: 1.6; }
.chart-label { fill: var(--muted); font-size: 10px; }
.chart-empty,
.empty-state {
  min-height: 240px;
  display: grid;
  place-items: center;
  padding: 26px;
  text-align: center;
  color: var(--muted);
}
.chart-empty strong,
.empty-state strong { display: block; margin-bottom: 7px; color: var(--muted-strong); font-size: 13px; }
.chart-empty p,
.empty-state p { max-width: 460px; margin-bottom: 0; font-size: 11px; line-height: 1.6; }

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(260px, 310px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.strategy-sidebar { position: sticky; top: 20px; padding: 22px; }
.strategy-list { display: grid; gap: 8px; }
.strategy-item {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  padding: 12px;
  color: var(--text);
  text-align: left;
}
.strategy-item:hover { border-color: #40474c; }
.strategy-item.is-selected {
  border-color: #3b5542;
  box-shadow: inset 2px 0 0 var(--success);
}
.strategy-item-title { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 650; overflow-wrap: anywhere; }
.strategy-item-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 9px; text-transform: uppercase; }
.strategy-list-empty { margin: 0; padding: 16px; border: 1px solid var(--border-soft); color: var(--muted); font-size: 11px; line-height: 1.55; }
.add-strategy-button { width: 100%; margin-top: 14px; }

.observation-form {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
}
.form-title-row { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 17px; }
.form-title-row h3 { margin-bottom: 4px; font-size: 15px; font-weight: 650; }
.form-title-row p { margin-bottom: 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.icon-button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted-strong);
  font-size: 19px;
}
.icon-button:hover { border-color: #454c52; color: var(--text); }
.form-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.form-columns .field { margin-top: 0; }
.submit-observation { width: 100%; margin-top: 18px; }

.strategy-preview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0 16px;
}
.strategy-preview > div {
  border: 1px solid var(--border-soft);
  background: var(--surface);
  padding: 10px;
}
.strategy-preview strong { display: block; margin-top: 7px; font-size: 12px; }

.strategy-detail { min-width: 0; padding: 26px; background: var(--panel-strong); }
.detail-kicker { margin-bottom: 7px !important; color: var(--accent) !important; font-size: 9px !important; letter-spacing: 0.12em; text-transform: uppercase; }
.subheading { margin: 24px 0 11px; font-size: 14px; font-weight: 630; }
.detail-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.detail-metrics article { min-height: 82px; }
.detail-metrics strong { display: block; margin-top: 10px; font-size: 16px; font-weight: 590; overflow-wrap: anywhere; }
.quality-metrics strong { font-size: 15px; }
.strategy-chart-card { margin-top: 24px; }
.history-section { margin-top: 24px; }
.history-section h3 { margin-bottom: 11px; font-size: 14px; font-weight: 630; }
.history-scroll { overflow-x: auto; border: 1px solid var(--border-soft); }
table { width: 100%; min-width: 700px; border-collapse: collapse; background: var(--surface); }
th,
td { padding: 11px 12px; border-bottom: 1px solid var(--border-soft); font-size: 10px; text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; }
td { color: var(--muted-strong); }
tr:last-child td { border-bottom: 0; }
.history-empty { margin: 0; padding: 18px; border: 1px solid var(--border-soft); color: var(--muted); font-size: 11px; }

.disclaimer {
  margin: 20px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--border-soft);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}

.value-positive { color: var(--success) !important; }
.value-negative { color: var(--danger) !important; }

@media (max-width: 1050px) {
  .summary-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .strategy-sidebar { position: static; }
  .detail-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .header-inner,
  main { width: min(calc(100% - 28px), var(--content)); }
  .brand-product,
  .header-status { display: none; }
  main { padding-top: 38px; }
  .workspace-header { align-items: flex-start; flex-direction: column; }
  .workspace-actions { width: 100%; flex-direction: column; align-items: stretch; }
  .summary-panel,
  .strategy-sidebar,
  .strategy-detail,
  .access-panel { padding: 20px; }
  .summary-metrics,
  .detail-metrics,
  .form-columns { grid-template-columns: 1fr; }
  .strategy-preview { grid-template-columns: 1fr 1fr; }
  .primary-button,
  .secondary-button { width: 100%; }
}
