/* Delta Packing Board - DCL brand theme
   Fits every item on screen from phone to TV.
   Indicator colours (red / amber / green, status dots, banners) are unchanged. */

:root {
  /* Brand (sampled from the DCL logo) */
  --dcl-navy: #003060;
  --dcl-deep: #021a36;
  --dcl-abyss: #010f22;
  --dcl-blue: #106090;
  --dcl-sky: #3aa0dc;
  --dcl-yellow: #f0d818;
  --dcl-gold: #f0a020;

  /* Indicators (unchanged) */
  --cyan: #21b6e6;
  --green: #18a66b;
  --amber: #e79b16;
  --red: #dc3d50;

  /* Surfaces and text */
  --ink: #eef4fb;
  --muted: #8fa9c4;
  --glass: rgba(255, 255, 255, 0.045);
  --glass-strong: rgba(255, 255, 255, 0.07);
  --edge: rgba(255, 255, 255, 0.09);
  --edge-hi: rgba(255, 255, 255, 0.16);

  --gap: clamp(6px, 0.8vw, 14px);
  --radius: clamp(10px, 1vw, 18px);
  --fs: 18px;            /* row text size, set by app.js */
  --cols: 1;             /* grid columns, set by app.js */
  --rows: 10;            /* rows per column, set by app.js */

  --display: "Montserrat", "Segoe UI", Roboto, Arial, sans-serif;
  --text: "Inter", "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--text);
  color: var(--ink);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  background-color: var(--dcl-deep);
  background-image:
    url("../img/weave.svg"),
    radial-gradient(1200px 700px at 8% -10%, rgba(16, 96, 144, 0.55), transparent 60%),
    radial-gradient(900px 600px at 105% 110%, rgba(240, 160, 32, 0.14), transparent 60%),
    linear-gradient(160deg, var(--dcl-navy) 0%, var(--dcl-deep) 45%, var(--dcl-abyss) 100%);
  background-attachment: fixed;
}

button, input, select { font: inherit; }

.hidden { display: none !important; }

/* Shared glass panel look */
.kpi,
.board,
.control select,
.btn {
  background: linear-gradient(180deg, var(--glass-strong), var(--glass));
  border: 1px solid var(--edge);
  box-shadow:
    inset 0 1px 0 var(--edge-hi),
    0 10px 30px rgba(0, 8, 24, 0.35);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

/* ---------- Shell ---------- */

.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: var(--gap);
  padding: var(--gap);
  padding-left: max(var(--gap), env(safe-area-inset-left));
  padding-right: max(var(--gap), env(safe-area-inset-right));
  padding-bottom: max(var(--gap), env(safe-area-inset-bottom));
}

/* ---------- Header ---------- */

.top {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  flex-wrap: wrap;
  padding-bottom: calc(var(--gap) * 0.8);
}

/* Gold swoosh hairline under the header */
.top::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--dcl-yellow) 18%, var(--dcl-gold) 60%, transparent);
  opacity: 0.85;
}

.brand {
  display: flex;
  align-items: center;
  gap: clamp(10px, 1vw, 18px);
  min-width: 0;
}

.logo {
  flex: none;
  height: clamp(40px, 4vw, 72px);
  aspect-ratio: 191 / 85;
  padding: clamp(4px, 0.4vw, 8px) clamp(8px, 0.7vw, 14px);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #eef4fa);
  box-shadow:
    0 0 0 1px rgba(240, 216, 24, 0.55),
    0 8px 24px rgba(0, 0, 0, 0.35);
  display: grid;
  place-items: center;
}

.logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-text { min-width: 0; }

.brand h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(18px, 2vw, 40px);
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: #ffffff;
}

.brand p {
  margin: 5px 0 0;
  font-family: var(--display);
  font-size: clamp(10px, 0.72vw, 14px);
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--dcl-yellow), var(--dcl-gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.controls {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.control {
  display: grid;
  gap: 4px;
}

.control > span {
  font-size: 10px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.control select,
.btn {
  height: 38px;
  border-radius: 10px;
  padding: 0 12px;
  color: var(--ink);
  font-weight: 700;
}

.control select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--dcl-yellow) 50%),
    linear-gradient(135deg, var(--dcl-yellow) 50%, transparent 50%),
    linear-gradient(180deg, var(--glass-strong), var(--glass));
  background-position:
    calc(100% - 17px) 16px,
    calc(100% - 12px) 16px,
    0 0;
  background-size: 5px 5px, 5px 5px, 100% 100%;
  background-repeat: no-repeat;
  cursor: pointer;
}

