/* Encirc loads dashboard portal (public, read-only) */
:root {
  --primary: #2fa84f;
  --primaryDark: #238a3f;
  --danger: #ef4444;
  --ok: #10b981;
  --warn: #f59e0b;

  --bg: #f1f5f9;
  --panel: #ffffff;
  --panelSoft: #f8fafc;
  --panelBorder: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.10);

  --green: #16a34a;
  --flint: #0ea5e9;
  --amber: #d97706;
  --fine: #8b5cf6;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 12px 14px 12px 14px;
}

.wrap { width: 100%; max-width: 1100px; margin: 0 auto; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 10px; padding: 8px 16px;
  border: 1px solid var(--panelBorder); border-radius: 16px; background: var(--panel);
  box-shadow: var(--shadow);
}
/* Brand lockup: logo shares the title's centerline; subtitle sits under the title. */
.brandMark {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto;
  column-gap: 16px; align-items: center;
}
.brandMark img {
  grid-column: 1; grid-row: 1 / span 2; align-self: center;
  height: 40px; width: auto; max-width: 200px; object-fit: contain;
  display: block; padding-right: 16px; border-right: 1px solid var(--panelBorder);
}
.brandMark h1 { grid-column: 2; grid-row: 1; align-self: center; font-size: 17px; line-height: 1.15; margin: 0; letter-spacing: 0.2px; }
.brandMark p { grid-column: 2; grid-row: 2; align-self: center; margin: 2px 0 0; color: var(--muted); font-size: 13px; line-height: 1.2; }

.card {
  background: var(--panel); border: 1px solid var(--panelBorder);
  border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; margin-bottom: 8px;
}
.cardHeader { padding: 9px 16px 0 16px; }
.cardBody { padding: 10px 16px; }

.grid { display: grid; gap: 14px; }
.actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input[type="email"], input[type="text"] {
  width: 100%; padding: 12px 14px; border: 1px solid var(--panelBorder);
  border-radius: 12px; font-size: 15px; background: #fff; color: var(--text);
}
input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47,168,79,0.15); }

