/* YLP dashboard theme. Colours and feel follow yourlocalplumber.co.nz: deep navy, bright blue, and a colour for each trade. */
:root {
  --navy: #003E5F; --blue: #1070B5; --teal: #5BC6CC; --yellow: #FFDA5E; --brown: #AE6B29; --pink: #E12162; --grey: #9D9FA2;
  --bg: #EDF2F6; --panel: #FFFFFF; --panel2: #F6F9FB; --fg: #1C3C50; --head: #003E5F; --muted: #5F7787; --line: #DCE5EC;
  --accent: #1070B5; --accent-fg: #fff; --ok: #1E8A5C; --warn: #B7791F; --bad: #D01C58;
  --side: #003E5F; --side2: #002F4A; --side-fg: #E9F2F8; --side-muted: #9FBBCC;
  --radius: 16px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(0, 62, 95, .06), 0 10px 28px rgba(0, 62, 95, .08); --shadow-up: 0 2px 4px rgba(0, 62, 95, .08), 0 16px 36px rgba(0, 62, 95, .16);
  --tip-bg: #fff; --hero-a: #003E5F; --hero-b: #0A5A8F; --hero-c: #1070B5;
  color-scheme: light;
  font-family: "Proxima Nova", "Nunito Sans", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
:root[data-theme="dark"], :root[data-theme="auto"][data-dark="1"] { }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="ylp"]) { --bg: #0A1B27; --panel: #112A3A; --panel2: #0E2332; --fg: #DCEBF4; --head: #F2F8FC; --muted: #8FB0C3; --line: #1E3A4C; --ok: #4CC38A; --warn: #E8B04A; --bad: #FF6B8F; --side: #06141E; --side2: #04101A; --tip-bg: #17364A; --shadow: 0 10px 28px rgba(0, 0, 0, .45); --shadow-up: 0 16px 36px rgba(0, 0, 0, .6); color-scheme: dark; }
}
:root[data-theme="dark"] { --bg: #0A1B27; --panel: #112A3A; --panel2: #0E2332; --fg: #DCEBF4; --head: #F2F8FC; --muted: #8FB0C3; --line: #1E3A4C; --ok: #4CC38A; --warn: #E8B04A; --bad: #FF6B8F; --side: #06141E; --side2: #04101A; --tip-bg: #17364A; --shadow: 0 10px 28px rgba(0, 0, 0, .45); --shadow-up: 0 16px 36px rgba(0, 0, 0, .6); color-scheme: dark; }
:root[data-theme="clean"] { --bg: #FFFFFF; --panel2: #F7F9FA; --hero-a: #FFFFFF; --hero-b: #FFFFFF; --hero-c: #FFFFFF; --shadow: 0 0 0 1px var(--line); }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.2; color: var(--head); }
.muted { color: var(--muted); } .small { font-size: .85em; } .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
.r { text-align: right; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }
svg { flex-shrink: 0; }

/* ---------- buttons and forms ---------- */
.btn { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--line); background: var(--panel); color: var(--head); padding: .5rem 1rem; border-radius: 8px; cursor: pointer; text-decoration: none; line-height: 1.2; font-weight: 600; transition: transform .12s, box-shadow .15s, border-color .15s, background .15s; }
.btn:hover { border-color: var(--accent); box-shadow: 0 4px 12px rgba(16, 112, 181, .18); transform: translateY(-1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn.danger { color: var(--bad); }
.btn.small { padding: .3rem .7rem; font-size: .86em; }
.btn[disabled], .tb[disabled] { opacity: .45; cursor: default; transform: none; box-shadow: none; }
.tb { border: 1px solid var(--line); background: var(--panel); color: var(--fg); padding: .2rem .55rem; border-radius: 6px; cursor: pointer; font-size: .8em; font-weight: 600; }
.tb:hover { border-color: var(--accent); color: var(--accent); }
.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font-size: .9em; }
input[type="text"], input[type="password"], input[type="search"], input[type="number"], input[type="date"], select, textarea { width: 100%; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); outline: none; }
textarea { resize: vertical; }
input[type="color"] { width: 3.5rem; height: 2.3rem; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); }
input.short { width: 9rem; }
.f { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .75rem; }
.fl { font-size: .84em; color: var(--muted); font-weight: 700; }
.hint { font-size: .82em; color: var(--muted); } .hint.ok { color: var(--ok); } .hint.bad { color: var(--bad); }
.chk { display: flex; align-items: center; gap: .45rem; font-size: .92em; cursor: pointer; }
.chk input { width: auto; accent-color: var(--accent); }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row > select, .row > input:not(.short) { flex: 1 1 8rem; min-width: 0; width: auto; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; align-items: end; }
.stack { display: flex; flex-direction: column; gap: .5rem; }
.form-error { color: var(--bad); min-height: 1.2em; margin: 0; }

