/* Tateside client portal: black on off-white, dark grey to split the page and lift key buttons */
:root {
  color-scheme: light;
  --paper: #F8F7F4;
  --ink: #000000;
  --ink-2: #3B3B39;          /* Tateside dark grey */
  --ink-2-hover: #4A4A47;
  --muted: #64635E;
  --rule: #D6D4CD;
  --rule-strong: #8F8C85;
  --hover: #EEECE6;
  --on-dark: #F8F7F4;
  --on-dark-muted: #D6D4CD;
  --field: #FFFFFF;
  --ok: #24663F;
  --due: #8A5300;
  --bad: #A3221A;
  --led-on: #2E8A52;
  --led-off: #C2382C;
  --led-idle: #8F8C85;
  --sans: 'Lato', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #161615; --ink: #F8F7F4; --ink-2: #3B3B39; --ink-2-hover: #4A4A47;
    --muted: #B3B1AA; --rule: #3A3936; --rule-strong: #6F6E69; --hover: #232321;
    --field: #1F1F1D; --ok: #6FC48F; --due: #E3A94F; --bad: #F08A80;
    --led-on: #3FAE69; --led-off: #E2554A; --led-idle: #6F6E69;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #161615; --ink: #F8F7F4; --ink-2: #3B3B39; --ink-2-hover: #4A4A47;
  --muted: #B3B1AA; --rule: #3A3936; --rule-strong: #6F6E69; --hover: #232321;
  --field: #1F1F1D; --ok: #6FC48F; --due: #E3A94F; --bad: #F08A80;
  --led-on: #3FAE69; --led-off: #E2554A; --led-idle: #6F6E69;
}
*, *::before, *::after { box-sizing: inherit; }
html { height: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
body { margin: 0; min-height: 100%; background: var(--paper); color: var(--ink); font: 16px/1.5 var(--sans); -webkit-text-size-adjust: 100%; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; color: var(--ink); margin: 0; letter-spacing: -0.01em; }
a { color: var(--ink); text-underline-offset: 3px; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.mono { font-family: var(--mono); font-size: 0.86em; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; padding: 0; }

/* Logo: dark ink on light, light ink on dark */
.logo { display: block; height: 34px; width: auto; }
.logo-light { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo-dark { display: none; } :root:not([data-theme="light"]) .logo-light { display: block; } }
:root[data-theme="dark"] .logo-dark { display: none; }
:root[data-theme="dark"] .logo-light { display: block; }

/* Shell */
.shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto; border-right: 1px solid var(--rule); padding: 28px 18px 20px; display: flex; flex-direction: column; gap: 26px; }
.client { border-top: 2px solid var(--ink); padding-top: 14px; display: flex; flex-direction: column; gap: 4px; }
.client-name { font-family: var(--display); font-size: 19px; font-weight: 600; }
.client-logo { max-width: 100%; max-height: 60px; width: auto; height: auto; object-fit: contain; align-self: flex-start; margin-top: 10px; }
.logo-actions { display: flex; gap: 16px; font-size: 13.5px; }
.upload { display: flex; align-items: center; justify-content: center; min-height: 56px; margin-top: 10px; border: 1px dashed var(--rule-strong); color: var(--muted); font-size: 14px; cursor: pointer; text-align: center; }
.upload:hover { border-color: var(--ink); color: var(--ink); }
#logo-file:focus-visible + .upload, #logo-file:focus-visible ~ .logo-actions label { outline: 2px solid var(--ink); outline-offset: 2px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; padding: 0 12px; text-decoration: none; font-family: var(--display); font-size: 14.5px; border-radius: 2px; }
.nav a:hover { background: var(--hover); }
.nav a[aria-current="page"] { background: var(--ink-2); color: var(--on-dark); font-weight: 500; }
.nav a.sub { padding-left: 26px; font-size: 14px; min-height: 40px; }
.nav .count { font-family: var(--sans); font-size: 12.5px; font-weight: 700; color: var(--bad); }
.nav a[aria-current="page"] .count { color: var(--on-dark); }
.contract { margin-top: auto; border-top: 1px solid var(--rule); padding-top: 14px; display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; }
.contract strong { font-family: var(--display); font-size: 16px; font-weight: 600; }
.whoami { font-size: 13px; color: var(--muted); word-break: break-all; }
.signout { display: flex; align-items: center; min-height: 44px; padding: 0 12px; text-decoration: none; font-family: var(--display); font-size: 14.5px; }
.signout:hover { background: var(--hover); }

.main { min-width: 0; padding: 36px clamp(16px, 4vw, 56px) 64px; display: flex; flex-direction: column; gap: 32px; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.head h1 { font-size: clamp(26px, 3.2vw, 34px); line-height: 1.15; }
.head .sub { color: var(--muted); font-size: 15px; margin-top: 6px; }
.back { display: inline-flex; align-items: center; min-height: 32px; font-size: 14px; margin-bottom: 4px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px; border: 1px solid var(--ink); border-radius: 2px; background: var(--ink); color: var(--paper); font-family: var(--display); font-size: 14.5px; font-weight: 500; cursor: pointer; text-decoration: none; }
.btn:hover { opacity: 0.85; }
.btn-grey { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border: 0; border-radius: 2px; background: var(--ink-2); color: var(--on-dark); font-family: var(--display); font-size: 14.5px; font-weight: 500; cursor: pointer; text-decoration: none; }
.btn-grey:hover { background: var(--ink-2-hover); }
.btn-grey[disabled], .btn[disabled] { opacity: 0.55; cursor: progress; }
.linkbtn { border: 0; background: none; padding: 0; font-weight: 700; text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: 3px; cursor: pointer; text-align: left; }
.linkbtn:hover { text-decoration-color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 40px; padding: 0 14px; border: 1px solid var(--rule-strong); border-radius: 2px; background: transparent; font-family: var(--display); font-size: 13.5px; cursor: pointer; }
.chip:hover { border-color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink-2); border-color: var(--ink-2); color: var(--on-dark); }

/* The live band: the one bold element. A strip of status lights per site, like the LEDs on a rack. */
.live { background: var(--ink-2); color: var(--on-dark); border-radius: 2px; padding: 22px clamp(16px, 2.5vw, 28px); display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: 20px 40px; }
.live-figure { display: flex; flex-direction: column; gap: 4px; }
.live-figure .big { font-family: var(--display); font-size: 44px; font-weight: 600; line-height: 1; letter-spacing: -0.02em; }
.live-figure .big span { font-size: 22px; font-weight: 500; color: var(--on-dark-muted); letter-spacing: 0; }
.live-figure p { margin: 6px 0 0; font-size: 14px; color: var(--on-dark-muted); }
.live-figure .alert { color: #FFB3AB; font-weight: 700; }
.strips { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.strip { display: grid; grid-template-columns: minmax(120px, 190px) minmax(0, 1fr); gap: 14px; align-items: center; color: var(--on-dark); text-decoration: none; padding: 4px 0; }
.strip:hover .strip-name { text-decoration: underline; }
.strip-name { font-family: var(--display); font-size: 14.5px; font-weight: 500; }
.strip-note { display: block; font-family: var(--sans); font-size: 12.5px; color: var(--on-dark-muted); font-weight: 400; }
.leds { display: flex; flex-wrap: wrap; gap: 5px; }
.led { width: 14px; height: 14px; border-radius: 1px; }
.led.online { background: #46C277; }
.led.offline { background: #FF5F52; box-shadow: 0 0 0 2px #3B3B39, 0 0 0 3px #FF5F52; }
.led.awaiting { border: 1.5px dashed #B3B1AA; }
.led.unmonitored, .led.none { background: #5C5B57; }
.legend { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 13px; color: var(--on-dark-muted); border-top: 1px solid #55544F; padding-top: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend .led { width: 11px; height: 11px; }
.legend .led.offline { box-shadow: none; animation: none; }

/* Sections */
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 40px; align-items: start; }
.sec { display: flex; flex-direction: column; min-width: 0; }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; border-bottom: 2px solid var(--ink); padding-bottom: 10px; }
.sec-head h2 { font-size: 19px; }
.sec-head a, .sec-head .linkbtn { font-size: 14px; font-weight: 400; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--rule); }
.row .what { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row .what strong { font-size: 15px; }
.row .what span { font-size: 13.5px; color: var(--muted); }
.row .when { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }
.row .when span:last-child { font-size: 13.5px; color: var(--muted); }
a.row { color: inherit; text-decoration: none; }
a.row:hover strong { text-decoration: underline; }
.empty { margin: 0; padding: 14px 0; border-bottom: 1px solid var(--rule); font-size: 15px; }

/* Status words with a square marker. Colour is never the only signal: the word is always shown. */
.tag { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; white-space: nowrap; }
.tag::before { content: ""; width: 8px; height: 8px; background: currentColor; flex: none; }
.tag.ok, .tag.online { color: var(--ok); }
.tag.due { color: var(--due); }
.tag.expired, .tag.offline { color: var(--bad); }
.tag.tbc, .tag.pending, .tag.awaiting, .tag.unmonitored, .tag.none { color: var(--muted); font-weight: 400; }
.tag.awaiting::before, .tag.pending::before { background: transparent; border: 1.5px dashed currentColor; }

/* Tables */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-family: var(--display); font-size: 13px; font-weight: 500; padding: 10px 16px 10px 0; border-bottom: 1.5px solid var(--ink); white-space: nowrap; }
td { padding: 12px 16px 12px 0; border-bottom: 1px solid var(--rule); font-size: 14.5px; white-space: nowrap; vertical-align: middle; }
td a { font-weight: 700; text-decoration-color: var(--rule-strong); }
td a:hover { text-decoration-color: var(--ink); }

.tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.tools .search { flex: 1 1 320px; display: flex; flex-direction: column; gap: 6px; }
label.lbl { font-size: 14px; font-weight: 700; }
.field { width: 100%; min-height: 46px; padding: 0 12px; border: 1px solid var(--rule-strong); border-radius: 2px; background: var(--field); color: var(--ink); font: inherit; font-size: 16px; }
.field:focus { outline: 2px solid var(--ink); outline-offset: 1px; }
.shown { font-size: 14px; color: var(--muted); min-height: 46px; display: flex; align-items: center; }

/* Device page */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 32px 40px; align-items: start; }
.facts dl { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 10px 16px; margin: 12px 0 0; font-size: 15px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.statusbox { display: flex; flex-direction: column; gap: 6px; padding-top: 12px; font-size: 15px; }
.statusbox .tag { font-size: 16px; }
.offer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--rule); }
.offer .what { display: flex; flex-direction: column; gap: 4px; flex: 1 1 320px; min-width: 0; }
.offer .what strong { font-family: var(--display); font-size: 15.5px; font-weight: 500; }
.offer .what span { font-size: 14px; color: var(--muted); }
.offer .pick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sent { font-size: 14px; font-weight: 700; color: var(--ok); min-height: 44px; display: inline-flex; align-items: center; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.note { margin: 0; font-size: 14px; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); max-width: calc(100% - 32px); background: var(--ink); color: var(--paper); padding: 14px 20px; border-radius: 2px; font-size: 15px; z-index: 20; }
.toast[hidden] { display: none; }
.loading, .failed { min-height: 60vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; }

/* Phones and small tablets: the sidebar becomes a top bar with a scrolling menu */
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--rule); padding: 18px 16px 10px; gap: 14px; }
  .side-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .client { border-top: 0; padding-top: 0; flex-direction: row; align-items: center; gap: 10px; }
  .client .lbl-client, .client .upload, .client .logo-actions, .client .client-logo { display: none; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; margin: 0 -16px; padding: 0 16px 6px; scrollbar-width: none; }
  .nav a, .nav a.sub { flex: none; padding: 0 14px; min-height: 40px; }
  .contract { display: none; }
  .side-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; order: 3; }
  .signout { min-height: 40px; padding: 0; }
  .live { grid-template-columns: minmax(0, 1fr); }
  .strip { grid-template-columns: minmax(0, 1fr); gap: 6px; }
}
@media (prefers-reduced-motion: no-preference) {
  .led.offline { animation: blink 2s steps(1, end) infinite; }
  @keyframes blink { 50% { opacity: 0.35; } }
}
@media print {
  .side, .actions, .chips, .tools, .toast { display: none !important; }
  .shell { display: block; }
}
