:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #6b7785;
  --line: #e3e8ee;
  --brand: #1f6feb;
  --brand-soft: #e8f0fe;
  --ok: #1a7f37;
  --ok-soft: #e6f4ea;
  --off: #8a94a3;
  --off-soft: #eef1f4;
  --danger: #c62828;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --card: #1a1f25;
    --text: #e6e9ed;
    --muted: #97a1ad;
    --line: #2a313a;
    --brand: #5b9dff;
    --brand-soft: #1c2a40;
    --ok: #4cc26b;
    --ok-soft: #173222;
    --off: #8a94a3;
    --off-soft: #22282f;
    --danger: #ff6b6b;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.3; margin: 0 0 8px; }
p { margin: 0 0 6px; }
.muted { color: var(--muted); }
.error { color: var(--danger); }
.center { text-align: center; }
.empty { padding: 32px 0; text-align: center; }
.hidden { display: none; }

.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px max(20px, calc((100% - 1040px) / 2));
  background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--text); }
.brand:hover { text-decoration: none; }
.logo {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--brand); color: #fff; font-size: 16px;
}
#nav { display: flex; align-items: center; gap: 16px; }
.hello { font-size: 14px; }
main { max-width: 1040px; margin: 0 auto; padding: 24px 20px 48px; }
.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 0 32px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border: 1px solid var(--brand); border-radius: 8px;
  background: var(--brand); color: #fff; font: inherit; cursor: pointer;
}
.btn:hover { text-decoration: none; filter: brightness(1.05); }
.btn.small { padding: 5px 12px; font-size: 14px; }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
button.link { border: 0; background: none; color: var(--brand); font: inherit; cursor: pointer; padding: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card + .card, .card + .table-wrap, .card + div { margin-top: 16px; }
.card.highlight { border-color: var(--brand); }

.hero { padding: 12px 0 20px; }
.hero h1 { font-size: 26px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.chip { padding: 5px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-size: 14px; }
.chip:hover { text-decoration: none; border-color: var(--brand); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.doctor { display: flex; gap: 14px; color: var(--text); transition: border-color .15s; }
.doctor:hover { text-decoration: none; border-color: var(--brand); }
.doctor-info { min-width: 0; }
.doctor h3, .doctor-detail h2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dept { color: var(--brand); font-size: 14px; }
.intro { color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tag { font-size: 12px; font-weight: 500; padding: 1px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); }

.avatar { flex: none; width: 64px; height: 64px; border-radius: 50%; object-fit: cover; }
.avatar.large { width: 96px; height: 96px; }
.avatar.placeholder, .thumb.placeholder {
  display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 24px;
}
.thumb { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; font-size: 16px; }
.doctor-detail { display: flex; gap: 20px; align-items: flex-start; margin: 12px 0 24px; }
.back { display: inline-block; margin-bottom: 4px; font-size: 14px; }
.section-title { margin: 8px 0 12px; }

.days { display: grid; gap: 12px; }
.day h4 { margin-bottom: 12px; }
.slots { display: flex; flex-wrap: wrap; gap: 10px; }
.slot {
  display: flex; flex-direction: column; align-items: center; min-width: 118px;
  padding: 8px 12px; border: 1px solid var(--brand); border-radius: 10px;
  background: var(--brand-soft); color: var(--brand); font: inherit; cursor: pointer;
}
.slot small { font-size: 12px; }
.slot:hover:not(:disabled) { background: var(--brand); color: #fff; }
.slot.full { border-color: var(--line); background: var(--off-soft); color: var(--off); cursor: not-allowed; }

.form { display: grid; gap: 14px; }
.form.narrow { max-width: 400px; margin: 24px auto; }
.grid-form { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); align-items: end; }
.field { display: grid; gap: 6px; }
.field .label { font-size: 14px; font-weight: 500; }
input, select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { width: auto; }

.list { display: grid; gap: 12px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.row-end { display: flex; align-items: center; gap: 12px; }
.badge { font-size: 12px; padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.off { background: var(--off-soft); color: var(--off); }
.prose { max-width: 680px; }

.admin-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { padding: 7px 14px; border: 1px solid transparent; border-radius: 8px; background: none; color: var(--muted); font: inherit; cursor: pointer; }
.tab.active { background: var(--card); border-color: var(--line); color: var(--text); font-weight: 600; }
.who { display: flex; gap: 12px; align-items: center; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.inline { display: flex; align-items: end; gap: 12px; }
.inline .field { max-width: 240px; }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-top: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; background: var(--bg); }
tr:last-child td { border-bottom: 0; }

.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%); z-index: 100;
  padding: 10px 20px; border-radius: 8px; color: #fff; background: #1f2933; box-shadow: 0 6px 24px rgba(0, 0, 0, .2);
}
.toast.error { background: var(--danger); }

@media (max-width: 640px) {
  .hero h1 { font-size: 22px; }
  .doctor-detail { flex-direction: column; }
  .hello { display: none; }
}