/* ---------- sign-in ---------- */
.center { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: radial-gradient(1200px 600px at 80% -10%, color-mix(in srgb, var(--blue) 35%, transparent), transparent), linear-gradient(160deg, var(--hero-a), var(--hero-b)); }
.center-card { background: var(--panel); border-radius: 20px; padding: 1.6rem; width: min(26rem, 100%); display: flex; flex-direction: column; gap: .8rem; box-shadow: var(--shadow-up); }
.center-card label { display: flex; flex-direction: column; gap: .25rem; font-size: .85em; color: var(--muted); font-weight: 700; }
.center-card .brand { background: var(--side); border-radius: 14px; padding: 1.1rem; color: var(--side-fg); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 16.5rem minmax(0, 1fr); min-height: 100vh; }
.side { background: linear-gradient(180deg, var(--side), var(--side2)); color: var(--side-fg); padding: 1.1rem .8rem; display: flex; flex-direction: column; gap: 1rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; flex-direction: column; gap: .4rem; padding: .25rem .4rem .6rem; }
.brand img { display: block; width: 100%; max-width: 11.5rem; height: auto; }
.brand-text strong { display: block; font-size: 1.05rem; color: #fff; }
.brand-text small { color: var(--side-muted); }
.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.navgroup { color: var(--side-muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; padding: 1rem .6rem .3rem; font-weight: 700; }
.navlink { display: flex; align-items: center; gap: .65rem; padding: .38rem .55rem; border-radius: 12px; color: var(--side-fg); text-decoration: none; font-weight: 600; transition: background .15s, transform .12s; }
.navlink .ic { display: grid; place-items: center; width: 1.95rem; height: 1.95rem; border-radius: 50%; background: var(--c, var(--blue)); color: #fff; flex: 0 0 auto; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); transition: transform .15s; }
.navlink:hover { background: rgba(255, 255, 255, .09); } .navlink:hover .ic { transform: scale(1.08); }
.navlink.on { background: rgba(255, 255, 255, .16); box-shadow: inset 3px 0 0 var(--yellow); }
.side .btn.small { background: transparent; color: var(--side-fg); border-color: rgba(255, 255, 255, .3); margin-top: .5rem; }
.side-foot { border-top: 1px solid rgba(255, 255, 255, .15); padding-top: .75rem; display: flex; flex-direction: column; gap: .5rem; }
.side-foot .navlink { padding: .3rem .55rem; }
.kbd { margin-left: auto; font-size: .7rem; border: 1px solid rgba(255, 255, 255, .3); padding: .05rem .4rem; border-radius: 5px; color: var(--side-muted); }
.who { display: flex; justify-content: space-between; align-items: center; font-size: .88em; color: var(--side-muted); padding: 0 .4rem; }
.who .link { color: var(--side-fg); }
.main { min-width: 0; padding-bottom: 3rem; }
.hero { position: relative; overflow: hidden; padding: 1.5rem 1.8rem 3.6rem; background: linear-gradient(115deg, var(--hero-a) 0%, var(--hero-b) 55%, var(--hero-c) 100%); color: #fff; }
.hero::before { content: ""; position: absolute; inset: 0; background: var(--hero-img, none) center / cover; opacity: .35; mix-blend-mode: luminosity; }
.hero::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 54px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 54' preserveAspectRatio='none'%3E%3Cpath d='M0 30c180 26 360 26 540 6s360-34 540-12 270 20 360 8v22H0z' fill='%23EDF2F6' fill-opacity='.35'/%3E%3Cpath d='M0 40c200 18 380 16 560 0s380-22 560-6 220 14 320 6v14H0z' fill='%23EDF2F6'/%3E%3C/svg%3E") bottom / 100% 100% no-repeat; }
:root[data-theme="dark"] .hero::after { filter: brightness(.12); }
:root[data-theme="clean"] .hero { color: var(--head); padding-bottom: 1.2rem; } :root[data-theme="clean"] .hero::after { display: none; }
.drops { position: absolute; right: 2rem; top: .6rem; display: flex; gap: .5rem; opacity: .9; pointer-events: none; }
.drops i { display: block; width: 14px; height: 14px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--c); }
.top { position: relative; z-index: 1; display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.top-title { display: flex; flex-direction: column; gap: .15rem; }
.top-title h1 { font-size: 1.9rem; font-weight: 700; color: inherit; letter-spacing: -.01em; }
.top-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.hero .btn { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .35); color: #fff; backdrop-filter: blur(4px); }
.hero .btn:hover { background: rgba(255, 255, 255, .26); border-color: #fff; box-shadow: none; }
.hero .btn.primary { background: #fff; color: var(--navy); border-color: #fff; }
.asof { color: rgba(255, 255, 255, .8); font-size: .85em; }
:root[data-theme="clean"] .asof { color: var(--muted); }
.view { min-width: 0; padding: 0 1.8rem; margin-top: -2.3rem; position: relative; z-index: 2; }

/* ---------- grid and widgets ---------- */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1.1rem; align-items: stretch; }
.widget { background: var(--panel); border-radius: var(--radius); padding: 1.1rem 1.2rem; min-width: 0; position: relative; display: flex; flex-direction: column; box-shadow: var(--shadow); animation: rise .5s cubic-bezier(.2, .8, .2, 1) both; }
.widget.heading, .widget.control { background: transparent; box-shadow: none; padding: .2rem 0; }
.widget.heading { margin-top: .5rem; }
.widget.text { background: color-mix(in srgb, var(--blue) 6%, var(--panel)); box-shadow: none; border: 1px solid color-mix(in srgb, var(--blue) 18%, var(--line)); }
.span-1 { grid-column: span 1; } .span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-9 { grid-column: span 9; } .span-10 { grid-column: span 10; } .span-11 { grid-column: span 11; } .span-12 { grid-column: span 12; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.grid > .widget:nth-child(2) { animation-delay: .04s; } .grid > .widget:nth-child(3) { animation-delay: .08s; } .grid > .widget:nth-child(4) { animation-delay: .12s; } .grid > .widget:nth-child(5) { animation-delay: .16s; } .grid > .widget:nth-child(6) { animation-delay: .2s; }
.wbody { display: flex; flex-direction: column; gap: .45rem; flex: 1; min-width: 0; }
.widget h3 { font-size: .95rem; font-weight: 700; color: var(--head); }
.wsub { margin: 0; color: var(--muted); font-size: .84em; max-width: 72ch; }
.section-title { font-size: 1.15rem; font-weight: 700; display: flex; align-items: center; gap: .6rem; }
.section-title::before { content: ""; width: 5px; height: 1.2em; border-radius: 3px; background: linear-gradient(var(--blue), var(--teal)); }
.werr { color: var(--bad); font-size: .9em; padding: .4rem 0; } .werr.small { font-size: .8em; }
.wtools { position: absolute; top: .7rem; right: .8rem; display: flex; gap: .2rem; opacity: 0; transition: opacity .15s; z-index: 2; }
.widget:hover .wtools, .widget:focus-within .wtools { opacity: 1; }
.wt { display: grid; place-items: center; width: 1.8rem; height: 1.8rem; border: 0; border-radius: 8px; background: color-mix(in srgb, var(--blue) 9%, transparent); color: var(--muted); cursor: pointer; }
.wt:hover { background: var(--accent); color: #fff; }

/* ---------- tiles ---------- */
.kpi { overflow: hidden; cursor: default; transition: transform .18s cubic-bezier(.2, .8, .2, 1), box-shadow .18s; border-top: 4px solid var(--kc, var(--blue)); }
.kpi.warn { --kc: #F2B01E; } .kpi.bad { --kc: var(--pink); } .kpi.ok { --kc: var(--teal); }
.kpi.clickable { cursor: pointer; } .kpi.clickable:hover, .kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-up); }
.kpi .kpi-head { display: flex; align-items: center; gap: .5rem; padding-right: 1.6rem; }
.kpi .kpi-ic { display: grid; place-items: center; width: 1.7rem; height: 1.7rem; border-radius: 50%; background: color-mix(in srgb, var(--kc, var(--blue)) 18%, transparent); color: var(--kc, var(--blue)); }
.kpi .kpi-value { font-size: 2rem; font-weight: 700; color: var(--head); line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.01em; margin-top: .1rem; }
.kpi.warn .kpi-value { color: var(--warn); } .kpi.bad .kpi-value { color: var(--bad); } .kpi.ok .kpi-value { color: var(--ok); }
.kpi .kpi-sub { color: var(--muted); font-size: .85em; font-variant-numeric: tabular-nums; }
.kpi .kpi-go { color: var(--accent); font-size: .78em; font-weight: 700; margin-top: auto; padding-top: .35rem; opacity: .85; }
.kpi .kpi-viz { margin-top: .2rem; }
.kpi .kpi-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.spark { width: 100%; height: 44px; display: block; overflow: visible; }
.spark path.l { fill: none; stroke: var(--kc, var(--blue)); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: var(--len, 1000); stroke-dashoffset: var(--len, 1000); animation: dash 1.1s .1s ease forwards; }
.spark circle { fill: var(--kc, var(--blue)); }
.ring { width: 76px; height: 76px; flex: 0 0 auto; }
.ring .bg { fill: none; stroke: color-mix(in srgb, var(--kc, var(--blue)) 16%, transparent); stroke-width: 9; }
.ring .fg { fill: none; stroke: var(--kc, var(--blue)); stroke-width: 9; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; animation: ringIn 1s ease both; }
@keyframes ringIn { from { stroke-dashoffset: var(--circ); } }
.ring text { font-size: 15px; font-weight: 700; fill: var(--head); }
.rich p { margin: 0 0 .6rem; max-width: 78ch; } .rich p:last-child { margin: 0; }
.rich { font-size: .9em; color: var(--muted); } .rich strong { color: var(--head); font-weight: 700; }
.skeleton { height: 3.2rem; border-radius: 10px; background: linear-gradient(90deg, var(--line), transparent, var(--line)); background-size: 200% 100%; animation: sk 1.4s linear infinite; opacity: .6; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.empty { color: var(--muted); padding: 1.2rem 0; text-align: center; } .empty.big { padding: 3rem 1rem; font-size: 1.05em; }
.widget.add { border: 2px dashed var(--line); background: transparent; color: var(--accent); cursor: pointer; grid-column: span 12; padding: 1.2rem; font-weight: 700; box-shadow: none; }
.widget.editing { outline: 2px dashed color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 3px; }
.toolbar { position: absolute; top: -.95rem; right: .7rem; display: flex; gap: .25rem; flex-wrap: wrap; z-index: 4; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: .22rem; box-shadow: var(--shadow-up); }

/* ---------- charts ---------- */
.chart { min-width: 0; position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.chart text.vl { fill: var(--head); font-weight: 600; } .chart text.big { font-size: 17px; font-weight: 700; } .chart text.sub { font-size: 11.5px; }
.chart text.rl { fill: var(--fg); font-weight: 600; } .chart text.tm { font-weight: 700; font-size: 12.5px; } .chart text.tm.sub2 { font-weight: 500; font-size: 11.5px; opacity: .92; }
.chart .axis { stroke: var(--line); stroke-width: 1.4; } .chart .grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.chart .line { fill: none; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.chart .line.draw { stroke-dasharray: var(--len, 2000); stroke-dashoffset: var(--len, 2000); animation: dash 1.2s ease forwards; }
@keyframes dash { to { stroke-dashoffset: 0; } }
.chart .guide { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; }
.chart .hit { cursor: pointer; } .chart .hit:hover { fill: color-mix(in srgb, var(--accent) 6%, transparent); }
.chart .rowbg { fill: transparent; transition: fill .15s; } .chart g:hover > .rowbg { fill: color-mix(in srgb, var(--accent) 7%, transparent); }
.chart .mark { transition: opacity .18s, filter .18s; } .chart .mark.dim { opacity: .28; }
.chart .mark:not(.dim):hover { filter: brightness(1.08) saturate(1.1); }
.chart .grow { transform-box: fill-box; transform-origin: 50% 100%; animation: grow .6s cubic-bezier(.2, .8, .2, 1) both; }
.chart .growx { transform-box: fill-box; transform-origin: 0 50%; animation: growx .6s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes grow { from { transform: scaleY(0); opacity: .2; } } @keyframes growx { from { transform: scaleX(0); opacity: .2; } }
.chart .slice { transition: transform .18s, opacity .18s; animation: fadeIn .6s both; } .chart .slice:hover { transform: translate(var(--dx), var(--dy)); }
.chart .dotp { transition: r .15s; animation: fadeIn .5s both; cursor: pointer; }
@keyframes fadeIn { from { opacity: 0; } }
.legend { display: flex; flex-wrap: wrap; gap: .3rem .5rem; font-size: .8em; color: var(--muted); margin-bottom: .4rem; }
.leg { display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--line); background: var(--panel2); border-radius: 99px; padding: .12rem .65rem; cursor: pointer; color: var(--fg); transition: opacity .15s, border-color .15s; }
.leg:hover { border-color: var(--accent); } .leg.off { opacity: .45; text-decoration: line-through; }
.legend i, .leg i { display: inline-block; width: .65rem; height: .65rem; border-radius: 3px; }
.legend.col { flex-direction: column; align-items: flex-start; margin: 0; }
.donut { display: flex; align-items: center; gap: 1.4rem; flex-wrap: wrap; }
.tip { position: absolute; display: none; z-index: 20; background: var(--tip-bg); border-radius: 10px; box-shadow: var(--shadow-up); padding: .45rem .7rem; font-size: .8rem; pointer-events: none; max-width: 19rem; font-variant-numeric: tabular-nums; border: 1px solid var(--line); }
.tip .t { color: var(--muted); font-weight: 600; margin-bottom: .15rem; } .tip .tl { display: flex; align-items: center; justify-content: space-between; gap: 1rem; } .tip .tl.total { border-top: 1px solid var(--line); margin-top: .2rem; padding-top: .2rem; }
.tip i { display: inline-block; width: .6rem; height: .6rem; border-radius: 3px; margin-right: .4rem; }

/* ---------- tables ---------- */
.tools { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.tools input[type="search"] { width: 15rem; max-width: 100%; border-radius: 99px; padding-left: 1rem; }
.tablewrap { max-height: 30rem; overflow: auto; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); margin-top: .35rem; }
.tablewrap.short { max-height: none; }
table { border-collapse: collapse; width: 100%; font-size: .86em; font-variant-numeric: tabular-nums; }
th { position: sticky; top: 0; background: color-mix(in srgb, var(--blue) 8%, var(--panel)); text-align: left; padding: 0; border-bottom: 2px solid color-mix(in srgb, var(--blue) 30%, var(--line)); white-space: nowrap; z-index: 1; }
th button, th .th { all: unset; display: block; box-sizing: border-box; padding: .55rem .75rem; width: 100%; cursor: pointer; font-weight: 700; color: var(--head); font-size: .92em; }
th .th { cursor: default; } th button:hover { color: var(--accent); }
th.r button { text-align: right; }
th[aria-sort="ascending"] button::after { content: " \25B2"; font-size: .7em; color: var(--accent); } th[aria-sort="descending"] button::after { content: " \25BC"; font-size: .7em; color: var(--accent); }
td { padding: .5rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; position: relative; }
tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--blue) 2.5%, transparent); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.pick { cursor: pointer; } tbody tr.pick:hover td { background: color-mix(in srgb, var(--accent) 9%, transparent); }
td.wrap { min-width: 13rem; max-width: 26rem; }
td.has-bar { background-repeat: no-repeat; background-position: right center; background-size: var(--bar, 0%) 62%; background-image: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 22%, transparent)); }
.chip { display: inline-block; padding: .05rem .6rem; border-radius: 99px; font-size: .92em; font-weight: 700; background: color-mix(in srgb, var(--cc, var(--blue)) 14%, transparent); color: var(--cc, var(--blue)); }
.chip.Red { --cc: var(--bad); } .chip.Amber { --cc: var(--warn); } .chip.Green { --cc: var(--ok); }

/* ---------- controls ---------- */
.control { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; background: var(--panel); border-radius: 99px; padding: .35rem .5rem .35rem 1.1rem; box-shadow: var(--shadow); width: fit-content; max-width: 100%; }
.control .cl { font-size: .84em; font-weight: 700; color: var(--head); }
.seg { display: inline-flex; border-radius: 99px; overflow: hidden; background: var(--panel2); border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; padding: .3rem .95rem; cursor: pointer; font-weight: 600; transition: background .15s, color .15s; }
.seg button:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.control select, .control input[type="date"], .control input[type="number"] { width: auto; border-radius: 99px; padding: .3rem .8rem; }
.filters-note { font-size: .8em; color: var(--muted); }

/* ---------- drill-through drawer, palette, modal ---------- */
.drawer-back { position: fixed; inset: 0; background: rgba(0, 30, 48, .5); backdrop-filter: blur(2px); z-index: 60; animation: fadeIn .2s both; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(52rem, 94vw); background: var(--bg); z-index: 61; box-shadow: -20px 0 50px rgba(0, 20, 35, .35); display: flex; flex-direction: column; animation: slideIn .28s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } }
.drawer-head { padding: 1.1rem 1.3rem; background: linear-gradient(115deg, var(--hero-a), var(--hero-c)); color: #fff; display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.drawer-head h2 { color: #fff; font-size: 1.2rem; } .drawer-head p { margin: .2rem 0 0; opacity: .85; font-size: .88em; }
.drawer-body { padding: 1.1rem 1.3rem; overflow: auto; flex: 1; display: flex; flex-direction: column; gap: .8rem; }
.drawer .wt { background: rgba(255, 255, 255, .15); color: #fff; } .drawer .wt:hover { background: #fff; color: var(--navy); }
.kv { display: grid; grid-template-columns: minmax(8rem, 13rem) 1fr; gap: .1rem 1rem; background: var(--panel); border-radius: 12px; padding: .8rem 1rem; box-shadow: var(--shadow); }
.kv dt { color: var(--muted); font-size: .85em; padding: .3rem 0; border-bottom: 1px solid var(--line); } .kv dd { margin: 0; padding: .3rem 0; border-bottom: 1px solid var(--line); font-weight: 600; word-break: break-word; }
.palette-back { position: fixed; inset: 0; background: rgba(0, 30, 48, .5); backdrop-filter: blur(3px); z-index: 70; display: grid; align-items: start; justify-items: center; padding-top: 14vh; animation: fadeIn .15s both; }
.palette { width: min(36rem, 94vw); background: var(--panel); border-radius: 16px; box-shadow: var(--shadow-up); overflow: hidden; }
.palette input { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 1rem 1.2rem; font-size: 1.05rem; background: var(--panel); }
.palette ul { list-style: none; margin: 0; padding: .4rem; max-height: 22rem; overflow: auto; }
.palette li { display: flex; align-items: center; gap: .7rem; padding: .55rem .8rem; border-radius: 10px; cursor: pointer; }
.palette li.on, .palette li:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.palette li small { color: var(--muted); margin-left: auto; }
.modal-back { position: fixed; inset: 0; background: rgba(0, 30, 48, .55); backdrop-filter: blur(2px); z-index: 50; display: grid; place-items: center; padding: 1rem; animation: fadeIn .15s both; }
.modal { background: var(--panel); border-radius: 18px; width: min(40rem, 100%); max-height: calc(100vh - 2rem); display: flex; flex-direction: column; box-shadow: var(--shadow-up); }
.modal.wide { width: min(78rem, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: .95rem 1.2rem; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 1.1rem; }
.modal-body { padding: 1.1rem 1.2rem; overflow: auto; flex: 1; }
.modal-foot { padding: .8rem 1.2rem; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: .5rem; }
.editor { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 1.3rem; align-items: start; }
.editor-right { position: sticky; top: 0; }
.editor-right .widget { animation: none; }
.editor-form section { border-bottom: 1px solid var(--line); padding-bottom: .6rem; margin-bottom: .8rem; }
.editor-form h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: .5rem; }
.block { margin-bottom: .7rem; }
.list { display: flex; flex-direction: column; gap: .35rem; margin: .3rem 0; }
.item { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; padding: .4rem; border: 1px solid var(--line); border-radius: 10px; background: var(--panel2); }
.item.col { flex-direction: column; align-items: stretch; }
.item > select, .item > input { flex: 1 1 7rem; min-width: 0; width: auto; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem 1rem; }
.fwrap { display: flex; flex-direction: column; gap: .15rem; }
textarea.json { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; margin: .5rem 0; }
.typegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr)); gap: .7rem; }
.typecard { text-align: left; border: 1px solid var(--line); background: var(--panel2); border-radius: 14px; padding: .9rem; cursor: pointer; display: flex; flex-direction: column; gap: .25rem; transition: transform .15s, border-color .15s, box-shadow .15s; }
.typecard:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
details summary { cursor: pointer; color: var(--accent); font-weight: 600; }

/* ---------- settings ---------- */
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1rem; background: var(--panel); border-radius: 99px; padding: .3rem; width: fit-content; box-shadow: var(--shadow); }
.tab { padding: .45rem 1rem; text-decoration: none; color: var(--muted); border-radius: 99px; font-weight: 600; transition: background .15s; }
.tab:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); } .tab.on { background: var(--accent); color: #fff; }
.settings { display: flex; flex-direction: column; gap: 1.1rem; max-width: 64rem; }
.card { background: var(--panel); border-radius: var(--radius); padding: 1.1rem 1.3rem; box-shadow: var(--shadow); }
.card h2 { font-size: 1.02rem; margin-bottom: .6rem; } .card h3 { font-size: .95rem; margin: .8rem 0 .4rem; }
.intro { color: var(--muted); max-width: 72ch; margin: 0; }
.savebar { display: flex; justify-content: flex-end; margin-top: .6rem; }
.prow { display: grid; grid-template-columns: 17rem minmax(0, 1fr) auto; gap: 1rem; padding: .65rem 0; border-top: 1px solid var(--line); align-items: start; }
.prow:first-of-type { border-top: 0; }
.pmain { display: flex; flex-direction: column; gap: .25rem; } .pmain code { font-size: .8em; color: var(--muted); }
.pdesc { display: flex; flex-direction: column; gap: .3rem; }
.acts { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; }
.logo-preview { background: var(--side); display: inline-block; padding: 1rem; border-radius: 14px; margin-bottom: .6rem; } .logo-preview img { display: block; max-width: 16rem; height: auto; }
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: .7rem; }
.themecard { border: 2px solid var(--line); border-radius: 14px; padding: .5rem; cursor: pointer; background: var(--panel2); text-align: left; }
.themecard.on { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.themecard .sw { height: 3.2rem; border-radius: 9px; margin-bottom: .4rem; }
.callout { border: 1px solid var(--accent); border-radius: 12px; padding: .9rem; margin-top: .8rem; display: flex; flex-direction: column; gap: .5rem; }
.url { word-break: break-all; font-size: .85em; background: var(--panel2); padding: .4rem .5rem; border-radius: 6px; }
#toasts { position: fixed; bottom: 1rem; right: 1rem; z-index: 99; display: flex; flex-direction: column; gap: .4rem; }
.toast { background: var(--navy); color: #fff; padding: .6rem 1rem; border-radius: 10px; box-shadow: var(--shadow-up); max-width: 24rem; animation: rise .3s both; }
.toast.bad { background: var(--bad); }
.flash { animation: flash 1.6s ease; } @keyframes flash { 0%, 100% { box-shadow: var(--shadow); } 20%, 60% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--yellow) 85%, transparent), var(--shadow-up); } }

