:root {
  --bg: #eee9df;
  --paper: #faf7f0;
  --ink: #25231f;
  --muted: #746f65;
  --line: #d8d0c2;
  --accent: #b45132;
  --accent-soft: #f1ded3;
  --danger: #a43d32;
  --shadow: 0 18px 45px rgb(74 58 37 / 8%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 85% 0%, rgb(255 255 255 / 55%), transparent 32rem),
    var(--bg);
  color: var(--ink);
}

button, input { font: inherit; }
button { cursor: pointer; }

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 64px 0 80px;
}

.hero, .section-heading, .dialog-head, .node-head, .dialog-actions, .hero-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.hero { margin-bottom: 34px; }
.hero-actions { flex: 0 0 auto; gap: 10px; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: .72rem;
  font-weight: 750;
  letter-spacing: .13em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(2.4rem, 6vw, 4.6rem); letter-spacing: -.06em; }
h2 { margin-bottom: 0; font-size: 1.65rem; letter-spacing: -.03em; }
h3 { margin: 0; font-size: 1.35rem; letter-spacing: -.025em; }
.intro, .hint { color: var(--muted); }
.intro { max-width: 630px; margin-bottom: 0; line-height: 1.65; }
.hint { margin-bottom: 0; font-size: .9rem; }

.primary, .quiet, .settings-button, .icon-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 17px;
  color: var(--ink);
  background: var(--paper);
}

.primary {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.primary:disabled, button:disabled { cursor: not-allowed; opacity: .48; }
.quiet { background: transparent; }
.icon-button { width: 40px; height: 40px; padding: 0; font-size: 1.6rem; }

button:focus-visible, input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 40%, transparent);
  outline-offset: 2px;
}

.overview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgb(250 247 240 / 78%);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.overview article { min-height: 116px; padding: 24px 28px; }
.overview article + article { border-left: 1px solid var(--line); }
.overview span, .metric span { display: block; color: var(--muted); font-size: .82rem; }
.overview strong { display: block; margin-top: 10px; font-size: 1.6rem; }

.error-banner {
  margin: 18px 0 0;
  padding: 13px 16px;
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--line));
  border-radius: 12px;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 7%, var(--paper));
}

.nodes-section { margin-top: 58px; }
.section-heading { align-items: end; margin-bottom: 18px; }
.nodes { display: grid; gap: 18px; }

.node-card {
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.node-head { align-items: flex-start; }
.node-meta { margin: 6px 0 0; color: var(--muted); font-size: .83rem; }
.badges { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.badge { padding: 5px 9px; border-radius: 999px; background: var(--accent-soft); font-size: .75rem; }
.badge.muted { background: transparent; border: 1px solid var(--line); color: var(--muted); }

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 24px 0 10px;
}

.metric { padding: 14px 16px; border-top: 1px solid var(--line); }
.metric strong { display: block; margin-top: 7px; font-size: 1rem; }
.metric strong.over { color: var(--danger); }

.chart-shell { position: relative; min-height: 290px; margin-top: 8px; overflow: hidden; }
.chart { display: block; width: 100%; min-width: 0; overflow: visible; touch-action: pan-y; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 11px; }
.actual-line, .reference-line { fill: none; stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.reference-line { stroke: var(--muted); stroke-width: 2; stroke-dasharray: 7 8; opacity: .72; }
.chart-empty { display: grid; min-height: 250px; place-items: center; color: var(--muted); }
.chart-legend { display: flex; gap: 18px; margin: -4px 0 0 62px; color: var(--muted); font-size: .78rem; }
.legend-line { display: inline-block; width: 22px; margin-right: 7px; border-top: 3px solid currentColor; vertical-align: middle; }
.legend-line.reference { border-top-style: dashed; border-color: var(--muted); }

.empty { padding: 64px 20px; border: 1px dashed var(--line); border-radius: 20px; text-align: center; color: var(--muted); }
.empty strong { color: var(--ink); }

dialog {
  width: min(520px, calc(100% - 28px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 30px 90px rgb(0 0 0 / 24%);
}

dialog::backdrop { background: rgb(30 27 23 / 42%); backdrop-filter: blur(4px); }
dialog form { padding: 26px; }
.dialog-head { align-items: flex-start; margin-bottom: 24px; }
label { display: grid; gap: 8px; margin: 18px 0; font-size: .88rem; font-weight: 650; }
input[type="number"], input[type="time"] {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: transparent;
}

.login-body { min-height: 100vh; }
.login-shell {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
}
.login-card {
  width: min(420px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.login-card h1 { margin-bottom: 10px; font-size: 2.5rem; }
.login-form { margin-top: 28px; }
.login-form label { margin-bottom: 8px; }
.login-form input[type="password"] {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: transparent;
}
.login-form .primary { width: 100%; margin-top: 18px; }
.login-error { margin: 12px 0 0; color: var(--danger); font-size: .88rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.switch-row { grid-template-columns: auto 1fr; align-items: start; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.switch-row input { margin-top: 3px; }
.switch-row strong, .switch-row small { display: block; }
.switch-row small { margin-top: 4px; color: var(--muted); font-weight: 400; line-height: 1.45; }
.dialog-actions { justify-content: flex-end; margin-top: 26px; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100% - 40px));
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--paper);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: .18s ease;
}
.toast.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 760px) {
  .page { width: min(100% - 22px, 680px); padding-top: 34px; }
  .hero, .section-heading { align-items: flex-start; }
  .hero { flex-direction: column; }
  .overview { grid-template-columns: 1fr; }
  .overview article { min-height: auto; padding: 18px 20px; }
  .overview article + article { border-left: 0; border-top: 1px solid var(--line); }
  .section-heading { display: block; }
  .section-heading .hint { margin-top: 8px; }
  .node-card { padding: 19px 14px; }
  .node-head { display: block; }
  .badges { justify-content: flex-start; margin-top: 14px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric { padding: 12px 8px; }
  .chart-shell { margin-left: -8px; margin-right: -2px; }
  .chart-legend { margin-left: 90px; }
}

@media (max-width: 430px) {
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .metrics { gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1b18;
    --paper: #27241f;
    --ink: #f3eee5;
    --muted: #aaa397;
    --line: #454037;
    --accent: #e68b66;
    --accent-soft: #51352a;
    --danger: #f08373;
    --shadow: 0 18px 45px rgb(0 0 0 / 20%);
  }
  body { background: var(--bg); }
  .overview { background: rgb(39 36 31 / 80%); }
}
