:root {
  --bg: #f5f7f7;
  --bg-warm: #fbf6ec;
  --surface: #ffffff;
  --ink: #1b2326;
  --muted: #5b6b6e;
  --teal: #1f6f72;
  --teal-dark: #154f52;
  --gold: #d9a440;
  --gold-light: #f4ddab;
  --gold-dark: #93600f;
  --ok: #2f9e62;
  --err: #c44545;
  --warn-bg: #fbf3e6;
  --warn-text: #7a4d00;
  --border: #e1e8e8;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(27, 35, 38, 0.05);
  --shadow-md: 0 4px 16px rgba(27, 35, 38, 0.07);
  --shadow-lg: 0 10px 30px rgba(27, 35, 38, 0.09);
}

* { box-sizing: border-box; }
/* Prevent any display:X rule from overriding the hidden attribute */
[hidden] { display: none !important; }

/* Skip-navigation link — visible only on focus so keyboard users can jump to main content */
.skip-nav {
  position: absolute;
  top: -100px;
  left: 10px;
  z-index: 9999;
  background: var(--teal);
  color: #fff;
  padding: 8px 16px;
  border-radius: 0 0 8px 8px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.15s;
}
.skip-nav:focus { top: 0; }

/* Anchor focus ring (matches button pattern) */
a:focus-visible {
  outline: 2px solid var(--teal-dark);
  outline-offset: 2px;
  border-radius: 2px;
}

body {
  margin: 0;
  background: linear-gradient(180deg, var(--bg-warm) 0%, var(--bg) 320px);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Tablet-first: base wrap is for 768px–1099px (tablet).
   Laptop (≥1100px) expands; mobile (<640px) shrinks. */
.wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

@media (min-width: 1100px) {
  .wrap { max-width: 1100px; padding: 32px 32px 80px; }
}

@media (max-width: 639px) {
  .wrap { padding: 20px 14px 60px; }
}

/* Header / branding */
.head {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.head::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, var(--gold-light) 0%, transparent 55%);
  opacity: 0.35;
  pointer-events: none;
}

.logo {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  box-shadow: 0 2px 8px rgba(217, 164, 64, 0.45);
  position: relative;
  z-index: 1;
}

.head-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  z-index: 1;
}

.head h1 {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.1;
}

.tag {
  color: var(--muted);
  font-size: 12.5px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 2px 10px;
  width: fit-content;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
  margin-left: auto;
  position: relative;
  z-index: 1;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.04);
}
.dot.ok { background: var(--ok); }
.dot.err { background: var(--err); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease;
}
.card:hover { box-shadow: var(--shadow-md); }

.card.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 10px;
}
.card.row h2 { margin: 0; }

.muted {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 12px;
}

code {
  background: #f0f4f4;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.9em;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.tab-btn {
  background: none;
  border: none;
  padding: 8px 4px 10px;
  margin-right: 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  min-height: 44px;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.tab-btn:focus-visible {
  outline: 2px solid var(--teal-dark);
  outline-offset: 2px;
  border-radius: 4px;
}
.tab-btn.active {
  color: var(--teal-dark);
  border-bottom-color: var(--teal);
}

/* Forms */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}
.auth-form input {
  font-size: 14px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  color: var(--ink);
}
.auth-form input:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
  border-color: var(--teal);
}

/* Generic form controls */
select, input[type="date"], input[type="time"], input[type="number"], input[type="text"], input[type="email"], textarea {
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
}
textarea { resize: vertical; width: 100%; }
select:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
  border-color: var(--teal);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 14px;
  min-width: 90px;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.row.spaced { margin-top: 10px; }
.mt { margin-top: 14px; }
.flex-1 { flex: 1; }

/* Slot picker */
.slot-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 4px;
}
.slot-btn {
  background: #fff;
  color: var(--teal-dark);
  border: 1px solid var(--teal);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 7px;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.slot-btn:hover { background: #eef6f6; }
.slot-btn.selected {
  background: var(--teal);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* Appointment rows */
.appt-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 14px;
}
.appt-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.appt-list li:first-child { border-top: none; }
.appt-meta { color: var(--muted); font-size: 12.5px; }
.appt-status {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 999px;
}
.appt-status.requested { background: var(--warn-bg); color: var(--warn-text); }
.appt-status.scheduled { background: #e7f3ee; color: var(--ok); }
.appt-status.cancelled { background: #f5e9e9; color: var(--err); }
.appt-status.completed { background: #eef0f0; color: var(--muted); }
.appt-status.pending { background: var(--warn-bg); color: var(--warn-text); }
.appt-status.paid { background: #e7f3ee; color: var(--ok); }

/* Touch-friendly link button — meets 44px minimum tap target */
.link-btn {
  background: none;
  border: none;
  color: var(--err);
  font-size: 13px;
  padding: 6px 8px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  text-decoration: underline;
  cursor: pointer;
  vertical-align: middle;
}
.link-btn:focus-visible {
  outline: 2px solid var(--teal-dark);
  outline-offset: 2px;
  border-radius: 4px;
}

button {
  background: linear-gradient(180deg, var(--teal) 0%, var(--teal-dark) 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease, transform 0.1s ease;
  /* 44px minimum touch target on mobile */
  min-height: 44px;
}
button:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
button:active { transform: translateY(0); }
button:focus-visible {
  outline: 2px solid var(--teal-dark);
  outline-offset: 2px;
}
button.secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  box-shadow: none;
}
button.secondary:hover {
  background: var(--bg);
  color: var(--ink);
  box-shadow: none;
  transform: none;
}

/* Laptop: slightly tighter buttons since pointer accuracy is higher (pointer:fine = mouse/trackpad) */
@media (pointer: fine) {
  button { min-height: 38px; padding: 8px 16px; }
  .link-btn { min-height: 36px; }
  .tab-btn { min-height: 36px; }
}

.error {
  color: var(--err);
  font-size: 13px;
  margin: 0;
  min-height: 1em;
}

.success {
  color: var(--ok);
  font-size: 13px;
  margin: 0;
}

#patients-area ul {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 14px;
}
#patients-area li {
  padding: 8px 0;
  border-top: 1px solid var(--border);
}
#patients-area li:first-child { border-top: none; }

.empty {
  color: var(--muted);
  font-size: 13.5px;
  margin: 0;
}

.restricted {
  background: var(--warn-bg);
  color: var(--warn-text);
  font-size: 13.5px;
  padding: 10px 12px;
  border-radius: 8px;
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