/* ---------- office screen ---------- */
body.tvmode { overflow: hidden; }
.tv { display: flex; flex-direction: column; height: 100vh; background: var(--bg); }
.tv-head { display: flex; align-items: center; gap: 1.2rem; padding: .8rem 1.6rem; background: linear-gradient(115deg, var(--hero-a), var(--hero-b) 60%, var(--hero-c)); color: #fff; box-shadow: 0 4px 18px rgba(0, 30, 48, .3); position: relative; z-index: 3; }
.tv-head .brand { flex-direction: row; align-items: center; padding: 0; } .tv-head .brand img { max-height: 2.8rem; width: auto; } .tv-head .brand-text { display: none; }
.tv-head h1 { flex: 1; font-size: 1.7rem; font-weight: 700; color: #fff; }
.tv-right { display: flex; flex-direction: column; align-items: flex-end; font-size: .95rem; } .tv-right .asof { color: rgba(255, 255, 255, .8); }
.tv-view { flex: 1; overflow: hidden; padding: 1.1rem 1.6rem; }
.tv .kpi .kpi-value { font-size: 2.7rem; } .tv .widget { padding: 1rem 1.25rem; } .tv .wtools { display: none; }
.tv-foot { padding: .5rem 1.6rem .9rem; display: flex; flex-direction: column; gap: .55rem; }
.tv-dots { display: flex; gap: .45rem; justify-content: center; } .tv-dots span { width: .65rem; height: .65rem; border-radius: 50%; background: var(--line); } .tv-dots span.on { background: var(--accent); }
.tv-bar { height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; } .tv-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--blue), var(--teal)); }
.tv .tablewrap { max-height: none; overflow: hidden; } .tv .tools { display: none; }

