/* ==========================================================================
   PileManager — application stylesheet (no external dependencies)

   House style: a contractor's back-office system, not a consumer product.
   Flat surfaces, hairline rules, one navy accent, tabular figures, and a
   fixed side rail so the application reads as a tool rather than a page.
   ========================================================================== */

:root {
  color-scheme: light;

  /* neutrals — cool grey, the colour of drawing paper under office light */
  --surface-0:  #eef0f3;   /* app background          */
  --surface-1:  #ffffff;   /* cards, inputs           */
  --surface-2:  #f3f5f7;   /* zebra, wells, tracks    */
  --surface-3:  #e7eaee;   /* headers inside cards    */
  --border:     #d7dce3;
  --border-str: #bcc4ce;

  --text-primary:   #16202c;
  --text-secondary: #4b5766;
  --text-muted:     #78838f;

  /* navy: the only strong colour in the interface */
  --navy:       #12365f;
  --navy-dark:  #0d2946;
  --navy-light: #1d5089;

  --accent:      #1c4c86;
  --accent-weak: #e8eef6;
  --accent-ink:  #123563;

  --good:     #16704a;
  --good-bg:  #e6f2ec;
  --warn:     #8a6100;
  --warn-bg:  #f8f0dd;
  --danger:   #a52630;
  --danger-bg:#f8e9ea;
  --info-bg:  #e8eef6;

  --series-1: #1c4c86;
  --series-2: #4a7ab0;
  --series-3: #7d95ab;

  --radius:   4px;
  --radius-s: 3px;
  --shadow:   none;

  --side-w:   214px;
  --top-h:    54px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-0:  #11161c;
    --surface-1:  #171d25;
    --surface-2:  #1e262f;
    --surface-3:  #232c37;
    --border:     #2b343f;
    --border-str: #3b4653;

    --text-primary:   #eef2f6;
    --text-secondary: #b0bac6;
    --text-muted:     #8794a2;

    --navy:      #0f2b4a;
    --navy-dark: #0a1e36;

    --accent:      #5c93d6;
    --accent-weak: #17304d;
    --accent-ink:  #9dc0e8;

    --good:     #4fae86;  --good-bg:  #12291f;
    --warn:     #c99a3a;  --warn-bg:  #2c2411;
    --danger:   #d97b82;  --danger-bg:#2e1a1c;
    --info-bg:  #17304d;

    --series-1: #5c93d6;
    --series-2: #4a7ab0;
    --series-3: #7d95ab;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0:  #11161c;
  --surface-1:  #171d25;
  --surface-2:  #1e262f;
  --surface-3:  #232c37;
  --border:     #2b343f;
  --border-str: #3b4653;
  --text-primary:   #eef2f6;
  --text-secondary: #b0bac6;
  --text-muted:     #8794a2;
  --navy:      #0f2b4a;
  --navy-dark: #0a1e36;
  --accent:      #5c93d6;
  --accent-weak: #17304d;
  --accent-ink:  #9dc0e8;
  --good: #4fae86;  --good-bg: #12291f;
  --warn: #c99a3a;  --warn-bg: #2c2411;
  --danger: #d97b82; --danger-bg: #2e1a1c;
  --info-bg: #17304d;
  --series-1: #5c93d6;
  --series-2: #4a7ab0;
  --series-3: #7d95ab;
}

/* -------------------------------------------------------------- base */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--surface-0);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.005em; }
h1 { font-size: 19px; }
h2 { font-size: 14px; letter-spacing: .01em; }
h3 { font-size: 13px; }

p { margin: 0 0 10px; }
p:last-child { margin-bottom: 0; }

