:root {
  --bg: #eef2f7;
  --bg-accent: #e0e7ff;
  --surface: #ffffff;
  --sidebar: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #ffffff;
  --line: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --blue: #3b82f6;
  --blue-deep: #2563eb;
  --blue-soft: #eff6ff;
  --ok: #10b981;
  --ok-soft: #ecfdf5;
  --danger: #ef4444;
  --danger-soft: #fef2f2;
  --wa: #25d366;
  --wa-deep: #1ebe57;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --font: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
[hidden] { display: none !important; }

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(900px 420px at 0% 0%, rgba(59, 130, 246, 0.12), transparent 55%),
    radial-gradient(700px 360px at 100% 0%, rgba(99, 102, 241, 0.1), transparent 50%),
    var(--bg);
}

.eyebrow {
  margin: 0 0 0.3rem;
  color: var(--blue-deep);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.02em; }
h1 { font-size: 1.65rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.02rem; }

.btn {
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 0.72rem 1.05rem;
  font: inherit;
  font-weight: 650;
  font-size: 0.92rem;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.btn-primary {
  background: linear-gradient(135deg, var(--blue), var(--blue-deep));
  color: #fff;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.25);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.3);
}
.btn-primary:disabled { opacity: 0.7; cursor: wait; transform: none; }
.btn-ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}
.btn-ghost:hover { background: #f8fafc; }
.btn-wa {
  background: var(--wa) !important;
  border-color: var(--wa) !important;
  color: #fff !important;
  box-shadow: none !important;
}
.btn-wa:hover {
  background: var(--wa-deep) !important;
  border-color: var(--wa-deep) !important;
  color: #fff !important;
}
.btn-sm {
  padding: 0.42rem 0.72rem;
  font-size: 0.8rem;
  border-radius: 9px;
  font-weight: 600;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-card {
  width: min(420px, 100%);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 20px;
  padding: 1.75rem;
  box-shadow: var(--shadow);
}
.login-brand {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  margin-bottom: 1rem;
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  box-shadow: 0 10px 20px rgba(59, 130, 246, 0.3);
}
.login-kicker {
  margin: 0 0 0.15rem;
  color: #64748b;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.login-title {
  margin: 0 0 0.85rem;
  font-size: 1.1rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: #0f172a;
}
.login-select-wrap {
  position: relative;
  display: block;
}
.login-select-wrap::after {
  content: "";
  position: absolute;
  right: 0.95rem;
  top: 50%;
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid #64748b;
  border-bottom: 2px solid #64748b;
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}
.login-select-wrap select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.4rem;
  cursor: pointer;
  background: #fff;
}
.login-submit {
  width: 100%;
  margin-top: 0.15rem;
}
.login-back {
  display: block;
  margin-top: 0.75rem;
  text-align: center;
  color: #64748b;
  font-size: 0.78rem;
  font-weight: 500;
  text-decoration: none;
}
.login-back:hover {
  color: #2563eb;
  text-decoration: underline;
}
.login-sub { color: var(--muted); margin: 0.45rem 0 1.25rem; font-size: 0.95rem; line-height: 1.45; }
.login-card label,
.modal-form label,
.date-field {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
  color: #475569;
  font-size: 0.84rem;
  font-weight: 600;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 11px;
  padding: 0.72rem 0.85rem;
  font: inherit;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}
.hint { color: var(--muted); font-size: 0.8rem; margin: 0.9rem 0 0; }
.form-error { color: var(--danger); margin: 0.55rem 0 0; font-size: 0.88rem; }

.app-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
}