@media (max-width: 1000px) { .editor { grid-template-columns: 1fr; } .editor-right { position: static; } .prow { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .nav { flex-direction: row; flex-wrap: wrap; } .navgroup { display: none; }
  .hero { padding: 1rem 1rem 3rem; } .view { padding: 0 .8rem; }
  .widget { grid-column: span 12 !important; } .widget.kpi { grid-column: span 6 !important; }
  .row2 { grid-template-columns: 1fr; }
  .kpi .kpi-value { font-size: 1.45rem; overflow-wrap: anywhere; }
  .wtools { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001s !important; animation-delay: 0s !important; transition-duration: .001s !important; } }

/* tiles get wider on ordinary screens so big dollar figures fit */
@media (max-width: 1750px) { .grid > .widget.kpi.span-2 { grid-column: span 3; } }
@media (max-width: 1280px) { .grid > .widget.kpi.span-2, .grid > .widget.kpi.span-3 { grid-column: span 4; } }
@media (max-width: 900px) { .grid > .widget.kpi { grid-column: span 6 !important; } }
.control { border-radius: 18px; padding: .45rem .6rem .45rem 1.1rem; }

/* the big figure scales to its tile and never breaks across two lines */
.kpi { container-type: inline-size; }
.kpi .kpi-value { font-size: clamp(1.35rem, 12.5cqw, 2.15rem); white-space: nowrap; overflow-wrap: normal; }
.tv .kpi .kpi-value { font-size: clamp(1.6rem, 13cqw, 2.9rem); }
.kpi .kpi-row > div:first-child { min-width: 0; }

/* definition notes use the full width of their box: long text flows into columns instead of one narrow strip */
.rich { font-size: .92em; line-height: 1.55; }
.rich p { max-width: none; break-inside: avoid; }
.widget.text .rich.cols { columns: 26rem 3; column-gap: 2.4rem; }
.widget.text { padding: 1.1rem 1.4rem; }
.rich p { break-inside: auto; orphans: 2; widows: 2; }

/* ---------- table filters, sort and date range ---------- */
.tools select { max-width: 14rem; }
.tools .badge { display: inline-block; min-width: 1.2rem; margin-left: .4rem; padding: 0 .35rem; border-radius: 99px; background: var(--accent); color: #fff; font-size: .8em; font-weight: 700; text-align: center; }
.filterpanel { margin-top: .5rem; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: color-mix(in srgb, var(--blue) 4%, var(--panel)); display: grid; gap: .8rem; max-height: 22rem; overflow: auto; }
.filterpanel[hidden] { display: none; }
.filterpanel .fl { font-size: .8em; font-weight: 700; color: var(--muted); margin-bottom: .25rem; text-transform: uppercase; letter-spacing: .03em; }
.filterpanel .fgroup .row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.filterpanel .fgroup label { display: flex; align-items: center; gap: .4rem; font-size: .9em; }
.filterpanel .presets { margin-top: .4rem; }
.filterpanel .fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: .7rem .9rem; }
.filterpanel .fitem .row { display: flex; gap: .4rem; }
.filterpanel .fitem input, .filterpanel .fitem select { width: 100%; min-width: 0; box-sizing: border-box; }
.fchip { all: unset; cursor: pointer; padding: .15rem .65rem; border-radius: 99px; font-size: .82em; font-weight: 600; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.fchip:hover, .fchip:focus-visible { background: color-mix(in srgb, var(--accent) 26%, transparent); }
.chips:has(.fchip) { margin-top: .5rem; gap: .35rem; }
.asof.stale, .tv-right .asof.stale { color: #FFC107; font-weight: 700; }

/* ---------- layout fixes kept from the 20 Oct refresh (colours and style are the original ones) ---------- */
.kpi-strip { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 1.1rem; --cols: 4; }
.kpi-strip > .widget { grid-column: auto !important; flex: 1 1 calc((100% - (var(--cols) - 1) * 1.1rem) / var(--cols)); min-width: 12.5rem; }
.filterbar { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; }
.filterbar > .widget { background: transparent; box-shadow: none; padding: 0; width: auto; flex: 0 1 auto; grid-column: auto !important; }
.filterbar .filters-note { display: none; }
.kpi .kpi-head { align-items: flex-start; min-height: 2.3rem; }
.kpi .kpi-row { align-items: flex-end; }
.kpi .spark { margin-top: auto; }
.widget.text .rich.cols { column-count: 1; columns: auto; }
@media (max-width: 900px) { .filterbar .control { flex-wrap: wrap; } }

/* donuts keep a fixed size beside their key, so a wide card does not blow them up */
.donut { justify-content: center; }
.donut svg { width: 260px; max-width: 100%; height: auto; flex: 0 0 auto; }
.donut .legend.col { flex: 1 1 11rem; min-width: 0; }

/* cards take the height of their own content, so a short card is not stretched into empty white space next to a tall one; tiles stay equal */
.grid { align-items: start; }
.kpi-strip { align-items: stretch; }
