@import url("https://fonts.googleapis.com/css2?family=Public+Sans:wght@400;500;600;700;800&display=swap");
body { margin: 0; }

/* ---------- Tokens ---------- */
.dw {
  --band: #1f2e55;
  --band-2: #2a3c6b;
  --band-ink: #ffffff;
  --band-dim: #b9c3dc;
  --paper: #f4f6fa;
  --surface: #ffffff;
  --ink: #17213a;
  --muted: #5b6478;
  --line: #dde2eb;
  --line-strong: #c4ccda;
  --accent: #2f5bd3;
  --good: #17795a;
  --good-bg: #e3f3ec;
  --warn: #946010;
  --warn-bg: #fbf0d9;
  --bad: #b4352f;
  --bad-bg: #fbe5e3;
  --off-bg: #f1f2f5;
  --work: #c9d4ee;
  --active: #2f5bd3;

  font-family: "Public Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
}
@media (prefers-color-scheme: dark) {
  .dw {
    --band: #142041;
    --band-2: #1e2d57;
    --band-dim: #9aa6c4;
    --paper: #0f1424;
    --surface: #171e33;
    --ink: #e7ebf5;
    --muted: #9aa3b8;
    --line: #2a3350;
    --line-strong: #3a4466;
    --accent: #7b9cff;
    --good: #5fd0a3;
    --good-bg: #173a2f;
    --warn: #f0c068;
    --warn-bg: #3d3018;
    --bad: #ff8a80;
    --bad-bg: #44201f;
    --off-bg: #1b2238;
    --work: #33426b;
    --active: #7b9cff;
    color-scheme: dark;
  }
}
.dw *,
.dw *::before,
.dw *::after {
  box-sizing: border-box;
}
.dw button,
.dw select,
.dw input {
  font: inherit;
  color: inherit;
}
.dw :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.dw-num {
  font-variant-numeric: tabular-nums;
}
.dw-muted {
  color: var(--muted);
}
.dw-pre {
  white-space: pre-line;
}
.dw-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ---------- Header band ---------- */
.dw-band {
  background: var(--band);
  color: var(--band-ink);
  padding: 22px clamp(14px, 3vw, 32px) 0;
}
.dw-band__top {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  align-items: flex-end;
}
.dw-title {
  margin: 0;
  font-size: clamp(26px, 3.2vw, 34px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.dw-band__sub {
  margin: 4px 0 0;
  color: var(--band-dim);
  font-size: 14px;
}
.dw-band__dim {
  color: var(--band-dim);
}
.dw-refresh {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}
.dw-live {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #5fd0a3;
  box-shadow: 0 0 0 3px rgba(95, 208, 163, 0.25);
}
.dw-live.is-busy {
  background: #f0c068;
  box-shadow: 0 0 0 3px rgba(240, 192, 104, 0.3);
}
.dw-select,
.dw-select-wrap select,
.dw-btn {
  background: var(--band-2);
  color: var(--band-ink);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
}
.dw .dw-btn {
  background: #ffffff;
  color: #1f2e55;
  font-weight: 600;
  border-color: #ffffff;
}
.dw .dw-btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

/* Day tabs */
.dw-tabs {
  display: flex;
  gap: 4px;
  margin-top: 20px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.dw-tab {
  flex: none;
  background: transparent;
  border: 0;
  color: var(--band-dim);
  padding: 9px 14px 10px;
  border-radius: 8px 8px 0 0;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.dw-tab:hover {
  color: var(--band-ink);
  background: var(--band-2);
}
.dw-tab.is-on {
  background: var(--paper);
  color: var(--ink);
}
.dw-tab.is-empty {
  font-weight: 500;
}
.dw-tab__note {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.75;
}

/* Day ledger: sits on the paper colour directly under the active tab */
.dw-ledger {
  margin: 0 calc(-1 * clamp(14px, 3vw, 32px));
  padding: 16px clamp(14px, 3vw, 32px);
  background: var(--paper);
  color: var(--ink);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 0;
  border-bottom: 1px solid var(--line);
}
.dw-ledger__item {
  padding: 4px 16px 4px 0;
  margin-right: 16px;
  border-right: 1px solid var(--line);
}
.dw-ledger__item:last-child {
  border-right: 0;
}
.dw-ledger dt {
  font-size: 12.5px;
  color: var(--muted);
}
.dw-ledger dd {
  margin: 2px 0 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ---------- Main ---------- */
.dw-main {
  padding: 18px clamp(14px, 3vw, 32px) 40px;
}
.dw-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.dw-views {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}
.dw-view {
  border: 0;
  background: transparent;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
}
.dw-view.is-on {
  background: var(--band);
  color: #ffffff;
}
.dw-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.dw-input {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 7px 10px;
  min-width: 0;
}
input.dw-input {
  width: 230px;
  max-width: 100%;
}
.dw-toggle {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  font-size: 14px;
  cursor: pointer;
}

.dw-alert {
  margin: 16px clamp(14px, 3vw, 32px) 0;
  padding: 12px 14px;
  border-radius: 6px;
  background: var(--bad-bg);
  color: var(--bad);
  border-left: 4px solid var(--bad);
  font-weight: 500;
}
.dw-alert--soft {
  background: var(--warn-bg);
  color: var(--warn);
  border-left-color: var(--warn);
}
.dw-empty {
  padding: 40px 0;
  text-align: center;
  color: var(--muted);
}

/* ---------- Tables ---------- */
.dw-scroll {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 78vh;
  overflow-y: auto;
}
.dw-team,
.dw-sheet {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 14px;
}
.dw-team thead th,
.dw-sheet thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  text-align: left;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 2px solid var(--line-strong);
  white-space: nowrap;
}
.dw-team td,
.dw-team tbody th,
.dw-sheet td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  text-align: left;
}
.dw-sticky-col {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--line);
}
thead .dw-sticky-col {
  z-index: 3;
}
.dw-r {
  text-align: right !important;
}
.dw-big {
  font-size: 17px;
  font-weight: 700;
}

.dw-row {
  cursor: pointer;
}
.dw-row:hover td,
.dw-row:hover th {
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}
.dw-row.is-off td,
.dw-row.is-off th {
  background: var(--off-bg);
  color: var(--muted);
}
.dw-row.is-flagged > th {
  box-shadow: inset 4px 0 0 var(--bad), 1px 0 0 var(--line);
}
.dw-name {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  font-weight: 700;
  font-size: 15px;
  text-align: left;
  white-space: nowrap;
  display: inline-flex;
  gap: 6px;
  align-items: baseline;
}
.dw-name-plain {
  font-weight: 700;
  white-space: nowrap;
}
.dw-caret {
  color: var(--muted);
  font-size: 12px;
  width: 10px;
}
.dw-flagcount {
  display: block;
  margin: 2px 0 0 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--bad);
}
.dw-sort {
  border: 0;
  background: none;
  padding: 0;
  font-weight: 600;
  color: inherit;
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.dw-sort.is-on {
  color: var(--accent);
  text-decoration: underline solid;
}
.dw-remarks-col {
  min-width: 260px;
  max-width: 380px;
}

/* Type tags */
.dw-type {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.dw-type--retail { background: #e2eafc; color: #1f47b0; }
.dw-type--search { background: #efe6fb; color: #6b33b3; }
.dw-type--meet { background: #e0f2f4; color: #0f6a75; }
.dw-type--visit { background: #fff0dc; color: #8a5208; }
.dw-type--off { background: transparent; color: var(--muted); border-color: var(--line-strong); }
.dw-type--other { background: var(--off-bg); color: var(--ink); }
@media (prefers-color-scheme: dark) {
  .dw-type--retail { background: #213463; color: #a9c0ff; }
  .dw-type--search { background: #36235a; color: #d2b6ff; }
  .dw-type--meet { background: #163f45; color: #8fdbe4; }
  .dw-type--visit { background: #43311a; color: #f3c27c; }
}

/* Beat plan */
.dw-plan {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.dw-plan--yes { color: var(--good); }
.dw-plan--no { color: var(--bad); }
.dw-plan--unknown { color: var(--muted); font-weight: 500; }
.dw-plan--yes::before { content: "✓ "; }
.dw-plan--no::before { content: "✕ "; }

/* Check cells */
.dw-check {
  display: inline-block;
  max-width: 220px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  white-space: pre-line;
  line-height: 1.35;
}
.dw-check--good { background: var(--good-bg); color: var(--good); }
.dw-check--warn { background: var(--warn-bg); color: var(--warn); }
.dw-check--bad { background: var(--bad-bg); color: var(--bad); }
.dw-check--empty { color: var(--muted); font-weight: 400; padding: 0; }
.dw-fakes {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: flex-start;
}

/* Productivity */
.dw-prod {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 120px;
}
.dw-prod__bar {
  flex: 1;
  height: 8px;
  background: var(--off-bg);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.dw-prod__fill { display: block; height: 100%; }
.dw-prod__fill--good { background: var(--good); }
.dw-prod__fill--warn { background: #d49a2a; }
.dw-prod__fill--bad { background: var(--bad); }
.dw-prod .dw-num {
  font-weight: 700;
  width: 3.2em;
  text-align: right;
}

/* Day strip — the timeline from 6 AM to midnight */
.dw-strip {
  min-width: 230px;
}
.dw-strip__track {
  position: relative;
  height: 14px;
  background: var(--off-bg);
  border-radius: 3px;
  border: 1px solid var(--line);
}
.dw-strip__tick {
  position: absolute;
  top: -1px;
  bottom: -1px;
  width: 1px;
  background: var(--line-strong);
}
.dw-strip__work,
.dw-strip__active {
  position: absolute;
  top: 2px;
  bottom: 2px;
  border-radius: 2px;
}
.dw-strip__work {
  background: var(--work);
}
.dw-strip__active {
  top: 0;
  bottom: 0;
  background: var(--active);
}
.dw-strip__open {
  position: absolute;
  top: 2px;
  bottom: 2px;
  right: 0;
  background: repeating-linear-gradient(90deg, var(--work) 0 4px, transparent 4px 8px);
}
.dw-strip__text {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.dw-strip__sep {
  color: var(--muted);
}
.dw-strip__active-text {
  margin-left: 6px;
  color: var(--active);
  font-weight: 600;
}

/* Expanded detail */
.dw-detail-row td {
  background: color-mix(in srgb, var(--accent) 4%, var(--surface));
  padding: 0;
}
.dw-detail {
  position: sticky;
  left: 0;
  max-width: min(100vw - 60px, 1100px);
  padding: 14px 16px 18px 30px;
}
.dw-detail__grid {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px 20px;
}
.dw-detail__item dt {
  font-size: 12px;
  color: var(--muted);
}
.dw-detail__item dd {
  margin: 2px 0 0;
  font-weight: 600;
}

/* Full sheet view */
.dw-sheet td {
  white-space: nowrap;
  vertical-align: top;
}
.dw-sheet td:last-child {
  white-space: normal;
  min-width: 280px;
}
.dw-sheet tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--off-bg) 60%, var(--surface));
}
.dw-sheet td.dw-sticky-col {
  font-weight: 700;
}
.dw-sheet td.dw-cell--good { color: var(--good); font-weight: 600; }
.dw-sheet td.dw-cell--warn { color: var(--warn); font-weight: 600; background: var(--warn-bg) !important; }
.dw-sheet td.dw-cell--bad { color: var(--bad); font-weight: 600; background: var(--bad-bg) !important; }

/* Legend */
.dw-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  margin: 12px 2px 0;
  font-size: 13px;
  color: var(--muted);
}
.dw-legend__strip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.dw-legend__work,
.dw-legend__active {
  display: inline-block;
  width: 18px;
  height: 10px;
  border-radius: 2px;
  background: var(--work);
}
.dw-legend__active {
  background: var(--active);
  margin-left: 8px;
}

/* ---------- All days view ---------- */
.dw-trend {
  display: grid;
  gap: 18px;
}
.dw-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
.dw-panel .dw-scroll {
  border: 0;
  border-radius: 0;
  max-height: none;
}
.dw-h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
}
.dw-sub {
  margin: 4px 0 14px;
  color: var(--muted);
  font-size: 13.5px;
}
.dw-panel .dw-h2 + .dw-scroll {
  margin-top: 12px;
}
.dw-days {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.dw-days__row {
  display: grid;
  grid-template-columns: 70px 1fr 190px 130px;
  gap: 12px;
  align-items: center;
  font-size: 14px;
}
.dw-days__label {
  font-weight: 700;
}
.dw-days__bar {
  height: 18px;
  background: var(--off-bg);
  border-radius: 3px;
  overflow: hidden;
}
.dw-days__tc {
  display: block;
  height: 100%;
  background: var(--work);
}
.dw-days__pc {
  display: block;
  height: 100%;
  background: var(--active);
}
.dw-days__team {
  color: var(--muted);
  font-size: 13px;
}
.dw-text-bad {
  color: var(--bad);
  font-weight: 700;
}

/* ---------- Small screens ---------- */
@media (max-width: 720px) {
  .dw-band__top {
    align-items: flex-start;
  }
  .dw-ledger {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px 0;
  }
  .dw-ledger__item:nth-child(2n) {
    border-right: 0;
  }
  .dw-ledger dd {
    font-size: 22px;
  }
  .dw-days__row {
    grid-template-columns: 56px 1fr;
  }
  .dw-days__nums,
  .dw-days__team {
    grid-column: 2;
  }
  .dw-filters,
  input.dw-input {
    width: 100%;
  }
}
@media (prefers-reduced-motion: no-preference) {
  .dw-live.is-busy {
    animation: dw-pulse 1s ease-in-out infinite;
  }
  @keyframes dw-pulse {
    50% { opacity: 0.4; }
  }
}

/* keep hidden elements hidden even when they have a display rule */
.dw [hidden] {
  display: none !important;
}

/* long check notes get room instead of wrapping to one word per line */
.dw-team .dw-check {
  width: max-content;
  max-width: 220px;
}

/* ---------- Rule-based red flags ---------- */
.dw-bad {
  color: var(--bad);
  font-weight: 700;
}
.dw-ok {
  color: var(--good);
  font-size: 13px;
  font-weight: 600;
}
.dw-flags-col {
  min-width: 220px;
}
.dw-flags {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.dw-flag {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  width: max-content;
  max-width: 260px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bad-bg);
  color: var(--bad);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}
.dw-flag--ai {
  background: #ece8fb;
  color: #5a3fb8;
}
.dw-flag--inline {
  display: inline-flex;
}
.dw-flag__tag {
  flex: none;
  font-size: 10.5px;
  font-weight: 800;
  padding: 0 4px;
  border-radius: 3px;
  background: #5a3fb8;
  color: #ffffff;
  letter-spacing: 0.02em;
}
@media (prefers-color-scheme: dark) {
  .dw-flag--ai { background: #2e2550; color: #c9b8ff; }
  .dw-flag__tag { background: #8f74ff; color: #120d24; }
}
.dw-text-cell {
  max-width: 220px;
  white-space: normal;
}
.dw-sheet td.dw-cell--bad {
  color: var(--bad);
  font-weight: 700;
  background: var(--bad-bg) !important;
}

/* Target working window on the timeline (10 AM to 6 PM) */
.dw-strip__target {
  position: absolute;
  top: -1px;
  bottom: -1px;
  border-left: 1px dashed var(--good);
  border-right: 1px dashed var(--good);
}
.dw-legend__target {
  display: inline-block;
  width: 18px;
  height: 10px;
  border-left: 1px dashed var(--good);
  border-right: 1px dashed var(--good);
  margin-left: 8px;
}

/* ---------- AI review ---------- */
.dw-ai {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid #5a3fb8;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 14px;
}
.dw-ai__title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  gap: 8px;
  align-items: center;
}
.dw-ai__text {
  margin: 0;
  max-width: 80ch;
}
.dw-ai-note {
  margin: 6px 0 0;
  display: flex;
  gap: 6px;
  align-items: baseline;
  color: #5a3fb8;
  font-size: 13px;
  font-weight: 500;
}
@media (prefers-color-scheme: dark) {
  .dw-ai-note { color: #c9b8ff; }
  .dw-ai { border-left-color: #8f74ff; }
}