.control select option {
  background: var(--dcl-deep);
  color: var(--ink);
}

.btn { cursor: pointer; }

.btn:hover,
.control select:hover,
.datepick:hover .date-btn {
  border-color: rgba(240, 216, 24, 0.45);
}

/* Date shows as DD-MM-YYYY; the native picker sits invisibly on top */
.datepick { position: relative; }

.date-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 140px;
  font-variant-numeric: tabular-nums;
  text-align: left;
}

.date-btn::before {
  content: "";
  width: 14px;
  height: 14px;
  flex: none;
  border-radius: 3px;
  border: 2px solid var(--dcl-yellow);
  border-top-width: 4px;
  opacity: 0.9;
}

.date-native {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
  border: 0;
  padding: 0;
}

.datepick:focus-within .date-btn,
.btn:focus-visible,
select:focus-visible {
  outline: 2px solid var(--dcl-yellow);
  outline-offset: 2px;
}

.btn:disabled { opacity: 0.6; }

/* Kiosk mode (?kiosk=1) hides the controls for TVs */
.kiosk .controls { display: none; }

/* ---------- KPIs ---------- */

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--gap);
}

.kpi {
  border-radius: var(--radius);
  padding: clamp(8px, 0.9vw, 18px) clamp(10px, 1.1vw, 22px) clamp(10px, 1vw, 20px);
  position: relative;
  overflow: hidden;
  min-width: 0;
}

/* Soft accent glow in the corner of each tile */
.kpi::before {
  content: "";
  position: absolute;
  right: -30%;
  top: -60%;
  width: 70%;
  height: 160%;
  background: radial-gradient(closest-side, var(--accent), transparent);
  opacity: 0.12;
  pointer-events: none;
}

.kpi::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 4px;
  background: var(--accent);
  box-shadow: 0 0 14px var(--accent);
}

.kpi-required { --accent: var(--cyan); }
.kpi-filled { --accent: var(--green); }
.kpi-pending { --accent: var(--red); }
.kpi-complete { --accent: var(--amber); }

.kpi .lab {
  position: relative;
  font-family: var(--display);
  font-size: clamp(9px, 0.68vw, 14px);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  font-weight: 700;
}

.kpi .val {
  position: relative;
  font-family: var(--display);
  font-size: clamp(18px, 3vw, 64px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: #ffffff;
}

.kpi-pending .val { color: var(--red); }

.progress {
  position: relative;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 6px;
}

.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.5s ease;
}

/* ---------- Main body ---------- */

.body {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(200px, 17vw, 340px);
  gap: var(--gap);
}

.board {
  min-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  padding: 5px;
}

.board.scroll { overflow-y: auto; }

/* The grid fills column by column so the list reads top to bottom, then across */
.grid {
  height: 100%;
  display: grid;
  grid-auto-flow: column;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows), minmax(0, 1fr));
  column-gap: 6px;
}

.board.scroll .grid {
  height: auto;
  grid-auto-flow: row;
  grid-template-rows: none;
  grid-auto-rows: calc(var(--fs) * 2.2);
}

