/* SMSRC Maintenance Planning — Aquatilis house theme (brand #00414B,
   Century Gothic), shared visual language with the Feeding Plan app. */

:root {
  /* Brand colour #00414B and its nuances */
  --brand: #00414b;
  --brand-dark: #002a31;
  --brand-deep: #001a1f;
  --brand-1: #0a5a66;
  --brand-2: #15737f;
  --brand-3: #2e8f99;
  --brand-4: #5fb0b8;
  --brand-tint: #e7f0f1;
  --brand-tint2: #f3f8f8;
  --bg: #eef3f3;
  --panel: #ffffff;
  --panel2: #f3f8f8;
  --line: #cdddde;
  --text: #00414b;
  --muted: #5b7a80;
  --accent: #0a7b87;
  --accent2: #00414b;
  --warn: #b5740a;
  --bad: #c0392b;
  --good: #1e8e5a;
  --chip: #e1edee;
  --radius: 10px;
  --shadow: 0 3px 14px rgba(0, 65, 75, 0.1);
  --font: "Century Gothic", "CenturyGothic", "URW Gothic", "Avant Garde",
    "Futura", "Bahnschrift", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Top bar ---- */
.topbar {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 8px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
}
/* Left block: logos on top, then the site selector + date underneath them. */
.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.brand-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}
/* Right block: "Maintenance Planning" + client on top, nav buttons beneath. */
.header-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.brand-logos {
  display: flex;
  align-items: flex-end; /* Aquatilis aligns with the BOTTOM of the 360 mark */
  gap: 18px; /* tight — leaves room for the title + nav to the right */
}
.logo-lockup {
  margin: 0;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 9px;
}
/* Aquatilis lockup: "For" on top (left-aligned with the manta), manta at the
   bottom, spanning the same height as the 360 mark. Pushed right of the 360. */
