:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --border: #e2e6ed;
  --text: #111827;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --error: #dc2626;
  --ok: #16a34a;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }

.wrap { max-width: 720px; margin: 0 auto; padding: 32px 20px 80px; }

h1 { margin: 0 0 4px; font-size: 28px; }
h2 { margin: 0 0 12px; font-size: 18px; }
.muted { color: var(--muted); margin: 0; }
.hidden { display: none; }
.error { color: var(--error); min-height: 1.2em; margin: 8px 0 0; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-top: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

label { display: block; margin: 10px 0; font-size: 14px; color: var(--muted); }
input, select {
  width: 100%;
  padding: 10px 12px;
  background: #f9fafb;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  margin-top: 4px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

button {
  background: var(--accent);
  color: white;
  border: 0;
  padding: 10px 16px;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}
button:hover { background: var(--accent-hover); }
button[type="button"] { background: transparent; color: var(--muted); border: 1px solid var(--border); }
button[type="button"]:hover { background: #f3f4f6; color: var(--text); }

dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}
dialog::backdrop { background: rgba(0,0,0,0.35); }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; }
code { background: #f3f4f6; padding: 2px 6px; border-radius: 4px; }

/* ─── Auth pages (login, register) ────────────────────────────────── */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px 32px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}
.auth-logo { font-size: 22px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.auth-sub  { font-size: 14px; color: var(--muted); margin-bottom: 28px; }
.auth-card label { color: var(--text); font-size: 13px; font-weight: 500; }
.auth-card input { margin-top: 6px; }
.auth-submit { width: 100%; margin-top: 20px; padding: 11px; font-size: 15px; font-weight: 600; }
.auth-footer { margin-top: 20px; text-align: center; font-size: 13px; color: var(--muted); }
.auth-footer a { color: var(--accent); text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }
.org-badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  background: #eff6ff; color: var(--accent);
  font-size: 13px; font-weight: 600; margin-bottom: 16px;
}
#setup-org-field { display: none; }

/* ─── Calendar loading shimmer ─────────────────────────────────────── */
.cal-grid.cal-loading {
  position: relative;
  pointer-events: none;
}
.cal-grid.cal-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.6) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

/* ─── Confirm dialog ───────────────────────────────────────────────── */
#confirm-dialog { max-width: 380px; }
#confirm-dialog p { margin: 8px 0 20px; color: var(--muted); font-size: 14px; }

/* ─── Calendar widget ──────────────────────────────────────────────── */
.cal-panel { padding: 16px 20px 20px; }