.muted     { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.small     { font-size: 12px; }
.mono      { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.nowrap    { white-space: nowrap; }
.right     { text-align: right; }
.center    { text-align: center; }

code {
  font-family: var(--mono); font-size: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 1px 4px; border-radius: 2px;
}
.code-block {
  font-family: var(--mono); font-size: 12px; line-height: 1.6;
  background: var(--surface-2); border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  padding: 9px 11px; margin: 8px 0 0;
  overflow-x: auto; white-space: pre-wrap; word-break: break-all;
  color: var(--text-secondary);
}

svg { flex: none; }

/* -------------------------------------------------------------- shell */

.side {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w); z-index: 50;
  display: flex; flex-direction: column;
  background: var(--navy);
  border-right: 1px solid var(--navy-dark);
  color: #dbe4ef;
}

.side-brand {
  display: flex; align-items: center; gap: 9px;
  height: var(--top-h); padding: 0 14px; flex: none;
  border-bottom: 1px solid rgba(255,255,255,.10);
  color: #fff; font-weight: 600; font-size: 14.5px; letter-spacing: .01em;
}
.side-brand:hover { text-decoration: none; color: #fff; }
.side-brand .brand-mark {
  width: 26px; height: 26px; flex: none; border-radius: 3px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.13); color: #fff;
}
.side-brand .brand-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.side-scroll { flex: 1; overflow-y: auto; padding: 12px 0 24px; }

.side-group {
  padding: 14px 15px 5px;
  font-size: 10px; font-weight: 700; letter-spacing: .10em; text-transform: uppercase;
  color: rgba(255,255,255,.42);
}
.side-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 15px;
  color: #cfdae8; font-size: 13px; font-weight: 500;
  border-left: 2px solid transparent;
}
.side-link:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.side-link.active {
  background: rgba(255,255,255,.11); color: #fff; font-weight: 600;
  border-left-color: #7fb0e8;
}
.side-link svg { opacity: .85; }
.side-link.active svg { opacity: 1; }

.side-foot {
  flex: none; padding: 11px 15px;
  border-top: 1px solid rgba(255,255,255,.10);
  font-size: 11px; color: rgba(255,255,255,.45);
}

.side-credit { display: block; margin-top: 3px; color: rgba(255,255,255,.32); font-size: 10.5px; }

