:root {
  --bg: #fbf6ef;
  --surface: #fffdf9;
  --surface-2: #f3e9de;
  --text: #342821;
  --muted: #78665b;
  --border: #e5d7ca;
  --primary: #a3442e;
  --primary-hover: #853622;
  --primary-soft: #f9e4d9;
  --accent: #c18a39;
  --danger: #b13a0a; /* 5.1:1 on --danger-soft, 6:1 on white (WCAG AA) */
  --danger-soft: #fde8dd;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #854d0e; /* 6.2:1 on --warn-soft */
  --warn-soft: #fef3c7;
  --info: #1d4ed8;
  --info-soft: #dbeafe;
  --shadow: 0 1px 2px rgba(16, 24, 22, 0.06), 0 4px 16px rgba(16, 24, 22, 0.06);
  --radius: 22px;
  --radius-sm: 12px;
  --on-primary: #fffaf5;
  --on-danger: #fff;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1714;
    --surface: #261f1b;
    --surface-2: #332923;
    --text: #f6eade;
    --muted: #c0aa99;
    --border: #49392f;
    --primary: #f3a487;
    --primary-hover: #ffc0a6;
    --primary-soft: #492c22;
    --danger: #fb923c;
    --danger-soft: #3b2216;
    --ok: #4ade80;
    --ok-soft: #14301f;
    --warn: #facc15;
    --warn-soft: #332b10;
    --info: #93c5fd;
    --info-soft: #172a45;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
    --on-primary: #351b12;
    --on-danger: #1f0f05;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #1c1714;
    --surface: #261f1b;
    --surface-2: #332923;
    --text: #f6eade;
    --muted: #c0aa99;
    --border: #49392f;
    --primary: #f3a487;
    --primary-hover: #ffc0a6;
    --primary-soft: #492c22;
    --danger: #fb923c;
    --danger-soft: #3b2216;
    --ok: #4ade80;
    --ok-soft: #14301f;
    --warn: #facc15;
    --warn-soft: #332b10;
    --info: #93c5fd;
    --info-soft: #172a45;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
    --on-primary: #351b12;
    --on-danger: #1f0f05;
    color-scheme: dark;
}


* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
.container { width: 100%; max-width: 1140px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: .62em 1.1em; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--primary); color: #fff; text-decoration: none;
  transition: background .15s, border-color .15s, transform .05s;
}
/* Filled controls use a foreground matched to the active theme. */
.btn:where(:not(.ghost, .danger)) { color: var(--on-primary); }
.btn:hover { background: var(--primary-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
/* A disabled field must look disabled (author colors override the browser's own greying). */
input:disabled, select:disabled, textarea:disabled { opacity: .55; cursor: not-allowed; background: var(--surface-2); }
input[readonly] { background: var(--surface-2); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: .35em .7em; font-size: .85rem; }
.btn.block { width: 100%; }

label { display: block; font-size: .875rem; font-weight: 600; margin-bottom: .3em; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .6em .75em;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary);
}
textarea { min-height: 80px; resize: vertical; }
.field { margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.req::after { content: " *"; color: var(--danger); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}

.alert { border-radius: var(--radius-sm); padding: .75em 1em; margin: 0 0 14px; font-size: .925rem; }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.success { background: var(--ok-soft); color: var(--ok); }

.badge {
  display: inline-block; padding: .15em .6em; border-radius: 999px;
  font-size: .78rem; font-weight: 600; white-space: nowrap;
}
.badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.confirmed { background: var(--info-soft); color: var(--info); }
.badge.completed { background: var(--ok-soft); color: var(--ok); }
.badge.cancelled { background: var(--surface-2); color: var(--muted); text-decoration: line-through; }
.badge.no_show { background: var(--danger-soft); color: var(--danger); }

/* ---------- public site ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 12px; }
.brand { display: flex; align-items: center; gap: .5em; font-weight: 800; font-size: 1.2rem; color: var(--text); text-decoration: none; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: var(--primary); color: #fff; font-size: 1.15rem;
}
/* The web icon (/img/icon-48.png, rounded square with its own colours) in place of the 🐾 badge. */
img.brand-logo { width: 28px; height: 28px; background: none; border-radius: 0; display: block; object-fit: contain; }
.nav { display: flex; gap: 22px; align-items: center; }
.nav a { color: var(--muted); text-decoration: none; font-weight: 500; }
.nav a:hover { color: var(--text); }
.nav .btn:where(:not(.ghost, .danger)) { color: #fff; }
@media (max-width: 760px) { .nav a:not(.btn) { display: none; } }

.hero { padding: 72px 0 56px; }
.hero .container { display: grid; grid-template-columns: 1.15fr .85fr; gap: 40px; align-items: center; }
.hero h1 { font-size: clamp(2rem, 4.5vw, 3.1rem); letter-spacing: -.02em; }
.hero h1 span { color: var(--primary); }
.hero p.lead { font-size: 1.12rem; color: var(--muted); max-width: 34em; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }
.hero-art {
  aspect-ratio: 1; border-radius: 28px; display: grid; place-items: center;
  background: radial-gradient(circle at 30% 30%, var(--primary-soft), transparent 70%), var(--surface-2);
  border: 1px solid var(--border); font-size: clamp(5rem, 14vw, 9rem);
}
.hero-facts { display: flex; gap: 28px; margin-top: 32px; flex-wrap: wrap; }
.hero-facts b { display: block; font-size: 1.5rem; color: var(--text); }
.hero-facts span { color: var(--muted); font-size: .9rem; }
@media (max-width: 820px) {
  .hero { padding: 40px 0; }
  .hero .container { grid-template-columns: 1fr; }
  .hero-art { max-width: 260px; justify-self: center; order: -1; }
}

section.block { padding: 56px 0; }
section.block.alt { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-head { text-align: center; max-width: 620px; margin: 0 auto 32px; }
.section-head h2 { font-size: clamp(1.6rem, 3vw, 2.1rem); }

.services { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.service { display: flex; flex-direction: column; gap: 6px; }
.service .icon { font-size: 1.9rem; }
.service h3 { font-size: 1.05rem; margin: 4px 0 0; }
.service p { margin: 0; color: var(--muted); font-size: .92rem; flex: 1; }
.service .meta { display: flex; justify-content: space-between; margin-top: 8px; font-size: .9rem; }
.service .price { font-weight: 700; color: var(--primary); }

.vets { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.vet { text-align: center; }
.avatar {
  width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 10px;
  display: grid; place-items: center; font-weight: 800; font-size: 1.4rem;
  background: var(--primary-soft); color: var(--primary);
}
.vet h3 { font-size: 1.05rem; margin-bottom: 2px; }
.vet .spec { color: var(--primary); font-weight: 600; font-size: .9rem; }
.vet p { color: var(--muted); font-size: .9rem; margin: 6px 0 0; }

.booking-wrap { display: grid; grid-template-columns: 1.4fr .9fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .booking-wrap { grid-template-columns: 1fr; } }
.form-section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 8px 0 10px; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.slot {
  padding: .5em 0; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; font: inherit; font-weight: 600; color: var(--text);
}
.slot:hover { border-color: var(--primary); }
.slot.selected { background: var(--primary); border-color: var(--primary); color: #fff; }
.slot.selected { color: var(--on-primary); }
.slots-empty { color: var(--muted); font-size: .9rem; padding: 10px 0; }

.info-list { list-style: none; padding: 0; margin: 0; }
.info-list li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.info-list li:last-child { border-bottom: 0; }
.info-list .ic { font-size: 1.3rem; }

.lookup-results { margin-top: 14px; display: grid; gap: 10px; }
.lookup-item { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); flex-wrap: wrap; }

.site-footer { padding: 32px 0; color: var(--muted); font-size: .9rem; }
.site-footer .container { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(8, 14, 12, .5);
  display: grid; place-items: center; padding: 16px;
}
.modal {
  width: 100%; max-width: 640px; max-height: calc(100vh - 32px); overflow: auto;
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal header h3 { margin: 0; font-size: 1.1rem; }
.modal .body { padding: 20px; }
.modal footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }
.icon-btn { background: none; border: 0; font-size: 1.4rem; cursor: pointer; color: var(--muted); line-height: 1; }

.toast-wrap { position: fixed; bottom: 16px; right: 16px; z-index: 200; display: grid; gap: 8px; }
.toast { background: var(--text); color: var(--bg); padding: .7em 1em; border-radius: var(--radius-sm); box-shadow: var(--shadow); font-size: .92rem; max-width: 340px; }
.toast.error { background: var(--danger); color: #fff; }
/* The dark-mode danger token is light orange: dark text keeps toasts readable (8:1). */
.toast.error { color: var(--on-danger); }

/* ---------- admin ---------- */
.admin-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
}
.sidebar .brand { padding: 0 8px 16px; }
.sidebar a.nav-item {
  display: flex; gap: 10px; align-items: center; padding: .6em .8em; border-radius: var(--radius-sm);
  color: var(--muted); text-decoration: none; font-weight: 500;
}
.sidebar a.nav-item:hover { background: var(--surface-2); color: var(--text); }
.sidebar a.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.sidebar .spacer { flex: 1; }
.main { padding: 24px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.5rem; margin: 0; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }
@media (max-width: 860px) {
  .admin-shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar {
    position: sticky; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: 8px; z-index: 10;
    border-right: 0; border-bottom: 1px solid var(--border);
  }
  .sidebar .brand, .sidebar .spacer { display: none; }
  .sidebar a.nav-item { white-space: nowrap; }
  .main { padding: 16px; }
  .toolbar input, .toolbar select { flex: 1 1 140px; min-width: 0; }
}

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat .label { color: var(--muted); font-size: .85rem; font-weight: 500; }
.stat .value { font-size: 1.75rem; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.dash-grid { display: grid; grid-template-columns: 1fr 300px; gap: 14px; align-items: start; }
@media (max-width: 1400px) { .dash-grid { grid-template-columns: 1fr; } }
.dash-grid > *, .detail-grid > * { min-width: 0; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: var(--surface-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { white-space: nowrap; text-align: right; }
td.actions .btn + .btn { margin-left: 4px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--primary); cursor: pointer; font-weight: 600; text-align: left; }
.link:hover { text-decoration: underline; }

.bar-row { display: grid; grid-template-columns: 90px 1fr 34px; gap: 10px; align-items: center; margin: 8px 0; font-size: .9rem; }
.bar { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--primary); border-radius: 999px; }

.detail-grid { display: grid; grid-template-columns: 320px 1fr; gap: 14px; align-items: start; }
@media (max-width: 1100px) { .detail-grid { grid-template-columns: 1fr; } }
dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: .93rem; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; font-weight: 500; }
.timeline { display: grid; gap: 12px; }
.record { border-left: 3px solid var(--primary); padding: 4px 0 4px 14px; }
.record h4 { margin: 0 0 4px; font-size: 1rem; }
.record .vitals { display: flex; gap: 14px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); }
.record p { margin: 6px 0 0; font-size: .92rem; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }
/* Sign-in with the phone number (verify.mn): the button under the form, and the card shown while the SMS is awaited */
.login-phone-btn { margin-top: 10px; }
.phone-wait > * + * { margin-top: 12px; }
.phone-wait #phone-wait-text { font-size: 1.05rem; line-height: 1.5; }
/* Sign-up: the owner's number proven through verify.mn (public/signup.html) */
.phone-verify { margin: 4px 0 14px; }
.phone-verify-ok { margin: 0; color: var(--ok); font-weight: 600; }
.phone-verify-wait { padding: 12px; border: 1px solid var(--border); border-radius: 10px; }
.phone-verify-wait > * + * { margin-top: 10px; }
.phone-verify-wait #phone-verify-text { margin: 0; line-height: 1.5; }
