/* Ampline app, artled Poster example. Both themes ship (U9). Versioned ?v=2.
   Extends site.css (shared tokens, Deco geometry, chart rules). Glass: top bar only (P7). */

/* App shell */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); grid-template-rows: auto auto 1fr auto; min-height: 100vh; }
/* Explicit placement: banner across the top, nav in the left column, main and footer on the right. */
.app > .banner { grid-column: 1 / -1; grid-row: 2; }
.app > .sidenav { grid-column: 1; grid-row: 3 / span 2; }
.app > .main { grid-column: 2; grid-row: 3; }
.app > .app-foot { grid-column: 2; grid-row: 4; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 0 20px; background: var(--glass); backdrop-filter: blur(14px) saturate(1.15); -webkit-backdrop-filter: blur(14px) saturate(1.15); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40; }
.topbar .logo { font-size: 1.1rem; margin-right: 6px; }
.topbar .spacer { flex: 1; }
.mode-tag { font: 500 .68rem var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); border: 1px solid var(--line); padding: 3px 8px; border-radius: var(--radius); }
.acct { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius); background: none; color: var(--text); font: 500 .8125rem var(--sans); }
.acct .ph { font-size: 1.05rem; color: var(--muted); }
.acct:hover { border-color: var(--line-2); }

/* Poster banner cut from the estate art (app-harmony.md). Dark scrim keeps it theme-independent. */
.banner { position: relative; overflow: hidden; height: 190px; border-bottom: 1px solid var(--line); }
.banner img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 34%; }
.banner::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(19, 22, 28, .5) 0%, rgba(19, 22, 28, .94) 97%); }
.banner-in { position: absolute; z-index: 1; inset: auto 24px 16px; max-width: 1200px; margin: 0 auto; left: 0; right: 0; display: grid; gap: 3px; }
.banner .kicker { color: #E8B84A; }
.banner-h { font-family: var(--display); font-size: clamp(1.7rem, 3.2vw, 2.4rem); color: #F4E9D0; letter-spacing: -0.01em; }
.banner-status { color: #B9B2A2; font-size: .82rem; font-family: var(--mono); }

/* Nav (U1) */
.sidenav { border-right: 1px solid var(--line); padding: 16px 12px; background: var(--bg); }
.sidenav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.sidenav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: var(--radius); text-decoration: none; color: var(--muted); font: 500 .9rem var(--sans); }
.sidenav a .ph { font-size: 1.15rem; flex: none; }
.sidenav a:hover { background: rgba(244, 233, 208, .07); color: var(--text); }
[data-theme="light"] .sidenav a:hover { background: rgba(19, 22, 28, .06); }
.sidenav a[aria-current="page"] { background: rgba(232, 184, 74, .14); color: var(--gold); border-left: 3px solid var(--gold); padding-left: 9px; }
[data-theme="light"] .sidenav a[aria-current="page"] { background: rgba(138, 95, 10, .1); }
.sidenav .soon { font: 500 .66rem var(--mono); color: var(--muted); border: 1px dashed var(--line); padding: 1px 6px; border-radius: var(--radius); margin-left: auto; }
.sidenav .foot { margin-top: 20px; padding: 0 12px; font-size: .74rem; color: var(--muted); display: grid; gap: 8px; }
.sidenav .foot a { color: var(--link); display: inline; min-height: 0; }

/* Main column */
.main { padding: 24px; display: grid; gap: 20px; align-content: start; }
.page-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.page-head h1, .page-head .page-title { font-size: 1.45rem; margin: 0; font-weight: 600; }
.page-head .updated { color: var(--muted); font-size: .8125rem; display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.segctl { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.segctl button { min-height: 40px; padding: 0 16px; background: none; border: 0; color: var(--muted); font: 500 .8125rem var(--sans); }
.segctl button + button { border-left: 1px solid var(--line); }
.segctl button[aria-pressed="true"] { background: var(--gold); color: var(--on-gold); }
.segctl button:not([aria-pressed="true"]):hover { background: rgba(244, 233, 208, .07); color: var(--text); }
[data-theme="light"] .segctl button:not([aria-pressed="true"]):hover { background: rgba(19, 22, 28, .06); }

/* Grid of tiles */
.board { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 20px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.tile h2 { font-size: 1rem; margin: 0 0 4px; font-family: var(--sans); font-weight: 600; letter-spacing: 0; }
.tile .sub { color: var(--muted); font-size: .8125rem; }
.span-8 { grid-column: span 8; } .span-4 { grid-column: span 4; } .span-6 { grid-column: span 6; }
.span-12 { grid-column: span 12; }

/* Main metric (U11, PO5): unit, period, comparison. The live number is gold (PO3). */
.metric { display: grid; gap: 10px; }
.big { font-family: var(--mono); font-weight: 500; font-size: clamp(2.6rem, 4vw, 3.4rem); line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--gold); }
.big small { font-size: .3em; font-weight: 400; color: var(--muted); letter-spacing: 0; margin-left: 8px; }
.index-line { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: .9rem; }
.swatch { width: 12px; height: 12px; border-radius: 2px; flex: none; }
.metric .ctx { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 6px; }
.metric .ctx .k, .compare .k, .window .k { font: 500 .66rem var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); display: block; margin-bottom: 3px; }
.metric .ctx .v, .compare .v, .window .v { font-family: var(--mono); font-weight: 500; font-size: .9rem; }
.window { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--ink-line); }
.window .rule { color: var(--muted); font-size: .78rem; margin-top: 6px; }

/* Charts (U6). Series gold (PO3); bands are data roles with their words beside them. */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; }
.axis-t { font: 400 11px var(--mono); fill: var(--muted); font-variant-numeric: tabular-nums; }
.gridline { stroke: var(--ink-line); stroke-width: 1; }
.baseline { stroke: var(--line-2); stroke-width: 1; }
.series { stroke: var(--gold); stroke-width: 2; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.area { fill: var(--gold); opacity: .1; }
.nowline { stroke: var(--red); stroke-width: 1; }
.now-label { font: 500 10px var(--mono); fill: var(--red); }
.bar-label { font: 500 11px var(--mono); fill: var(--text); font-variant-numeric: tabular-nums; }
.tooltip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 8px 10px; font: 500 .8125rem var(--mono); box-shadow: 0 4px 16px var(--shadow); min-width: 14ch; display: none; z-index: 5; }
.tooltip .t { color: var(--muted); font-size: .7rem; margin-top: 2px; font-family: var(--sans); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; font-size: .75rem; color: var(--muted); }
.legend .li { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.draw .series { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: dash 400ms var(--ease) forwards; }
@keyframes dash { to { stroke-dashoffset: 0; } }

/* Index band colours (data roles, both themes measured at 3:1 on every surface). */
:root {
  --band-vlow: #3DD6B0; --band-low: #5BC9E8; --band-mod: #EFC24B; --band-high: #FFA961; --band-vhigh: #FF8266;
}
[data-theme="light"] {
  --band-vlow: #0E7C66; --band-low: #0B5C6E; --band-mod: #7A6100; --band-high: #A84B0C; --band-vhigh: #B3361F;
}

/* Generation mix: ranked horizontal bars (U2, U6). */
.mix { display: grid; gap: 12px; }
.mix-row { display: grid; grid-template-columns: 88px minmax(0, 1fr) 56px; gap: 12px; align-items: center; font-size: .8125rem; }
.mix-row .nm { color: var(--text); }
.mix-row .track { height: 12px; background: rgba(244, 233, 208, .08); border-radius: 2px; overflow: hidden; }
[data-theme="light"] .mix-row .track { background: rgba(19, 22, 28, .09); }
.mix-row .fill { height: 100%; background: var(--gold); }
.mix-row .pc { font-family: var(--mono); text-align: right; font-variant-numeric: tabular-nums; }

/* Appliances planner (sample data, H23) */
.plan { display: grid; gap: 0; }
.plan-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.1fr) auto; gap: 16px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--ink-line); }
.plan-row:last-child { border-bottom: 0; }
.plan-row .nm { display: flex; align-items: center; gap: 10px; font: 500 .9rem var(--sans); }
.plan-row .nm .ph { font-size: 1.1rem; color: var(--muted); flex: none; }
.plan-row .when { font-size: .8125rem; color: var(--muted); }
.plan-row .when .t { font-family: var(--mono); color: var(--text); font-weight: 500; }
.plan-row .save { font-family: var(--mono); font-weight: 500; font-size: .8125rem; text-align: right; white-space: nowrap; }
.plan-row .save .k { font-family: var(--sans); font-weight: 400; color: var(--muted); display: block; font-size: .68rem; }
.plan-row .btn { min-height: 44px; }
.plan-note { color: var(--muted); font-size: .74rem; margin-top: 14px; }
.plan-head-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 4px; flex-wrap: wrap; }
.sample-inline { font: 500 .68rem var(--mono); color: var(--gold); border: 1px dashed var(--line-2); padding: 2px 8px; border-radius: var(--radius); }

