/* =====================================================================
   CARNET DE TOURNÉES — feuille de style
   ---------------------------------------------------------------------
   Aucune dépendance. Tout passe par des variables CSS définies dans
   :root, redéfinies pour le thème sombre. Pour changer l'apparence,
   modifier les variables — pas les composants.
   ===================================================================== */

/* ============ TOKENS ============ */
/* Identité DUO Catering : orange brûlé #CE5E12, espresso #3B2A20, taupe, crème #FAF5EC.
   Les couleurs de statut forment une échelle réservée, distincte de l'accent de marque. */
:root {
  --ground: #faf5ec;
  --surface: #ffffff;
  --surface-2: #f7f1e5;
  --surface-3: #efe6d6;
  --ink: #3b2a20;
  --ink-2: #6a574a;
  --ink-3: #8e7b6e;
  --line: #e3d8c6;
  --line-2: #cbbba2;
  --accent: #ce5e12;
  --accent-2: #a94a0b;
  --accent-soft: #fbeadb;
  --nav: #3b2a20;
  --nav-ink: #faf5ec;
  --nav-ink-2: #b9a796;
  --nav-line: #57402f;
  --st-ok: #12805c;
  --st-late: #a98a00;
  --st-warn: #be3b2a;
  --st-fault: #7e1d18;
  --st-exempt: #3d5ba8;
  --st-draft: #8e7b6e;
  --st-ok-bg: #e3f1ea;
  --st-late-bg: #f7f0da;
  --st-warn-bg: #fae7e2;
  --st-fault-bg: #f3dcd9;
  --st-exempt-bg: #e5e9f6;
  --st-draft-bg: #efe6d6;
  --focus: #ce5e12;
  --on-accent: #ffffff;
  --r: 6px;
  --r-lg: 10px;
  --shadow: 0 12px 34px rgba(59, 42, 32, 0.2);
  --font-d: "Archivo", system-ui, sans-serif;
  --font-b: "IBM Plex Sans", system-ui, sans-serif;
  --font-m: "IBM Plex Mono", ui-monospace, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #181109;
    --surface: #241a14;
    --surface-2: #2e2118;
    --surface-3: #3a2a20;
    --ink: #f5ede1;
    --ink-2: #cbb9a8;
    --ink-3: #a08f80;
    --line: #3e2d22;
    --line-2: #57402f;
    --accent: #e8823a;
    --accent-2: #f49e5f;
    --accent-soft: #3a2317;
    --nav: #120c08;
    --nav-ink: #f5ede1;
    --nav-ink-2: #a08f80;
    --nav-line: #31241b;
    --st-ok: #2fa87e;
    --st-late: #b98c00;
    --st-warn: #cf4a57;
    --st-fault: #ec8a7c;
    --st-exempt: #7089d6;
    --st-draft: #a08f80;
    --st-ok-bg: #102a22;
    --st-late-bg: #2a2208;
    --st-warn-bg: #34161a;
    --st-fault-bg: #3a1f1a;
    --st-exempt-bg: #191f33;
    --st-draft-bg: #2e2118;
    --focus: #e8823a;
    --on-accent: #2a1408;
    --shadow: 0 12px 34px rgba(0, 0, 0, 0.55);
  }
}
:root[data-theme="dark"] {
  --ground: #181109;
  --surface: #241a14;
  --surface-2: #2e2118;
  --surface-3: #3a2a20;
  --ink: #f5ede1;
  --ink-2: #cbb9a8;
  --ink-3: #a08f80;
  --line: #3e2d22;
  --line-2: #57402f;
  --accent: #e8823a;
  --accent-2: #f49e5f;
  --accent-soft: #3a2317;
  --nav: #120c08;
  --nav-ink: #f5ede1;
  --nav-ink-2: #a08f80;
  --nav-line: #31241b;
  --st-ok: #2fa87e;
  --st-late: #b98c00;
  --st-warn: #cf4a57;
  --st-fault: #ec8a7c;
  --st-exempt: #7089d6;
  --st-draft: #a08f80;
  --st-ok-bg: #102a22;
  --st-late-bg: #2a2208;
  --st-warn-bg: #34161a;
  --st-fault-bg: #3a1f1a;
  --st-exempt-bg: #191f33;
  --st-draft-bg: #2e2118;
  --focus: #e8823a;
  --on-accent: #2a1408;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.55);
}