.logo-lockup.lockup-aq {
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  align-self: stretch;
  margin-left: 26px;
}
.for-label {
  font-weight: 700;
  color: var(--brand);
  font-size: 13px;
  letter-spacing: 0.4px;
  line-height: 1;
}
.logo-lockup img {
  width: auto;
  display: block;
}
/* Caption beside the logo, lines spread to span the logo height. */
.logo-lockup figcaption.cap-side {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: left;
  line-height: 1;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--brand);
  padding: 1px 0;
}
/* Motto beside the logo — sentence case, italic, centred on the logo. */
.logo-lockup figcaption.cap-motto {
  text-transform: none;
  font-style: italic;
  font-weight: 600;
  justify-content: center;
  gap: 3px;
}
/* Aquatilis: logo stacked with its motto underneath. */
.logo-lockup.stack {
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.logo-lockup figcaption.cap-under {
  line-height: 1;
  letter-spacing: 0.2px;
  font-style: italic;
  font-weight: 600;
  color: var(--brand);
  text-align: center;
  white-space: nowrap;
}
/* 360Aqua: motto curved around the circular logo (SVG ring). */
.ring-wrap {
  position: relative;
  width: 78px;
  height: 78px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ring-wrap svg.ring-motto {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.logo-lockup .ring-wrap img.ll-360 {
  height: 54%;
  width: auto;
}
/* RULE (2026-07-24, plain marks): size the pair by the "www." font — it must
   render at the same size in both. Measured: 360 = 1.77× Aquatilis height. */
.brand-logos .ll-aq {
  height: 60px;
}
.brand-logos .ll-360 {
  height: 106px;
}
/* 360 caption the same size as the Aquatilis caption. */
.brand-logos figcaption.cap-side,
.brand-logos figcaption.cap-under {
  font-size: 10.5px;
}
.app-title {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.4px;
  color: var(--brand);
}
.brand-client {
  font-size: 11px;
  color: var(--muted);
}
.brand-client .brand-title {
  font-weight: 700;
  color: var(--brand);
}
.brand-client .brand-sub {
  color: var(--muted);
}
/* Nav: a 2-row grid filling column by column, so Backup lands under Report and
   items align in neat vertical columns. Pushed to the bottom of the bar. */
.nav {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(3, auto); /* columns of 3 buttons (Marco) */
  gap: 3px 16px;
  align-content: start;
  justify-content: start;
}
.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 5px 9px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
}
.nav a:hover {
  background: var(--brand-tint);
  color: var(--brand);
}
.nav a.active {
  background: var(--brand);
  color: #fff;
}
.nav .nav-badge {
  background: var(--bad);
  color: #fff;
  border-radius: 10px;
  font-size: 10px;
  padding: 1px 6px;
  font-weight: 700;
}
/* Right group: site selector on top, date underneath, aligned right. */
.topbar-right {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.today-label {
  color: var(--muted);
  font-size: 12px;
}
.site-switch {
  display: flex;
  align-items: center;
  gap: 4px;
}
.site-name-static {
  font-weight: 700;
  color: var(--brand);
  font-size: 14px;
}
.role-control {
  display: flex;
  align-items: center;
  gap: 6px;
}
.role-chip {
  background: #fdf4e3;
  color: var(--warn);
  border: 1px solid #e8c98a;
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
}
.site-select {
  font-weight: 700;
  color: var(--brand);
  padding: 6px 8px;
}
/* Daily-list controls */
.day-move {
  padding: 3px 6px;
  font-size: 12px;
}
.day-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.day-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text);
}
.extra-card {
  border-left: 4px solid var(--warn);
  margin-bottom: 16px;
}
.extra-card .chk {
  font-size: 15px;
  color: var(--muted);
  min-width: 18px;
}

/* ---- Layout ---- */
.view {
  flex: 1;
  padding: 24px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}
.loading {
  color: var(--muted);
  padding: 40px;
  text-align: center;
}
.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.page-head h1 {
  font-size: 22px;
  margin: 0;
  color: var(--brand);
}
.page-head .sub {
  color: var(--muted);
  font-size: 13px;
}
.footer {
  padding: 12px 20px;
  color: var(--muted);
  font-size: 11px;
  border-top: 1px solid var(--line);
}

/* ---- Cards / panels ---- */
.grid {
  display: grid;
  gap: 16px;
}
.grid.cols-4 {
  grid-template-columns: repeat(4, 1fr);
}
.grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}
.grid.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}
@media (max-width: 900px) {
  .grid.cols-4,
  .grid.cols-3,
  .grid.cols-2 {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 640px) {
  .grid.cols-4,
  .grid.cols-3,
  .grid.cols-2 {
    grid-template-columns: 1fr;
  }
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card h2 {
  font-size: 13px;
  margin: 0 0 12px;
  color: var(--brand-2);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 700;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat .label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.stat .value {
  font-size: 30px;
  font-weight: 700;
  margin-top: 4px;
  color: var(--brand);
}
.stat .unit {
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
}
.stat .hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* ---- Banners ---- */
.banner {
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid;
}
.banner .ico {
  font-size: 18px;
  line-height: 1.2;
}
.banner.warn {
  background: #fdf4e3;
  border-color: #e8c98a;
  color: #7a4e06;
}
.banner.danger {
  background: #fbeae8;
  border-color: #e0a59e;
  color: #8e2c20;
}
.banner.info {
  background: var(--brand-tint);
  border-color: var(--brand-4);
  color: var(--brand);
}
.banner strong {
  color: inherit;
}
.banner .b-body {
  flex: 1;
}
.banner .muted {
  color: inherit;
  opacity: 0.85;
}

/* ---- Tables ---- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}
/* Wide tables (Tasks, Equipment): take natural column widths and scroll
   sideways instead of squeezing right-hand columns off-screen. */
table.wide {
  width: auto;
  min-width: 100%;
}
table.wide th,
table.wide td {
  white-space: nowrap;
  padding: 6px 9px;
}
table.wide th.wrap,
table.wide td.wrap {
  white-space: normal;
  max-width: 300px;
}
/* Pin the last column (row actions, incl. the ✕ remove) to the right edge so
   it's always visible, even before you scroll the wide table sideways. */
table.wide tbody td:last-child,
table.wide thead th:last-child {
  position: sticky;
  right: 0;
  background: var(--panel);
  box-shadow: -8px 0 8px -8px rgba(0, 26, 31, 0.18);
}
table.wide thead th:last-child {
  background: var(--brand-tint2);
}
table.wide tbody tr:hover td:last-child {
  background: var(--brand-tint2);
}
thead th {
  text-align: left;
  background: var(--brand-tint2);
  color: var(--brand-2);
  font-weight: 700;
  padding: 9px 12px;
  border-bottom: 2px solid var(--line);
  white-space: nowrap;
  position: sticky;
  top: 0;
  cursor: default;
}
thead th.sortable {
  cursor: pointer;
  user-select: none;
}
thead th.sortable:hover {
  color: var(--brand);
}
tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
tbody tr:hover {
  background: var(--brand-tint2);
}
tbody tr.inactive {
  opacity: 0.5;
}
td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---- Pills / badges ---- */
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.pill.routine {
  background: var(--brand-tint);
  color: var(--brand-2);
}
.pill.periodic {
  background: #e7e9f7;
  color: #3a44a0;
}
.pill.gray {
  background: var(--chip);
  color: var(--muted);
}
.pill.red {
  background: #fbeae8;
  color: #b5392b;
}
.pill.amber {
  background: #fdf4e3;
  color: #9a6206;
}
.pill.green {
  background: #e3f3e9;
  color: #1c7d4d;
}
.pill.active-yes {
  background: #e3f3e9;
  color: #1c7d4d;
}
.pill.active-no {
  background: var(--chip);
  color: var(--muted);
}
.trade-tag {
  font-weight: 700;
}
.trade-Electrician {
  color: #b5740a;
}
.trade-Plumber {
  color: #15737f;
}
.trade-MaintenanceTeam {
  color: #1e8e5a;
}
.trade-Biologist {
  color: #7b4fa6;
}
.trade-Aquarist {
  color: #2a6fbb;
}
.trade-Technician {
  color: #8a5a13;
}
.trade-Diver {
  color: #0a5a9e;
}

/* ---- Controls ---- */
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}
input[type="text"],
input[type="date"],
input[type="number"],
select,
textarea {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  outline: none;
}
input[type="text"]:focus,
select:focus,
textarea:focus,
input[type="date"]:focus,
input[type="number"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10, 123, 135, 0.12);
}
input[type="text"].search {
  min-width: 240px;
  flex: 1;
  max-width: 380px;
}
label.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.btn {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--brand);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}
.btn:hover {
  border-color: var(--accent);
  background: var(--brand-tint2);
}
.btn.primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.btn.primary:hover {
  background: var(--brand-1);
}
.btn.danger {
  color: var(--bad);
  border-color: #e0a59e;
}
.btn.danger:hover {
  background: #fbeae8;
}
.btn.small {
  padding: 4px 10px;
  font-size: 12px;
}
.btn.ghost {
  background: transparent;
}
.muted {
  color: var(--muted);
}
.count-note {
  color: var(--muted);
  font-size: 12px;
  margin-left: auto;
}

