@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600;9..40,700&family=Fraunces:opsz,wght@9..144,400;9..144,500&display=swap');

/* Digital Subak — Watershed components. Plain CSS, class prefix ds-. Tokens come from tokens.css. */
.ds-root, .ds-root * { box-sizing: border-box; }
.ds-root { color-scheme: light; font-family: var(--font-sans); color: var(--ink); background: var(--surface-100); font-size: 14px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
.ds-root :focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.ds-num { font-variant-numeric: tabular-nums; }
.ds-eyebrow { font: 700 11px/1.4 var(--font-sans); letter-spacing: .2em; text-transform: uppercase; color: var(--river-text); }
.ds-muted { color: var(--ink-muted); }
.ds-caption { font-size: 11px; line-height: 1.5; color: var(--ink-muted); }

/* Button */
.ds-btn { display: inline-flex; align-items: center; gap: var(--space-2); border: 0; border-radius: var(--radius-pill); padding: 13px 22px; font: 700 12px/1.2 var(--font-sans); cursor: pointer; text-decoration: none; white-space: nowrap; }
.ds-btn--primary { background: var(--teal); color: var(--on-teal); }
.ds-btn--outline { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); padding: 10px 16px; font-weight: 600; }
.ds-btn--ghost { background: transparent; color: var(--teal); padding: 13px 4px; }
.ds-btn--report { background: var(--surface-raised); color: var(--teal); box-shadow: inset 0 0 0 1.5px var(--teal), var(--shadow-note); }
.ds-btn:disabled { opacity: .45; cursor: not-allowed; }
.ds-btn svg { width: 16px; height: 16px; flex: none; }

/* Status chip — colour + glyph + word, never colour alone */
.ds-status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--radius-pill); font: 600 12px/1.3 var(--font-sans); background: var(--surface-raised); box-shadow: inset 0 0 0 1px var(--line); }
.ds-status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.ds-status--ok { color: var(--ok); }
.ds-status--warn { color: var(--warn); }
.ds-status--warn::before { background: linear-gradient(90deg, currentColor 50%, transparent 50%); box-shadow: inset 0 0 0 1.5px currentColor; }
.ds-status--danger { color: var(--danger); }
.ds-status--danger::before { border-radius: 0; width: 9px; height: 8px; clip-path: polygon(50% 0, 100% 100%, 0 100%); }

/* Brand bar */
.ds-brandbar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); }
.ds-brand { display: flex; align-items: center; gap: var(--space-2); font: 700 17px/1 var(--font-sans); letter-spacing: -.035em; color: var(--ink); white-space: nowrap; }
.ds-brand img { display: block; width: auto; height: 40px; }

/* Station header */
.ds-station-head { padding: var(--space-4); }
.ds-station-head h1 { font: 500 36px/1.08 var(--font-display); letter-spacing: -.04em; margin: 6px 0 var(--space-2); }
.ds-station-head .ds-meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); font-size: 12px; color: var(--ink-muted); }
.ds-now { display: flex; align-items: flex-end; gap: var(--space-4); margin-top: var(--space-4); }
.ds-now .ds-reading { font: 500 56px/1 var(--font-display); letter-spacing: -.04em; }
.ds-now .ds-now-side { font-size: 13px; color: var(--ink-muted); padding-bottom: 6px; }
.ds-now .ds-now-side b { color: var(--ink); font-weight: 600; }

/* Metric tile */
.ds-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.ds-tile { background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 12px 14px; min-width: 0; }
.ds-tile .ds-tile-label { font: 600 12px/1.4 var(--font-sans); color: var(--ink-muted); display: flex; justify-content: space-between; gap: 6px; }
.ds-tile .ds-tile-value { font: 600 24px/1.1 var(--font-sans); letter-spacing: -.035em; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.ds-tile .ds-tile-value small { font-size: 13px; font-weight: 500; color: var(--ink-muted); letter-spacing: 0; margin-left: 2px; }
.ds-tile .ds-tile-sub { font-size: 11px; color: var(--ink-muted); }
.ds-tile .ds-spark { display: block; width: 100%; height: 26px; margin-top: 6px; }
.ds-tile .ds-spark path { fill: none; stroke: var(--river); stroke-width: 2; }
.ds-tile .ds-spark .area { fill: var(--river); opacity: .12; stroke: none; }
.ds-tile--flagged { border-style: dashed; border-color: var(--warn); }
.ds-flag { font: 600 11px/1.3 var(--font-sans); color: var(--warn); }

/* Water balance bar */
.ds-balance { background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 14px; }
.ds-balance-track { position: relative; height: 10px; border-radius: 10px; margin: 12px 0 6px; background: linear-gradient(90deg, var(--warn) 0 33%, var(--line) 33% 67%, var(--leaf) 67% 100%); }
.ds-balance-dot { position: absolute; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%; background: var(--surface-raised); box-shadow: inset 0 0 0 4px var(--ink); }
.ds-balance-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-muted); }

