:root {
  color-scheme: only light;
  --sky: #0ea5e9;
  --sky-dark: #0284c7;
  --sky-soft: #e0f2fe;
  --sky-faint: #f3faff;
  --text: #1f2d3d;
  --muted: #6b7a8c;
  --line: #dde8f0;
  --red: #d33a3a;
  --red-soft: #fdeeee;
  --green: #1f9d55;
  --green-soft: #e8f7ee;
  --amber: #b7791f;
  --amber-soft: #fdf6e7;
}

* { box-sizing: border-box; }
html { font-size: 16px; background: #fff; }
body {
  margin: 0;
  background: #fff;
  color: var(--text);
  font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", Arial, sans-serif;
  line-height: 1.6;
}
a { color: var(--sky-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.red { color: var(--red); }
.green { color: var(--green); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--sky);
  color: #fff;
}
.topbar-inner {
  max-width: 1150px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 56px;
  flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 1.05rem; }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a {
  color: #fff;
  padding: 6px 14px;
  border-radius: 4px;
  font-size: .95rem;
}
.nav a:hover { background: rgba(255, 255, 255, .15); text-decoration: none; }
.nav a.active { background: #fff; color: var(--sky-dark); font-weight: 600; }
.topbar .user { display: flex; gap: 12px; align-items: center; font-size: .9rem; }
.topbar .user a { color: #fff; opacity: .9; }

/* ---------- Layout ---------- */
.page { max-width: 1150px; margin: 0 auto; padding: 24px 16px 60px; }
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.section { margin-top: 28px; }
.section > h2 { margin-bottom: 10px; }
.box {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
}

/* ---------- Forms ---------- */
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid #c9d8e4;
  border-radius: 4px;
  padding: 7px 10px;
  width: 100%;
  min-height: 38px;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--sky-soft); border-color: var(--sky); }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--sky); }
.field { margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 14px; }
.inline-input { width: auto; }
.choice {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 4px;
  padding: 10px 12px; margin-bottom: 8px; cursor: pointer; color: var(--text); font-size: 1rem;
}
.choice.on { border-color: var(--sky); background: var(--sky-faint); }
.hint { font-size: .85rem; color: var(--muted); margin-top: 4px; }
.hint.red { color: var(--red); }
.hint.green { color: var(--green); }

/* ---------- Buttons ---------- */
button, .btn {
  font: inherit;
  font-size: .95rem;
  border: 1px solid var(--sky);
  background: #fff;
  color: var(--sky-dark);
  border-radius: 4px;
  padding: 7px 16px;
  cursor: pointer;
  min-height: 38px;
  white-space: nowrap;
}
button:hover, .btn:hover { background: var(--sky-faint); text-decoration: none; }
button.primary, .btn.primary { background: var(--sky); color: #fff; }
button.primary:hover, .btn.primary:hover { background: var(--sky-dark); border-color: var(--sky-dark); }
button.danger { border-color: var(--red); color: var(--red); }
button.danger:hover { background: var(--red-soft); }
button.link { border: 0; background: none; padding: 2px 6px; min-height: 0; color: var(--sky-dark); }
button.link:hover { text-decoration: underline; background: none; }
button.link.danger { color: var(--red); }
button.sm { padding: 3px 10px; min-height: 30px; font-size: .875rem; }
button:disabled { opacity: .5; cursor: default; }

.tabs { display: inline-flex; border: 1px solid var(--sky); border-radius: 4px; overflow: hidden; }
.tabs button { border: 0; border-radius: 0; border-inline-start: 1px solid var(--sky); }
.tabs button:first-child { border-inline-start: 0; }
.tabs button.on { background: var(--sky); color: #fff; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 10px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .85rem; color: var(--muted); font-weight: 600; background: var(--sky-faint); border-bottom: 1px solid var(--line); }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--sky-faint); }
tr.dim td { color: var(--muted); }
td.actions { white-space: nowrap; text-align: end; }
.empty { padding: 36px 10px; text-align: center; color: var(--muted); }

/* ---------- Status labels ---------- */
.status { display: inline-block; font-size: .8rem; padding: 1px 8px; border-radius: 3px; white-space: nowrap; }
.st-booked { background: var(--sky-soft); color: var(--sky-dark); }
.st-done { background: var(--green-soft); color: var(--green); }
.st-missed { background: var(--amber-soft); color: var(--amber); }
.st-cancelled { background: #eef1f4; color: var(--muted); }

/* ---------- Numbers strip ---------- */
.figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  border: 1px solid var(--line);
  border-radius: 6px;
}
.figure { padding: 14px 16px; border-inline-start: 1px solid var(--line); }
.figure:first-child { border-inline-start: 0; }
.figure .k { font-size: .85rem; color: var(--muted); }
.figure .v { font-size: 1.4rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Booking slots ---------- */
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.slot {
  display: block;
  text-align: center;
  padding: 8px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  white-space: normal;
  min-height: 0;
}
.slot .t { font-weight: 600; font-size: 1rem; }
.slot .c { font-size: .8rem; color: var(--green); }
.slot.busy { background: var(--amber-soft); border-color: #efd9a8; }
.slot.busy .c { color: var(--amber); }
.slot.sel { outline: 2px solid var(--sky); border-color: var(--sky); background: var(--sky-soft); }
.step { display: flex; gap: 10px; align-items: baseline; margin-bottom: 10px; }
.step .n {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--sky); color: #fff; font-size: .85rem;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.picked {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; background: var(--sky-faint); border: 1px solid var(--line); border-radius: 4px;
}
.results { border: 1px solid var(--line); border-radius: 4px; margin-top: 6px; max-height: 260px; overflow-y: auto; }
.results div { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.results div:last-child { border-bottom: 0; }
.results div:hover { background: var(--sky-faint); }

/* ---------- Bars (stats) ---------- */
.bar { height: 10px; background: var(--sky); border-radius: 2px; min-width: 2px; }

/* ---------- Dialog ---------- */
dialog {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  color: var(--text);
}
dialog::backdrop { background: rgba(20, 40, 60, .35); }
.dlg-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.dlg-head button { border: 0; font-size: 1.4rem; line-height: 1; padding: 0 6px; min-height: 0; color: var(--muted); }
.dlg-body { padding: 18px; overflow-y: auto; max-height: calc(100vh - 170px); }
.dlg-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-start; }
.dlg-foot .spacer { flex: 1; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 10px 20px; border-radius: 4px;
  font-size: .95rem; z-index: 50; max-width: calc(100vw - 32px);
}
#toast.err { background: var(--red); }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: flex; flex-direction: column; }
.login-page .topbar-inner { justify-content: center; }
.login-box { width: min(380px, calc(100vw - 32px)); margin: 70px auto; }
.login-box h1 { margin-bottom: 4px; }
.login-box p { margin: 0 0 22px; }
.login-box button.primary { width: 100%; margin-top: 6px; }
.alert { padding: 10px 12px; border-radius: 4px; background: var(--red-soft); color: var(--red); margin-bottom: 14px; font-size: .95rem; }

/* ---------- Schedule editor ---------- */
.sched td, .sched th { padding: 6px 8px; }
.sched input[type="time"] { min-width: 110px; }

@media (max-width: 700px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .topbar-inner { gap: 8px; padding: 8px 16px; }
  .nav a { padding: 4px 8px; }
  .figure { border-inline-start: 0; border-top: 1px solid var(--line); }
  .figure:first-child { border-top: 0; }
  th, td { padding: 8px 6px; }
}

@media print {
  .topbar, button, .no-print { display: none !important; }
  .page { padding: 0; }
}
