:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #16202f;
  --ink-soft: #5b6779;
  --ink-faint: #8b95a5;
  --line: #dde3ed;
  --line-soft: #eaeef5;
  --brand: #1f3864;
  --brand-soft: #eaf0fb;
  --accent: #2563c9;
  --good: #16794a;
  --warn: #b45309;
  --bad: #b42318;
  --stripe: #f7f9fc;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 6px 20px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
}

h2 { font-size: 17px; margin: 0; }
h3 { font-size: 15px; margin: 0; }

/* ------------------------------------------------------------ top bar */

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 56px;
  background: var(--brand);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: rgba(255, 255, 255, .16);
  font-size: 12px;
  letter-spacing: .5px;
}

.topnav { display: flex; gap: 18px; margin-left: auto; }

.topnav a {
  color: rgba(255, 255, 255, .82);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 2px;
}

.topnav a:hover { color: #fff; }

/* --------------------------------------------------------------- page */

.page {
  max-width: 1680px;
  margin: 0 auto;
  padding: 20px 24px 60px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.meta-row strong { color: var(--ink); font-weight: 600; }

/* ----------------------------------------------------------- dropzone */

.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--stripe);
  padding: 26px 20px;
  text-align: center;
  transition: border-color .15s, background .15s;
}

.dropzone.is-over { border-color: var(--accent); background: var(--brand-soft); }
.dz-title { margin: 0 0 4px; font-size: 14.5px; }
.dz-hint { margin: 0; font-size: 12.5px; color: var(--ink-faint); }
.dz-status { margin-top: 10px; font-size: 13px; min-height: 18px; }
.dz-status.is-error { color: var(--bad); }
.dz-status.is-ok { color: var(--good); }
.dz-status.is-busy { color: var(--ink-soft); }

.link-btn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

/* -------------------------------------------------------- upload list */

.upload-list {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.upload-row {
  display: grid;
  grid-template-columns: 110px 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}

.upload-row:last-child { border-bottom: 0; }
.upload-row:nth-child(even) { background: var(--stripe); }
.upload-date { font-weight: 600; font-variant-numeric: tabular-nums; }
.upload-name { color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-counts { color: var(--ink-faint); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ----------------------------------------------------------- controls */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
}

.control-group { display: flex; flex-direction: column; gap: 5px; }
.control-group.grow { flex: 1 1 200px; min-width: 160px; }
.control-group.actions { margin-left: auto; }

.control-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--ink-faint);
  font-weight: 600;
}

.input {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  min-width: 120px;
}

.input:focus { outline: 2px solid var(--brand-soft); border-color: var(--accent); }

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  background: #fff;
}

.seg-btn {
  border: 0;
  background: #fff;
  padding: 0 14px;
  height: 34px;
  font: inherit;
  color: var(--ink-soft);
  cursor: pointer;
  border-right: 1px solid var(--line);
}

.seg-btn:last-child { border-right: 0; }
.seg-btn:hover { background: var(--stripe); }
.seg-btn.is-active { background: var(--brand); color: #fff; font-weight: 600; }

.btn-row { display: flex; gap: 8px; }

.btn {
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}

.btn:hover { background: var(--stripe); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #16294a; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--brand-soft); }
.btn-danger { color: var(--bad); border-color: transparent; background: transparent; }
.btn-danger:hover { background: #fdf1f0; }

.pill {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 19px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11.5px;
  font-weight: 700;
}

.icon-btn {
  border: 0;
  background: none;
  font-size: 22px;
  line-height: 1;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 0 4px;
}

.icon-btn:hover { color: var(--ink); }

/* --------------------------------------------------------- grid meta */

.grid-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 2px;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.spacer { flex: 1; }

.pager { display: flex; align-items: center; gap: 6px; }

.pager button {
  min-width: 30px;
  height: 28px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
}

.pager button:disabled { opacity: .4; cursor: not-allowed; }
.pager .page-info { font-variant-numeric: tabular-nums; padding: 0 4px; }

/* --------------------------------------------------------------- grid */

.grid-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  max-height: 68vh;
  background: #fff;
}

table.grid {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 12.5px;
}

table.grid th, table.grid td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line-soft);
  border-right: 1px solid var(--line-soft);
  white-space: nowrap;
  text-align: left;
}

