/* ═══════════════════════════════════════════════════════════════════════════
   AuditTimeSlotPicker.module.css
   Palette: cool slate neutrals, a single navy accent, muted status colours.
   Tokens are declared on both .root (inline field, date tiles) and .overlay
   (portaled modal, which lives outside .root in the DOM).
   ═══════════════════════════════════════════════════════════════════════════ */

.root,
.overlay {
  /* Neutrals */
  --ink: #1a202c;
  --ink-2: #2d3748;
  --mute: #5f6b7a;
  --faint: #94a3b8;
  --line: #e2e8f0;
  --line-strong: #cbd5e0;
  --surface: #ffffff;
  --surface-2: #f7f9fc;

  /* Accent: navy */
  --accent: #1f4e79;
  --accent-hover: #173b5c;
  --accent-soft: #eaf1f8;
  --accent-line: #c9dbec;

  /* Status (muted) */
  --ok: #2f7d5b;
  --warn: #a86b12;
  --danger: #b42318;
  --danger-bg: #fdf3f2;
  --danger-line: #f3c4bf;

  font-family: inherit;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

/* ── Trigger (field) ─────────────────────────────────────────────────────── */
.trigger {
  width: 100%;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.trigger:hover:not(:disabled) {
  border-color: var(--faint);
}
.trigger:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 78, 121, 0.14);
}
.trigger:disabled {
  background: var(--surface-2);
  color: var(--faint);
  cursor: not-allowed;
}
.triggerLead {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--mute);
}
.tValue {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}
.tEmpty {
  font-size: 14px;
  color: var(--faint);
}
.tGo {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  white-space: nowrap;
}
.hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--mute);
}

/* ── Date tiles ──────────────────────────────────────────────────────────── */
.days {
  display: grid;
  gap: 8px;
}
.day {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  min-height: 96px;
  padding: 12px 12px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.day:hover:not(:disabled):not(.dayOn) {
  border-color: var(--faint);
}
.day:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.dayHead {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.dayW {
  font-size: 11px;
  font-weight: 600;
  color: var(--mute);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.dayN {
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1;
}
.dayM {
  font-size: 12px;
  color: var(--mute);
}
.bar {
  display: block;
  height: 3px;
  background: var(--line);
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}
.tone_high .bar i {
  background: var(--warn);
}
.tone_full .bar i {
  background: var(--danger);
}
.dayS {
  font-size: 11px;
  font-weight: 500;
  color: var(--mute);
  margin-top: auto;
}
.tone_full .dayS {
  color: var(--danger);
}
.dayOn {
  background: var(--accent);
  border-color: var(--accent);
}
.dayOn .dayW,
.dayOn .dayM,
.dayOn .dayS {
  color: rgba(255, 255, 255, 0.75);
}
.dayOn .dayN {
  color: #ffffff;
}
.dayOn .bar {
  background: rgba(255, 255, 255, 0.22);
}
.dayOn .bar i {
  background: #ffffff;
}
.dayOff {
  background: var(--surface-2);
  border-color: var(--line);
  cursor: not-allowed;
}
.dayOff .dayN,
.dayOff .dayW,
.dayOff .dayM,
.dayOff .dayS {
  color: var(--faint);
}
.tone_full.dayOff .dayS {
  color: var(--danger);
}

/* ── Overlay + modal ─────────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(26, 32, 44, 0.5);
}
.modal {
  width: 100%;
  max-width: 720px;
  max-height: min(88vh, 860px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 6px;
  border: 1px solid var(--line);
  box-shadow: 0 20px 40px -12px rgba(26, 32, 44, 0.28);
  color: var(--ink);
  animation: modalIn 0.18s ease-out;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.mh {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 24px 18px;
  border-bottom: 1px solid var(--line);
}
.title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--mute);
}
.dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--faint);
  display: inline-block;
}
.x {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  border-radius: 4px;
  color: var(--mute);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.x:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.x:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.mb {
  padding: 20px 24px 8px;
  overflow-y: auto;
}
.section {
  margin-top: 20px;
}
.section:first-child {
  margin-top: 0;
}
.lbl {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mute);
}

.mf {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.note {
  font-size: 12px;
  color: var(--mute);
}
.actions {
  display: flex;
  gap: 8px;
}

.btn {
  height: 36px;
  padding: 0 16px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--faint);
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}
.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.primary:disabled {
  background: var(--line-strong);
  border-color: var(--line-strong);
  color: #ffffff;
  cursor: not-allowed;
}

/* ── Session headings + chip grid ────────────────────────────────────────── */
.sessH {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.sessH span {
  font-size: 12px;
  font-weight: 400;
  color: var(--mute);
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
.chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-height: 68px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.chip:hover:not(.closed):not(.sel) {
  border-color: var(--faint);
  background: var(--surface-2);
}
.chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.t {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.pips {
  display: inline-flex;
  gap: 4px;
}
.pips i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: block;
}
.pipOn {
  background: var(--ok);
}
.pipOff {
  background: var(--line);
}
.st {
  font-size: 11px;
  font-weight: 500;
  color: var(--ok);
}

.limited .pipOn {
  background: var(--warn);
}
.limited .st {
  color: var(--warn);
}

.closed {
  background: var(--surface-2);
  border-color: var(--line);
  cursor: not-allowed;
}
.closed .t {
  color: var(--faint);
  text-decoration: line-through;
  text-decoration-color: var(--line-strong);
}
.closed .st {
  color: var(--faint);
}

.sel {
  background: var(--accent);
  border-color: var(--accent);
}
.sel .t {
  color: #ffffff;
}
.sel .st {
  color: rgba(255, 255, 255, 0.8);
}
.sel .pipOn {
  background: #ffffff;
}
.sel .pipOff {
  background: rgba(255, 255, 255, 0.3);
}

.skel {
  height: 68px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

/* ── Lunch divider ───────────────────────────────────────────────────────── */
.lunch {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 20px;
  padding: 10px 0;
  border-top: 1px dashed var(--line-strong);
  border-bottom: 1px dashed var(--line-strong);
  font-size: 12px;
  color: var(--mute);
}
.lunch b {
  font-weight: 500;
  color: var(--ink-2);
}

/* ── Legend + meta ───────────────────────────────────────────────────────── */
.meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12px;
  color: var(--mute);
}
.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.lgOpen { background: var(--ok); }
.lgLimited { background: var(--warn); }
.lgClosed { background: var(--line-strong); }
.lgSel { background: var(--accent); }
.updated {
  font-size: 12px;
  color: var(--faint);
}

/* ── Feedback states ─────────────────────────────────────────────────────── */
.notice {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--danger-bg);
  border: 1px solid var(--danger-line);
  border-radius: 4px;
  color: var(--danger);
  font-size: 13px;
}
.notice p {
  margin: 0;
}
.alts {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-2);
}
.alts span {
  margin-right: 4px;
}
.alts button {
  height: 28px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--danger-line);
  border-radius: 4px;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--danger);
  cursor: pointer;
}
.alts button:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
}

.summary {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
}
.summaryEmpty {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--mute);
  font-weight: 400;
}

.state {
  padding: 32px 0;
  text-align: center;
  color: var(--mute);
  font-size: 14px;
}
.state p {
  margin: 0 0 12px;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 620px) {
  .overlay {
    padding: 0;
    align-items: flex-end;
  }
  .modal {
    max-height: 94vh;
    border-radius: 6px 6px 0 0;
  }
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  }
  .mh,
  .mb,
  .mf {
    padding-left: 18px;
    padding-right: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .modal,
  .bar i,
  .day,
  .chip,
  .btn {
    animation: none !important;
    transition: none !important;
  }
}