.btn {
  appearance: none; border: 1px solid var(--panelBorder); background: #fff; color: var(--text);
  padding: 11px 18px; border-radius: 12px; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: transform .05s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { background: var(--panelSoft); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:disabled:hover, .weekNav .btn:disabled:hover { background: transparent; transform: none; }
.btnPrimary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btnPrimary:hover { background: var(--primaryDark); border-color: var(--primaryDark); }
.btnGhost { background: transparent; }

.hint { color: var(--muted); font-size: 13px; margin: 0 0 6px; line-height: 1.5; }

/* Status card: calm headline + small inline pace pill + tight KPI row */
.statusCard.none { color: var(--muted); text-align: center; font-size: 14px; padding: 8px 0; }

.paceHeadline {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--panelBorder);
  border-left-width: 4px;
  background: var(--panel);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.paceHeadlineMain { min-width: 0; }
.paceHeadline.ahead,
.paceHeadline.ontrack { border-left-color: var(--ok); }
.paceHeadline.behind { border-left-color: var(--warn); }
.paceHeadline.behindMajor { border-left-color: var(--danger); }
.paceHeadline.none { border-left-color: var(--panelBorder); }

.paceTitle {
  margin: 0;
  font-size: 17px; font-weight: 700; letter-spacing: 0.1px;
  color: var(--text);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.paceDetail { margin: 4px 0 0; font-size: 13px; color: var(--muted); }

/* Pace badge - plain-language "X up/down" immediately after the headline. */
.pacePill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  margin: 0;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 13px; font-weight: 800; white-space: nowrap;
}
.pacePill.ahead, .pacePill.ontrack {
  background: rgba(16,185,129,0.12); color: #047857; border-color: rgba(16,185,129,0.28);
}
.pacePill.behind {
  background: rgba(245,158,11,0.16); color: #b45309; border-color: rgba(245,158,11,0.32);
}
.pacePill.behindMajor {
  background: rgba(239,68,68,0.12); color: #b91c1c; border-color: rgba(239,68,68,0.28);
}
.pacePillArrow { font-size: 11px; line-height: 1; }

/* Full-width summary progress rows */
.summaryProgressList { display: grid; gap: 10px; }
.summaryProgress {
  background: var(--panelSoft);
  border: 1px solid var(--panelBorder);
  border-radius: 12px;
  padding: 10px 14px;
}
.summaryProgressHead {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin-bottom: 8px;
}
.summaryProgressTitle { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 800; }
.summaryProgressMeta { font-size: 13px; color: var(--text); font-weight: 700; text-align: right; }
.summaryProgressTrack {
  height: 14px; display: flex; overflow: hidden; border-radius: 999px;
  background: rgba(148,163,184,0.28);
}
.summaryProgressCollected {
  background: linear-gradient(90deg, var(--primary), var(--primaryDark));
  min-width: 0;
}
.summaryProgressCollected.ahead { background: linear-gradient(90deg, var(--ok), #059669); }
.summaryProgressCollected.ontrack { background: linear-gradient(90deg, var(--ok), #059669); }
.summaryProgressCollected.behind { background: linear-gradient(90deg, var(--warn), #d97706); }
.summaryProgressCollected.behindMajor { background: linear-gradient(90deg, var(--danger), #b91c1c); }
.summaryProgressOutstanding {
  background: linear-gradient(90deg, #cbd5e1, #94a3b8);
  min-width: 0;
}
.summaryProgressFoot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 7px; font-size: 12px; color: var(--muted);
}
.summaryProgressLegend { display: inline-flex; align-items: center; gap: 6px; }
.summaryProgressLegend::before {
  content: ""; width: 9px; height: 9px; border-radius: 999px; display: inline-block;
}
.summaryProgressLegend.collected::before { background: var(--primary); }
.summaryProgressLegend.collected.ahead::before { background: var(--ok); }
.summaryProgressLegend.collected.ontrack::before { background: var(--ok); }
.summaryProgressLegend.collected.behind::before { background: var(--warn); }
.summaryProgressLegend.collected.behindMajor::before { background: var(--danger); }
.summaryProgressLegend.outstanding::before { background: #94a3b8; }
.summaryProgressOver { color: #047857; font-weight: 800; }
.summaryProgressEmpty { color: var(--muted); font-size: 13px; }
@supports not (display: flex) {
  .summaryProgressTrack { display: block; }
}

/* Inline progress (for the By Colour table Progress column) */
.progressWrap { height: 8px; background: rgba(148,163,184,0.28); border-radius: 999px; overflow: hidden; flex: 1; min-width: 60px; }
.progressBar { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primaryDark)); border-radius: 999px; transition: width .4s ease; }
.progressBar.ahead { background: linear-gradient(90deg, var(--ok), #059669); }
.progressBar.ontrack { background: linear-gradient(90deg, var(--warn), #d97706); }
.progressBar.behind { background: linear-gradient(90deg, var(--warn), #d97706); }
.progressInline { display: flex; align-items: center; gap: 8px; width: 100%; }
.pctLabel { font-size: 12px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; min-width: 36px; text-align: right; }
.colProgress { text-align: right; }

/* By Colour table: fixed, balanced columns so progress bars fill their lane.
   Headers wrap instead of overflowing their column, so the table never forces
   horizontal scrolling. */
#colourTable { table-layout: fixed; }
#colourTable thead th { white-space: normal; }
#colourTable th:nth-child(1), #colourTable td:nth-child(1) { width: 20%; }
#colourTable th:nth-child(2), #colourTable td:nth-child(2) { width: 16%; }
#colourTable th:nth-child(3), #colourTable td:nth-child(3) { width: 13%; }
#colourTable th:nth-child(4), #colourTable td:nth-child(4) { width: 13%; }
#colourTable th:nth-child(5), #colourTable td:nth-child(5) { width: 13%; }
#colourTable th:nth-child(6), #colourTable td:nth-child(6) { width: 13%; }
#colourTable th:nth-child(7), #colourTable td:nth-child(7) { width: 12%; }
/* Centre every numeric column so each figure sits cleanly under its heading */
#colourTable th:not(:first-child), #colourTable td:not(:first-child) { text-align: center; }

@media (max-width: 720px) {
  .paceHeadline { align-items: flex-start; flex-direction: column; }
  .summaryProgressHead { align-items: flex-start; flex-direction: column; gap: 4px; }
  .summaryProgressMeta { text-align: left; }
}

/* Combined matrix: scheduled header, haulier rows, collected totals, status row */
table.matrix tbody tr.rowSchedHeader td { background: var(--panelSoft); font-weight: 700; border-bottom: 2px solid var(--panelBorder); }
table.matrix tbody tr.rowSchedHeader .haulierCol { background: var(--panelSoft); }
table.matrix tbody tr.rowSchedHeader td.schedCell { text-align: center; font-size: 14px; }
table.matrix tfoot tr.rowCollectedTotal td { background: var(--panelSoft); font-weight: 700; border-top: 2px solid var(--panelBorder); }
table.matrix tfoot tr.rowCollectedTotal .haulierCol { background: var(--panelSoft); }
table.matrix tfoot tr.rowCollectedTotal .totalCol { background: var(--panelSoft); }
table.matrix tfoot tr.rowStatusFoot td { font-size: 13px; font-weight: 700; background: var(--panel); border-top: 1px solid var(--panelBorder); }
table.matrix tfoot tr.rowStatusFoot .haulierCol { background: var(--panelSoft); }
table.matrix .dayAhead { color: var(--ok); }
table.matrix .dayBehind { color: var(--warn); }
table.matrix .dayOn { color: var(--ok); }
table.matrix .dayMuted { color: var(--muted); }

/* Week navigation - grouped into a tidy pill */
.weekNav {
  display: flex; align-items: center; gap: 6px;
  padding: 6px; border: 1px solid var(--panelBorder); border-radius: 999px;
  background: var(--panelSoft);
}
.weekNav .btn { padding: 7px 11px; border-radius: 999px; border-color: transparent; background: transparent; }
.weekNav .btn:hover { background: #fff; }
.weekNav .weekLabel { font-weight: 700; font-size: 15px; min-width: 120px; text-align: center; }

/* Table */
.tableWrap { overflow-x: auto; }
table.encirc { width: 100%; border-collapse: collapse; font-size: 14px; }
table.encirc th, table.encirc td { padding: 6px 12px; text-align: right; border-bottom: 1px solid var(--panelBorder); white-space: nowrap; }
table.encirc th:first-child, table.encirc td:first-child { text-align: left; }
table.encirc thead th { background: var(--panelSoft); color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .3px; position: sticky; top: 0; }
table.encirc tbody tr:hover { background: var(--panelSoft); }
table.encirc tfoot td { font-weight: 700; background: var(--panelSoft); border-top: 2px solid var(--panelBorder); }

.colourDot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.dot-green { background: var(--green); }
.dot-flint { background: var(--flint); }
.dot-amber { background: var(--amber); }
.dot-fine_grind { background: var(--fine); }

.cellMain { font-weight: 600; }
.cellSub { font-size: 12px; color: var(--muted); }
.cellZero { color: #cbd5e1; }
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); }

/* Compact matrix: one row per haulier, days across, colour sub-columns */
table.matrix { font-size: 11.5px; min-width: 0; }
table.matrix th, table.matrix td { padding: 4px 4px; text-align: center; }
/* Day group header (top header row) */
table.matrix thead th.dayGroup {
  text-align: center; font-size: 12px; color: var(--text);
  border-left: 2px solid var(--panelBorder);
}
/* Colour sub-headers, tinted like the internal email */
table.matrix thead th.cGreen { background: #dcfce7; color: #14532d; text-transform: none; letter-spacing: 0; font-size: 11px; }
table.matrix thead th.cFlint { background: #e0f2fe; color: #075985; text-transform: none; letter-spacing: 0; font-size: 11px; }
table.matrix thead th.cAmber { background: #ffedd5; color: #7c2d12; text-transform: none; letter-spacing: 0; font-size: 11px; }
table.matrix thead th.cGreen { border-left: 2px solid var(--panelBorder); }
/* Fixed layout gives every colour column an identical width, so each day's
   three figures and the per-day +/- pace value all line up in one clean
   vertical column (and the table can never force horizontal scroll). */
table.matrix { table-layout: fixed; }
table.matrix .haulierCol { width: 118px; }
table.matrix .totalCol { width: 52px; }
/* Vertical separator at the end of each day group */
table.matrix td.dayEnd, table.matrix th.dayEnd { border-right: 2px solid var(--panelBorder); }
/* Haulier column: left-aligned, sticky, prominent */
table.matrix .haulierCol {
  text-align: left; font-weight: 700; white-space: nowrap;
  position: sticky; left: 0; background: var(--panel); z-index: 1;
  border-right: 2px solid var(--panelBorder);
}
table.matrix tbody tr:hover .haulierCol { background: var(--panelSoft); }
table.matrix .totalCol { font-weight: 700; background: var(--panelSoft); }
table.matrix tbody td { border-bottom: 1px solid #eef2f7; }
/* Totals footer */
table.matrix tfoot td { font-weight: 700; background: var(--panelSoft); border-top: 2px solid var(--panelBorder); }
table.matrix tfoot .haulierCol { background: var(--panelSoft); }
table.matrix tfoot .totalCol { background: var(--panelSoft); }

.muted { color: var(--muted); }
.right { text-align: right; }
.center { text-align: center; }

.skeleton { color: var(--muted); padding: 24px; text-align: center; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px;
  background: #0f172a; color: #fff; box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; z-index: 100; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.toast.err .dot { background: var(--danger); }

/* Banner shown when staff change the weekly schedule (figures auto-refresh). */
.scheduleNote {
  display: none;
  margin: 0 0 12px; padding: 10px 14px; border-radius: 12px;
  background: rgba(47, 168, 79, 0.10); color: var(--primaryDark);
  border: 1px solid rgba(47, 168, 79, 0.30); font-size: 14px; font-weight: 600;
}
.scheduleNote.show { display: block; }
.scheduleNote.fresh { animation: scheduleNotePulse 1.4s ease-in-out 0s 3; }
@keyframes scheduleNotePulse {
  0%, 100% { background: rgba(47, 168, 79, 0.10); }
  50% { background: rgba(47, 168, 79, 0.30); }
}

.logoutFixed { position: fixed; right: 18px; bottom: 18px; z-index: 50; }

/* Branded footer line under the data-updated hint */
.pageFooter {
  text-align: center; color: var(--muted); font-size: 12px;
  margin: 10px 0 0; padding-top: 12px;
}

@media (max-width: 640px) {
  .topbar { gap: 12px; }
  .brandMark { column-gap: 12px; width: 100%; }
  .brandMark img { height: 34px; padding-right: 12px; }
  .brandMark h1 { font-size: 16px; }
  .weekNav { width: 100%; justify-content: space-between; }
  .weekNav .weekLabel { min-width: 0; flex: 1; font-size: 14px; }
}