/* ============ BASE ============ */
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-b);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
h1,
h2,
h3,
h4 {
  font-family: var(--font-d);
  margin: 0;
  text-wrap: balance;
  letter-spacing: -0.015em;
}
button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}
:where(a) {
  color: var(--accent);
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 3px;
}
.mono {
  font-family: var(--font-m);
  font-variant-numeric: tabular-nums;
}
.eyebrow {
  font-family: var(--font-m);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.muted {
  color: var(--ink-2);
}
.page-loader {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--ground) 82%, transparent);
  backdrop-filter: blur(2px);
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.page-loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.page-loader-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 22px 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--r) + 4px);
  box-shadow: 0 10px 30px color-mix(in srgb, var(--ink) 12%, transparent);
  min-width: 160px;
}
.page-loader-card p {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: 0.02em;
}
.page-loader-spin {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid var(--surface-3);
  border-top-color: var(--accent);
  animation: page-loader-spin 0.7s linear infinite;
}
@keyframes page-loader-spin {
  to {
    transform: rotate(360deg);
  }
}
.small {
  font-size: 13px;
}
.tiny {
  font-size: 12px;
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ============ SHELL ============ */
.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.topbar {
  background: var(--nav);
  color: var(--nav-ink);
  border-bottom: 1px solid var(--nav-line);
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar-in {
  max-width: 1240px;
  margin: 0 auto;
  padding: 9px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin-right: auto;
}
.brand b {
  font-family: var(--font-d);
  font-weight: 700;
  font-size: 16.5px;
  letter-spacing: -0.02em;
}
.brand span {
  font-family: var(--font-m);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--nav-ink-2);
}
.roleswitch {
  display: flex;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--nav-line);
  border-radius: 99px;
  padding: 2px;
}
.roleswitch button {
  background: none;
  border: 0;
  padding: 5px 13px;
  border-radius: 99px;
  color: var(--nav-ink-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.roleswitch button[aria-pressed="true"] {
  background: var(--nav-ink);
  color: var(--nav);
  font-weight: 600;
}

.shellbody {
  flex: 1;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 212px minmax(0, 1fr);
  gap: 0;
}
.rail {
  border-right: 1px solid var(--line);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: sticky;
  top: 53px;
  align-self: start;
  max-height: calc(100dvh - 53px);
  overflow: auto;
}
.rail-lbl {
  padding: 10px 10px 5px;
}
.rail button,
.rail a.rail-link {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 9px 10px;
  border-radius: var(--r);
  cursor: pointer;
  color: var(--ink-2);
  font-weight: 500;
  font-size: 14px;
  text-decoration: none;
  box-sizing: border-box;
}
.rail button:hover,
.rail a.rail-link:hover {
  background: var(--surface-3);
  color: var(--ink);
}
.rail button[aria-current="page"],
.rail a.rail-link[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.rail .ico {
  width: 16px;
  flex: none;
  opacity: 0.8;
}
.rail .badge {
  margin-left: auto;
  font-family: var(--font-m);
  font-size: 11px;
  font-weight: 600;
  background: var(--st-warn);
  color: #fff;
  border-radius: 99px;
  min-width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  padding: 0 5px;
}
main {
  padding: 22px 20px 64px;
  min-width: 0;
}

@media (max-width: 860px) {
  .shellbody {
    grid-template-columns: minmax(0, 1fr);
  }
  .rail {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    flex-direction: row;
    border-right: 0;
    border-top: 1px solid var(--line);
    background: var(--surface);
    padding: 6px;
    gap: 2px;
    z-index: 35;
    max-height: none;
    justify-content: space-around;
  }
  .rail-lbl {
    display: none;
  }
  .rail button,
  .rail a.rail-link {
    flex-direction: column;
    gap: 3px;
    font-size: 11px;
    padding: 6px 4px;
    text-align: center;
    justify-content: center;
  }
  .rail .ico {
    width: 18px;
  }
  .rail .badge {
    position: absolute;
    transform: translate(16px, -4px);
  }
  main {
    padding: 16px 14px 96px;
  }
}

/* ============ PIECES ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.card-h {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.card-h h3 {
  font-size: 15px;
  font-weight: 600;
}
.card-b {
  padding: 16px;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.spacer {
  margin-left: auto;
}
.grid-kpi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
  gap: 12px;
}

h1.page {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.025em;
}
.page-sub {
  color: var(--ink-2);
  font-size: 14px;
  margin-top: 3px;
  max-width: 66ch;
}
.pagehead {
  margin-bottom: 18px;
}

.btn {
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  padding: 9px 15px;
  border-radius: var(--r);
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  line-height: 1.2;
}
.btn:hover {
  border-color: var(--ink-3);
  background: var(--surface-2);
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
}
.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--accent);
}
.btn-ghost:hover {
  background: var(--accent-soft);
  border-color: transparent;
}
.btn-danger {
  color: var(--st-warn);
  border-color: var(--line-2);
}
.btn-danger:hover {
  background: var(--st-warn-bg);
  border-color: var(--st-warn);
}
.btn-sm {
  padding: 6px 11px;
  font-size: 13px;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 3px 9px 3px 7px;
  border-radius: 99px;
  white-space: nowrap;
}
.pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
  background: currentColor;
}
.pill.ok {
  color: var(--st-ok);
  background: var(--st-ok-bg);
}
.pill.late {
  color: var(--st-late);
  background: var(--st-late-bg);
}
.pill.warn {
  color: var(--st-warn);
  background: var(--st-warn-bg);
}
.pill.fault {
  color: var(--st-fault);
  background: var(--st-fault-bg);
}
.pill.exempt {
  color: var(--st-exempt);
  background: var(--st-exempt-bg);
}
.pill.draft {
  color: var(--st-draft);
  background: var(--st-draft-bg);
}
.pill.fault .dot {
  background: repeating-linear-gradient(
      45deg,
      currentColor 0 2px,
      transparent 2px 4px
    ),
    currentColor;
}

table.t {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.t th {
  text-align: left;
  font-family: var(--font-m);
  font-size: 10.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}
table.t td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.t tr:last-child td {
  border-bottom: 0;
}
table.t td.nw,
table.t th.nw {
  white-space: nowrap;
}
table.t tbody tr:hover {
  background: var(--surface-2);
}
table.t tbody tr.cur {
  background: var(--accent-soft);
}
table.t tbody tr.cur td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}
.t-wrap {
  overflow-x: auto;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field > label:not(.check):not(.btn),
.lbl {
  font-family: var(--font-m);
  font-size: 10.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}
input[type="text"],
input[type="date"],
input[type="number"],
select,
textarea {
  font-family: var(--font-b);
  font-size: 15px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  padding: 9px 11px;
  width: 100%;
}
input[type="date"],
.mono-in {
  font-family: var(--font-m);
  font-variant-numeric: tabular-nums;
}
textarea {
  min-height: 104px;
  resize: vertical;
  line-height: 1.55;
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 0;
  border-color: var(--focus);
}
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}
.check {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  cursor: pointer;
}
.check input {
  margin: 2px 0 0;
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  flex: none;
}

.banner {
  border-radius: var(--r-lg);
  padding: 14px 16px;
  display: flex;
  gap: 13px;
  align-items: flex-start;
  border: 1px solid;
  border-left-width: 4px;
}
.banner.warn {
  background: var(--st-warn-bg);
  border-color: var(--st-warn);
  color: var(--ink);
}
.banner.info {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--ink);
}
.banner.ok {
  background: var(--st-ok-bg);
  border-color: var(--st-ok);
  color: var(--ink);
}
.banner h4 {
  font-size: 14.5px;
  font-weight: 700;
  margin-bottom: 3px;
}
.banner .ic {
  flex: none;
  margin-top: 1px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px;
}
.kpi .v {
  font-family: var(--font-d);
  font-size: 30px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  margin: 6px 0 2px;
}
.kpi .u {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-3);
  margin-left: 3px;
}
.kpi.accent .v {
  color: var(--accent);
}
.kpi.bad .v {
  color: var(--st-warn);
}

.strip {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}
.strip .w {
  width: 100%;
  max-width: 38px;
  flex: 1 1 26px;
  border-radius: 3px;
  padding: 5px 0 4px;
  text-align: center;
  font-family: var(--font-m);
  font-size: 10.5px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--surface-3);
  color: var(--ink-3);
}
.strip .w.ok {
  background: var(--st-ok-bg);
  color: var(--st-ok);
  border-color: var(--st-ok);
}
.strip .w.late {
  background: var(--st-late-bg);
  color: var(--st-late);
  border-color: var(--st-late);
}
.strip .w.warn {
  background: var(--st-warn-bg);
  color: var(--st-warn);
  border-color: var(--st-warn);
}
.strip .w.fault {
  background: var(--st-fault-bg);
  color: var(--st-fault);
  border-color: var(--st-fault);
  background-image: repeating-linear-gradient(
    45deg,
    color-mix(in srgb, var(--st-fault) 22%, transparent) 0 3px,
    transparent 3px 6px
  );
}
.strip .w.exempt {
  background: var(--st-exempt-bg);
  color: var(--st-exempt);
  border-color: var(--st-exempt);
}
.strip .w.draft {
  background: var(--st-draft-bg);
  color: var(--st-draft);
  border-color: var(--st-draft);
  border-style: dashed;
}

/* frise annuelle : 53 semaines en une ligne continue */
.frisewrap {
  overflow-x: auto;
  padding-bottom: 4px;
}
.frise {
  min-width: 660px;
}
.frise-m {
  display: grid;
  grid-template-columns: repeat(53, minmax(0, 1fr));
  margin-bottom: 5px;
}
.frise-m span {
  font-family: var(--font-m);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  border-left: 1px solid var(--line-2);
  padding-left: 4px;
  overflow: hidden;
  white-space: nowrap;
}
.frise-c {
  display: grid;
  grid-template-columns: repeat(53, minmax(0, 1fr));
  gap: 2px;
}
.frise-c button {
  height: 38px;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  padding: 0;
  background: var(--surface-3);
  color: var(--ink-3);
  font-family: var(--font-m);
  font-size: 9px;
  font-weight: 600;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 3px;
  overflow: hidden;
}
.frise-c button:hover {
  outline: 2px solid var(--ink-3);
  outline-offset: 1px;
}
.frise-c button.ok {
  background: var(--st-ok-bg);
  color: var(--st-ok);
  border-color: var(--st-ok);
}
.frise-c button.late {
  background: var(--st-late-bg);
  color: var(--st-late);
  border-color: var(--st-late);
}
.frise-c button.warn {
  background: var(--st-warn-bg);
  color: var(--st-warn);
  border-color: var(--st-warn);
}
.frise-c button.fault {
  background: var(--st-fault-bg);
  color: var(--st-fault);
  border-color: var(--st-fault);
  background-image: repeating-linear-gradient(
    45deg,
    color-mix(in srgb, var(--st-fault) 22%, transparent) 0 3px,
    transparent 3px 6px
  );
}
.frise-c button.exempt {
  background: var(--st-exempt-bg);
  color: var(--st-exempt);
  border-color: var(--st-exempt);
}
.frise-c button.draft {
  background: var(--st-draft-bg);
  color: var(--st-draft);
  border-color: var(--st-draft);
  border-style: dashed;
}
.frise-c button.now {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.frise-n {
  display: grid;
  grid-template-columns: repeat(53, minmax(0, 1fr));
  margin-top: 4px;
  height: 12px;
}
.frise-n span {
  font-family: var(--font-m);
  font-size: 9px;
  color: var(--accent);
  font-weight: 600;
  text-align: center;
}
.frise.tall .frise-c button {
  height: 58px;
}
.frise-c button.past {
  opacity: 1;
}

/* attribution des exploitations */
.assign {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 0 22px;
}
.arow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 186px;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
}
.arow .nm {
  font-size: 13.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.arow select {
  padding: 6px 9px;
  font-size: 13px;
}
.arow.orph .nm {
  color: var(--st-warn);
  font-weight: 600;
}
.arow.orph select {
  border-color: var(--st-warn);
}

/* liste des collaborateurs */
.perim {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  max-width: 300px;
}
.perim .chip {
  font-size: 11px;
  padding: 2px 7px;
  white-space: nowrap;
}
.pickbox {
  max-height: 236px;
  overflow: auto;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  padding: 9px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 5px 12px;
  background: var(--surface-2);
}
.pickbox label {
  font-size: 13px;
}
.inactive td {
  opacity: 0.55;
}
.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--ink-2);
}
.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: -1px;
}

/* visit blocks */
.visit {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
}
.visit-h {
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  padding: 9px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.visit-h b {
  font-family: var(--font-d);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.visit-b {
  padding: 14px;
  display: grid;
  gap: 14px 16px;
  grid-template-columns: 210px minmax(0, 1fr);
}
.visit-b .wide {
  grid-column: 1/-1;
}
@media (max-width: 700px) {
  .visit-b {
    grid-template-columns: minmax(0, 1fr);
  }
}
.aitools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 8px;
}
.counter {
  font-family: var(--font-m);
  font-size: 11.5px;
  color: var(--ink-3);
  margin-left: auto;
}
.counter.over {
  color: var(--st-warn);
  font-weight: 600;
}
.rec {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--st-warn);
}
.rec .blob {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--st-warn);
  animation: pulse 1.1s infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.35;
    transform: scale(0.8);
  }
}
@media (prefers-reduced-motion: reduce) {
  .rec .blob {
    animation: none;
  }
}
.preview {
  border: 1px dashed var(--accent);
  background: var(--accent-soft);
  border-radius: var(--r);
  padding: 12px;
  margin-top: 10px;
}
.preview .lbl {
  color: var(--accent);
  margin-bottom: 7px;
  display: block;
}
.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.chip {
  font-size: 12px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 3px 9px;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.chip button {
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--ink-3);
  padding: 0;
  font-size: 14px;
  line-height: 1;
}