.sidebar {
  background: var(--sidebar);
  padding: 1.15rem 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  color: var(--sidebar-text);
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0.45rem 1rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
}
.brand strong {
  display: block;
  font-size: 0.95rem;
  color: #fff;
}
.brand span { color: #94a3b8; font-size: 0.78rem; display: block; }
.role-pill {
  display: inline-flex !important;
  margin-top: 0.35rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.68rem !important;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #dbeafe !important;
  background: rgba(59, 130, 246, 0.25);
  border: 1px solid rgba(147, 197, 253, 0.3);
}
.role-pill[data-role="atendente"] {
  color: #ecfccb !important;
  background: rgba(132, 204, 22, 0.2);
  border-color: rgba(190, 242, 100, 0.35);
}
.side-nav { display: grid; gap: 0.3rem; }
.nav-item {
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--sidebar-text);
  border-radius: 11px;
  padding: 0.72rem 0.8rem;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 550;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item:hover { background: rgba(148, 163, 184, 0.12); color: #fff; }
.nav-item.active {
  color: var(--sidebar-active);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.35), rgba(99, 102, 241, 0.28));
  box-shadow: inset 0 0 0 1px rgba(147, 197, 253, 0.25);
}
a.nav-item.nav-support {
  display: block;
  text-decoration: none;
  color: var(--sidebar-text);
  box-sizing: border-box;
}
a.nav-item.nav-support:hover {
  color: #fff;
}
a.nav-item.nav-support.active {
  background: transparent;
  box-shadow: none;
  color: var(--sidebar-text);
}
.logout {
  margin-top: auto;
  width: 100%;
  background: transparent;
  border-color: rgba(148, 163, 184, 0.3);
  color: #e2e8f0;
}
.logout:hover { background: rgba(148, 163, 184, 0.12); }