.row {
  --p: 0%;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: calc(var(--fs) * 0.6);
  padding: 0 calc(var(--fs) * 0.6);
  border-radius: 9px;
  font-size: var(--fs);
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

/* Progress fill behind each row (same indicator colours, tuned for the dark board) */
.row::before {
  content: "";
  position: absolute;
  inset: 2px auto 2px 0;
  width: var(--p);
  background: linear-gradient(90deg, rgba(24, 166, 107, 0.04), rgba(24, 166, 107, 0.2));
  box-shadow: inset -3px 0 0 rgba(24, 166, 107, 0.85);
  border-radius: 9px;
  z-index: -1;
  transition: width 0.5s ease;
}

.row.amber::before {
  background: linear-gradient(90deg, rgba(231, 155, 22, 0.03), rgba(231, 155, 22, 0.18));
  box-shadow: inset -3px 0 0 rgba(231, 155, 22, 0.9);
}
.row.red::before {
  background: linear-gradient(90deg, rgba(220, 61, 80, 0.03), rgba(220, 61, 80, 0.18));
  box-shadow: inset -3px 0 0 rgba(220, 61, 80, 0.9);
}

.row:nth-child(odd) { background: rgba(255, 255, 255, 0.025); }

.row.done { opacity: 0.55; }

.name {
  min-width: 0;
  font-weight: 700;
  line-height: 1.12;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #ffffff;
}

.name small {
  display: block;
  font-size: 0.62em;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.left {
  font-family: var(--display);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--red);
  text-align: right;
  font-size: 1.1em;
}

.done .left { color: var(--green); }

.pill {
  min-width: 3.4em;
  text-align: center;
  padding: 0.18em 0.45em;
  border-radius: 99px;
  font-size: 0.72em;
  font-weight: 800;
  color: #fff;
  background: var(--green);
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.pill.amber { background: var(--amber); }
.pill.red { background: var(--red); }

.empty {
  display: grid;
  place-items: center;
  height: 100%;
  font-family: var(--display);
  font-weight: 700;
  color: var(--muted);
}

/* ---------- Side panel ---------- */

.side {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--radius);
  color: #fff;
  padding: clamp(12px, 1.1vw, 22px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid rgba(58, 160, 220, 0.25);
  background-color: var(--dcl-navy);
  background-image:
    url("../img/swoosh.svg"),
    url("../img/weave.svg"),
    linear-gradient(165deg, var(--dcl-blue) 0%, var(--dcl-navy) 55%, var(--dcl-deep) 100%);
  background-repeat: no-repeat, repeat, no-repeat;
  background-size: 150% auto, auto, 100% 100%;
  background-position: 30% 104%, 0 0, 0 0;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.15),
    0 12px 34px rgba(0, 8, 24, 0.45);
}

.side-title {
  font-family: var(--display);
  font-size: clamp(10px, 0.68vw, 14px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--dcl-yellow);
  margin-top: 8px;
}

.cat-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding: 7px 0;
  font-weight: 600;
  font-size: clamp(13px, 1vw, 22px);
}

.cat-row strong {
  font-family: var(--display);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.focus {
  font-family: var(--display);
  font-size: clamp(18px, 1.6vw, 34px);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

/* ---------- Footer ---------- */

.foot {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: clamp(11px, 0.7vw, 14px);
  font-weight: 600;
  min-width: 0;
}

.status {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conn {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  color: var(--ink);
  font-weight: 700;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  margin-right: 6px;
}

.dot.live { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.stale { background: var(--amber); }
.dot.error { background: var(--red); }
.dot.demo { background: var(--cyan); }

/* Big warning when data is old or demo */
.banner {
  position: fixed;
  left: 50%;
  top: 8px;
  transform: translateX(-50%);
  background: var(--red);
  color: #fff;
  font-weight: 900;
  padding: 8px 16px;
  border-radius: 99px;
  font-size: clamp(12px, 1vw, 20px);
  box-shadow: 0 6px 20px #0006;
  z-index: 10;
  max-width: calc(100vw - 20px);
  text-align: center;
}

.banner.demo { background: var(--cyan); }

/* ---------- Tablet and portrait ---------- */

@media (max-width: 1000px), (orientation: portrait) {
  .body { grid-template-columns: 1fr; }
  .side { display: none; }
}

/* ---------- Phone ---------- */

@media (max-width: 600px) {
  .brand p { display: none; }
  .brand h1 { font-size: 17px; }
  .logo { height: 38px; padding: 3px 7px; border-radius: 9px; }
  .top { gap: 8px; }
  .controls { width: 100%; flex-wrap: nowrap; }
  .control { flex: 1; min-width: 0; }
  .control > span { display: none; }
  .control select, .date-btn { width: 100%; padding: 0 8px; height: 36px; }
  .control select { padding-right: 28px; }
  .date-btn { min-width: 0; }
  .btn { height: 36px; padding: 0 10px; }
  #full { display: none; }
  .kpis { gap: 5px; }
  .kpi { padding: 7px 8px 9px; }
  .kpi .lab { letter-spacing: 0.06em; }
  .row { padding: 0 7px; }
  .foot .status { font-size: 10px; }
  .banner { top: auto; bottom: 34px; font-size: 11px; padding: 6px 12px; }
}