.journal {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13.5px;
}
.journal li {
  display: flex;
  gap: 11px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
}
.journal li:last-child {
  border-bottom: 0;
}
.journal time {
  font-family: var(--font-m);
  font-size: 12px;
  color: var(--ink-3);
  flex: none;
  width: 120px;
}

.sig {
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--surface-2);
  position: relative;
  touch-action: none;
}
.sig canvas {
  display: block;
  width: 100%;
  height: 110px;
  border-radius: var(--r);
  cursor: crosshair;
}
.sig .ph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--ink-3);
  font-size: 13px;
  pointer-events: none;
}

/* matrix */
table.mx {
  border-collapse: separate;
  border-spacing: 3px;
  font-size: 13px;
  width: 100%;
}
table.mx th {
  font-family: var(--font-m);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  font-weight: 600;
  padding: 4px 6px;
  text-align: center;
}
table.mx th.who {
  text-align: left;
  min-width: 158px;
}
table.mx td.who {
  font-weight: 600;
  font-size: 13.5px;
  padding: 0 8px 0 2px;
  white-space: nowrap;
}
table.mx td.who small {
  display: block;
  font-weight: 400;
  color: var(--ink-3);
  font-size: 11.5px;
}
.cell {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 9px 2px;
  font-family: var(--font-m);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface-3);
  color: var(--ink-3);
  min-width: 42px;
}
.cell:hover {
  filter: brightness(0.96);
  border-color: var(--ink-3);
}
.cell.ok {
  background: var(--st-ok-bg);
  color: var(--st-ok);
  border-color: var(--st-ok);
}
.cell.late {
  background: var(--st-late-bg);
  color: var(--st-late);
  border-color: var(--st-late);
}
.cell.warn {
  background: var(--st-warn-bg);
  color: var(--st-warn);
  border-color: var(--st-warn);
}
.cell.fault {
  background: var(--st-fault-bg);
  color: var(--st-fault);
  border-color: var(--st-fault);
  background-image: repeating-linear-gradient(
    45deg,
    color-mix(in srgb, var(--st-fault) 20%, transparent) 0 3px,
    transparent 3px 6px
  );
}
.cell.exempt {
  background: var(--st-exempt-bg);
  color: var(--st-exempt);
  border-color: var(--st-exempt);
}
.cell.draft {
  background: var(--st-draft-bg);
  color: var(--st-draft);
  border-color: var(--st-draft);
  border-style: dashed;
}