table.grid th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f0f3f9;
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--line);
}

table.grid th:hover { background: var(--brand-soft); }
table.grid th .sort-arrow { color: var(--accent); margin-left: 4px; font-size: 10px; }
table.grid tbody tr:nth-child(even) { background: var(--stripe); }
table.grid tbody tr:hover { background: var(--brand-soft); }

table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td.is-null { color: var(--ink-faint); }

/* frozen name column */
table.grid th.sticky-col, table.grid td.sticky-col {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
  border-right: 1px solid var(--line);
}

table.grid tbody tr:nth-child(even) td.sticky-col { background: var(--stripe); }
table.grid tbody tr:hover td.sticky-col { background: var(--brand-soft); }
table.grid th.sticky-col { z-index: 4; background: #f0f3f9; }

table.grid td.sticky-col a { color: var(--accent); text-decoration: none; font-weight: 600; }
table.grid td.sticky-col a:hover { text-decoration: underline; }

.grid-empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--ink-faint);
}

/* ------------------------------------------------------ column panel */

.col-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 340px;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 30px rgba(16, 24, 40, .1);
  display: flex;
  flex-direction: column;
  z-index: 60;
  transform: translateX(100%);
  transition: transform .18s ease;
}

.col-panel.is-open { transform: translateX(0); }

.col-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.col-panel-tools {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}

.col-panel-tools .input { flex: 1 1 100%; min-width: 0; }

.col-panel-body { flex: 1; overflow-y: auto; padding: 6px 0 20px; }

.col-group-title {
  padding: 12px 16px 5px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--ink-faint);
  font-weight: 700;
}

.col-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 16px;
  cursor: pointer;
  font-size: 13px;
}

.col-item:hover { background: var(--stripe); }
.col-item input { width: 15px; height: 15px; cursor: pointer; accent-color: var(--brand); }
.col-item .col-key { color: var(--ink-faint); font-size: 11px; margin-left: auto; }
.col-item.is-locked { opacity: .55; cursor: not-allowed; }

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, .28);
  z-index: 55;
}

.hidden { display: none !important; }

/* -------------------------------------------------------------- modal */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, .35);
  display: grid;
  place-items: center;
  z-index: 70;
  padding: 24px;
}

.modal-card {
  background: #fff;
  border-radius: var(--radius);
  width: min(520px, 100%);
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 12px;
  box-shadow: var(--shadow);
}

.modal-head { display: flex; align-items: center; justify-content: space-between; }

.captain-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }

.captain-list li a {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 7px;
  text-decoration: none;
  color: var(--ink);
  font-size: 13px;
}

.captain-list li a:hover { background: var(--brand-soft); }
.captain-list .cap-sub { color: var(--ink-faint); font-size: 11.5px; }

/* -------------------------------------------------------------- toast */

.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 90;
}

.toast {
  background: #16202f;
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  max-width: 380px;
  box-shadow: var(--shadow);
}

.toast.is-error { background: var(--bad); }
.toast.is-ok { background: var(--good); }

/* ------------------------------------------------------------ confirm */

.confirm-actions { display: flex; gap: 8px; justify-content: flex-end; }
.confirm-text { font-size: 13.5px; color: var(--ink-soft); }

/* ------------------------------------------------------- card view (daily) */

.cards-wrap { padding-top: 2px; }

/* Headline strip: raw values lifted out of the row, nothing computed.

   Flex with a max-width rather than a stretching grid, because a single-group
   view (Putaway, Audit) has only one or two tiles and a 1fr grid would smear
   one number across the whole page. */
.summary-strip {
  display: inline-flex;      /* shrink-wraps, so the border hugs the tiles */
  flex-wrap: wrap;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  margin-bottom: 16px;
}