.patient-hub {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}
.patient-choice {
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 16px;
  padding: 1.05rem 1.1rem;
  display: grid;
  gap: 0.3rem;
  cursor: pointer;
  font: inherit;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.patient-choice strong { font-size: 1.02rem; }
.patient-choice span { color: var(--muted); font-size: 0.86rem; line-height: 1.35; }
.patient-choice:hover { border-color: #93c5fd; background: #f8fbff; }
.patient-choice.primary {
  border-color: #93c5fd;
  background: linear-gradient(135deg, #eff6ff, #ffffff);
}
.patient-choice.primary strong { color: var(--blue-deep); }
.inline-search {
  max-width: 220px;
  margin: 0;
  padding: 0.5rem 0.7rem;
}

.main { padding: 1.35rem 1.6rem 2rem; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1.2rem;
}
.topbar-right {
  display: flex;
  align-items: end;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.date-field { margin: 0; min-width: 168px; }

.global-search {
  position: relative;
  min-width: min(320px, 70vw);
}
.global-search .search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.global-search input {
  padding-left: 2.35rem;
  background: rgba(255,255,255,0.95);
}
.search-results {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  right: 0;
  z-index: 40;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.14);
  max-height: 360px;
  overflow: auto;
  padding: 0.35rem;
}
.search-item {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  border-radius: 10px;
  padding: 0.7rem 0.75rem;
  cursor: pointer;
  display: grid;
  gap: 0.15rem;
  font: inherit;
  color: var(--text);
}
.search-item:hover { background: #f8fafc; }
.search-type {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--blue-deep);
}
.search-item strong { font-size: 0.92rem; }
.search-item small { color: var(--muted); font-size: 0.8rem; }
.search-empty {
  padding: 0.85rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.guidance-card {
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: #e2e8f0;
  border-radius: 16px;
  padding: 1.05rem 1.1rem 1.15rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.guidance-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.guidance-head .eyebrow {
  color: #93c5fd;
  margin: 0;
  line-height: 1.2;
}
.guidance-tag {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 700;
  color: #bfdbfe;
  background: rgba(59, 130, 246, 0.18);
  border: 1px solid rgba(147, 197, 253, 0.25);
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  line-height: 1.2;
  white-space: nowrap;
}
.guidance-list { display: grid; gap: 0.55rem; }
.guidance-item {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.35);
  color: inherit;
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
  display: grid;
  gap: 0.35rem;
  cursor: pointer;
  font: inherit;
}
.guidance-item:hover { background: rgba(59, 130, 246, 0.16); border-color: rgba(147, 197, 253, 0.35); }
.guidance-item strong {
  color: #fff;
  font-size: 0.95rem;
  line-height: 1.25;
  font-weight: 700;
}
.guidance-item span {
  color: #cbd5e1;
  font-size: 0.86rem;
  line-height: 1.45;
}
.guidance-item.priority-alta { border-left: 3px solid #f87171; }
.guidance-item.priority-media { border-left: 3px solid #fbbf24; }
.guidance-item.priority-ok { border-left: 3px solid #34d399; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}
.stat {
  background: var(--surface);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: var(--radius);
  padding: 1rem 1.05rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, #3b82f6, #6366f1);
}
.stat small { color: var(--muted); display: block; margin-bottom: 0.35rem; font-size: 0.78rem; font-weight: 600; }
.stat strong { font-size: 1.35rem; font-weight: 750; letter-spacing: -0.03em; }

.card {
  background: var(--surface);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 16px;
  padding: 1.05rem;
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.9rem;
}
.list { display: grid; gap: 0.55rem; }
.row {
  display: grid;
  grid-template-columns: 68px 1fr auto;
  gap: 0.8rem;
  align-items: center;
  padding: 0.8rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #fff, #f8fafc);
}
.row .meta { color: var(--muted); font-size: 0.82rem; margin-top: 0.18rem; }
.row-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; justify-content: end; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.18rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 700;
  background: #f1f5f9;
  color: #475569;
}
.badge.confirmado { color: #047857; background: var(--ok-soft); }
.badge.agendado { color: var(--blue-deep); background: var(--blue-soft); }
.badge.concluido { color: #64748b; background: #f1f5f9; }
.badge.cancelado { color: #b91c1c; background: var(--danger-soft); }
.badge.em_atendimento { color: #b45309; background: #fffbeb; }
.badge.falta { color: #b91c1c; background: var(--danger-soft); }
.badge.atrasado { color: #b91c1c; background: var(--danger-soft); }
.badge.hoje { color: var(--blue-deep); background: var(--blue-soft); }
.badge.semana { color: #6d28d9; background: #f5f3ff; }
.badge.futuro { color: #64748b; background: #f1f5f9; }
.returns-auto-card {
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-radius: 14px;
  padding: 0.9rem 1rem 0.75rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
.clinic-form {
  display: grid;
  gap: 0.75rem;
  max-width: 420px;
}
.clinic-form label {
  display: grid;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.88rem;
}
.clinic-form input {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
}
.row-inactive {
  opacity: 0.55;
}
.returns-auto-card .card-head,
.appointments-auto-card .card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}
.returns-auto-hint {
  margin: 0 0 0.65rem;
}
.returns-auto-card .list,
.appointments-auto-card .list {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  padding: 0.25rem 0.55rem;
}
.returns-auto-card .list { border-color: #fed7aa; }
.appointments-auto-card .list { border-color: #bfdbfe; }

.guidance-compact { margin-bottom: 0.75rem; }
.guidance-compact .guidance-list { gap: 0.35rem; }
.guidance-compact .guidance-item { padding: 0.65rem 0.8rem; }

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
  padding: 0.25rem;
  background: #f1f5f9;
  border-radius: 12px;
}
.mode-btn {
  border: 0;
  background: transparent;
  border-radius: 9px;
  padding: 0.55rem 0.5rem;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 650;
  color: #64748b;
  cursor: pointer;
}
.mode-btn.active {
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.head-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.field-block { margin-bottom: 0.9rem; }
.field-label {
  display: block;
  margin-bottom: 0.4rem;
  color: #475569;
  font-size: 0.84rem;
  font-weight: 600;
}
.service-chips {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem;
}
.service-chips-wrap {
  grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
  max-height: 9.5rem;
  overflow: auto;
  padding-right: 0.15rem;
}
.service-chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 0.55rem 0.4rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 650;
  color: #475569;
  cursor: pointer;
}
.service-chip.active {
  border-color: #93c5fd;
  background: #eff6ff;
  color: var(--blue-deep);
}
.opt-label {
  font-weight: 500;
  color: #94a3b8;
  font-size: 0.78rem;
}
.appt-note {
  margin-top: 0.2rem;
  color: #475569;
}
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 11px;
  padding: 0.72rem 0.85rem;
  font: inherit;
  resize: vertical;
  min-height: 4.5rem;
}
textarea:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(4.4rem, 1fr));
  gap: 0.35rem;
  margin-top: 0.45rem;
}
.slot-chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 0.5rem 0.25rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 650;
  color: #334155;
  cursor: pointer;
}
.slot-chip:hover:not(:disabled) {
  border-color: #93c5fd;
  background: #f8fbff;
}
.slot-chip.active {
  border-color: #2563eb;
  background: #eff6ff;
  color: var(--blue-deep);
}
.slot-chip.slot-busy,
.slot-chip:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  text-decoration: line-through;
  background: #f8fafc;
}
.clinic-hours {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}
.mini-stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  box-shadow: var(--shadow-sm);
  font: inherit;
  color: inherit;
}
.mini-stat span { color: var(--muted); font-size: 0.75rem; font-weight: 650; }
.mini-stat strong { font-size: 0.95rem; font-weight: 750; }
.mini-stat.warn { border-color: #fecaca; background: #fff7f7; }
.mini-stat.linkish { cursor: pointer; }
.mini-stat.linkish:hover { border-color: #93c5fd; background: #f8fbff; }

.alert-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.95rem;
}
.alert-chip {
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fed7aa;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 700;
}
.alert-strip.ok .alert-chip {
  background: var(--ok-soft);
  color: #047857;
  border-color: #a7f3d0;
}

.stats-ops { grid-template-columns: repeat(6, minmax(0, 1fr)); }

.next-card {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  background: linear-gradient(135deg, #eff6ff, #ffffff 55%);
  border: 1px solid #bfdbfe;
  border-radius: 16px;
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow-sm);
}
.next-card .meta { color: var(--muted); margin: 0.35rem 0 0; }
.empty-next { justify-content: center; color: var(--muted); }

.split-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 0.9rem;
}
.stack { display: grid; gap: 0.85rem; }
.insight {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.9rem;
  color: #334155;
  box-shadow: var(--shadow-sm);
}
.insight p { margin: 0; line-height: 1.45; font-size: 0.92rem; }
.row-late { border-color: #fecaca; background: linear-gradient(180deg, #fff, #fef2f2); }
.row-active {
  border-color: #fde68a;
  background: linear-gradient(180deg, #fff, #fffbeb);
}
.agenda-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.35rem 0 0;
}
.row-priority {
  border-color: #fdba74;
  background: linear-gradient(180deg, #fff, #fff7ed);
  box-shadow: inset 3px 0 0 #ea580c;
}
.next-priority {
  border-color: #fdba74;
  background: linear-gradient(180deg, #fff7ed, #fff);
}
.row-compact { grid-template-columns: 88px 1fr auto; }

@media (max-width: 1100px) {
  .stats-ops { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .split-grid { grid-template-columns: 1fr; }
  .mini-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 920px) {
  .next-card { flex-direction: column; align-items: stretch; }
  .side-nav { grid-template-columns: repeat(5, 1fr); }
}

.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: left;
  padding: 0.78rem 0.4rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 0.92rem;
}
.table th {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.toolbar {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}
.toolbar input { max-width: 300px; }

.money { color: #059669; font-weight: 750; }

dialog {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  color: var(--text);
  padding: 0;
  width: min(460px, calc(100vw - 2rem));
  max-height: min(92vh, 720px);
  overflow: auto;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.18);
}
dialog::backdrop { background: rgba(15, 23, 42, 0.45); backdrop-filter: blur(2px); }
.modal-form { padding: 1.25rem; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.55rem;
}

.empty {
  color: var(--muted);
  padding: 0.95rem 0.2rem;
}

.owner-alert-banner {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.05rem;
  border-radius: 14px;
  margin-bottom: 1rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
}
.owner-alert-banner.priority-alta {
  background: #fff5f5;
  border-color: #fecaca;
  color: #7f1d1d;
}
.owner-alert-banner.compact { margin-bottom: 0.85rem; }
.owner-alert-banner .eyebrow { color: inherit; opacity: 0.85; }
.owner-alert-banner strong { display: block; font-size: 0.98rem; margin-top: 0.15rem; }

.billing-banner {
  margin: 0 0 0.9rem;
  padding: 0.75rem 0.95rem;
  border-radius: 12px;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.35;
}
.billing-banner.level-warn {
  background: rgba(251, 191, 36, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.35);
  color: #92400e;
}
.billing-banner.level-danger {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #991b1b;
}
.billing-inline {
  margin: 0.55rem 0 0;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  font-size: 0.9rem;
}
.billing-inline.level-warn {
  background: rgba(251, 191, 36, 0.12);
  color: #92400e;
}
.billing-inline.level-danger {
  background: rgba(248, 113, 113, 0.12);
  color: #991b1b;
}
.owner-alert-pill {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid currentColor;
}

.gab-layout { display: grid; gap: 1rem; }
.gab-stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.65rem;
}
.gab-stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.8rem 0.9rem;
  box-shadow: var(--shadow-sm);
}
.gab-stat span {
  display: block;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.gab-stat strong {
  display: block;
  margin-top: 0.25rem;
  font-size: 1.35rem;
}
.gab-stat.warn {
  background: #fff7ed;
  border-color: #fdba74;
}
.gab-focus { border-left: 4px solid var(--blue-deep); }

.alert-command .alert-form {
  display: grid;
  gap: 0.75rem;
}
.alert-form label { display: grid; gap: 0.35rem; font-weight: 600; font-size: 0.88rem; }
.alert-form textarea,
.alert-form select,
.price-input {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  width: 100%;
}
.price-input { max-width: 140px; }
.price-from-admin {
  margin: -0.25rem 0 0.35rem;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  background: var(--blue-soft);
  color: var(--blue-deep);
  font-size: 0.88rem;
  font-weight: 700;
}
.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}
.service-price-table {
  margin: 0 0 0.75rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
}
.price-table-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}
.price-table-row:last-child { border-bottom: 0; }
.service-chip {
  display: grid;
  gap: 0.15rem;
  text-align: left;
}
.service-chip strong { font-size: 0.86rem; }
.service-chip small {
  color: var(--blue-deep);
  font-weight: 700;
  font-size: 0.78rem;
}
.check-inline {
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-start;
  gap: 0.55rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}
.check-inline input { margin-top: 0.2rem; }

.sidebar-prices {
  margin: 0.35rem 0.85rem 0.75rem;
}
.sidebar-prices-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(15, 23, 42, 0.35);
  color: #e2e8f0;
  border-radius: 11px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}
.sidebar-prices-toggle:hover {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(96, 165, 250, 0.45);
}
.sidebar-prices-chevron {
  transition: transform 0.18s ease;
  opacity: 0.85;
}
.sidebar-prices-toggle.open .sidebar-prices-chevron {
  transform: rotate(180deg);
}
.sidebar-prices-panel {
  margin-top: 0;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.22s ease, opacity 0.18s ease, margin 0.18s ease, padding 0.18s ease;
  padding: 0 0.7rem;
  border-radius: 11px;
  background: rgba(2, 6, 23, 0.45);
  border: 1px solid transparent;
}
.sidebar-prices.open .sidebar-prices-panel {
  max-height: 280px;
  opacity: 1;
  margin-top: 0.45rem;
  padding: 0.55rem 0.7rem;
  border-color: rgba(148, 163, 184, 0.22);
  overflow: auto;
}
.sidebar-price-row {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.38rem 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
  color: #cbd5e1;
  font-size: 0.8rem;
}
.sidebar-price-row:last-child { border-bottom: 0; }
.sidebar-price-row strong {
  color: #fff;
  font-weight: 750;
  white-space: nowrap;
}
.sidebar-prices-empty {
  margin: 0;
  color: #94a3b8;
  font-size: 0.8rem;
}
.stack.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 920px) {
  .app-view { grid-template-columns: 1fr; }
  .sidebar {
    padding-bottom: 0.85rem;
  }
  .logout { display: none; }
  .patient-hub { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gab-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stack.two-col { grid-template-columns: 1fr; }
  .row { grid-template-columns: 56px 1fr; }
  .row-actions { grid-column: 1 / -1; justify-content: start; }
  .main { padding: 1rem; }
  .brand { border-bottom: 0; padding-bottom: 0.35rem; }
}

.ops-clean .guidance-card,
.ops-clean .mini-stats { display: none !important; }
.ops-clean .next-card {
  border-radius: 18px;
  padding: 1.15rem 1.2rem;
  box-shadow: none;
  border: 1px solid var(--line);
  background: #fff;
}
.ops-clean .next-card h3 {
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  margin: 0.15rem 0 0;
}
.ops-clean .ops-queue {
  border-radius: 18px;
  box-shadow: none;
}
.ops-clean .ops-row {
  align-items: center;
  padding: 0.85rem 0.2rem;
  border-color: #eef2f7;
}
.ops-clean .row-actions {
  gap: 0.4rem;
}
.ops-clean .row-actions .btn-sm {
  min-height: 2.1rem;
}
.ops-clean .empty-next {
  text-align: center;
  color: var(--muted);
  padding: 1.4rem;
}

.demo-timer {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1e3a8a;
  white-space: nowrap;
}
.demo-timer-label {
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #3b82f6;
}
.demo-timer strong {
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.demo-timer.warn {
  border-color: #fdba74;
  background: #fff7ed;
  color: #9a3412;
}
.demo-timer.warn .demo-timer-label { color: #ea580c; }
.demo-timer.urgent {
  border-color: #fca5a5;
  background: #fef2f2;
  color: #991b1b;
}
.demo-timer.urgent .demo-timer-label { color: #dc2626; }
@media (max-width: 900px) {
  .demo-timer-label { display: none; }
}

.password-wrap {
  position: relative;
  display: block;
}
.password-wrap input {
  width: 100%;
  padding-right: 2.6rem;
}
.password-toggle {
  position: absolute;
  right: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  width: 2rem;
  height: 2rem;
  border: 0;
  background: transparent;
  color: #64748b;
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.password-toggle:hover { color: #0f172a; background: #f1f5f9; }
.password-toggle[aria-pressed="true"] .eye-open { display: none; }
.password-toggle[aria-pressed="true"] .eye-off { display: block; }
.password-toggle[aria-pressed="false"] .eye-off { display: none; }
.password-toggle[aria-pressed="false"] .eye-open { display: block; }

/* —— Mobile polish —— */
@media (max-width: 920px) {
  .login-view {
    padding: 1rem;
    align-items: flex-start;
    padding-top: max(1.5rem, env(safe-area-inset-top));
  }
  .login-card {
    width: min(400px, 100%);
    padding: 1.25rem 1.1rem 1.1rem;
    border-radius: 16px;
  }
  .login-title { font-size: 1.05rem; margin-bottom: 0.75rem; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--sidebar);
    padding: 0.75rem 0.7rem 0.55rem;
  }
  .brand {
    padding: 0.15rem 0.25rem 0.55rem;
    gap: 0.55rem;
  }
  .brand-mark { width: 32px; height: 32px; border-radius: 9px; font-size: 0.65rem; }
  .side-nav {
    display: flex;
    gap: 0.3rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.2rem;
    scrollbar-width: none;
  }
  .side-nav::-webkit-scrollbar { display: none; }
  .side-nav .nav-item {
    flex: 0 0 auto;
    white-space: nowrap;
    min-width: 4.4rem;
    text-align: center;
    padding: 0.55rem 0.7rem;
    font-size: 0.8rem;
  }
  .sidebar-prices { margin-top: 0.35rem; }
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }
  .topbar h2 { font-size: 1.15rem; }
  .topbar-right {
    justify-content: stretch;
    flex-wrap: wrap;
    gap: 0.45rem;
  }
  .global-search,
  .date-field {
    width: 100%;
    max-width: none;
    min-width: 0;
  }
  .date-field {
    margin-bottom: 0;
  }
  .row-actions {
    width: 100%;
  }
  .row-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
    min-height: 40px;
  }
  .modal-actions {
    flex-direction: column-reverse;
  }
  .modal-actions .btn {
    width: 100%;
  }
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 560px) {
  .main { padding: 0.85rem 0.85rem 1.4rem; }
  .demo-timer { padding: 0.35rem 0.55rem; }
  .global-search { order: 2; }
  .date-field { order: 3; flex: 1 1 100%; }
  dialog {
    width: calc(100vw - 0.5rem) !important;
    max-width: calc(100vw - 0.5rem) !important;
    max-height: calc(100dvh - 0.75rem);
    margin: 0.35rem auto;
    border-radius: 14px;
  }
  .modal-form {
    padding: 0.85rem 0.75rem 1rem;
  }
  .modal-form h3 {
    font-size: 1.05rem;
    margin: 0 0 0.75rem;
  }
  .mode-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
  }
  .mode-btn {
    text-align: center;
    padding: 0.65rem 0.4rem;
    font-size: 0.82rem;
  }
  .service-chips,
  .service-chips-wrap {
    grid-template-columns: 1fr 1fr !important;
    max-height: none;
  }
  .service-chip {
    min-height: 2.6rem;
    padding: 0.55rem 0.35rem;
    font-size: 0.78rem;
  }
  .slot-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
  .slot-chip {
    font-size: 0.75rem;
    padding: 0.55rem 0.1rem;
    min-height: 2.5rem;
  }
  textarea {
    min-height: 5rem;
    font-size: 1rem;
  }
  .logout {
    display: block !important;
    margin-top: 0.35rem;
  }
}

