/* ==========================================================================
   SPC Treatment Board - design system
   ========================================================================== */
:root {
  --bg: #f3f6f8;
  --card: #ffffff;
  --ink: #0f1f2e;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e3e9ef;
  --line-2: #eef2f6;
  --brand: #0f766e;
  --brand-d: #0b5d57;
  --brand-l: #d9f3ef;
  --side: #0b2e2b;
  --side-2: #0f3f3a;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #16a34a;
  --info: #2563eb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 31, 46, .05), 0 4px 14px rgba(15, 31, 46, .06);
  --shadow-lg: 0 20px 50px rgba(15, 31, 46, .22);
  --side-w: 248px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* treatment kinds */
  --k-contract: #0d9488; --kb-contract: #d5f5ef;
  --k-ot:       #0284c7; --kb-ot:       #dbeefb;
  --k-pre:      #4f46e5; --kb-pre:      #e4e5fd;
  --k-post:     #9333ea; --kb-post:     #f0e3fd;
  --k-complaint:#e11d48; --kb-complaint:#ffe0e7;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.45;
  color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.i { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.2em; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.hide { display: none !important; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w); z-index: 40;
  background: linear-gradient(180deg, var(--side) 0%, #08201e 100%); color: #cfe7e3;
  display: flex; flex-direction: column; padding: 18px 14px; transition: transform .25s ease;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 20px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, #14b8a6, #0f766e); font-weight: 800; letter-spacing: .04em; font-size: 14px;
  box-shadow: 0 6px 16px rgba(20, 184, 166, .35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text b { font-size: 16px; }
.brand-text small { color: #8fc2bb; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px;
  color: #cfe7e3; font-weight: 500; transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav-item.is-active { background: rgba(20, 184, 166, .18); color: #fff; box-shadow: inset 3px 0 0 #2dd4bf; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 14px; }
.who { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; color: #fff; }
.who:hover { background: rgba(255, 255, 255, .07); text-decoration: none; }
.who-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.who-text b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-text small { color: #8fc2bb; font-size: 12px; }
.avatar {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, #5eead4, #14b8a6); color: #053b36; font-weight: 700; font-size: 14px;
}
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }
.scrim, .panel-scrim { position: fixed; inset: 0; background: rgba(8, 20, 30, .45); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 35; }
.scrim.is-open, .panel-scrim.is-open { opacity: 1; pointer-events: auto; }
.main { flex: 1; min-width: 0; margin-left: var(--side-w); display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 14px 24px; background: rgba(243, 246, 248, .88); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.page-title { font-size: 20px; font-weight: 700; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.menu-btn { display: none; }
.content { padding: 20px 24px 40px; max-width: 1700px; width: 100%; }

/* ---------- buttons / inputs ---------- */
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink-2); transition: all .15s;
}
.icon-btn:hover { border-color: #c7d2dc; background: #f8fafc; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 10px;
  border: 1px solid transparent; font-weight: 600; background: var(--card); color: var(--ink); line-height: 1.2;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(15, 118, 110, .28); }
.btn-primary:hover:not(:disabled) { background: var(--brand-d); }
.btn-ghost { border-color: var(--line); background: var(--card); color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: #f8fafc; border-color: #c7d2dc; }
.btn-warn { background: #fff7ed; color: #b45309; border-color: #fed7aa; }
.btn-warn:hover:not(:disabled) { background: #ffedd5; }
.btn-danger { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover:not(:disabled) { background: #fee2e2; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); letter-spacing: .01em; }
.input, .select, textarea.input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
  transition: border-color .15s, box-shadow .15s; min-height: 42px;
}
textarea.input { min-height: 74px; resize: vertical; }
.input:focus, .select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15, 118, 110, .16); }
.input.is-bad { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(220, 38, 38, .12); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.hint { font-size: 12.5px; color: var(--muted); }

/* ---------- cards / chips / badges ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: #eef2f6; color: var(--ink-2); line-height: 1.5; white-space: nowrap;
}
.chip.kind-contract { background: var(--kb-contract); color: #0a6b60; }
.chip.kind-ot { background: var(--kb-ot); color: #075f8d; }
.chip.kind-pre { background: var(--kb-pre); color: #3730a3; }
.chip.kind-post { background: var(--kb-post); color: #6b21a8; }
.chip.kind-complaint { background: var(--kb-complaint); color: #be123c; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 6px; font-size: 11.5px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; }
.badge.confirmed { background: #fef3c7; color: #92400e; }
.badge.assigned { background: #dbeafe; color: #1e40af; }
.badge.done { background: #dcfce7; color: #166534; }
.badge.pending { background: #e5e7eb; color: #374151; }
.count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--brand-l); color: var(--brand-d); font-size: 12px; font-weight: 700; }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; font-size: 13.5px; margin-bottom: 14px; }
.alert.warn { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; }
.alert.err { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert.ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-ico { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 14px; background: var(--brand-l); color: var(--brand-d); font-size: 24px; font-weight: 700; }
.empty-state h2 { color: var(--ink); margin-bottom: 6px; }
.empty-state .btn { margin-top: 18px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: flex; flex-direction: column; gap: 10px; max-width: min(380px, calc(100vw - 36px)); }
.toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; color: #fff; background: #0f1f2e;
  box-shadow: var(--shadow-lg); animation: toast-in .25s ease; font-size: 14px;
}
.toast.ok { background: #0f5132; } .toast.err { background: #7f1d1d; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- tables (admin screens) ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 11px 14px; border-bottom: 1px solid var(--line); background: #fafcfd; white-space: nowrap; }
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: #fbfdfe; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .grow { flex: 1; }

.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.perm {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; background: #fff; transition: all .15s;
}
.perm:hover { border-color: #b8c7d3; }
.perm input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--brand); flex: none; }
.perm b { display: block; font-size: 14px; }
.perm small { color: var(--muted); font-size: 12.5px; }
.perm:has(input:checked) { border-color: var(--brand); background: #f0fbf9; }

/* ---------- login ---------- */
body.login { background: radial-gradient(1200px 600px at 10% -10%, #14b8a6 0%, transparent 55%), linear-gradient(160deg, #08201e, #0b3b36 60%, #0f766e); min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(420px, 100%); background: #fff; border-radius: 22px; padding: 34px 30px 28px; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.login-brand img { height: 46px; width: auto; max-width: 70%; object-fit: contain; }
.login-card h1 { font-size: 24px; margin-bottom: 4px; }
.login-card .sub { color: var(--muted); margin-bottom: 22px; }

/* ==========================================================================
   Board
   ========================================================================== */
.board-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.datenav { display: flex; align-items: center; gap: 6px; }
.date-pill {
  position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 0 16px; height: 38px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); font-weight: 700; min-width: 190px; justify-content: center; cursor: pointer;
}
.date-pill input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.seg { display: inline-flex; padding: 3px; background: #e8eef3; border-radius: 11px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.seg button.is-on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(15, 31, 46, .12); }
.seg button .dot { width: 8px; height: 8px; border-radius: 50%; }
.search { position: relative; flex: 1; min-width: 180px; max-width: 320px; }
.search .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 36px; }
.tb-right { margin-left: auto; display: flex; gap: 8px; }

.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.stat .ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.stat b { font-size: 22px; display: block; line-height: 1; }
.stat span { color: var(--muted); font-size: 12.5px; }
.stat.s-total .ico { background: #e0f2fe; color: #0369a1; }
.stat.s-need .ico { background: #fef3c7; color: #b45309; }
.stat.s-asg .ico { background: #dbeafe; color: #1d4ed8; }
.stat.s-done .ico { background: #dcfce7; color: #15803d; }
.stat.s-cmp .ico { background: #ffe4e6; color: #be123c; }

.section-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px 10px; }
.section-head h3 { font-size: 15px; }
.section-head small { color: var(--muted); }

/* tray: confirmed, waiting for a technician */
.tray { margin-bottom: 16px; }
.tray-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 10px; padding: 4px 18px 18px; }
.tcard {
  display: flex; gap: 12px; align-items: center; text-align: left; padding: 11px 12px; border-radius: 12px; background: #fff;
  border: 1px solid var(--line); border-left: 4px solid var(--k, #94a3b8); transition: all .15s; width: 100%; min-width: 0; overflow: hidden;
}
.tray-list > *, .ag > * { min-width: 0; }
.tcard .chip { flex: none; }
.tcard:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: #cbd5e1; border-left-color: var(--k); }
.tcard-time { font-weight: 800; font-size: 15px; min-width: 50px; color: var(--ink); }
.tcard-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.tcard-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tcard-main span { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tray-empty { padding: 4px 18px 18px; color: var(--muted); display: flex; gap: 8px; align-items: center; }

.kind-contract { --k: var(--k-contract); --kb: var(--kb-contract); }
.kind-ot { --k: var(--k-ot); --kb: var(--kb-ot); }
.kind-pre { --k: var(--k-pre); --kb: var(--kb-pre); }
.kind-post { --k: var(--k-post); --kb: var(--kb-post); }
.kind-complaint { --k: var(--k-complaint); --kb: var(--kb-complaint); }

/* timeline */
.view-card { overflow: hidden; }
.tl-scroll { overflow: auto; max-height: calc(100vh - 250px); min-height: 220px; }
.tl { --hw: 96px; --namew: 190px; position: relative; min-width: max-content; }
.tl-head { display: flex; position: sticky; top: 0; z-index: 6; background: #fafcfd; border-bottom: 1px solid var(--line); }
.tl-corner {
  position: sticky; left: 0; z-index: 7; width: var(--namew); flex: none; padding: 11px 16px; background: #fafcfd;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border-right: 1px solid var(--line);
}
.tl-hours { position: relative; height: 40px; flex: none; }
.tl-hours span { position: absolute; top: 12px; padding-left: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.tl-row { display: flex; border-bottom: 1px solid var(--line-2); }
.tl-row:last-child { border-bottom: 0; }
.tl-name {
  position: sticky; left: 0; z-index: 4; width: var(--namew); flex: none; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: #fff; border-right: 1px solid var(--line); box-shadow: 4px 0 8px -6px rgba(15, 31, 46, .15);
}
.tl-name div { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.tl-name b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-name small { color: var(--muted); font-size: 12px; }
.tl-track {
  position: relative; flex: none;
  background-image:
    repeating-linear-gradient(to right, #dfe7ee 0, #dfe7ee 1px, transparent 1px, transparent var(--hw)),
    repeating-linear-gradient(to right, transparent 0, transparent calc(var(--hw) / 2), #f0f4f8 calc(var(--hw) / 2), #f0f4f8 calc(var(--hw) / 2 + 1px), transparent calc(var(--hw) / 2 + 1px), transparent var(--hw));
}
.tl-ev {
  position: absolute; height: 58px; padding: 4px 9px; border-radius: 10px; overflow: hidden; text-align: left;
  background: var(--kb); border: 1px solid color-mix(in srgb, var(--k) 35%, transparent); border-left: 4px solid var(--k);
  color: var(--ink); display: flex; flex-direction: column; justify-content: center; gap: 0; transition: box-shadow .15s, transform .15s;
}
.tl-ev:hover { box-shadow: 0 6px 18px rgba(15, 31, 46, .2); transform: translateY(-1px); z-index: 3; }
.tl-ev .t { display: block; font-size: 11px; line-height: 1.3; font-weight: 700; color: var(--k); letter-spacing: .01em; white-space: nowrap; }
.tl-ev .c { display: block; font-size: 12.5px; line-height: 1.3; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-ev .s { display: block; font-size: 11px; line-height: 1.3; color: var(--ink-2); opacity: .8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-ev.noend { border-right: 2px dashed var(--k); }
.tl-ev.is-done { opacity: .62; }
.tl-ev.is-done .c { text-decoration: line-through; text-decoration-color: rgba(15, 31, 46, .35); }
.tl-ev.clash { outline: 2px solid var(--danger); outline-offset: 1px; }
.tl-now { position: absolute; top: 0; bottom: 0; width: 2px; background: #ef4444; z-index: 2; opacity: .85; pointer-events: none; }
.tl-now::before { content: ""; position: absolute; top: -1px; left: -4px; width: 10px; height: 10px; border-radius: 50%; background: #ef4444; }
.view-empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.view-empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; padding: 12px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* agenda */
.ag { padding: 6px 18px 18px; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.ag-group { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff; }
.ag-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: #f8fafc; border-bottom: 1px solid var(--line); }
.ag-head b { flex: 1; }
.ag-item { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 11px 14px; border: 0; border-bottom: 1px solid var(--line-2); background: #fff; border-left: 4px solid var(--k); }
.ag-item:last-child { border-bottom: 0; }
.ag-item:hover { background: #fbfdfe; }
.ag-time { min-width: 56px; font-weight: 800; line-height: 1.15; }
.ag-time small { display: block; font-weight: 600; color: var(--muted); font-size: 12px; }
.ag-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ag-body b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-body span { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-item.is-done { opacity: .6; }

/* side panel */
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100vw); z-index: 60; background: #fff;
  transform: translateX(104%); transition: transform .28s cubic-bezier(.2, .8, .2, 1); display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
}
.panel.is-open { transform: none; }
.panel-scrim { z-index: 55; }
.panel-head { display: flex; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); border-top: 5px solid var(--k, var(--brand)); }
.panel-head h2 { font-size: 19px; margin: 8px 0 3px; }
.panel-head p { color: var(--muted); font-size: 13.5px; }
.panel-head .icon-btn { margin-left: auto; flex: none; }
.panel-body { flex: 1; overflow-y: auto; padding: 16px 20px 24px; }
.info { display: grid; gap: 9px; margin-bottom: 16px; padding: 14px; border-radius: 12px; background: #f6f9fb; border: 1px solid var(--line-2); }
.info div { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; }
.info .i { color: var(--muted); margin-top: 2px; }
.info a { font-weight: 600; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 -20px 16px; padding: 0 20px; overflow-x: auto; }
.tab { border: 0; background: transparent; padding: 10px 12px; font-weight: 600; font-size: 13.5px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab.is-on { color: var(--brand-d); border-bottom-color: var(--brand); }
.reasons { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.reason { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 11px; font-size: 12.5px; color: var(--ink-2); }
.reason:hover { border-color: var(--brand); color: var(--brand-d); background: #f0fbf9; }
.slots { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.slots button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 4px 9px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.slots button:hover { border-color: var(--brand); color: var(--brand-d); }
.busy { margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: #f6f9fb; border: 1px dashed #cbd5e1; font-size: 12.5px; color: var(--ink-2); }
.busy b { display: block; margin-bottom: 4px; }
.busy .row { display: flex; gap: 8px; padding: 2px 0; }
.panel-actions { display: flex; gap: 10px; margin-top: 6px; }
.panel-actions .btn { flex: 1; }
.sub-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line); }
.timeline-log { list-style: none; margin: 0; padding: 0; }
.timeline-log li { position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline-log li::before { content: ""; position: absolute; left: -7px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.timeline-log b { font-size: 13.5px; }
.timeline-log small { display: block; color: var(--muted); font-size: 12.5px; }
.timeline-log .why { margin-top: 3px; padding: 6px 9px; background: #f6f9fb; border-radius: 8px; font-size: 13px; }

.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff; animation: spin .7s linear infinite; }
.btn-ghost .spin, .btn-warn .spin { border-color: rgba(15, 31, 46, .2); border-top-color: var(--ink); }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { height: 140px; margin: 18px; border-radius: 12px; background: linear-gradient(90deg, #eef2f6 25%, #f7f9fb 37%, #eef2f6 63%); background-size: 400% 100%; animation: sk 1.3s ease infinite; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-102%); box-shadow: var(--shadow-lg); }
  .sidebar.is-open { transform: none; }
  .main { margin-left: 0; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 12px 14px; }
  .content { padding: 14px 14px 80px; }
  .page-title { font-size: 18px; }
}
@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat { padding: 11px 12px; }
  .stat b { font-size: 19px; }
  .board-toolbar { gap: 8px; }
  .datenav { width: 100%; }
  .datenav .date-pill { flex: 1; min-width: 0; }
  .seg { max-width: 100%; overflow-x: auto; }
  .search { max-width: none; flex-basis: 100%; order: 5; }
  .tb-right { margin-left: 0; }
  .tray-list { grid-template-columns: 1fr; padding: 4px 12px 14px; }
  .ag { grid-template-columns: 1fr; padding: 6px 12px 14px; }
  .row-2, .row-3 { grid-template-columns: 1fr; }
  .panel { width: 100vw; }
  .tl-scroll { max-height: none; }
  .perm-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Print (day schedule)
   ========================================================================== */
@media print {
  body { background: #fff; font-size: 12px; }
  .sidebar, .topbar, .scrim, .board-toolbar, .stats, .tray, .panel, .panel-scrim, .toasts, .legend, .tb-right, .no-print { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; }
  .ag { grid-template-columns: 1fr 1fr; padding: 0; }
  .ag-group { break-inside: avoid; }
  .print-title { display: block !important; }
}
.print-title { display: none; margin-bottom: 10px; }