.summary-tile {
  flex: 0 0 auto;
  min-width: 158px;
  padding: 14px 18px;
  border-right: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.summary-tile:last-child { border-right: 0; }

.summary-value {
  font-size: 24px;
  font-weight: 650;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.4px;
  line-height: 1.15;
}

.summary-value.is-empty { color: var(--ink-faint); font-weight: 500; }

.summary-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--ink-faint);
  font-weight: 600;
}

/* Card deck.

   A column flow rather than a grid: cards have very different heights (8 time
   fields against 2 audit fields) and CSS grid would leave dead space under
   every short card.  Columns pack them tightly instead. */
.card-deck {
  column-width: 320px;
  column-gap: 14px;
}

.info-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  display: inline-block;
  width: 100%;
  margin: 0 0 14px;
}

.info-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--stripe);
  border-bottom: 1px solid var(--line-soft);
  border-left: 3px solid var(--ink-faint);
}

.info-card-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--ink);
}

.info-card-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-faint);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 1px 7px;
}

/* one hue per group so the eye finds a section without reading it */
.accent-picking .info-card-head { border-left-color: var(--accent); }
.accent-putaway .info-card-head { border-left-color: #0d9488; }
.accent-audit   .info-card-head { border-left-color: #7c3aed; }
.accent-context .info-card-head { border-left-color: #94a3b8; }

.tile-list { padding: 4px 0; }

.tile {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.tile:last-child { border-bottom: 0; }

.tile-label {
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.3;
}

.tile-value {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tile-value.is-empty { color: var(--ink-faint); font-weight: 400; }
.tile-value.is-raw { font-size: 12px; font-weight: 400; white-space: normal; text-align: right; }

/* shift sessions, reformatted from the raw {start TO end} text */
.tile-wide { flex-direction: column; align-items: stretch; gap: 7px; }

.shift-list { display: flex; flex-direction: column; gap: 5px; }

.shift-row {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--stripe);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  width: fit-content;
  max-width: 100%;
}

.shift-from, .shift-to { color: var(--ink); font-weight: 550; }
.shift-arrow { color: var(--accent); font-weight: 700; }

@media (max-width: 640px) {
  .summary-value { font-size: 20px; }
  .card-deck { column-width: auto; column-count: 1; }
}

/* ------------------------------------------------------ date navigator */

.date-bar {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--stripe);
}

.date-field { display: flex; flex-direction: column; gap: 5px; }

.date-field-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.date-input {
  min-width: 156px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.date-input::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .6; }
.date-input::-webkit-calendar-picker-indicator:hover { opacity: 1; }
.date-input:disabled { background: var(--line-soft); cursor: not-allowed; }

/* aligned with the inputs, not their labels */
.date-bar .nav-btn { margin-bottom: 1px; white-space: nowrap; }

@media (max-width: 560px) {
  .date-bar { gap: 8px; }
  .date-field { flex: 1 1 140px; }
  .date-input { min-width: 0; width: 100%; }
}

/* ------------------------------------------- captain: the fixed header */

.clock-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin: 0 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.clock-tile {
  flex: 1 1 168px;
  min-width: 148px;
  padding: 14px 18px;
  border-right: 1px solid var(--line-soft);
}

.clock-tile:last-child { border-right: 0; }

.clock-value {
  display: block;
  font-size: 20px;
  font-weight: 650;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}

.clock-value.is-empty { color: var(--ink-faint); font-weight: 500; }

.clock-label {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.clock-sub {
  display: block;
  margin-top: 5px;
  font-size: 11.5px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------ captain: overtime */

/* Sits directly under the five clocks but reads as a different kind of
   number: the clocks are sheet values, this is computed. */
.ot-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  margin: -10px 0 18px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius);
  background: var(--card);
}

.ot-label {
  font-size: 11px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.ot-value {
  font-size: 17px;
  font-weight: 650;
  color: var(--warn);
  font-variant-numeric: tabular-nums;
}

.ot-value.is-empty { color: var(--ink-faint); font-weight: 500; font-size: 15px; }
.ot-note { font-size: 12.5px; color: var(--ink-soft); }
.ot-strip.is-none { border-left-color: var(--line); }

/* ----------------------------------------- captain: accumulation band */

.acc-band {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 14px;
  margin-bottom: 14px;
  padding: 10px 14px;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--brand-soft);
}

.acc-band-main { font-weight: 650; color: var(--brand); font-size: 13.5px; }
.acc-band-sub { font-size: 12.5px; color: var(--ink-soft); }
.acc-band-warn { font-size: 12.5px; color: var(--warn); font-weight: 600; }

.tile-sub {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.shift-days { display: flex; flex-direction: column; gap: 8px; }
.shift-day-date {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------- captain: derived section */

.derived-wrap { margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--line); }

.derived-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-bottom: 12px;
}

.derived-title { margin: 0; font-size: 14px; color: var(--ink); }
.derived-note { font-size: 12.5px; color: var(--ink-faint); }

.accent-derived .info-card-head { border-left-color: #b45309; }

.fx {
  display: inline-block;
  font-style: italic;
  font-weight: 700;
  color: var(--warn);
  cursor: help;
}

.tile-caution {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--warn);
}

@media (max-width: 640px) {
  .clock-tile { flex: 1 1 50%; border-bottom: 1px solid var(--line-soft); }
}

/* The tile is a label/value row; a caution or an avg subline needs its own
   full-width line rather than competing for the value column. */
.tile { flex-wrap: wrap; }
.tile-label { flex: 1 1 auto; min-width: 0; }
.tile-value { flex: 0 0 auto; }
.tile-sub { flex: 1 0 100%; text-align: right; margin-top: 0; }
.tile-caution { flex: 1 0 100%; }

.tile-tag {
  margin-left: 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* An empty window is a result, not a failure - stated, not hidden. */
.no-data {
  padding: 44px 20px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--stripe);
}

.no-data-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--ink-soft);
}

.no-data-sub { margin-top: 6px; font-size: 13px; color: var(--ink-faint); }

/* A date inside the loaded range with no file is not a quiet day - say so. */
.gap-note {
  margin-top: 12px;
  padding: 9px 12px;
  border-left: 3px solid var(--warn);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: #fffbeb;
  font-size: 12.5px;
  color: #7c4a03;
}

/* An empty financial month says where the data actually is. */
.empty-hint {
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--stripe);
  text-align: center;
}

