:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #16191f;
  --muted: #626c7a;
  --line: #e2e6ec;
  --brand: #1b4fd8;
  --brand-dark: #143aa3;
  --brand-soft: #eaf0ff;
  --green: #0f7a5a;
  --green-soft: #e6f5f0;
  --amber: #9a6100;
  --amber-soft: #fdf1de;
  --red: #b3261e;
  --red-soft: #fdecea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--brand); }

/* ---------- shell ---------- */

.topbar {
  background: #0e1420;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0 1.25rem;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar .brand { font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.topbar nav { display: flex; gap: .25rem; flex: 1; overflow-x: auto; }
.topbar nav button {
  background: none; border: 0; color: #b9c3d4; font: inherit; font-size: .93rem;
  padding: .45rem .7rem; border-radius: 7px; cursor: pointer; white-space: nowrap;
}
.topbar nav button:hover { color: #fff; background: rgba(255,255,255,.08); }
.topbar nav button.active { color: #fff; background: rgba(255,255,255,.16); font-weight: 600; }
.topbar .who { color: #b9c3d4; font-size: .85rem; white-space: nowrap; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 1.25rem; }
.wrap.wide { max-width: 1500px; }

/* ---------- panels ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; flex-wrap: wrap; }

.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; }
.spacer { flex: 1; }

/* ---------- forms ---------- */

label.field { display: block; font-size: .8rem; color: var(--muted); font-weight: 600; margin-bottom: .3rem; }
input, select, textarea {
  font: inherit; color: var(--ink); background: #fff;
  border: 1px solid #cfd5de; border-radius: 8px; padding: .5rem .6rem; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
input[type=checkbox] { width: auto; }
.field-group { margin-bottom: .75rem; }
.hint { font-size: .8rem; color: var(--muted); }

button, .btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; border-radius: 8px; padding: .5rem .85rem;
  background: var(--brand); color: #fff; white-space: nowrap;
}
button:hover, .btn:hover { background: var(--brand-dark); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.secondary { background: #fff; color: var(--ink); border-color: #cfd5de; }
button.secondary:hover { background: #f2f4f8; }
button.ghost { background: transparent; color: var(--brand); border-color: transparent; padding: .35rem .5rem; }
button.ghost:hover { background: var(--brand-soft); }
button.danger { background: var(--red); }
button.danger:hover { background: #8f1d17; }
button.small { padding: .3rem .55rem; font-size: .85rem; }

/* ---------- tables ---------- */

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .45rem .5rem; border-bottom: 1px solid var(--line); }
td { padding: .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.table-scroll { overflow-x: auto; }

/* ---------- bits ---------- */

.tag {
  display: inline-block; font-size: .74rem; font-weight: 700; letter-spacing: .02em;
  padding: .15rem .45rem; border-radius: 999px; background: #eef1f5; color: var(--muted);
}
.tag.blue { background: var(--brand-soft); color: var(--brand-dark); }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }
.tag.red { background: var(--red-soft); color: var(--red); }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.stack > * + * { margin-top: .6rem; }
.empty { color: var(--muted); padding: 1.25rem; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }

.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; box-shadow: var(--shadow); }
.kpi .label { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.kpi .value { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .8rem; color: var(--muted); }

/* ---------- slot chips ---------- */

.slots { display: flex; flex-wrap: wrap; gap: .4rem; }
.slot {
  background: #fff; color: var(--ink); border: 1px solid #cfd5de;
  border-radius: 7px; padding: .35rem .6rem; font-size: .88rem; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.slot:hover { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }
.slot.selected { background: var(--brand); border-color: var(--brand); color: #fff; }

.resource-block { padding: .75rem 0; border-bottom: 1px solid var(--line); }
.resource-block:last-child { border-bottom: 0; }
.resource-block .head { display: flex; align-items: baseline; gap: .6rem; margin-bottom: .45rem; }

/* ---------- day grid (staff) ---------- */

.gridwrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.daygrid { display: grid; position: relative; min-width: 720px; }
.daygrid .colhead {
  position: sticky; top: 0; z-index: 3; background: #fff; border-bottom: 1px solid var(--line);
  padding: .5rem .4rem; font-weight: 650; font-size: .85rem; text-align: center;
}
.daygrid .timecol { position: sticky; left: 0; z-index: 2; background: #fff; border-right: 1px solid var(--line); }
.daygrid .timelabel { font-size: .72rem; color: var(--muted); text-align: right; padding-right: .4rem; height: 28px; line-height: 1; transform: translateY(-.4em); }
.daygrid .lane { position: relative; border-right: 1px solid var(--line); }
.daygrid .halfhour { height: 28px; border-bottom: 1px dashed #eef0f4; }
.daygrid .halfhour.hour { border-bottom: 1px solid var(--line); }
.daygrid .halfhour.closed { background: repeating-linear-gradient(45deg, #f4f5f7, #f4f5f7 6px, #eceef2 6px, #eceef2 12px); }
.daygrid .halfhour:hover { background: var(--brand-soft); cursor: pointer; }

.appt {
  position: absolute; left: 3px; right: 3px; border-radius: 6px; padding: .2rem .35rem;
  font-size: .76rem; line-height: 1.2; overflow: hidden; cursor: pointer;
  border-left: 3px solid var(--brand); background: var(--brand-soft); color: #12203d;
}
.appt.lesson { border-left-color: #0f7a5a; background: var(--green-soft); color: #0b3a2c; }
.appt.block { border-left-color: #6b7280; background: #eef0f3; color: #33393f; }
/* Tunnel time a coach is holding but hasn't sold — open inventory, not a booking. */
.appt.lesson_block {
  border-left-color: #9a6100; color: #5c3b00;
  background: repeating-linear-gradient(135deg, #fdf3e3, #fdf3e3 7px, #f8e9d2 7px, #f8e9d2 14px);
}
.appt.cancelled { opacity: .45; text-decoration: line-through; }
.appt .t { font-weight: 700; }
.appt.short { display: flex; gap: .3rem; align-items: baseline; padding-top: .1rem; }
.appt.short > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- modal ---------- */

.modal-back {
  position: fixed; inset: 0; background: rgba(12, 17, 26, .48);
  display: flex; align-items: flex-start; justify-content: center; padding: 4vh 1rem; z-index: 100; overflow: auto;
}
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 520px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { max-width: 760px; }
.modal header { padding: 1rem 1.1rem .6rem; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal .body { padding: 1rem 1.1rem; }
.modal footer { padding: .8rem 1.1rem; border-top: 1px solid var(--line); display: flex; gap: .5rem; justify-content: flex-end; background: #fafbfc; border-radius: 0 0 12px 12px; }

/* ---------- toast ---------- */

#toasts { position: fixed; bottom: 1rem; right: 1rem; z-index: 200; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  background: #12222f; color: #fff; padding: .65rem .9rem; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 380px; font-size: .9rem;
}
.toast.error { background: var(--red); }
.toast.ok { background: var(--green); }

/* ---------- bars (reports) ---------- */

/* Single-series chart: one hue, no legend (the title names it), recessive axis,
   4px rounded data-ends, 2px surface gap between bars, hover tooltip. */
.chart { position: relative; }
.chart .plot { display: flex; align-items: flex-end; gap: 2px; height: 130px; border-bottom: 1px solid var(--line); }
.chart .bar { flex: 1 1 0; min-width: 3px; max-width: 46px; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; cursor: default; }
.chart .bar:hover { background: var(--brand-dark); }
.chart .bar.zero { background: #e6e9ee; }
.barlabels { display: flex; justify-content: space-between; font-size: .72rem; color: var(--muted); margin-top: .3rem; }
.charttip {
  position: absolute; pointer-events: none; background: #12222f; color: #fff; font-size: .78rem;
  padding: .3rem .5rem; border-radius: 6px; transform: translate(-50%, -115%); white-space: nowrap; opacity: 0;
  transition: opacity .12s;
}
.meter { background: #eef1f5; border-radius: 999px; height: 10px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }

/* ---------- auth screen ---------- */

.auth-hero { display: grid; grid-template-columns: 1.1fr .9fr; gap: 2rem; align-items: center; }
@media (max-width: 800px) { .auth-hero { grid-template-columns: 1fr; } }
.auth-hero .pitch h1 { font-size: 2rem; letter-spacing: -.02em; }
.auth-hero .pitch li { margin-bottom: .35rem; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tabs button { background: none; color: var(--muted); border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: .5rem .75rem; }
.tabs button:hover { background: none; color: var(--ink); }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }

@media (max-width: 640px) {
  .wrap { padding: .85rem; }
  .topbar { padding: 0 .75rem; gap: .6rem; }
  .topbar .who { display: none; }
}