/* charts */
.chartwrap {
  position: relative;
  overflow-x: auto;
}
.chartwrap svg {
  display: block;
}
svg .grid {
  stroke: var(--line);
  stroke-width: 1;
}
svg .axis {
  fill: var(--ink-3);
  font-family: var(--font-m);
  font-size: 10px;
}
svg .val {
  fill: var(--ink-2);
  font-family: var(--font-m);
  font-size: 10.5px;
  font-weight: 600;
}
svg .bar {
  fill: var(--accent);
}
svg .bar.hot {
  fill: url(#hatch);
}
svg .target {
  stroke: var(--ink-3);
  stroke-width: 1;
  stroke-dasharray: 4 3;
}
svg .tlbl {
  fill: var(--ink-3);
  font-family: var(--font-m);
  font-size: 9.5px;
  letter-spacing: 0.06em;
}
svg .hit {
  fill: transparent;
  cursor: pointer;
}
.tip {
  position: absolute;
  pointer-events: none;
  background: var(--nav);
  color: var(--nav-ink);
  border-radius: var(--r);
  padding: 7px 10px;
  font-size: 12.5px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.1s;
  z-index: 5;
  white-space: nowrap;
}
.tip b {
  font-family: var(--font-m);
}
.tip.on {
  opacity: 1;
}
.hbar {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(0, 1fr) 44px;
  gap: 10px;
  align-items: center;
  padding: 5px 0;
  font-size: 13.5px;
}
.hbar .track {
  display: block;
  background: var(--surface-3);
  border-radius: 4px;
  height: 14px;
  overflow: hidden;
}
.hbar .fill {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
}
.hbar .n {
  font-family: var(--font-m);
  font-size: 12.5px;
  font-weight: 600;
  text-align: right;
  color: var(--ink-2);
}
.stackbar {
  display: flex;
  gap: 2px;
  height: 16px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface-3);
}
.stackbar span {
  display: block;
}

/* modal + toast */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 16, 19, 0.55);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 60;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  max-width: 640px;
  width: 100%;
  max-height: 88dvh;
  overflow: auto;
  box-shadow: var(--shadow);
}
#toasts {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: min(520px, calc(100% - 24px));
}
.toast {
  background: var(--nav);
  color: var(--nav-ink);
  border-radius: var(--r);
  padding: 11px 15px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 9px;
  align-items: flex-start;
}
.toast .ic {
  flex: none;
}
@media (max-width: 860px) {
  #toasts {
    bottom: 74px;
  }
}

.rules {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 13.5px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.rules li {
  display: flex;
  gap: 9px;
}
.rules b {
  font-family: var(--font-m);
  font-size: 11.5px;
  color: var(--accent);
  flex: none;
  width: 34px;
  padding-top: 2px;
}
.split {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  align-items: start;
}
.aiout {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.6;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 13px;
  background: var(--surface-2);
  min-height: 64px;
}
.deadline {
  font-family: var(--font-m);
  font-size: 12.5px;
  color: var(--ink-2);
}
hr.sep {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 16px 0;
}