.empty-hint-title { font-size: 13.5px; font-weight: 650; color: var(--ink-soft); }
.empty-hint-sub { margin-top: 5px; font-size: 12.5px; color: var(--ink-faint); }
.empty-hint-sub strong { color: var(--ink); }

/* ------------------------------------------------- store data analysis */

.analysis-scope {
  color: var(--ink-faint);
  font-size: 12px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-soft);
  margin-right: 12px;
  cursor: pointer;
}

.chart-sub {
  color: var(--ink-faint);
  font-size: 12px;
}

.chart-wrap {
  position: relative;
  padding: 8px 4px 0;
}

.chart-wrap svg { display: block; overflow: visible; }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 10px 4px 2px;
  font-size: 12px;
  color: var(--ink-soft);
}

.legend-item { display: inline-flex; align-items: center; gap: 6px; }

.legend-item i,
.tip-key i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
  flex: none;
}

.chart-tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 8px 10px;
  font-size: 12px;
  min-width: 168px;
}

.tip-head {
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}

.tip-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  align-items: center;
}

.tip-key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-soft);
}

.tip-val {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.tip-foot {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--line-soft);
  color: var(--ink-faint);
}

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 4px 0 2px;
}

.stat-tile {
  flex: 1 1 160px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--stripe);
}

.stat-label {
  font-size: 12px;
  color: var(--ink-soft);
}

.stat-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.stat-note {
  font-size: 11px;
  color: var(--ink-faint);
}

@media (max-width: 620px) {
  .stat-tile { flex-basis: 100%; }
}