.shell { margin-left: var(--side-w); min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px; height: var(--top-h); flex: none;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}
.topbar-context { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar-context .tc-icon { color: var(--text-muted); }
.topbar-context .tc-name {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-context .tc-sub { font-size: 12px; color: var(--text-muted); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar-right select { min-width: 190px; }

.user-chip {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 9px 4px 5px; border-radius: var(--radius-s);
  color: var(--text-secondary); font-size: 12.5px; font-weight: 550;
  border: 1px solid var(--border);
}
.user-chip:hover { background: var(--surface-2); text-decoration: none; color: var(--text-primary); }
.user-avatar {
  width: 22px; height: 22px; flex: none; border-radius: 2px;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  font-size: 10.5px; font-weight: 700; letter-spacing: .02em;
}

/* the mobile bar that replaces the side rail */
.side-toggle { display: none; }

.page { flex: 1; max-width: 1380px; width: 100%; padding: 20px 20px 56px; }

.page-head {
  display: flex; align-items: flex-start; gap: 16px;
  padding-bottom: 13px; margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.page-head .spacer { margin-left: auto; }
.page-head h1 { display: flex; align-items: center; gap: 9px; }
.page-head h1 .page-icon { color: var(--accent); }
.page-title-sub { color: var(--text-muted); font-size: 12.5px; margin-top: 3px; }

/* -------------------------------------------------------------- cards */

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.card-head h2 {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-secondary);
}
.card-head h2 svg { color: var(--accent); }
.card-head .spacer { margin-left: auto; }
.card-body { padding: 15px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 940px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}

/* -------------------------------------------------------------- stat tiles */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 1px;
  margin-bottom: 18px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
/* the shadow paints the 1px gap, so a half-filled last row has no stray rules */
.stat {
  background: var(--surface-1); padding: 11px 14px 12px;
  box-shadow: 1px 0 0 0 var(--border), 0 1px 0 0 var(--border);
}
.stat-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stat-value {
  margin-top: 5px;
  font-size: 23px; font-weight: 600; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}
.stat-value .unit { font-size: 12.5px; font-weight: 500; color: var(--text-muted); margin-left: 3px; }
.stat-delta { margin-top: 3px; font-size: 11.5px; display: flex; align-items: center; gap: 4px; }
.stat-delta.up   { color: var(--good); }
.stat-delta.down { color: var(--danger); }
.stat-delta.flat { color: var(--text-muted); }

/* -------------------------------------------------------------- charts */

.chart { width: 100%; height: auto; display: block; }
.chart-grid  { stroke: var(--border); stroke-width: 1; }
.chart-axis  { fill: var(--text-muted); font-size: 11px; font-family: var(--font); }
.chart-line  { fill: none; stroke: var(--series-1); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.chart-area  { fill: var(--series-1); opacity: .09; stroke: none; }
.chart-dot   { fill: var(--series-1); }
.chart-empty { fill: var(--text-muted); font-size: 13px; font-family: var(--font); }
.chart-hit   { fill: transparent; }
.chart-hit:hover { fill: var(--accent); opacity: .07; }

.barlist { display: flex; flex-direction: column; gap: 7px; }
.barlist-row { display: grid; grid-template-columns: 130px 1fr 74px; align-items: center; gap: 10px; }
.barlist-label {
  font-size: 12.5px; color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.barlist-track { background: var(--surface-2); border: 1px solid var(--border); height: 15px; overflow: hidden; }
.barlist-fill  { background: var(--series-1); height: 100%; }
.barlist-value { font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.barlist-value .unit { color: var(--text-muted); font-size: 11px; }

/* soil profile */
.soil-svg { width: 100%; height: auto; max-width: 280px; display: block; }
.soil-tick  { stroke: var(--border-str); stroke-width: 1; }
.soil-depth { fill: var(--text-secondary); font-size: 10px; font-family: var(--mono); }
.soil-name  { fill: var(--text-secondary); font-size: 10.5px; font-family: var(--font); }
.soil-axis-title { fill: var(--text-muted); font-size: 10px; font-family: var(--font); }

/* -------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; }

table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data th, table.data td {
  padding: 7px 12px; text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.data th {
  font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-secondary); background: var(--surface-2);
  border-bottom: 1px solid var(--border-str);
  position: sticky; top: 0; white-space: nowrap;
}
table.data tbody tr:nth-child(even) { background: var(--surface-2); }
table.data tbody tr:hover { background: var(--accent-weak); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* key/value display table */
table.kv { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.kv th, table.kv td { padding: 6px 10px; border-bottom: 1px solid var(--border); }
table.kv th {
  text-align: left; font-weight: 500; color: var(--text-secondary);
  width: 52%; font-size: 12.5px;
}
table.kv td { text-align: right; font-variant-numeric: tabular-nums; }
table.kv td .unit { color: var(--text-muted); font-size: 11.5px; margin-left: 2px; }
table.kv tr:last-child th, table.kv tr:last-child td { border-bottom: none; }
table.kv tr.is-computed th { color: var(--accent-ink); }
table.kv tr.is-computed td { font-weight: 600; }

/* -------------------------------------------------------------- forms */

.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }

label.label {
  display: block; margin-bottom: 4px;
  font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-secondary);
}
label.label .req { color: var(--danger); margin-left: 2px; }
label.label .unit { color: var(--text-muted); font-weight: 500; text-transform: none; letter-spacing: 0; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=time], input[type=datetime-local], input[type=search],
input[type=url], input[type=file], select, textarea {
  width: 100%;
  padding: 6px 9px;
  font-family: inherit; font-size: 13px; color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--border-str);
  border-radius: var(--radius-s);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
input[type=file] { padding: 5px 8px; font-size: 12.5px; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-weak);
}
input:disabled, select:disabled, textarea:disabled,
input[readonly] {
  background: var(--surface-2); color: var(--text-secondary); cursor: not-allowed;
}
textarea { min-height: 74px; resize: vertical; }

.check {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 13px; color: var(--text-secondary); cursor: pointer;
}
.check input { width: auto; margin-top: 2px; }

.input-error { border-color: var(--danger) !important; }
.field-error { margin-top: 3px; font-size: 12px; color: var(--danger); }
.field-help  { margin-top: 4px; font-size: 11.5px; color: var(--text-muted); line-height: 1.5; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 14px; }
.form-grid .field-wide { grid-column: 1 / -1; }
.form-grid.cols-2 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.form-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }

.computed-value {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 9px;
  background: var(--accent-weak);
  border: 1px solid var(--accent);
  border-left-width: 2px;
  border-radius: var(--radius-s);
  font-variant-numeric: tabular-nums; font-weight: 600;
  color: var(--accent-ink);
  min-height: 32px;
}
.computed-value .unit { font-weight: 400; font-size: 11.5px; opacity: .8; }

/* -------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  font-family: inherit; font-size: 13px; font-weight: 600; line-height: 1.35;
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--border-str);
  border-radius: var(--radius-s);
  cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn svg { opacity: .75; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-primary svg { opacity: 1; }
.btn-danger { color: var(--danger); border-color: var(--danger); background: var(--surface-1); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { padding: 3px 8px; font-size: 12px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-2); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* -------------------------------------------------------------- tool grid (admin console) */

.tool-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: 1px; background: var(--surface-1);
}
.tool {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 14px;
  background: var(--surface-1); color: var(--text-primary);
  box-shadow: 1px 0 0 0 var(--border), 0 1px 0 0 var(--border);
}
.tool:hover { background: var(--accent-weak); text-decoration: none; }
.tool-icon {
  width: 32px; height: 32px; flex: none;
  display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 2px; color: var(--accent);
}
.tool:hover .tool-icon { background: var(--accent); border-color: var(--accent); color: #fff; }
.tool-text { min-width: 0; flex: 1; }
.tool-text strong { display: block; font-size: 13px; font-weight: 600; }
.tool-text span {
  display: block; font-size: 11.5px; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tool-go { color: var(--border-str); flex: none; }
.tool:hover .tool-go { color: var(--accent); }

/* -------------------------------------------------------------- badges & alerts */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px; border-radius: 2px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  background: var(--surface-2); color: var(--text-secondary);
  border: 1px solid var(--border-str);
}
.badge.ok    { background: var(--good-bg);   color: var(--good);   border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.badge.info  { background: var(--info-bg);   color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.badge.warn  { background: var(--warn-bg);   color: var(--warn);   border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.badge.err   { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.badge.muted { background: var(--surface-2); color: var(--text-muted); }

.alert {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 9px 12px; margin-bottom: 12px;
  border: 1px solid var(--border-str);
  border-left-width: 3px;
  border-radius: var(--radius-s);
  font-size: 12.5px;
  background: var(--surface-1);
}
.alert-icon { flex: none; display: inline-flex; padding-top: 1px; }
.alert-success { background: var(--good-bg);   border-color: var(--good);   color: var(--good); }
.alert-error   { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.alert-warn    { background: var(--warn-bg);   border-color: var(--warn);   color: var(--warn); }
.alert-info    { background: var(--info-bg);   border-color: var(--accent); color: var(--accent-ink); }
.alert div { color: var(--text-primary); }
.alert-error div, .alert-success div, .alert-warn div, .alert-info div { color: inherit; }

.alert ul { margin: 4px 0 0; padding-left: 18px; }
.alert li { margin-bottom: 2px; }

/* -------------------------------------------------------------- filters */

.filters {
  display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
  padding: 11px 14px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.filters .field { margin-bottom: 0; }
.filters input, .filters select { min-width: 130px; }
.filters .spacer { margin-left: auto; }

.range-chips { display: flex; gap: 0; }
.range-chips a {
  padding: 5px 11px;
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
  border: 1px solid var(--border-str);
  border-right-width: 0;
  background: var(--surface-1);
}
.range-chips a:first-child { border-radius: var(--radius-s) 0 0 var(--radius-s); }
.range-chips a:last-child  { border-radius: 0 var(--radius-s) var(--radius-s) 0; border-right-width: 1px; }
.range-chips a:hover { background: var(--surface-2); text-decoration: none; }
.range-chips a.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* -------------------------------------------------------------- grid editor (repeating rows) */

.gridtable { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.gridtable th {
  padding: 6px 8px; text-align: left;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-secondary); background: var(--surface-2);
  border-bottom: 1px solid var(--border-str);
}
.gridtable td { padding: 3px 4px; border-bottom: 1px solid var(--border); }
.gridtable td:last-child { width: 34px; }
.gridtable input, .gridtable select { padding: 4px 7px; font-size: 12.5px; }
.gridtable tfoot td { padding: 8px 4px; border-bottom: none; background: var(--surface-2); }
.row-remove {
  border: none; background: transparent; color: var(--text-muted);
  cursor: pointer; font-size: 15px; line-height: 1; padding: 4px 6px; border-radius: 2px;
}
.row-remove:hover { background: var(--danger-bg); color: var(--danger); }

/* -------------------------------------------------------------- section nav inside the form */

.section-nav {
  display: flex; gap: 2px; flex-wrap: wrap;
  padding: 8px 14px; margin-bottom: 16px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
  position: sticky; top: var(--top-h); z-index: 20;
}
.section-nav a {
  padding: 4px 10px; border-radius: var(--radius-s);
  font-size: 12px; font-weight: 550; color: var(--text-secondary);
}
.section-nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text-primary); }

/* -------------------------------------------------------------- login */

.auth-wrap {
  min-height: 100vh; display: grid; place-items: center;
  padding: 24px; background: var(--surface-0);
}
.auth-card {
  width: 100%; max-width: 372px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-top: 3px solid var(--navy);
  border-radius: var(--radius);
  padding: 26px;
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.auth-brand .brand-mark {
  width: 30px; height: 30px; border-radius: 3px;
  display: grid; place-items: center;
  background: var(--navy); color: #fff;
}
.auth-title { font-size: 17px; font-weight: 650; }
.auth-foot {
  margin: 16px 0 0; text-align: center;
  font-size: 11.5px; color: var(--text-muted);
}

/* -------------------------------------------------------------- misc */

.pagination { display: flex; gap: 6px; align-items: center; justify-content: center; padding: 14px; }
.empty-state { padding: 40px 20px; text-align: center; color: var(--text-muted); }
.empty-state h3 { color: var(--text-secondary); margin-bottom: 6px; }
.empty-state svg { color: var(--border-str); margin-bottom: 10px; }

.divider { height: 1px; background: var(--border); margin: 15px 0; border: none; }

.legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--text-secondary); }
.legend-swatch { width: 11px; height: 11px; border: 1px solid var(--border-str); }

.tooltip {
  position: fixed; z-index: 100; pointer-events: none;
  padding: 5px 8px; border-radius: 2px;
  background: var(--navy-dark); color: #fff; font-size: 12px;
  opacity: 0; transition: opacity .1s;
  white-space: nowrap;
}
.tooltip.show { opacity: 1; }
.tooltip .t-label { color: #9fb4cc; margin-right: 6px; }

/* rows written by the production auto-fill */
.gridtable tr.row-filled > td { background: var(--accent-weak); }
.gridtable tr.row-filled > td:first-child { box-shadow: inset 2px 0 0 var(--accent); }

/* ---------------------------------------------------------------- landing page */
.land { min-height: 100vh; display: flex; flex-direction: column; background: var(--surface-0); }
.land-top {
  background: var(--navy); color: #fff;
  border-bottom: 3px solid var(--navy-dark);
}
.land-top-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 24px;
  height: 58px; display: flex; align-items: center;
}
.land-brand { display: flex; align-items: center; gap: 11px; }
.land-brand .brand-mark {
  width: 28px; height: 28px; border-radius: 3px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.14); color: #fff;
}
.land-name { font-size: 16px; font-weight: 650; letter-spacing: .01em; color: #fff; }
.land-tag { margin-left: auto; font-size: 12px; color: rgba(255,255,255,.6); letter-spacing: .06em; text-transform: uppercase; }

.land-inner {
  flex: 1; width: 100%; max-width: 1180px; margin: 0 auto;
  padding: 44px 24px 40px;
  display: grid; grid-template-columns: 1.25fr 0.95fr; gap: 52px; align-items: start;
}
.land-h1 { font-size: 32px; line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 16px; max-width: 24ch; }
.land-lead { font-size: 15px; line-height: 1.65; color: var(--text-secondary); margin: 0 0 28px; max-width: 56ch; }

.land-features {
  display: grid; gap: 1px; margin-bottom: 26px;
  background: var(--surface-1); border: 1px solid var(--border);
}
.land-feature + .land-feature { box-shadow: 0 -1px 0 0 var(--border); }
.land-feature {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 13px 15px; background: var(--surface-1);
}
.land-feature .lf-icon {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  background: var(--accent-weak); color: var(--accent);
  border-radius: 2px;
}
.land-feature strong { display: block; font-size: 13.5px; margin-bottom: 2px; }
.land-feature span { font-size: 12.5px; color: var(--text-secondary); line-height: 1.5; }

.land-points { list-style: none; margin: 0 0 24px; padding: 0; display: grid; gap: 10px; }
.land-points li {
  position: relative; padding-left: 20px;
  font-size: 13.5px; line-height: 1.6; color: var(--text-secondary);
}
.land-points li::before {
  content: ""; position: absolute; left: 2px; top: 8px;
  width: 6px; height: 6px; background: var(--accent);
}
.land-points strong { color: var(--text-primary); font-weight: 600; }

.land-stat { font-size: 12.5px; color: var(--text-secondary); margin: 0; }
.land-stat strong { color: var(--text-primary); font-variant-numeric: tabular-nums; }

.land-login { position: sticky; top: 32px; }
.land-card { width: 100%; max-width: 420px; margin: 0; }
.land-signin { font-size: 18px; margin: 0 0 4px; letter-spacing: -0.01em; }
.land-help {
  margin: 16px 0 0; padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-secondary); line-height: 1.55;
}
/* showcase bands, each one screen of the application with its explanation */
.land-band { border-top: 1px solid var(--border); background: var(--surface-1); }
.land-band.alt { background: var(--surface-0); }

.land-band-inner {
  max-width: 1180px; margin: 0 auto; padding: 52px 24px;
  display: grid; grid-template-columns: 0.85fr 1.15fr;
  gap: 46px; align-items: center;
}
/* image first on the reversed band, and the wider column travels with it */
.land-band-inner.reverse { grid-template-columns: 1.15fr 0.85fr; }
.land-band-inner.reverse .band-text { order: 2; }
.land-band-inner.reverse .shot     { order: 1; }

.land-band-narrow { max-width: 940px; margin: 0 auto; padding: 52px 24px; }

.band-eyebrow {
  display: inline-flex; align-items: center; gap: 7px; margin-bottom: 10px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent);
}
.band-eyebrow.center { display: flex; justify-content: center; }
.band-h2 { font-size: 24px; line-height: 1.25; letter-spacing: -0.015em; margin: 0 0 14px; }
.band-h2.center { text-align: center; }
.band-text p { font-size: 14px; line-height: 1.7; color: var(--text-secondary); margin: 0 0 14px; }
.band-sub {
  text-align: center; max-width: 62ch; margin: 0 auto 26px;
  font-size: 13.5px; line-height: 1.7; color: var(--text-secondary);
}

.band-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.band-list li {
  position: relative; padding-left: 22px;
  font-size: 13px; color: var(--text-secondary);
}
.band-list li::before {
  content: ""; position: absolute; left: 4px; top: 7px;
  width: 7px; height: 7px; border: 1.5px solid var(--accent); border-radius: 50%;
}

/* a framed screenshot */
.shot { margin: 0; min-width: 0; }
.shot img {
  display: block; width: 100%; height: auto;
  border: 1px solid var(--border-str); border-radius: var(--radius);
  background: var(--surface-1);
}
.shot figcaption {
  margin-top: 9px; font-size: 11.5px; color: var(--text-muted);
  letter-spacing: .02em;
}

/* how a day runs */
.land-steps {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
  margin-top: 26px; background: var(--border);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.step { background: var(--surface-1); padding: 20px 18px; }
.step-no {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px; margin-bottom: 11px;
  background: var(--navy); color: #fff;
  font-size: 13px; font-weight: 700; line-height: 1; border-radius: 2px;
}
.step strong { display: block; font-size: 14px; margin-bottom: 5px; }
/* :not() keeps this off the numbered badge, which would otherwise win on
   specificity and paint the digit grey on navy */
.step > span:not(.step-no) {
  display: block; font-size: 12.5px; line-height: 1.6; color: var(--text-secondary);
}

.land-foot {
  border-top: 1px solid var(--border);
  text-align: center; padding: 18px 24px 24px;
  font-size: 12px; color: var(--text-muted);
}

@media (max-width: 900px) {
  .land-band-inner,
  .land-band-inner.reverse { grid-template-columns: 1fr; gap: 26px; padding: 36px 20px; }
  .land-band-inner.reverse .band-text { order: 1; }
  .land-band-inner.reverse .shot     { order: 2; }
  .land-band-narrow { padding: 36px 20px; }
  .land-steps { grid-template-columns: 1fr; }
  .band-h2 { font-size: 21px; }
}

@media (max-width: 900px) {
  .land-inner { grid-template-columns: 1fr; gap: 32px; padding: 32px 20px 28px; }
  .land-h1 { font-size: 27px; max-width: none; }
  .land-login { position: static; }
  .land-card { max-width: none; }
}

/* ---------------------------------------------------------------- overview board */

.prog { display: flex; align-items: center; gap: 10px; }
.prog-track {
  flex: 1; height: 8px;
  background: var(--surface-2); border: 1px solid var(--border); overflow: hidden;
}
.prog-fill { height: 100%; background: var(--accent); }
.prog-fill.good   { background: var(--good); }
.prog-fill.warn   { background: var(--warn); }
.prog-fill.danger { background: var(--danger); }
.prog-num { font-size: 12px; font-variant-numeric: tabular-nums; min-width: 46px; text-align: right; }

tr.row-total td { background: var(--surface-3); font-weight: 600; }

/* vertical column chart */
.colchart { display: flex; align-items: flex-end; gap: 6px; }
.col-item { flex: 1; display: flex; flex-direction: column; height: 100%; min-width: 0; }
.col-value {
  font-size: 11px; text-align: center; color: var(--text-secondary);
  font-variant-numeric: tabular-nums; margin-bottom: 4px; height: 15px;
}
.col-bar-wrap { flex: 1; display: flex; align-items: flex-end; }
.col-bar { width: 100%; background: var(--series-1); }
.col-label {
  font-size: 10.5px; text-align: center; color: var(--text-muted);
  margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* donut */
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut { flex: none; }
.donut-centre { font-size: 20px; font-weight: 700; fill: var(--text-primary); }
.donut-note   { font-size: 9px; fill: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.donut-legend { flex: 1; min-width: 130px; display: grid; gap: 8px; }
.donut-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.donut-swatch { width: 10px; height: 10px; flex: none; }
.donut-label { flex: 1; color: var(--text-secondary); }
.donut-val { font-variant-numeric: tabular-nums; color: var(--text-primary); font-weight: 600; }

.board-head {
  display: flex; align-items: center; gap: 18px;
  padding: 15px 20px; margin-bottom: 18px;
  border: 1px solid var(--navy-dark);
  border-radius: var(--radius);
  background: var(--navy);
  color: #fff;
}
.board-head h1 { margin: 0; font-size: 19px; letter-spacing: .01em; color: #fff; }
.board-sub { font-size: 12.5px; color: rgba(255,255,255,.66); margin-top: 3px; }
.board-stamp { text-align: right; }
.board-stamp .bs-label {
  display: block; font-size: 9.5px; text-transform: uppercase; letter-spacing: .1em;
  color: rgba(255,255,255,.55);
}
.board-stamp .bs-value { font-size: 12.5px; font-weight: 600; white-space: nowrap; }

.board { display: grid; grid-template-columns: 1fr 226px; gap: 18px; align-items: start; }
.board-main { min-width: 0; display: grid; gap: 16px; }

/* headline tiles */
.tiles {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 1px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.tile {
  position: relative; background: var(--surface-1); padding: 13px 14px 14px;
  box-shadow: 1px 0 0 0 var(--border), 0 1px 0 0 var(--border);
}
.tile-top { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.tile-icon {
  width: 30px; height: 30px; flex: none; border-radius: 2px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--tile-tone) 11%, transparent);
  color: var(--tile-tone);
  border: 1px solid color-mix(in srgb, var(--tile-tone) 26%, transparent);
}
.tile-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted); line-height: 1.3;
}
.tile-value {
  font-size: 24px; font-weight: 600; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.tile-note { font-size: 11px; color: var(--text-muted); margin-top: 5px; line-height: 1.4; }
.tile-rule { position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--tile-tone); }

.tile.tone-a { --tile-tone: var(--series-1); }
.tile.tone-b { --tile-tone: var(--series-2); }
.tile.tone-c { --tile-tone: var(--good); }
.tile.tone-d { --tile-tone: var(--accent); }
.tile.tone-e { --tile-tone: var(--warn); }
.tile.tone-f { --tile-tone: var(--series-3); }

.ch-icon { vertical-align: -3px; margin-right: 6px; color: var(--text-muted); }

.loc-chip {
  display: inline-block; padding: 1px 7px; border-radius: 2px;
  background: var(--accent-weak); color: var(--accent-ink);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  font-family: var(--mono); font-size: 11.5px;
  text-decoration: none; font-weight: 600;
}
.loc-chip:hover { background: var(--accent); color: #fff; text-decoration: none; }

/* filter rail */
.board-rail { display: grid; gap: 12px; position: sticky; top: calc(var(--top-h) + 12px); }
.rail-card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 11px 12px;
}
.rail-head {
  display: flex; align-items: center; gap: 7px; margin-bottom: 9px;
  padding-bottom: 7px; border-bottom: 1px solid var(--border);
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em;
  color: var(--text-secondary);
}
.rail-head svg { color: var(--accent); }
.rail-head .rail-clear {
  margin-left: auto; text-transform: none; letter-spacing: 0;
  font-weight: 600; font-size: 11px; color: var(--accent);
}
.rail-years { display: flex; gap: 0; margin-bottom: 8px; }
.rail-years a {
  flex: 1; text-align: center; padding: 4px 0;
  font-size: 11.5px; text-decoration: none; color: var(--text-secondary);
  background: var(--surface-1); border: 1px solid var(--border-str); border-right-width: 0;
}
.rail-years a:first-child { border-radius: var(--radius-s) 0 0 var(--radius-s); }
.rail-years a:last-child  { border-radius: 0 var(--radius-s) var(--radius-s) 0; border-right-width: 1px; }
.rail-years a.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.rail-chips { display: grid; grid-template-columns: 1fr; gap: 4px; }
.rail-chips.cols-2 { grid-template-columns: repeat(2, 1fr); }
.rail-chips.cols-3 { grid-template-columns: repeat(3, 1fr); }
.rail-chips a {
  display: block; text-align: center; padding: 5px 4px; border-radius: var(--radius-s);
  font-size: 11.5px; text-decoration: none;
  color: var(--text-secondary); background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rail-chips a:hover { border-color: var(--border-str); color: var(--text-primary); }
.rail-chips a.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.rail-form { display: grid; gap: 6px; }
.rail-form .label { margin: 0; }
.rail-form input { padding: 5px 8px; font-size: 12px; }
.rail-form .btn { margin-top: 4px; justify-content: center; }

.rail-links { display: grid; gap: 6px; font-size: 12.5px; }
.rail-links a { color: var(--accent); text-decoration: none; display: flex; align-items: center; gap: 7px; }
.rail-links a:hover { text-decoration: underline; }

.board-foot {
  margin-top: 16px; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-1); color: var(--text-muted);
  font-size: 11.5px; text-align: center;
}

/* a shortfall against plan */
.stat-value.neg, td.num.neg { color: var(--danger); }

/* -------------------------------------------------------------- responsive */

@media (max-width: 1240px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 1080px) {
  .board { grid-template-columns: 1fr; }
  .board-rail { position: static; grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  :root { --side-w: 0px; }
  .side {
    position: static; width: auto; inset: auto;
    flex-direction: row; align-items: center; gap: 4px;
    overflow-x: auto; border-right: none; border-bottom: 1px solid var(--navy-dark);
  }
  .side-brand { border-bottom: none; }
  .side-scroll { display: flex; padding: 0; overflow-x: auto; }
  .side-group, .side-foot { display: none; }
  .side-link { border-left: none; border-bottom: 2px solid transparent; white-space: nowrap; padding: 8px 12px; }
  .side-link.active { border-left: none; border-bottom-color: #7fb0e8; }
  .shell { margin-left: 0; }
  .topbar { gap: 8px; }
  .topbar-right select { min-width: 130px; }
}
@media (max-width: 640px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .board-rail { grid-template-columns: 1fr; }
  .board-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .board-stamp { text-align: left; }
  .page { padding: 14px 12px 40px; }
  .topbar-context .tc-sub { display: none; }
}

/* -------------------------------------------------------------- print */

@media print {
  .side, .topbar, .section-nav, .filters, .btn, .no-print, .pagination,
  .board-rail { display: none !important; }
  body { background: #fff; font-size: 11px; }
  .shell { margin-left: 0; }
  .page { max-width: none; padding: 0; }
  .board { grid-template-columns: 1fr; }
  .card { border: 1px solid #ccc; break-inside: avoid; page-break-inside: avoid; margin-bottom: 10px; }
  .card-head { background: #f1f1f1; padding: 6px 10px; }
  .card-body { padding: 10px; }
  .board-head { background: #fff !important; color: #000; border: 1px solid #999; }
  .board-head h1, .board-sub, .board-stamp .bs-label, .board-stamp .bs-value { color: #000 !important; }
  a { color: #000; text-decoration: none; }
  table.kv th, table.kv td { padding: 3px 7px; }
}
