:root {
  --bg: #f6f1e7; --paper: #fffaf1; --paper-2: #fdf5e6; --ink: #1f2522;
  --muted: #686e68; --line: #ded3bf; --accent: #245c4f; --accent-2: #8d4e2d; --accent-3: #b89b5e;
  --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); line-height: 1.45; }
.app { max-width: 560px; margin: 0 auto; padding: 0 16px calc(76px + env(safe-area-inset-bottom)); }
.topbar { position: sticky; top: 0; background: var(--bg); padding: 16px 0 8px; z-index: 5; }
.topbar h1 { margin: 0; font-size: 26px; letter-spacing: -0.03em; }
.error { display: none; margin-top: 6px; color: #fff; background: var(--accent-2); border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.error:not([hidden]) { display: block; }

.view { display: none; }
.view.active { display: block; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 5px; background: #eee3cf; border-radius: 999px; margin: 8px 0 16px; }
.segmented button { border: 0; border-radius: 999px; background: transparent; padding: 11px; font-weight: 800; color: var(--muted); cursor: pointer; }
.segmented button.active { background: var(--paper); color: var(--ink); box-shadow: 0 8px 20px rgba(38,31,20,.08); }

.form-view { display: none; }
.form-view.active { display: block; }
label { display: block; font-size: 14px; font-weight: 800; margin: 16px 0 8px; }
.prompt { font-size: 13px; color: var(--muted); margin: -4px 0 8px; }

.rating { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.rating label { position: relative; }
.rating input { position: absolute; opacity: 0; pointer-events: none; }
.rating span { display: flex; align-items: center; justify-content: center; height: 52px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper-2); cursor: pointer; font-weight: 900; }
.rating input:checked + span { background: var(--accent); color: #fff; border-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-flex; align-items: center; min-height: 44px; padding: 10px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper-2); font-size: 14px; font-weight: 800; cursor: pointer; }
.chip input:checked + span { background: var(--ink); color: var(--paper); border-color: var(--ink); }

textarea { width: 100%; border: 1px solid var(--line); background: var(--paper-2); border-radius: 14px; padding: 12px 13px; font: 500 15px/1.3 var(--font); color: var(--ink); min-height: 72px; resize: vertical; }
.btn { appearance: none; width: 100%; border: 1px solid var(--ink); background: var(--ink); color: var(--paper); border-radius: 999px; padding: 15px; font-weight: 900; font-size: 16px; cursor: pointer; margin-top: 18px; }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 18px; margin-bottom: 14px; }
.panel h3 { margin: 0 0 12px; font-size: 16px; }
.muted { color: var(--muted); }
.metric-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.metric { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.metric strong { display: block; font-size: 26px; letter-spacing: -0.04em; }
.metric span { color: var(--muted); font-size: 13px; font-weight: 700; }
.chart { width: 100%; height: 230px; background: var(--paper-2); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.chart svg { width: 100%; height: 100%; display: block; }
.axis { stroke: rgba(31,37,34,.25); stroke-width: 1; }
.line-energy { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.line-pressure { fill: none; stroke: var(--accent-2); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 7 6; }
.dot { fill: var(--accent); opacity: .9; }
.dot.activated { fill: var(--accent-2); }
.dot.foggy, .dot.drained { fill: #777; }
.bar { fill: var(--accent); opacity: .86; }
.bar-alt { fill: var(--accent-3); opacity: .9; }

.scroll-x { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 10px 8px; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--paper); border-top: 1px solid var(--line); padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); }
.tabbar .tab { border: 0; background: transparent; padding: 10px; font-weight: 800; color: var(--muted); border-radius: 12px; cursor: pointer; }
.tabbar .tab.active { background: var(--ink); color: var(--paper); }