/* The exclusions group is two rows tall; without this the date controls
   float to its vertical centre instead of lining up along the top. */
.analysis-controls { align-items: flex-start; }

.analysis-controls .check {
  display: flex;
  margin-right: 0;
}


/* ------------------------------------------------------------ red zone */

.pill-bad { background: #fde8e6; color: var(--bad); }

table.grid tbody tr.is-red-zone td:first-child { box-shadow: inset 3px 0 0 var(--bad); }

.zone-badge {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin-top: 10px;
  padding: 7px 12px;
  border: 1px solid #f3c1bc;
  border-radius: var(--radius);
  background: #fde8e6;
  color: var(--bad);
  font-size: 12.5px;
}
.zone-badge strong { font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }

/* ------------------------------------------------- nav groups (home menu) */

.topnav { align-items: center; }
.topnav { gap: 26px; }
.topnav > a.is-current, .nav-drop-btn.is-current { color: #fff; box-shadow: inset 0 -2px 0 #fff; }

/* Manpower Performance drop-down: opens on hover, and on click / keyboard
   focus so it works on touch screens too */
.nav-dropdown { position: relative; }
.nav-drop-btn {
  background: none;
  border: 0;
  color: rgba(255, 255, 255, .82);
  font: inherit;
  font-size: 13px;
  padding: 6px 2px;
  cursor: pointer;
}
.nav-drop-btn:hover { color: #fff; }
.nav-drop-btn .caret { font-size: 10px; margin-left: 3px; opacity: .8; }
.nav-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  min-width: 190px;
  padding: 6px;
  margin-top: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(16, 24, 40, .16);
  z-index: 60;
}
.nav-menu::before {            /* bridge the gap so the menu stays open while the pointer moves down */
  content: "";
  position: absolute;
  left: 0; right: 0; top: -10px; height: 10px;
}
.nav-dropdown:hover .nav-menu,
.nav-dropdown:focus-within .nav-menu { display: block; }
.topnav .nav-menu a {
  display: block;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--ink);
  font-size: 13px;
}
.topnav .nav-menu a:hover { background: var(--brand-soft); color: var(--brand); }
.topnav .nav-menu a.is-current { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

/* -------------------------------------------------------------- home */

.home-intro h1 { font-size: 22px; margin: 0 0 4px; }
.home-intro p { margin: 0; color: var(--ink-soft); }

.home-menu {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}

.home-tile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 24px;
  color: inherit;
  text-decoration: none;
  border-top: 4px solid var(--brand);
  transition: transform .12s, box-shadow .12s;
}
.home-tile:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(16, 24, 40, .12); }
.home-tile.accent-emp { border-top-color: #0d9488; }
.home-tile-num { font-size: 13px; font-weight: 700; color: var(--ink-faint); }
.home-tile h2 { font-size: 20px; }
.home-tile p { margin: 0; color: var(--ink-soft); }
.home-tile ul { margin: 0; padding-left: 18px; color: var(--ink-soft); font-size: 13px; }
.home-tile-stat { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line-soft);
  font-size: 13px; color: var(--ink-soft); }
.home-tile-stat strong { color: var(--ink); }
.home-tile-go { color: var(--accent); font-weight: 600; }