/* AI insight card */
.ds-insight { background: var(--surface-float); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 14px 16px; box-shadow: var(--shadow-note); }
.ds-insight-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-bottom: 6px; }
.ds-insight p { margin: 0; font-size: 15px; line-height: 1.6; }
.ds-insight ul { margin: 8px 0 0; padding-left: 18px; font-size: 14px; }
.ds-insight-foot { margin-top: 10px; font-size: 11px; color: var(--ink-muted); display: flex; justify-content: space-between; gap: var(--space-2); flex-wrap: wrap; }
.ds-insight--loading p { color: var(--ink-muted); }

/* Sensor socket — a reserved slot for a sensor that is not installed yet */
.ds-socket { border: 1.5px dashed var(--line-control); border-radius: var(--radius-md); padding: 12px 14px; background: transparent; min-width: 0; }
.ds-socket .ds-tile-label { font: 600 12px/1.4 var(--font-sans); color: var(--ink-muted); }
.ds-socket .ds-tag { display: inline-block; }
.ds-socket .ds-socket-empty { font: 500 15px/1.3 var(--font-sans); margin: 8px 0 2px; }
.ds-socket .ds-socket-hint { font-size: 11px; color: var(--ink-muted); }
.ds-tag { display: inline-block; font: 600 10px/1.4 var(--font-sans); letter-spacing: .08em; text-transform: uppercase; padding: 2px 6px; border-radius: var(--radius-sm); background: var(--surface-200); color: var(--ink); }

/* Widgets: tide, moon, sun */
.ds-widget { background: var(--surface-200); border-radius: var(--radius-md); padding: 12px 14px; min-width: 0; }
.ds-widget .ds-tile-label { font: 600 12px/1.4 var(--font-sans); color: var(--ink); display: flex; justify-content: space-between; }
.ds-widget .ds-widget-value { font: 600 18px/1.2 var(--font-sans); letter-spacing: -.03em; margin: 6px 0 2px; }
.ds-widget .ds-widget-sub { font-size: 11px; color: var(--ink); opacity: .8; }
.ds-widget svg { display: block; width: 100%; }
.ds-tide-curve { fill: none; stroke: var(--river-light); stroke-width: 2.5; }
.ds-tide-fill { fill: var(--river); opacity: .14; }
.ds-tide-now { fill: var(--surface-raised); stroke: var(--river); stroke-width: 3; }
.ds-moon-disc { fill: var(--cream); stroke: var(--line-control); stroke-width: 1; }
.ds-moon-shade { fill: var(--ink); opacity: .82; }