/* Tables (U3) */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.hours { width: 100%; border-collapse: collapse; font-size: .8125rem; min-width: 640px; }
.hours th, .hours td { padding: 10px 14px; border-bottom: 1px solid var(--ink-line); text-align: left; }
.hours thead th { background: var(--raised); font: 500 .68rem var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); position: sticky; top: 0; }
.hours tbody th { font: 600 .82rem var(--sans); }
.hours tbody tr:last-child td { border-bottom: 0; }
.hours td.num, .hours th.num { text-align: right; font-variant-numeric: tabular-nums; }
.hours td.num { font-family: var(--mono); }
.hours th button.sort { all: unset; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 2px 4px; border-radius: var(--radius); font: inherit; color: inherit; cursor: pointer; }
.hours th button.sort:hover { background: rgba(244, 233, 208, .08); }
[data-theme="light"] .hours th button.sort:hover { background: rgba(19, 22, 28, .07); }
.hours th button.sort .ph { font-size: .85rem; color: var(--muted); }
.hours .idx { display: inline-flex; align-items: center; gap: 6px; }
.hours tbody tr:hover { background: rgba(244, 233, 208, .04); }
[data-theme="light"] .hours tbody tr:hover { background: rgba(19, 22, 28, .04); }
.row-dim td { color: var(--muted); }