/* ---- Toggle switch ---- */
.switch {
  position: relative;
  width: 46px;
  height: 26px;
  display: inline-block;
  flex: none;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch .slider {
  position: absolute;
  inset: 0;
  background: #b9cccd;
  border-radius: 20px;
  transition: 0.15s;
  cursor: pointer;
}
.switch .slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.15s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.switch input:checked + .slider {
  background: var(--good);
}
.switch input:checked + .slider::before {
  transform: translateX(20px);
}

/* ---- Status board ---- */
.area-group {
  margin-bottom: 22px;
}
.area-group h2 {
  font-size: 15px;
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--brand);
}
.area-group h2 .count {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.sys-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  margin-bottom: 8px;
}
.sys-row.on {
  border-left: 3px solid var(--good);
}
.sys-row.off {
  border-left: 3px solid var(--line);
}
.sys-row .sys-code {
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  min-width: 90px;
  color: var(--brand);
}
.sys-row .sys-desc {
  flex: 1;
  color: var(--muted);
  font-size: 13px;
}
.sys-row .sys-state {
  font-size: 12px;
  font-weight: 700;
  min-width: 64px;
  text-align: right;
}
.sys-row.on .sys-state {
  color: var(--good);
}
.sys-row.off .sys-state {
  color: var(--muted);
}

/* ---- Schedule ---- */
.day-col h3 {
  margin: 0 0 8px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--brand);
}
.day-col h3 .h {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.sched-item {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand-2);
  border-radius: 6px;
  padding: 7px 9px;
  margin-bottom: 6px;
  font-size: 12px;
}
.sched-item .si-act {
  font-weight: 600;
}
.sched-item .si-meta {
  color: var(--muted);
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-top: 2px;
}
.sched-item.due {
  border-left-color: var(--warn);
}

/* ---- Deadline bars ---- */
.dl-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.dl-bar-track {
  flex: 1;
  height: 8px;
  background: var(--chip);
  border-radius: 4px;
  overflow: hidden;
  min-width: 80px;
}
.dl-bar {
  height: 100%;
  border-radius: 4px;
}
.dl-bar.red {
  background: var(--bad);
}
.dl-bar.amber {
  background: var(--warn);
}
.dl-bar.green {
  background: var(--good);
}
/* Planned-date marker in the deadlines table. */
.dl-planned {
  font-size: 11px;
  font-weight: 700;
  color: #8a5a13;
  white-space: nowrap;
}

