:root {
  --blue: #0078BF;
  --pink: #E44C9A;
  --amber: #D97706;
  --red: #B42318;
  --green: #047857;
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --text: #0F172A;
  --muted: #64748B;
  --line: #E2E8F0;
  --hover: #F1F5F9;
  --focus: #0078BF;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B1220;
    --card: #111A2C;
    --text: #E5E7EB;
    --muted: #94A3B8;
    --line: #1E293B;
    --hover: #1B2840;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: Raleway, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; }

header.topbar {
  background: var(--blue); color: white;
  padding: 14px 24px;
  display: flex; align-items: center; gap: 16px;
  border-bottom: 4px solid var(--pink);
}
header.topbar h1 { margin: 0; font-size: 20px; font-weight: 700; }
header.topbar .meta { margin-left: auto; font-size: 12px; opacity: 0.9; }

nav.tabs {
  background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; padding: 0 24px;
}
nav.tabs button {
  background: transparent; border: 0; border-bottom: 3px solid transparent;
  padding: 14px 18px; font-size: 14px; font-weight: 600; cursor: pointer;
  color: var(--muted); font-family: inherit;
}
nav.tabs button.active { color: var(--blue); border-bottom-color: var(--blue); }
nav.tabs button:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

main { padding: 24px; max-width: 1280px; margin: 0 auto; }
section.view { display: none; }
section.view.active { display: block; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 20px; margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px 0; font-size: 16px; font-weight: 700; }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 180px; }

label { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
label .req { color: var(--red); }
input, select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 7px;
  font-size: 14px; background: var(--bg); color: var(--text);
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 120, 191, 0.15);
}
textarea { min-height: 60px; resize: vertical; }
/* Date inputs natively shrink their content-height because the browser owns
   the picker UI — force the box to match text inputs so the field reads as a
   real input box next to siblings in a flex row. */
input[type="date"] {
  min-height: 40px;
  line-height: 1.2;
  cursor: pointer;
  color-scheme: light;
  appearance: none;
  -webkit-appearance: none;
  position: relative;
}
input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.7;
  padding: 2px;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 1; }
@media (prefers-color-scheme: dark) {
  input[type="date"] { color-scheme: dark; }
  /* Invert the calendar icon so it's visible against the dark input bg. */
  input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(1) opacity(0.7); }
}

button.btn {
  background: var(--blue); color: white; border: 0; border-radius: 7px;
  padding: 10px 18px; font-weight: 600; cursor: pointer; font-size: 14px;
  font-family: inherit;
}
button.btn:focus-visible { outline: 3px solid #0078BF55; outline-offset: 1px; }
button.btn.secondary { background: var(--card); color: var(--text); border: 1px solid var(--line); }
button.btn.danger { background: var(--red); }
button.btn.amber { background: var(--amber); }
button.btn:hover { filter: brightness(0.95); }
button.btn:disabled { opacity: 0.5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line);
  font-size: 14px;
}
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
tr:hover td { background: var(--hover); }
tr:focus-within td { background: var(--hover); }

.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
}
.pill.scheduled { background: #DBEAFE; color: #1E40AF; }
.pill.confirmed { background: #D1FAE5; color: #065F46; }
.pill.cancelled { background: #FEE2E2; color: #991B1B; }
.pill.completed { background: #E5E7EB; color: #374151; }
.pill.no_show   { background: #FEF3C7; color: #92400E; }

.info {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%; background: var(--muted); color: white;
  font-size: 11px; font-weight: 700; margin-left: 6px; cursor: help;
  font-style: italic; font-family: serif;
}
.info[data-tip]:hover::after, .info[data-tip]:focus::after {
  content: attr(data-tip);
  position: absolute; transform: translate(-50%, 8px);
  background: var(--text); color: var(--bg); padding: 6px 10px; border-radius: 6px;
  font-size: 12px; font-style: normal; font-family: inherit; font-weight: 500;
  max-width: 260px; white-space: normal; z-index: 10;
}

.kv { font-size: 13px; color: var(--muted); }
.kv strong { color: var(--text); font-weight: 600; }

.flash {
  position: fixed; bottom: 20px; right: 20px; max-width: 380px;
  padding: 12px 16px; border-radius: 8px; background: var(--text); color: var(--bg);
  font-size: 13px; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
  opacity: 0; transition: opacity 0.2s; z-index: 100; pointer-events: none;
}
.flash.show { opacity: 1; }
.flash.ok    { background: var(--green); color: white; }
.flash.err   { background: var(--red); color: white; }
.flash.warn  { background: var(--amber); color: white; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
@media (max-width: 720px) { .detail-grid { grid-template-columns: 1fr; } }

.notif-list { font-size: 13px; }
.notif-list li { margin-bottom: 6px; }
.notif-list .ch { font-weight: 700; }
.notif-list .st-sent    { color: var(--green); }
.notif-list .st-failed  { color: var(--red); }
.notif-list .st-skipped { color: var(--amber); }

.keyhint {
  font-size: 11px; color: var(--muted); margin-top: 8px;
}
.keyhint kbd {
  background: var(--card); border: 1px solid var(--line); border-radius: 4px;
  padding: 1px 5px; font-size: 11px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* -------- slot picker (date row + 30-min time grid) -------- */
.slot-picker {
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg);
  padding: 10px;
}
.slot-picker .sp-dates {
  display: flex; gap: 6px; overflow-x: auto;
  padding-bottom: 8px; margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.slot-picker .sp-date {
  flex: 0 0 auto; min-width: 64px;
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; cursor: pointer; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: transform 0.05s ease;
}
.slot-picker .sp-date:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 1px;
}
.slot-picker .sp-date .sp-dow {
  font-size: 10px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.slot-picker .sp-date .sp-day {
  font-size: 18px; font-weight: 800; line-height: 1;
}
.slot-picker .sp-date .sp-mon {
  font-size: 10px; color: var(--muted);
}
.slot-picker .sp-date.is-today { border-color: var(--pink); }
.slot-picker .sp-date.is-today .sp-dow { color: var(--pink); }
.slot-picker .sp-date.is-selected {
  background: var(--blue); color: white; border-color: var(--blue);
}
.slot-picker .sp-date.is-selected .sp-dow,
.slot-picker .sp-date.is-selected .sp-mon { color: rgba(255,255,255,0.85); }
.slot-picker .sp-date:hover { transform: translateY(-1px); }

.slot-picker .sp-times {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}
@media (max-width: 720px) {
  .slot-picker .sp-times { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 480px) {
  .slot-picker .sp-times { grid-template-columns: repeat(3, 1fr); }
}
.slot-picker .sp-slot {
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 7px;
  padding: 8px 0; cursor: pointer; font-family: inherit;
  font-size: 13px; font-weight: 600;
  transition: transform 0.05s ease;
}
.slot-picker .sp-slot:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 1px;
}
.slot-picker .sp-slot:hover { transform: translateY(-1px); border-color: var(--blue); }
.slot-picker .sp-slot.is-selected {
  background: var(--blue); color: white; border-color: var(--blue);
}
.slot-picker .sp-slot.is-past {
  opacity: 0.35; cursor: not-allowed; pointer-events: none;
}
.slot-picker .sp-summary {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 13px; color: var(--muted);
}
.slot-picker .sp-summary strong { color: var(--text); }
.slot-picker .sp-summary.is-set strong { color: var(--green); }