.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.cal-month-label {
  font-weight: 600; font-size: 15px; letter-spacing: -0.2px;
}
.cal-nav {
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); padding: 6px 8px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.cal-nav:hover { color: var(--text); border-color: var(--accent); background: #eff6ff; }

.cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center; font-size: 11px; font-weight: 600;
  color: var(--muted); letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px;
}
.cal-day {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent;
  color: var(--text); border-radius: 8px;
  font-size: 13px; font-weight: 500; cursor: pointer; padding: 0;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.cal-day:hover:not(:disabled):not(.cal-day--selected) {
  background: #dbeafe; border-color: #93c5fd; color: var(--accent);
}
.cal-day.cal-day--empty { cursor: default; }
.cal-day.cal-day--no-slots {
  color: #d1d5db;
  background: #f3f4f6;
  cursor: not-allowed;
}
.cal-day.cal-day--past {
  color: #d1d5db;
  background: #f3f4f6;
  text-decoration: line-through;
  cursor: default;
  font-weight: 400;
}
.cal-day.cal-day--today {
  border-color: var(--accent);
  color: var(--accent);
  background: #eff6ff;
  font-weight: 700;
}
.cal-day.cal-day--selected {
  background: var(--accent); color: #fff;
  border-color: var(--accent); font-weight: 700;
  box-shadow: 0 2px 8px rgba(37,99,235,0.35);
}
.cal-day.cal-day--selected:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* ─── Slots panel ───────────────────────────────────────────────────── */
.slots-header {
  display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px;
}
.slots-header h2 { margin: 0; }
.slots-meta {
  font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.slots-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px;
}
.slot-btn {
  background: #f9fafb; border: 1px solid var(--border);
  color: var(--text); padding: 10px 8px; border-radius: 8px;
  cursor: pointer; font-variant-numeric: tabular-nums; font-size: 13px;
  font-weight: 500; transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.slot-btn.slot-available {
  border-color: #4ade80;
  color: #15803d;
  background: #dcfce7;
  font-weight: 600;
}
.slot-btn.slot-available:hover {
  border-color: #16a34a;
  background: #bbf7d0;
}
.slot-btn.slot-taken {
  border-color: #e5e7eb;
  color: #9ca3af;
  background: #f3f4f6;
  text-decoration: line-through;
  cursor: not-allowed;
}

/* ─── Confirmation overlay ─────────────────────────────────────────── */
.conf-overlay {
  position: fixed; inset: 0;
  background: rgba(245, 247, 250, 0.92);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 200;
  animation: fade-in 0.35s ease both;
}
.conf-overlay.hidden { display: none; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.conf-card {
  width: 100%; max-width: 460px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 44px 36px 36px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.1);
  animation: slide-up 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes slide-up {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Checkmark icon */
.conf-check-wrap {
  position: relative;
  width: 72px; height: 72px;
  margin: 0 auto 28px;
}
.conf-check-glow {
  position: absolute; inset: -12px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(22,163,74,0.15) 0%, transparent 70%);
  animation: glow-pulse 2.4s ease-in-out infinite;
}
@keyframes glow-pulse {
  0%,100% { transform: scale(1);   opacity: 0.7; }
  50%      { transform: scale(1.12); opacity: 1; }
}
.conf-checkmark { width: 72px; height: 72px; display: block; }

.chk-circle {
  stroke: var(--ok); stroke-width: 2;
  stroke-dasharray: 151; stroke-dashoffset: 151;
  animation: draw 0.55s ease forwards;
}
.chk-tick {
  stroke: var(--ok); stroke-width: 3;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 44; stroke-dashoffset: 44;
  animation: draw 0.35s ease 0.5s forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }

/* Text */
.conf-title {
  margin: 0 0 8px;
  font-size: 24px; font-weight: 700; letter-spacing: -0.3px;
}
.conf-sub { margin: 0 0 28px; color: var(--muted); font-size: 14px; }

/* Details box */
.conf-details {
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 24px;
  text-align: left;
}
.conf-detail-row { display: flex; align-items: flex-start; gap: 12px; }
.conf-detail-icon { flex-shrink: 0; width: 18px; height: 18px; margin-top: 2px; color: var(--muted); }
.conf-date { font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.conf-time { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

/* Calendar buttons */
.conf-cta-row { display: flex; gap: 8px; margin-bottom: 20px; }
.conf-btn-cal, .conf-btn-ics {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 12px; border-radius: 10px;
  font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; text-decoration: none; transition: filter 0.15s;
}
.conf-btn-cal {
  background: #eff6ff; color: #2563eb;
  border: 1px solid #bfdbfe;
}
.conf-btn-ics {
  background: transparent; color: var(--muted);
  border: 1px solid var(--border);
}
.conf-btn-cal:hover { filter: brightness(0.95); }
.conf-btn-ics:hover { color: var(--text); border-color: #9ca3af; }

/* Reference + reset */
.conf-ref { margin: 0 0 20px; font-size: 12px; color: var(--muted); }
.conf-ref code { font-size: 12px; letter-spacing: 0.5px; }
.conf-reset {
  background: none; border: none; color: var(--muted);
  font: inherit; font-size: 13px; cursor: pointer;
  padding: 0; text-decoration: underline;
  text-decoration-color: transparent;
  transition: color 0.15s, text-decoration-color 0.15s;
}
.conf-reset:hover { color: var(--accent); text-decoration-color: var(--accent); }

/* Financial confirmation dialogs */
#finance-dialog, #reschedule-dialog {
  border: none; border-radius: 12px; padding: 0;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  max-width: 420px; width: 90%;
}
#finance-dialog::backdrop, #reschedule-dialog::backdrop {
  background: rgba(0,0,0,0.4);
}
.finance-body {
  padding: 28px 24px 24px;
}
.finance-question {
  font-size: 16px; font-weight: 600; margin: 0 0 8px; line-height: 1.4;
}
.finance-sub {
  font-size: 14px; color: var(--muted); margin: 0 0 24px;
}
.btn-primary {
  background: var(--accent); color: #fff; border: none;
  padding: 10px 20px; border-radius: 8px; font: inherit;
  font-size: 14px; font-weight: 500; cursor: pointer;
}
.btn-primary:hover { background: var(--accent-hover); }