.dl-days {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
/* RAG colour dot at the start of a deadline row. */
table.wide td.dl-dot {
  width: 8px;
  min-width: 8px;
  padding: 0 !important;
}
td.dl-dot.red {
  background: var(--bad);
}
td.dl-dot.amber {
  background: var(--warn);
}
td.dl-dot.green {
  background: var(--good);
}
.dl-days.red {
  color: var(--bad);
}
.dl-days.amber {
  color: var(--warn);
}
.dl-days.green {
  color: var(--good);
}

/* ---- Daily task list ---- */
.daily-day {
  margin-bottom: 22px;
}
.daily-day-head {
  font-size: 16px;
  color: var(--brand);
  margin: 0 0 8px;
  padding-bottom: 4px;
  border-bottom: 2px solid var(--brand-tint);
}
.daily-table td.chk,
.daily-table th.chk {
  width: 28px;
  text-align: center;
  font-size: 15px;
  color: var(--muted);
}
/* Notes column: compact on SCREEN so the whole row fits without scrolling
   (the print stylesheet re-widens it for hand-writing). */
.daily-table td.sign,
.daily-table th.sign {
  min-width: 110px;
  width: 13%;
}
.daily-table td.time-box,
.daily-table th.time-box {
  width: 54px;
  min-width: 54px;
  text-align: center;
}
.daily-table th.time-box {
  white-space: nowrap;
  font-size: 10px;
  line-height: 1.1;
}
.daily-table th.act-col,
.daily-table td.act-col {
  min-width: 200px;
  width: 24%;
}
.daily-table td.sign {
  padding: 2px 4px;
}
.daily-table .note-input {
  width: 100%;
  border: none;
  background: transparent;
  padding: 4px 6px;
  font: inherit;
  color: var(--text);
  border-radius: 4px;
}
.daily-table .note-input:hover {
  background: var(--brand-tint2);
}
.daily-table .note-input:focus {
  background: var(--brand-tint);
  outline: none;
}
.daily-table td.time-box {
  padding: 2px 2px;
}
.daily-table .time-input {
  text-align: center;
  padding: 4px 2px;
}
/* Denser daily-list rows. */
.daily-table td,
.daily-table th {
  padding: 4px 8px;
}
.daily-table td.done-cell {
  cursor: pointer;
  font-size: 16px;
  text-align: center;
  user-select: none;
}
.daily-table td.done-cell.done {
  color: var(--good);
}
.rep-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.week-nav {
  align-items: center;
}
.week-label {
  font-weight: 700;
  color: var(--brand);
}
.week-summary {
  background: var(--brand-tint2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 14px;
  margin-bottom: 14px;
  font-size: 14px;
}
.day-move {
  color: var(--brand-2);
  font-weight: 700;
}
.daily-table .rm-cell {
  width: 34px;
  text-align: center;
}
.rm-btn {
  color: var(--bad);
  font-weight: 700;
  padding: 2px 7px;
}
.rm-btn:hover {
  background: #fbeae8;
  border-color: #e0a59e;
}

/* ---- Print header (only visible when printing) ---- */
.print-only {
  display: none;
}
.print-header {
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--brand);
}
.print-header .ph-left,
.print-header .ph-right {
  flex: 0 0 auto;
}
.print-header .ph-center {
  flex: 1;
  text-align: center;
}
.print-header .ph-h1 {
  font-size: 16px;
  font-weight: 700;
  color: var(--brand);
  line-height: 1.15;
}
.print-header .ph-site {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
.print-header .ph-full {
  font-size: 8px;
  color: var(--muted);
  line-height: 1.1;
}
.print-header .ph-sub {
  font-size: 10px;
  color: var(--muted);
}
.print-header .ll-aq {
  height: 36px;
}
.print-header .ll-360 {
  height: 64px; /* 1.77× — equal "www." size on the plain marks */
}
.print-header .ring-wrap {
  width: 66px;
  height: 66px;
}
.print-header .lockup-360 figcaption {
  font-size: 12px;
}
.print-header .lockup-aq figcaption {
  font-size: 9px;
}
.print-header .ph-h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--brand);
}
.print-header .ph-sub {
  font-size: 12px;
  color: var(--muted);
}

/* ---- Regular checklist ---- */
.chk-table td,
.chk-table th {
  padding: 4px 6px;
  font-size: 12.5px;
}
.chk-table th.chk-date {
  text-align: center;
  min-width: 56px;
}
.chk-table th.chk-today {
  background: var(--brand-tint);
}
.chk-table td.chk-cell {
  padding: 1px 2px;
  text-align: center;
}
/* Result cells stay clean and narrow — a mark or a short number only; the
   details live in the notes layer, not in the cell. */