/* Dialog (U12) */
dialog { border: 1px solid var(--line-2); border-radius: var(--radius); padding: 24px; background: var(--surface); color: var(--text); width: min(480px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(19, 22, 28, .6); }
dialog h2 { font-size: 1.15rem; margin-bottom: 4px; font-family: var(--sans); font-weight: 600; letter-spacing: 0; }
dialog .hint { color: var(--muted); font-size: .8125rem; margin-bottom: 18px; }
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 500; font-size: .8125rem; }
.field .help { color: var(--muted); font-size: .75rem; }
.field input, .field select { min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--text); font: 400 .875rem var(--sans); }
.field input:focus-visible, .field select:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.field .err { color: var(--red); font-size: .75rem; display: none; }
.field.invalid .err { display: block; }
.field.invalid input, .field.invalid select { border-color: var(--red); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* Toast (undo, U5/U7) */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 0); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 12px 16px; display: none; gap: 14px; align-items: center; box-shadow: 0 6px 24px var(--shadow); font-size: .875rem; z-index: 90; }
.toast.show { display: flex; }
.toast button { all: unset; color: var(--gold); font-weight: 600; padding: 6px 10px; border-radius: var(--radius); min-height: 32px; cursor: pointer; }
.toast button:hover { background: rgba(232, 184, 74, .14); }
[data-theme="light"] .toast button:hover { background: rgba(138, 95, 10, .12); }

/* Views */
.view { display: none; }
.view.on { display: grid; gap: 20px; }
.settings-list { display: grid; gap: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.set-row { display: flex; align-items: center; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--ink-line); }
.set-row:last-child { border-bottom: 0; }
.set-row .t { flex: 1; }
.set-row .t .h { font-weight: 500; font-size: .9rem; }
.set-row .t .d { color: var(--muted); font-size: .8125rem; }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch .tr { position: absolute; inset: 0; border-radius: var(--radius); background: rgba(244, 233, 208, .16); transition: background-color 160ms var(--ease); }
[data-theme="light"] .switch .tr { background: rgba(19, 22, 28, .18); }
.switch .kn { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 3px; background: var(--surface); transition: transform 160ms var(--ease); }
.switch input:checked ~ .tr { background: var(--gold); }
.switch input:checked ~ .kn { transform: translateX(18px); }
.switch input:focus-visible ~ .tr { outline: 2px solid var(--focus); outline-offset: 2px; }

/* App footer strip */
.app-foot { padding: 28px 24px 40px; display: grid; gap: 6px; }
.app-foot .small { color: var(--muted); }
.app-foot a { color: var(--link); }

/* Embed mode: hide nav and topbar extras */
.embed .sidenav { display: none; }
.embed .app { grid-template-columns: minmax(0, 1fr); }
.embed .mode-tag, .embed .acct { display: none; }
.embed .banner { height: 150px; }
.embed .main { padding: 18px; }

/* Responsive: tablet */
@media (max-width: 1000px) {
  .span-8, .span-4, .span-6 { grid-column: span 12; }
}

/* Responsive: phone: nav becomes a labelled top menu bar */
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; }
  .app > .banner, .app > .sidenav, .app > .main, .app > .app-foot { grid-column: 1; grid-row: auto; }
  .sidenav { border-right: 0; border-bottom: 1px solid var(--line); padding: 8px 12px; overflow-x: auto; }
  .sidenav ul { display: flex; gap: 4px; }
  .sidenav a { min-height: 44px; padding: 0 12px; white-space: nowrap; }
  .sidenav a[aria-current="page"] { border-left: 0; border-bottom: 3px solid var(--gold); padding-left: 12px; padding-bottom: 0; }
  .sidenav .foot { display: none; }
  .main { padding: 16px; }
  .page-head .updated { margin-left: 0; width: 100%; }
  .mix-row { grid-template-columns: 76px minmax(0, 1fr) 48px; }
  .plan-row { grid-template-columns: 1fr; gap: 6px; }
  .plan-row .save { text-align: left; }
  .banner { height: 160px; }
}
@media (max-width: 480px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .acct span { display: none; }
  .acct { padding: 0 10px; min-height: 44px; }
  .theme-btn span, .topbar .logo span { display: none; }
  .sidenav a span.soon { display: none; }
  .page-head h1, .page-head .page-title { font-size: 1.2rem; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .draw .series { stroke-dasharray: none; stroke-dashoffset: 0; }
}