/* --------------------------------------------------------- employees */

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--line-soft);
  color: var(--ink-soft);
  white-space: nowrap;
}
.badge.is-active { background: #e7f6ee; color: var(--good); }
.badge.is-left { background: #fdf1f0; color: var(--bad); }
.badge.is-warn { background: #fff6e6; color: var(--warn); }

table.grid td.actions { white-space: nowrap; }
table.grid td.actions .btn { padding: 3px 8px; font-size: 12px; }
table.grid tr.is-left td { color: var(--ink-faint); }
table.grid td.sub { color: var(--ink-faint); font-size: 12px; }

.modal-card.wide { width: min(860px, 100%); max-height: 90vh; overflow-y: auto; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 16px;
}
.form-section {
  grid-column: 1 / -1;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--ink-faint);
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 4px;
  margin-top: 6px;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.field label .req { color: var(--bad); }
.field .input { width: 100%; }
.field textarea.input { min-height: 56px; resize: vertical; font: inherit; }
.field .field-error { color: var(--bad); font-size: 12px; min-height: 0; }
.field.has-error .input { border-color: var(--bad); }
.field .hint { font-size: 11.5px; color: var(--ink-faint); }

.import-table td { vertical-align: top; }
.import-flags { margin: 0; padding-left: 16px; font-size: 12px; color: var(--warn); }
.history-list { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.history-list li { padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.history-list .when { color: var(--ink-faint); }
a.btn { text-decoration: none; }

/* ------------------------------------------- employees: selection + actions */

.action-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin: 4px 0 10px;
  background: var(--stripe);
  border: 1px solid var(--line);
  border-radius: 8px;
  position: sticky;
  top: 62px;
  z-index: 5;
}
.action-count { font-weight: 600; font-size: 13px; min-width: 110px; }
.action-sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

table.grid.selectable tbody tr { cursor: pointer; }
table.grid th.sel, table.grid td.sel { width: 34px; text-align: center; }
table.grid th.sel input, table.grid td.sel input { width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer; }
table.grid tbody tr.is-selected, table.grid tbody tr.is-selected:nth-child(even) { background: #dfe8fa; }
table.grid tr.is-doubt td { background: #fffaf0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.sub { color: var(--ink-faint); font-size: 12px; }
.member { padding: 2px 0; white-space: nowrap; }
.import-table select.input { min-width: 230px; }

.id-list { border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; }
.id-row {
  display: grid;
  grid-template-columns: 180px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line-soft);
}
.id-row:last-child { border-bottom: 0; }
.gap-note ul { margin: 4px 0 0; padding-left: 18px; }

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

.nav-user { display: flex; align-items: center; gap: 10px; margin-left: 8px;
  padding-left: 18px; border-left: 1px solid rgba(255, 255, 255, .25); }
.nav-user-name { color: rgba(255, 255, 255, .9); font-size: 13px; }
.nav-logout {
  background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .25);
  color: #fff; border-radius: 6px; padding: 4px 10px; font: inherit; font-size: 12.5px; cursor: pointer;
}
.nav-logout:hover { background: rgba(255, 255, 255, .22); }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(160deg, var(--brand) 0%, #2b4f8a 55%, var(--bg) 55.1%); }
.login-card { width: min(400px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 28px; }
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-brand .brand-mark { background: var(--brand); color: #fff; width: 38px; height: 38px; font-size: 14px; }
.login-brand h1 { font-size: 18px; margin: 0; }
.login-brand p { margin: 2px 0 0; color: var(--ink-soft); font-size: 12.5px; }
.login-card .field .input { padding: 9px 10px; font-size: 14px; }
.login-card .btn-primary { padding: 10px; font-size: 14px; justify-content: center; }
.login-error { color: var(--bad); font-size: 13px; min-height: 18px; }

/* access: controls the user may not use */
.no-access { display: none !important; }

/* ---------------------------------------------------- attendance / OT / bonus */
.emp-link { color: var(--brand); font-weight: 600; text-decoration: none; }
.emp-link:hover { text-decoration: underline; }
.month-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lock-banner { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-radius: 8px; margin: 10px 0; font-size: 13px; }
.lock-banner.is-locked { background: #e7f0fb; border: 1px solid #bcd3ef; }
.lock-banner.is-open { background: #fff6e6; border: 1px solid #f2d9a6; }
.att-grid td.d, .att-grid th.d { text-align: center; padding: 3px 2px; min-width: 22px; font-size: 12px; }
.att-grid th.sun, .att-grid td.sun { background: #f3f5f9; }
.d.v1 { color: #1b7f3b; font-weight: 600; }
.d.v05 { color: #b26a00; font-weight: 600; }
.d.v0 { color: #b42318; }
.d.adj { box-shadow: inset 0 -2px 0 #6b8fd6; }
.att-grid tbody tr { cursor: pointer; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.ok-mark { color: #1b7f3b; font-weight: 700; }
.no-mark { color: #b42318; font-weight: 700; }
.rules-list { margin: 6px 0 0; padding-left: 18px; }
.rules-list li { margin: 2px 0; }
.preview-box { max-height: 46vh; overflow-y: auto; font-size: 13px; }
.preview-box h4 { margin: 10px 0 4px; }
.preview-box ul { margin: 0; padding-left: 18px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 13px; }
.kv dt { color: var(--ink-soft); font-weight: 600; }
.kv dd { margin: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line, #dde3ea); margin: 6px 0 12px; }
.tabs button { border: 0; background: none; padding: 8px 14px; cursor: pointer; font: inherit; color: var(--ink-soft);
  border-bottom: 2px solid transparent; }
.tabs button.is-on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.stat-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.stat { background: var(--brand-soft, #eef3fb); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.stat b { font-size: 15px; }

/* ------------------------------------------------ Fetch from Gmail (admin) */
#mailfetch-card { margin-top: 16px; }
.mf-scope { margin: 4px 0 0; font-size: 13px; color: var(--ink-soft); }
.mf-scope.is-warn, .mf-note.is-warn { color: var(--warn); }
.mf-note.is-bad { color: var(--bad); }
.mf-actions { display: flex; gap: 8px; flex: none; }
.mf-settings {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px;
  padding: 14px; margin-bottom: 14px; border: 1px solid var(--line-soft);
  border-radius: 8px; background: var(--stripe);
}
.mf-check { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; font-size: 13px; }
.mf-form-actions { grid-column: 1 / -1; display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.mf-saved { font-size: 12px; color: var(--ink-faint); }
.mf-run-head { font-size: 13.5px; padding: 8px 12px; border-radius: 8px; background: var(--stripe); }
.mf-run-head.is-failed { background: #fdf1f0; }
.mf-run-head.is-done { background: #eef7f2; }
.mf-note { font-size: 13px; margin: 8px 0 0; }
.mf-empty { font-size: 13px; color: var(--ink-faint); margin: 0; }
.mf-table { margin-top: 10px; overflow-x: auto; }
.mf-items td.sub { max-width: 420px; white-space: normal; }
@media (max-width: 820px) { .mf-settings { grid-template-columns: 1fr; } }

/* ------------------------------------------------ Dashboard tabs */
.dash-tabs { margin: 0 0 14px; }
.dash-tabs button { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.dash-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--warn); color: #fff; font-size: 11px; font-weight: 700;
  line-height: 18px; text-align: center;
}
.dash-panel > .card + .card { margin-top: 16px; }
.toast-action {
  margin-left: 10px; padding: 2px 8px; border: 1px solid rgba(255,255,255,.6);
  border-radius: 6px; background: transparent; color: #fff; font: inherit;
  font-weight: 600; cursor: pointer;
}
.toast-action:hover { background: rgba(255,255,255,.15); }

/* ------------------------------------------- dashboard: Statistics tab */
#stats-card.is-loading { opacity: .6; transition: opacity .15s; }
.st-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.st-nav { display: flex; align-items: center; gap: 6px; }
.st-date { width: 150px; }
.st-meta { color: var(--ink-soft); font-size: 13px; }
.st-kpis .stat-tile.is-main { background: var(--brand-soft); border-color: #c9d6ee; }
.st-kpis .stat-tile.is-main .stat-value { color: var(--brand); font-size: 28px; }
.st-title { margin: 20px 0 10px; font-size: 14px; }
.st-hint { margin-left: 8px; font-weight: 400; font-size: 12px; color: var(--ink-faint); }
.st-shifts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.st-shift { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 8px; background: var(--card); }
.st-shift.is-on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.st-shift-head { display: flex; align-items: center; gap: 8px; }
.st-shift-name { font-weight: 600; }
.st-shift-roster { margin-left: auto; font-size: 11px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.st-shift-value { font-size: 30px; font-weight: 600; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.st-shift-split { display: flex; gap: 14px; font-size: 13px; color: var(--ink-soft); }
.st-shift-split .st-od { color: var(--ink); font-weight: 600; }
.st-shift-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; padding-top: 6px;
  border-top: 1px solid var(--line-soft); font-size: 11px; color: var(--ink-faint); }
.st-names { padding: 2px 6px; font-size: 12px; }
.st-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.st-legend { display: flex; gap: 16px; font-size: 12px; color: var(--ink-soft); margin-bottom: 4px; }
.st-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.st-trend { position: relative; }
.st-svg { width: 100%; height: auto; display: block; }
.st-svg .st-grid { stroke: var(--line-soft); stroke-width: 1; }
.st-svg .st-base { stroke: var(--line); stroke-width: 1; }
.st-svg .st-axis { font-size: 11px; fill: var(--ink-faint); }
.st-svg .st-axis.is-sel { fill: var(--ink); font-weight: 700; }
.st-svg .st-axis-sub { font-size: 10px; }
.st-svg .st-total { font-size: 12px; font-weight: 700; fill: var(--ink); }
.st-svg .st-hit { fill: transparent; cursor: pointer; }
.st-svg .st-bar.is-empty .st-hit { cursor: default; }
.st-svg .st-bar:not(.is-sel) path, .st-svg .st-bar:not(.is-sel) rect:not(.st-hit) { opacity: .55; }
.st-svg .st-bar:hover path, .st-svg .st-bar:hover rect:not(.st-hit) { opacity: 1; }
.st-tip { position: absolute; z-index: 5; min-width: 150px; padding: 8px 10px; border-radius: 8px; background: #fff;
  border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 12px; pointer-events: none; }
.st-tip strong { display: block; margin-bottom: 4px; }
.st-tip-row { display: flex; align-items: center; gap: 6px; }
.st-tip-n { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }
.st-tip-total { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--line-soft); }
.st-people-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 20px; }
.st-people-head .st-title { margin: 0; }
#st-people { margin-top: 10px; scroll-margin-top: 70px; }
.st-table td { vertical-align: top; }
.st-line { display: flex; align-items: center; justify-content: inherit; gap: 6px; white-space: nowrap; }
.st-table td.num .st-line { justify-content: flex-end; }
.st-tag { margin-left: 6px; }
.st-empty { color: var(--ink-faint); padding: 10px 0; }
.st-rules { margin: 14px 0 0; font-size: 12px; color: var(--ink-faint); line-height: 1.5; }
@media (max-width: 900px) { .st-shifts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .st-shifts { grid-template-columns: 1fr; } }

/* ------------------------------------------------------- Settings page */
#cfg-editor { margin-top: 16px; }
.cfg-help { margin: 0 0 12px; padding: 8px 12px; border-radius: 8px; background: var(--brand-soft); color: var(--ink-soft); font-size: 13px; }
#cfg-form { display: flex; flex-direction: column; gap: 14px; }
.field textarea.cfg-json { font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; min-height: 420px; white-space: pre; tab-size: 2; }
.cfg-json-state { font-size: 12px; }
.cfg-json-state.is-ok { color: var(--good); }
.cfg-json-state.is-bad { color: var(--bad); }
.field-note { font-size: 12px; color: var(--ink-faint); }
.cfg-errors { margin: 0; padding: 10px 12px 10px 28px; border-radius: 8px; background: #fdf1f0; color: var(--bad); font-size: 13px; }
.cfg-actions { align-items: center; }
.cfg-actions .grow { flex: 1; }
.cfg-table code { font-size: 13px; }
/* Statistics: newest-day note and the Absent card */
.st-note { margin: 0 0 12px; padding: 8px 12px; border-radius: 8px; background: var(--brand-soft); color: var(--brand); font-size: 13px; }
.st-shifts { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.st-absent { background: var(--stripe); }
.st-swatch-absent { background: var(--ink-faint); }
@media (max-width: 1100px) { .st-shifts { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) { .st-shifts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .st-shifts { grid-template-columns: 1fr; } }