.chk-table td.chk-cell {
  width: 54px;
  max-width: 64px;
}
.chk-table .chk-select {
  min-width: 44px;
}
.chk-table td .chk-note,
.chk-table td .chk-operator {
  min-width: 90px;
}
.chk-table .chk-input {
  width: 100%;
  min-width: 44px;
  border: none;
  background: transparent;
  text-align: center;
  font: inherit;
  font-size: 12.5px;
  padding: 4px 2px;
  border-radius: 4px;
  color: var(--text);
}
.chk-table .chk-input:hover { background: var(--brand-tint2); }
.chk-table .chk-input:focus { background: var(--brand-tint); outline: none; }
.chk-table td.chk-ok .chk-input { color: #1d7a37; font-weight: 700; }
.chk-table td.chk-bad { background: #fbeae8; }
.chk-table td.chk-bad .chk-input { color: #b3261e; font-weight: 700; }
.chk-table td.chk-check { min-width: 170px; }
.chk-table td.chk-proc { min-width: 110px; font-size: 11.5px; }
.chk-table tr.chk-notes-row td {
  background: var(--brand-tint2);
  border-top: 2px solid var(--line);
}
.chk-table .chk-note { text-align: left; min-width: 90px; }

/* Phones/tablets: big enough inputs that iOS doesn't zoom on focus. */
@media (pointer: coarse) {
  .chk-table .chk-input {
    font-size: 16px;
    min-height: 40px;
  }
  .chk-table td.chk-check { min-width: 130px; }
}

/* ---- Snags list ---- */
/* Scroll INSIDE the table so the column titles stay visible (the base
   thead th is sticky; it needs the wrap to be the scroll container). */
.snag-scroll {
  max-height: max(420px, 72vh);
  overflow: auto;
}
.snag-table td.sn-desc,
.snag-table td.sn-sol,
.snag-table td.sn-act,
.snag-table td.sn-fu {
  min-width: 160px;
  white-space: normal;
}
.snag-table .fu-line {
  font-size: 12px;
  margin-bottom: 2px;
}

/* Priority partial totals: tinted chips in the summaries. */
.prio-split {
  display: inline-flex;
  gap: 5px;
  margin-left: 8px;
  vertical-align: middle;
}

/* Narrow priority column in the daily list (sortable). On screen it holds
   the compact selector; on paper only the badge prints. */
.daily-table th.prio-col,
.daily-table td.prio-col {
  width: 56px;
  text-align: center;
  padding-left: 2px;
  padding-right: 2px;
}
.daily-table td.prio-col .pill {
  min-width: 0;
  padding: 2px 7px;
}
.daily-table .prio-sel {
  width: 54px;
  min-height: 0;
  padding: 3px 2px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 6px;
}
.daily-table .prio-sel.p1 { color: #b3261e; border-color: #d99a94; background: #fbeae8; }
.daily-table .prio-sel.p2 { color: #8a5a13; border-color: #dbb877; background: #fdf3e0; }
.daily-table .prio-sel.p3 { color: #1d7a37; border-color: #93c7a1; background: #e3f3e9; }

/* ---- Past days in the current-week daily list ----
   Still fully visible and editable — tinted in the brand's grey-teal nuance
   so they read as history at a glance. */
.daily-day.past-day .daily-table tbody tr {
  background: #edf2f2;
}
.daily-day.past-day .daily-table tbody tr:hover {
  background: var(--brand-tint);
}
.daily-day.past-day .daily-day-head {
  color: var(--brand-2);
}
.daily-day.past-day .note-input,
.daily-day.past-day .time-input {
  background: #fff;
}

/* ---- Report print frame ----
   A one-cell table wrapping the report body; its <thead> holds the branded
   header so it repeats at the top of every printed page. Invisible chrome on
   screen (the header inside is .print-only). */
table.print-frame {
  width: 100%;
  border-collapse: collapse;
}
table.print-frame > thead > tr > th,
table.print-frame > tbody > tr > td {
  padding: 0;
  border: none;
  background: transparent;
  position: static;
  text-align: left;
  font-weight: normal;
  white-space: normal;
}
/* Activity narrower / Note wider in the report tables. */
.print-frame th.rep-act,
.print-frame td.rep-act {
  width: 22%;
}
.print-frame th.rep-note,
.print-frame td.rep-note {
  width: 26%;
}

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 26, 31, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 10px 40px rgba(0, 26, 31, 0.3);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  font-size: 16px;
  color: var(--brand);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.close-x {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}

/* ---- Misc ---- */
.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px;
}
.bar-mini {
  height: 6px;
  border-radius: 3px;
  background: var(--brand-2);
}
.trade-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.trade-row .tname {
  min-width: 130px;
}
.trade-row .ttrack {
  flex: 1;
  height: 10px;
  background: var(--chip);
  border-radius: 5px;
  overflow: hidden;
}
.trade-row .tval {
  min-width: 70px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
mark {
  background: #ffe9a8;
  color: var(--brand);
  border-radius: 2px;
  padding: 0 1px;
}
code.tag {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--brand-tint2);
  border: 1px solid var(--line);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--brand);
}
.row-actions {
  display: flex;
  gap: 6px;
}

/* ---- Print ---- */
/* Page box: safe printable margins, and "Page X of Y" in the bottom-right
   corner of every sheet. Must live at TOP level — Chrome ignores @page margin
   boxes when the rule is nested inside @media print. */
@page {
  margin: 12mm 10mm 16mm;
  @bottom-right {
    content: "Page " counter(page) " of " counter(pages);
    font-size: 9px;
    color: #666;
  }
}
/* The monthly report prints in LANDSCAPE (wide tables). Declaring it here —
   rather than picking Landscape in the print dialog — keeps the margins and
   the page numbers, which Chrome drops when the orientation is switched
   manually against a CSS-defined page. */
@page report {
  size: A4 landscape;
  margin: 12mm 10mm 16mm;
  @bottom-right {
    content: "Page " counter(page) " of " counter(pages);
    font-size: 9px;
    color: #666;
  }
}
@media print {
  body {
    background: #fff;
    color: #000;
    line-height: 1.15;
    font-size: 9px;
  }
  .daily-table {
    font-size: 9px;
  }
  .topbar,
  .footer,
  .toolbar,
  .no-print {
    display: none !important;
  }
  .print-only {
    display: flex !important;
  }
  .view {
    padding: 0;
    max-width: none;
  }
  /* Don't stretch to the screen height on paper — it forces a blank page
     after short documents. */
  #app {
    min-height: 0;
  }
  .print-header {
    margin-bottom: 8px;
    padding-bottom: 8px;
  }
  .week-summary {
    margin: 6px 0;
    padding: 5px 8px;
    background: #fff;
    border-color: #999;
  }
  /* Keep small things together, but let day blocks flow across pages so the
     first page isn't left almost empty. */
  .card,
  .sched-item {
    box-shadow: none;
    break-inside: avoid;
  }
  .daily-day {
    box-shadow: none;
    break-inside: auto;
  }
  .daily-day-head {
    margin: 6px 0 4px;
  }
  tbody td,
  thead th {
    padding: 2px 6px;
  }
  tbody tr {
    break-inside: avoid;
  }
  /* Empty boxes the operator fills in by hand. */
  .daily-table td.time-box,
  .daily-table td.sign {
    border: 1px solid #bbb;
  }
  /* On paper the notes box is wide again for hand-writing. */
  .daily-table td.sign,
  .daily-table th.sign {
    width: 32%;
    min-width: 0;
  }
  /* P column: only the badge prints, so it stays narrow. */
  .daily-table th.prio-col,
  .daily-table td.prio-col {
    width: 9mm;
  }
  /* Priority class: keep its colour on paper and ring it so it stands out
     even on greyscale printers. Same treatment in the legend badges. */
  .daily-table td.prio-col .pill,
  .prio-legend .pill {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    border: 1.2px solid currentColor;
    font-weight: 800;
    font-size: 9px;
  }
  /* Legend explaining the P column (print only). */
  .prio-legend {
    font-size: 8.5px;
    color: #333;
    margin: 2px 0 6px;
    align-items: center;
    gap: 3px;
  }
  .prio-legend .pill {
    padding: 1px 5px;
    min-width: 0;
  }
  .table-wrap {
    overflow: visible;
    box-shadow: none;
    border: none;
  }
  .snag-scroll {
    max-height: none; /* print the whole list, not a scroll window */
  }
  thead th {
    position: static;
  }
  a[href]:after {
    content: "";
  }
  /* The report's frame prints on the landscape "report" page (see @page).
     The WHOLE document must share that page box — content on a different
     page box (even invisible) would emit a stray portrait sheet. The
     Portrait print button sets body.print-portrait, which falls back to the
     generic portrait page box — same margins and page numbers. */
  /* Only landscape pages (snags/report) use the landscape box; the checklist
     prints on the normal PORTRAIT page. */
  body.print-landscape,
  body.print-landscape .print-frame {
    page: report;
  }
  body.print-portrait,
  body.print-portrait .print-frame {
    page: auto;
  }
  /* Report: the frame's thead repeats the branded header on every page —
     compact, with smaller logos, so it doesn't eat the sheet. */
  .print-frame .print-header {
    margin-bottom: 6px;
    padding-bottom: 5px;
    border-bottom-width: 1.5px;
  }
  /* Plain marks — 360 at 1.77× Aquatilis so the "www." prints at the same
     font size in both. */
  .print-frame .print-header .ll-aq {
    height: 32px;
  }
  .print-frame .print-header .ll-360 {
    height: 57px;
  }
  .print-frame .print-header .lockup-360 figcaption {
    font-size: 8px;
  }
  .print-frame .print-header .lockup-aq figcaption {
    font-size: 6.5px;
  }
  .print-frame .print-header .ph-h1 {
    font-size: 12px;
  }
  .print-frame .print-header .ph-site {
    font-size: 10px;
  }
  .print-frame .print-header .ph-full {
    font-size: 7px;
  }
  .print-frame .print-header .ph-sub {
    font-size: 9px;
  }
  /* Report tables: fixed layout so Activity stays narrow and Note wide, and
     long text wraps onto the next line instead of stretching the column. */
  .print-frame .card table {
    table-layout: fixed;
    width: 100%;
  }
  .print-frame .card td,
  .print-frame .card th {
    white-space: normal;
    overflow-wrap: break-word;
    vertical-align: top;
  }
  /* Column widths (both report tables share the same first 8 columns):
     Date · System · Item · Activity · Instruction · Trade · (Est.h) · Note */
  .print-frame table.rep-table th:nth-child(1) {
    width: 19mm;
  }
  .print-frame table.rep-table th:nth-child(2) {
    width: 17mm;
  }
  .print-frame table.rep-table th:nth-child(3) {
    width: 20mm;
  }
  .print-frame .card th.rep-act {
    width: 20%;
  }
  .print-frame table.rep-table th:nth-child(5) {
    width: 24mm;
  }
  .print-frame table.rep-table th:nth-child(6) {
    width: 19mm;
  }
  .print-frame table.rep-table td:nth-child(1) {
    white-space: nowrap;
  }
  /* Checklist grid: PORTRAIT one-pager. One-line rows, no Procedure column,
     tags on one line, narrow day columns, empty days hidden; the notes and
     X descriptions print in the Notes section under the table. */
  /* Standard print size: 7 pt (Marco 25/07/26) — fits a sheet + notes on one
     portrait page. Table hugs its columns (width auto) so the Operator row's
     boxes align exactly under the date columns. */
  .chk-table {
    width: auto;
  }
  .chk-table td,
  .chk-table th {
    font-size: 7pt;
    padding: 1px 3px;
    line-height: 1.25;
    white-space: nowrap !important; /* single-line rows, always */
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 44mm;
  }
  .chk-table td.chk-check { min-width: 0; }
  .chk-table .chk-proc { display: none; }
  .chk-table .chk-guide { display: none; }
  .chk-table .chk-day-off { display: none; }
  /* The in-table Notes line is screen-only; recorded notes print in the
     formatted Notes section under the table (with tag references). */
  .chk-table .chk-notes-row { display: none; }
  .chk-table .chk-tag-col,
  .chk-table .chk-tag-col .tag {
    white-space: nowrap;
    font-size: 6.5pt;
    padding: 0 1px;
  }
  .chk-table td.chk-cell {
    border: 1px solid #ccc;
    text-align: center;
    min-width: 11mm;
  }
  .chk-table .chk-input,
  .chk-table .chk-select { display: none; }
  .chk-print-val {
    font-size: 7pt;
    font-weight: 700;
  }
  /* X prints plain — no highlight, no colour block. */
  .chk-cell.chk-bad { background: none !important; }
  .chk-cell.chk-ok { background: none !important; }
  .chk-cell.chk-ok .chk-print-val { color: #1e8e5a; }
  .chk-op-val { font-weight: 600; font-size: 6.5pt; }
  .chk-print-notes {
    margin-top: 8px;
    font-size: 7.5pt;
    line-height: 1.5;
    border-top: 1px solid #999;
    padding-top: 4px;
  }
  .chk-print-notes strong {
    display: block;
    margin-bottom: 2px;
    font-size: 8pt;
  }
  .chk-print-notes div {
    display: block !important;
    width: 100% !important;
    text-align: left;
    break-inside: avoid;
  }
  .chk-print-notes {
    display: block !important;
    column-count: unset !important;
  }
  .chk-table .sortable { cursor: default; }

  /* Snags table: its own print widths (landscape).
     Raised · Location · Item · Snag · Scope · Solution · Responsible ·
     Action · Follow-ups · Status */
  .snag-table td.sn-desc,
  .snag-table td.sn-sol,
  .snag-table td.sn-act,
  .snag-table td.sn-fu {
    min-width: 0; /* screen-only min-widths would overflow the sheet */
  }
  .snag-table th:nth-child(1) { width: 17mm; }
  .snag-table th:nth-child(2) { width: 20mm; }
  .snag-table th:nth-child(3) { width: 20mm; }
  .snag-table th:nth-child(4) { width: 16%; }
  .snag-table th:nth-child(5) { width: 15mm; }
  .snag-table th:nth-child(6) { width: 15%; }
  .snag-table th:nth-child(7) { width: 21mm; }
  .snag-table th:nth-child(8) { width: 13%; }
  .snag-table th:nth-child(9) { width: 16%; }
  .snag-table th:nth-child(10) { width: 17mm; }
  .print-frame .card {
    break-inside: auto;
  }
  .print-frame h2 {
    font-size: 12px;
    margin: 4px 0 6px;
  }
}

/* ====================================================================== */
/* Mobile / tablet (iPhone + iPad). Phase 1 responsive interface.         */
/* ====================================================================== */

/* Touch devices: bigger tap targets; 16px inputs so iOS Safari doesn't zoom. */
@media (pointer: coarse) {
  .btn {
    min-height: 42px;
  }
  .btn.small {
    min-height: 34px;
  }
  .nav a {
    padding: 9px 12px;
  }
  input[type="text"],
  input[type="date"],
  input[type="number"],
  select,
  textarea {
    min-height: 42px;
    font-size: 16px;
  }
  .daily-table .note-input,
  .daily-table .time-input {
    min-height: 36px;
    font-size: 16px;
  }
  .switch {
    width: 52px;
    height: 30px;
  }
  .switch .slider::before {
    width: 24px;
    height: 24px;
  }
  .switch input:checked + .slider::before {
    transform: translateX(22px);
  }
  .daily-table td.done-cell {
    font-size: 24px;
  }
  .table-wrap {
    -webkit-overflow-scrolling: touch;
  }
}

/* Tablet / small laptop: tighten the header, make the nav a scrollable row. */
@media (max-width: 900px) {
  .topbar {
    gap: 14px;
    padding: 8px 12px;
  }
  .brand-logos {
    gap: 14px;
  }
  .brand-logos .ll-aq {
    height: 34px;
  }
  .brand-logos .ll-360 {
    height: 60px;
  }
  .header-main {
    width: 100%;
  }
  .nav {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }
  .nav a {
    flex: 0 0 auto;
  }
  .view {
    padding: 14px;
  }
}

/* Phone: hide the logo captions to declutter, shrink type, full-width search. */
@media (max-width: 560px) {
  .brand-logos figcaption.cap-side {
    display: none !important;
  }
  .brand-logos {
    gap: 10px;
  }
  .brand-logos .ll-aq {
    height: 28px;
  }
  .brand-logos .ll-360 {
    height: 50px;
  }
  .brand-controls {
    flex-wrap: wrap;
    gap: 8px;
  }
  .app-title {
    font-size: 15px;
  }
  .brand-client {
    font-size: 10px;
  }
  .page-head h1 {
    font-size: 20px;
  }
  .view {
    padding: 10px;
  }
  .stat .value {
    font-size: 26px;
  }
  .toolbar {
    gap: 8px;
  }
  input[type="text"].search {
    min-width: 0;
    max-width: none;
    flex: 1 1 100%;
  }
  .modal {
    max-width: 100%;
  }
  /* Keep the priciest columns; let the daily table scroll for the rest. */
  .daily-table th.act-col,
  .daily-table td.act-col {
    min-width: 220px;
    width: auto;
  }
}

/* ---- Operator daily list (phone-first) -------------------------------- */
/* Built from DIVs, not a table — iPhone Safari does not grid table rows.
   Desktop: one 9-column grid row per task, table look. Phone: card layout. */
.ops-table {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.ops-row {
  display: grid;
  grid-template-columns: 36px 30px 74px 96px 120px minmax(0, 1fr) 86px 62px 150px;
  gap: 0 8px;
  align-items: center;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}
.ops-row:last-child {
  border-bottom: none;
}
.ops-head {
  background: var(--panel2);
  font-weight: 700;
  color: var(--brand);
  font-size: 12px;
}
.ops-row .oc {
  min-width: 0;
  overflow-wrap: anywhere;
}
.ops-row .chk {
  font-size: 20px;
  cursor: pointer;
  user-select: none;
  text-align: center;
}
.ops-row .chk.done {
  color: var(--good);
}
.ops-row .time-input {
  width: 54px;
  min-width: 54px;
}
.ops-row .oc-9 .note-input {
  width: 100%;
  min-width: 0;
}
/* Phone: card per task — everything visible, no side-scroll. */
@media (max-width: 700px) {
  .ops-head {
    display: none;
  }
  .ops-row {
    grid-template-columns: 34px auto auto minmax(0, 1fr) auto;
    grid-template-areas:
      "tick p    sys  item trade"
      "tick act  act  act  act"
      "tick loc  time note note";
    gap: 3px 6px;
    padding: 9px 8px 9px 4px;
    font-size: 12px;
  }
  .ops-row .oc-1 { grid-area: tick; font-size: 24px; }
  .ops-row .oc-2 { grid-area: p; }
  .ops-row .oc-3 { grid-area: sys; }
  .ops-row .oc-4 { grid-area: loc; font-size: 10.5px; }
  .ops-row .oc-5 { grid-area: item; }
  .ops-row .oc-6 { grid-area: act; }
  .ops-row .oc-7 { grid-area: trade; justify-self: end; }
  .ops-row .oc-8 { grid-area: time; }
  .ops-row .oc-9 { grid-area: note; }
  .ops-row .time-input {
    width: 58px;
    min-width: 58px;
  }
}

/* Operator page day picker */
.ops-days {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.ops-week-label {
  font-weight: 700;
  color: var(--brand);
  font-size: 12.5px;
  min-width: 70px;
  text-align: center;
}
.ops-day-chip.today-chip {
  border-color: var(--good);
  color: var(--good);
  font-weight: 700;
}

/* "For" label scaled down in print headers and small screens */
.print-header .for-label {
  font-size: 9px;
}
@media print {
  .print-frame .print-header .for-label {
    font-size: 8px;
  }
}
@media (max-width: 900px) {
  .for-label {
    font-size: 11px;
  }
}
@media (max-width: 560px) {
  .for-label {
    font-size: 9.5px;
  }
}

/* Checklist choice cells (√ / X / ON / OFF dropdowns) */
.chk-select {
  width: 100%;
  border: none;
  background: transparent;
  font: inherit;
  text-align: center;
  padding: 2px 0;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.chk-cell.chk-bad .chk-select {
  color: var(--bad);
  font-weight: 700;
}
.chk-cell.chk-ok .chk-select {
  color: var(--good);
  font-weight: 700;
}

/* Report print: no Instruction column; auto-notes styled softly on screen. */
.rep-autonote {
  color: var(--muted);
  font-style: italic;
}
@media print {
  .rep-table .rep-instr { display: none; }
  .rep-autonote { color: inherit; font-style: normal; }
  /* Operator daily list print: compact 9-column rows, values in the boxes. */
  .ops-page .ops-row {
    font-size: 8px;
    padding: 2px 4px;
    gap: 0 4px;
    grid-template-columns: 8mm 6mm 16mm 20mm 22mm minmax(0, 1fr) 13mm 10mm 26mm;
  }
  .ops-page .ops-head {
    font-size: 8px;
  }
  .ops-page .ops-row .chk {
    font-size: 11px;
  }
  .ops-page .ops-row .pill {
    font-size: 6px;
    padding: 0 3px;
  }
  .ops-page .ops-row .note-input,
  .ops-page .ops-row .time-input {
    border: 1px solid #ccc;
    font-size: 8px;
    padding: 0 2px;
    min-width: 0;
    width: 100%;
    background: transparent;
  }
}
