:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1c2536;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-ink: #ffffff;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
}
a { color: var(--brand); text-decoration: none; }

/* ---------- layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--card);
  border-right: 1px solid var(--line); padding: 16px 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.sidebar .logo { font-weight: 700; font-size: 18px; padding: 8px 10px 16px; }
.sidebar .logo span { color: var(--brand); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav button {
  text-align: left; padding: 10px 12px; border: 0; background: none;
  border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--ink);
}
.sidebar nav button:hover { background: #eef2ff; }
.sidebar nav button.active { background: var(--brand); color: var(--brand-ink); font-weight: 600; }
.sidebar .foot { margin-top: auto; padding: 10px; color: var(--muted); font-size: 12px; }
.main { flex: 1; padding: 24px 28px; max-width: 1100px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.topbar h1 { font-size: 22px; margin: 0; }
.topbar .who { color: var(--muted); font-size: 13px; }

/* ---------- cards & grids ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px;
}
.grid { display: grid; gap: 16px; }
.grid.cols2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.stat { text-align: left; }
.stat .num { font-size: 30px; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: 13px; }
h2 { font-size: 16px; margin: 0 0 12px; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }

/* ---------- forms & buttons ---------- */
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 14px; font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--brand); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
button.btn {
  padding: 9px 16px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--brand); color: var(--brand-ink); font-size: 14px; font-weight: 600;
}
button.btn.secondary { background: #eef2ff; color: var(--brand); }
button.btn.danger { background: #fee2e2; color: var(--bad); }
button.btn.small { padding: 5px 10px; font-size: 12.5px; }
button.btn:disabled { opacity: .5; cursor: default; }

/* ---------- misc ---------- */
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.ok { background: #dcfce7; color: var(--ok); }
.pill.warn { background: #fef3c7; color: var(--warn); }
.pill.bad { background: #fee2e2; color: var(--bad); }
.pill.mut { background: #e2e8f0; color: var(--muted); }
.toast {
  position: fixed; bottom: 24px; right: 24px; padding: 12px 18px;
  border-radius: 10px; background: var(--ink); color: #fff; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18); z-index: 50;
}
.toast.err { background: var(--bad); }
.empty { color: var(--muted); text-align: center; padding: 24px 0; }

/* ---------- login ---------- */
.login-wrap { max-width: 380px; margin: 12vh auto 0; }
.login-wrap .logo { text-align: center; font-size: 26px; font-weight: 700; margin-bottom: 20px; }
.login-wrap .logo span { color: var(--brand); }

/* ---------- week calendar ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.cal-head h2 { margin: 0; }
.cal-nav { display: flex; align-items: center; gap: 8px; }
.cal-range { font-weight: 600; font-size: 14px; min-width: 150px; text-align: center; }
.cal-legend { display: flex; gap: 16px; align-items: center; font-size: 12.5px; color: var(--muted); margin-bottom: 10px; flex-wrap: wrap; }
.cal-legend .dot { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.busy-dot { background: #fecaca; border: 1px solid var(--bad); }
.conf-dot { background: #bbf7d0; border: 1px solid var(--ok); }
.free-dot { background: #f8fafc; border: 1px dashed #cbd5e1; }
.cal-count { margin-left: auto; font-weight: 600; color: var(--ink); }
.cal-wrap { overflow-x: auto; }
table.cal { border-collapse: collapse; font-size: 12px; min-width: 680px; }
table.cal th, table.cal td { border: 1px solid var(--line); padding: 0; }
table.cal thead th { padding: 7px 6px; background: #f8fafc; font-size: 12px; text-transform: none; letter-spacing: 0; text-align: center; }
table.cal thead th.today { background: var(--brand); color: #fff; }
table.cal .timecol { width: 52px; padding: 4px 6px; color: var(--muted); font-size: 11px; text-align: right; white-space: nowrap; }
table.cal td.slot { height: 26px; padding: 2px 4px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 90px; }
table.cal td.slot.free { background: #f8fafc; cursor: pointer; }
table.cal td.slot.free:hover { background: #dbeafe; }
table.cal td.slot.busy { background: #fee2e2; color: #7f1d1d; font-weight: 600; }
table.cal td.slot.busy.ok { background: #dcfce7; color: #14532d; }
table.cal tr.half td { border-top-style: dashed; border-top-color: #eef2f7; }
table.cal tbody tr:first-child td { border-top: 1px solid var(--line); }

@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; overflow-x: auto; }
  .sidebar nav { flex-direction: row; }
  .sidebar .foot { display: none; }
  .main { padding: 16px; }
}
