/* SIP Booking — internal scheduling tool. Dense, calm, legible. */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #dde1e7;
  --border-strong: #c3c9d2;
  --text: #1c2430;
  --text-2: #5a6472;
  --text-3: #8a93a0;
  --accent: #2f5bd3;
  --accent-soft: #e8eefc;
  --danger: #c23b30;
  --danger-soft: #fdecea;
  --ok: #1f7a4d;
  --ok-soft: #e3f4ea;
  --ok-2: #3d9a5f;
  --ok-2-soft: #eef8e8;
  --warn: #a8660b;
  --warn-soft: #fff2dc;
  --block: #eceef2;
  --row-h: 18px;
  --col-w: minmax(168px, 1fr);
  --radius: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------- buttons & inputs */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface);
  cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, .input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #274db5; }
.btn.danger { color: var(--danger); border-color: #e6b5b0; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--block); }
.btn.sm { height: 26px; padding: 0 8px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.input, select, textarea {
  height: 32px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); min-width: 0;
}
textarea { height: auto; padding: 8px 10px; resize: vertical; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); }
label.field > .input, label.field > select, label.field > textarea { font-size: 14px; color: var(--text); }
label.check { display: inline-flex; align-items: center; gap: 6px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.grid2 .span2 { grid-column: 1 / -1; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.error-text { color: var(--danger); font-size: 13px; }

/* ---------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px;
  height: 52px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); letter-spacing: -.01em; }
.nav { display: flex; gap: 2px; }
.nav a { padding: 6px 10px; border-radius: var(--radius); text-decoration: none; color: var(--text-2); }
.nav a:hover { background: var(--block); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.search { position: relative; margin-left: auto; width: 300px; max-width: 40vw; }
.search .input { width: 100%; }
.search-results {
  position: absolute; top: 38px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 60vh; overflow: auto; z-index: 40;
}
.search-results button {
  display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 12px; cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.search-results button:hover, .search-results button:focus { background: var(--surface-2); }
.user { display: flex; align-items: center; gap: 8px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--block); color: var(--text-2); text-transform: capitalize; }

.banner { position: sticky; top: 52px; z-index: 25; display: flex; gap: 12px; align-items: center; padding: 8px 16px; background: var(--accent); color: #fff; }
.banner .btn { height: 26px; }
.view { padding: 16px; }

/* ---------- auth screens */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 28px; }
.auth-card h1 { margin: 0 0 4px; font-size: 20px; }
.auth-card p { margin: 0 0 16px; color: var(--text-2); }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card .btn.primary { height: 38px; justify-content: center; }
.qr { display: block; margin: 0 auto; width: 200px; height: 200px; image-rendering: pixelated; border: 1px solid var(--border); border-radius: 6px; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 12px; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 6px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 15px; text-align: center; }

/* ---------- day toolbar */
.daybar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.daybar h2 { margin: 0; font-size: 18px; min-width: 220px; }
.week { display: flex; gap: 4px; }
.week button {
  display: flex; flex-direction: column; align-items: center; min-width: 58px; padding: 4px 6px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); cursor: pointer; line-height: 1.2;
}
.week button .d { font-size: 11px; color: var(--text-2); }
.week button .n { font-size: 11px; color: var(--text-3); }
.week button.on { border-color: var(--accent); background: var(--accent-soft); }
.week button.today .d { color: var(--accent); font-weight: 700; }
.live { font-size: 12px; color: var(--text-3); display: inline-flex; align-items: center; gap: 6px; }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.live.on::before { background: #2fb36b; }

.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px; border: 1px solid; }
.alert.warn { background: var(--warn-soft); border-color: #f0d09a; color: #6d4306; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }
.alert button.link { border: 0; background: none; color: inherit; text-decoration: underline; cursor: pointer; padding: 0; }

/* ---------- the grid */
.grid-scroll { overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); max-height: calc(100vh - 150px); }
.grid { display: grid; position: relative; min-width: max-content; }
.gh { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--border-strong); padding: 8px 10px; font-weight: 600; border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; min-height: 48px; }
.gh .sub { font-weight: 400; font-size: 11px; color: var(--text-3); }
.gh.time { left: 0; z-index: 6; border-left: 0; }
.gh.off { color: var(--text-3); }
.tl { position: sticky; left: 0; z-index: 3; background: var(--surface); font-size: 11px; color: var(--text-3); padding: 0 8px; text-align: right; border-top: 1px solid transparent; line-height: var(--row-h); }
.tl.hour { color: var(--text-2); font-weight: 600; border-top-color: var(--border); }
.cell { border-left: 1px solid var(--border); border-top: 1px solid transparent; }
.cell.hour { border-top-color: var(--border); }
.cell.q { border-top-color: #f0f2f5; }
.cell.dropok { background: var(--accent-soft); }
.cell.offday { background: repeating-linear-gradient(135deg, #f7f8fa 0 6px, #f1f2f5 6px 12px); }

.slot {
  margin: 1px 4px; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface);
  color: var(--text-2); font-size: 12px; text-align: left; padding: 2px 8px; cursor: pointer; z-index: 1;
  display: flex; align-items: flex-start;
}
.slot:hover, .slot.dropok { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.slot.picking { border-style: solid; border-color: var(--accent); }

.block {
  margin: 1px 4px; border-radius: var(--radius); font-size: 11px; font-weight: 600; color: var(--text-2);
  padding: 2px 8px; z-index: 1; overflow: hidden; text-transform: uppercase; letter-spacing: .03em;
  background: repeating-linear-gradient(135deg, var(--block) 0 6px, #e3e6eb 6px 12px); border: 1px solid #d9dde3;
}
.block .lbl { background: var(--block); padding: 0 4px; border-radius: 3px; }

.bk {
  margin: 1px 4px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border-strong);
  border-left: 4px solid var(--border-strong); box-shadow: var(--shadow); padding: 4px 8px; font-size: 12px;
  cursor: pointer; overflow: hidden; z-index: 2; text-align: left; display: flex; flex-direction: column; gap: 1px;
}
.bk:hover { border-color: var(--accent); }
.bk.dragging { opacity: .5; }
.bk .name { font-weight: 650; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk .meta { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bk .tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.tag { font-size: 10px; font-weight: 700; padding: 0 5px; border-radius: 3px; background: var(--block); color: var(--text-2); text-transform: uppercase; letter-spacing: .02em; }
.bk.o-complete { border-left-color: var(--ok); background: var(--ok-soft); }
.bk.o-complete-info { border-left-color: var(--ok-2); background: var(--ok-2-soft); }
.bk.o-amber { border-left-color: #d98a14; background: var(--warn-soft); }
.bk.o-red { border-left-color: var(--danger); background: var(--danger-soft); }
.bk.reassign { outline: 2px solid #d98a14; outline-offset: -2px; }
.badge { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 999px; }
.badge.o-complete { background: var(--ok); color: #fff; }
.badge.o-complete-info { background: var(--ok-2); color: #fff; }
.badge.o-amber { background: #d98a14; color: #fff; }
.badge.o-red { background: var(--danger); color: #fff; }

.standby { border-left: 1px solid var(--border-strong); background: var(--surface-2); padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.sb-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; font-size: 12px; display: flex; flex-direction: column; gap: 4px; }
.sb-card.done { opacity: .6; }
.sb-card .name { font-weight: 650; font-size: 13px; }

/* ---------- drawer (booking / case detail) */
.drawer {
  position: fixed; top: 52px; right: 0; bottom: 0; width: 460px; max-width: 100vw; z-index: 35; background: var(--surface);
  border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); overflow: auto; padding: 16px 18px 40px;
}
.drawer h3 { margin: 0; font-size: 18px; }
.drawer h4 { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
.drawer .close { position: absolute; top: 10px; right: 10px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; }
table.hist { width: 100%; border-collapse: collapse; font-size: 12px; }
table.hist th, table.hist td { text-align: left; padding: 6px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.hist th { color: var(--text-3); font-weight: 600; }
table.hist tr.current td { background: var(--accent-soft); }
table.hist tr.cancelled td { color: var(--text-3); text-decoration: line-through; }
.confirm { background: var(--danger-soft); border: 1px solid #e6b5b0; border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 8px; }

/* ---------- modal */
.modal-back { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 50; display: grid; place-items: start center; padding: 6vh 16px; overflow: auto; }
.modal { width: 100%; max-width: 620px; background: var(--surface); border-radius: 10px; box-shadow: var(--shadow-lg); }
.modal header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal header h3 { margin: 0; font-size: 16px; }
.modal .body { padding: 16px 18px; }
.modal footer { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.picked { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; background: var(--accent-soft); border-radius: var(--radius); }
.results { border: 1px solid var(--border); border-radius: var(--radius); max-height: 200px; overflow: auto; }
.results button { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--border); background: none; padding: 6px 10px; cursor: pointer; }
.results button:hover { background: var(--surface-2); }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 5px 12px; cursor: pointer; }
.seg button.on { background: var(--accent); color: #fff; }

/* ---------- toasts */
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #1c2430; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow-lg); max-width: 560px; }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }

/* ---------- admin / setup / reports pages */
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h2 { margin: 0; font-size: 18px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tabs button { border: 0; background: none; padding: 8px 14px; cursor: pointer; border-bottom: 2px solid transparent; color: var(--text-2); }
.tabs button.on { border-bottom-color: var(--accent); color: var(--accent); font-weight: 600; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 14px; }
.card h3 { margin: 0 0 10px; font-size: 15px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data th { color: var(--text-2); font-weight: 600; font-size: 12px; background: var(--surface-2); position: sticky; top: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tr.inactive td { color: var(--text-3); }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; border: 1px solid rgba(0,0,0,.15); }
.bar { height: 8px; border-radius: 4px; background: var(--accent); min-width: 2px; }
.bar.neg { background: #d98a14; }
.bar-cell { width: 40%; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; box-shadow: var(--shadow); }
.stat .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 12px; color: var(--text-2); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters label.field { min-width: 140px; }
.setup-row { display: grid; grid-template-columns: 28px 180px 110px 110px 1fr 90px 120px; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.setup-row.head { font-size: 12px; color: var(--text-2); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--block); }

@media (max-width: 900px) {
  .search { display: none; }
  .drawer { width: 100vw; }
  .setup-row { grid-template-columns: 28px 1fr; }
}