/* Map */
.ds-map { position: relative; background: var(--surface-200); border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--line); }
.ds-map svg.ds-map-art { display: block; width: 100%; height: 100%; }
.ds-map .island { fill: var(--terrace-pale); stroke: var(--terrace-mid); stroke-width: 1.5; }
.ds-map .contour { fill: none; stroke: var(--terrace-mid); stroke-opacity: .55; stroke-width: 1; }
.ds-map .river { fill: none; stroke: var(--river-light); stroke-width: 1.6; }
.ds-map-tag { position: absolute; left: 12px; top: 12px; background: var(--surface-float); color: var(--ink); border-radius: var(--radius-sm); padding: 6px 9px; font: 700 10px/1.2 var(--font-sans); letter-spacing: .1em; text-transform: uppercase; box-shadow: var(--shadow-note); }
.ds-pin { position: absolute; transform: translate(-50%, -100%); display: inline-flex; align-items: center; gap: 6px; background: var(--surface-raised); color: var(--ink); border-radius: var(--radius-pill); padding: 5px 10px 5px 6px; font: 700 11px/1.2 var(--font-sans); box-shadow: var(--shadow-note), inset 0 0 0 1px var(--line); white-space: nowrap; cursor: pointer; }
.ds-pin::after { content: ''; position: absolute; left: 50%; bottom: -5px; margin-left: -5px; border: 5px solid transparent; border-top-color: var(--surface-raised); border-bottom: 0; }
.ds-pin i { width: 18px; height: 18px; border-radius: 50%; background: var(--river); box-shadow: inset 0 0 0 4px var(--surface-raised), 0 0 0 1.5px var(--river); flex: none; }
.ds-pin b { font-weight: 600; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.ds-pin--active { background: var(--teal); color: var(--on-teal); }
.ds-pin--active::after { border-top-color: var(--teal); }
.ds-pin--active b { color: var(--on-teal); }
.ds-pin--active i { box-shadow: inset 0 0 0 4px var(--teal), 0 0 0 1.5px var(--on-teal); background: var(--on-teal); }
.ds-pin--stale i { background: var(--warn); box-shadow: inset 0 0 0 4px var(--surface-raised), 0 0 0 1.5px var(--warn); }
.ds-pin--offline i { background: var(--danger); box-shadow: inset 0 0 0 4px var(--surface-raised), 0 0 0 1.5px var(--danger); }
.ds-pin--planned { background: var(--surface-float); box-shadow: none; border: 1.5px dashed var(--line-control); color: var(--ink-muted); }
.ds-pin--planned::after { display: none; }
.ds-pin--planned i { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line-control); }
.ds-map-popup { position: absolute; background: var(--surface-float); border-radius: var(--radius-md); padding: 12px 14px; box-shadow: var(--shadow-note); border: 1px solid var(--line); width: 220px; font-size: 12px; }
.ds-map-popup strong { display: block; font: 500 18px/1.2 var(--font-display); letter-spacing: -.02em; }

/* Alert banner */
.ds-alert { display: flex; gap: var(--space-3); align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-md); background: var(--danger); color: var(--on-danger); }
.ds-alert b { display: block; font-size: 14px; }
.ds-alert span { font-size: 12px; opacity: .92; }
.ds-alert svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.ds-alert--info { background: var(--surface-raised); color: var(--ink); border: 1px solid var(--line); }
.ds-alert--info svg { color: var(--teal); }

/* Report sheet */
.ds-sheet { background: var(--surface-raised); border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: var(--shadow-sheet); padding: var(--space-4) var(--space-4) var(--space-5); }
.ds-sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--line-strong); margin: -4px auto 12px; }
.ds-sheet h2 { font: 500 22px/1.2 var(--font-display); letter-spacing: -.02em; margin: 4px 0 4px; }
.ds-choices { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: var(--space-3) 0; }
.ds-choice { border: 0; display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: var(--radius-pill); background: var(--surface-100); box-shadow: inset 0 0 0 1px var(--line-control); font: 600 12px/1.2 var(--font-sans); color: var(--ink); cursor: pointer; }
.ds-choice[aria-pressed="true"] { background: var(--terrace-pale); box-shadow: inset 0 0 0 2px var(--ink); }
.ds-field { display: block; margin-top: var(--space-3); }
.ds-field span { display: block; font: 600 12px/1.4 var(--font-sans); margin-bottom: 4px; }
.ds-field textarea, .ds-field input { width: 100%; border: 1px solid var(--line-control); border-radius: var(--radius-sm); padding: 10px 12px; font: 400 14px/1.4 var(--font-sans); color: var(--ink); background: var(--surface-100); }
.ds-photo { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-3); padding: 12px; border: 1.5px dashed var(--line-control); border-radius: var(--radius-md); font-size: 13px; color: var(--ink-muted); }

/* Section heading inside a dashboard */
.ds-section-title { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); margin: 0 0 var(--space-3); }
.ds-section-title h2 { font: 500 22px/1.2 var(--font-display); letter-spacing: -.02em; margin: 0; }
.ds-section-title a { font: 600 12px/1 var(--font-sans); color: var(--teal); text-decoration: none; }
