:root {
  /* Surfaces — warm neutral */
  --bg: #fafaf9;
  --surface: #ffffff;
  --surface-2: #f5f5f4;
  --border: #e7e5e4;
  --text: #0c0c0e;
  --text-2: #44403c;
  --text-3: #78716c;
  --text-4: #a8a29e;
  /* Primary — clinical teal */
  --accent: #0f766e;
  --accent-soft: #f0fdfa;
  --accent-mid: #14b8a6;
  /* Done / success */
  --green: #047857;
  --green-bg: #d1fae5;
  /* Money / offers — bronze */
  --bronze: #b45309;
  --bronze-soft: #fffbeb;
  --amber: #b45309;
  --amber-bg: #fffbeb;
  /* Alerts */
  --red: #b91c1c;
  --purple: #6d28d9;
  --purple-bg: #f5f3ff;
  --shadow-xs: 0 1px 2px rgba(12,12,14,.04);
  --shadow-sm: 0 2px 8px rgba(12,12,14,.06);
  --shadow-md: 0 8px 24px rgba(12,12,14,.08);
  --font: 'Outfit', system-ui, -apple-system, sans-serif;
  --radius: 14px;
  --sidebar: 232px;
  --bottom-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: #e7e5e4;
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font-family: inherit; }
.hidden { display: none !important; }

/* —— Device preview (PC testing mobile) —— */
.device-shell { min-height: 100dvh; background: var(--bg); }
body.mobile-preview {
  background: #18181b;
  padding: 20px 12px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100dvh;
}
body.mobile-preview .device-shell {
  width: 390px;
  max-width: 100%;
  height: min(844px, calc(100dvh - 40px));
  min-height: 0;
  border-radius: 32px;
  overflow: hidden;
  box-shadow: 0 25px 80px rgba(0,0,0,.5);
  border: 4px solid #3f3f46;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg);
}
body.mobile-preview #app {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  position: relative;
}
body.mobile-preview .sidebar { display: none !important; }
/* Tabs stay INSIDE the phone frame, not the browser window */
body.mobile-preview .bottom-nav {
  display: flex !important;
  position: absolute !important;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
}
body.mobile-preview .main {
  margin-left: 0;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-bottom: 0;
}
body.mobile-preview .view {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 14px calc(var(--bottom-h) + 20px) !important;
}
body.mobile-preview .topbar { padding: 10px 14px; }
body.mobile-preview .chart-layout,
body.mobile-preview .dash-grid,
body.mobile-preview .settings-grid {
  grid-template-columns: 1fr !important;
}
body.mobile-preview .kpi-row { grid-template-columns: 1fr 1fr !important; }
body.mobile-preview .plan-card { position: static; }
body.mobile-preview .settings-card { padding: 14px; }
body.mobile-preview .toast {
  position: absolute;
  bottom: calc(var(--bottom-h) + 12px);
}
/* Odontogram: fit all teeth in phone width */
body.mobile-preview .odontogram-card { padding: 12px 8px; }
body.mobile-preview .arch {
  justify-content: space-between;
  gap: 0;
  overflow-x: visible;
  padding: 4px 0;
  width: 100%;
}
body.mobile-preview .arch-gap { width: 4px; margin: 0 1px; }
body.mobile-preview .tooth {
  width: auto;
  flex: 1 1 0;
  min-width: 0;
  max-width: 22px;
  min-height: 44px;
  padding: 4px 0 5px;
}
body.mobile-preview .tooth-num { font-size: .55rem; }
body.mobile-preview .mouth-bg { height: 56px; }
body.mobile-preview .patient-bar { gap: 8px; }
body.mobile-preview .select-sm { min-width: 64px; height: 32px; font-size: .72rem; }
body.mobile-preview .dash-row { flex-direction: column; align-items: flex-start; }
body.mobile-preview .dash-actions { width: 100%; }

/* —— Auth —— */
.auth-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 16px;
  position: relative;
  background: #0c0a12 url("assets/login-bg.jpg") center / cover no-repeat;
}
.auth-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(165deg, rgba(12,12,14,.55) 0%, rgba(15,118,110,.4) 50%, rgba(12,12,14,.7) 100%);
  z-index: 0;
}
.auth-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
}
.auth-card {
  width: 100%;
  max-width: none;
  background: #fff;
  border: none;
  border-radius: 20px;
  padding: 32px 26px 28px;
  box-shadow: 0 28px 80px rgba(0,0,0,.4);
}
.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-mark, .mark {
  width: 48px; height: 48px;
  border-radius: 14px;
  background: var(--text);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.2rem;
  margin: 0 auto 14px;
  overflow: hidden;
}
.auth-brand h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.03em; }
.auth-tagline { font-size: .8rem; color: var(--text-3); margin-top: 6px; }
.auth-hint { font-size: .75rem; color: var(--text-4); text-align: center; margin-top: 16px; }

/* —— App shell desktop —— */
#app { display: flex; min-height: 100dvh; background: var(--bg); }
.sidebar {
  width: var(--sidebar);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .mark { margin: 0; width: 36px; height: 36px; font-size: 1rem; border-radius: 10px; }
.sidebar-brand .name { font-weight: 700; font-size: 1rem; letter-spacing: -.02em; }
.sidebar-brand .tag { font-size: .7rem; color: var(--text-3); }
.nav-side {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border: none;
  background: transparent;
  border-radius: 10px;
  color: var(--text-2);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background .12s, color .12s;
}
.nav-item svg { flex-shrink: 0; opacity: .85; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.nav-item.active svg { opacity: 1; stroke: var(--accent); }
.sidebar-footer { padding: 14px; border-top: 1px solid var(--border); }
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  background: var(--surface-2);
}
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--text);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 650; font-size: .8rem;
}
.user-name { font-size: .8rem; font-weight: 600; }
.logout-link {
  background: none; border: none;
  font-size: .7rem; color: var(--text-3);
  cursor: pointer; padding: 0;
}

/* Bottom nav — hidden on desktop */
.bottom-nav {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--bottom-h) + var(--safe-bottom));
  padding: 0 2px var(--safe-bottom);
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  z-index: 50;
  justify-content: space-around;
  align-items: stretch;
  box-shadow: 0 -4px 20px rgba(12,12,14,.04);
}
.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: transparent;
  color: var(--text-4);
  font-size: .62rem;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 4px;
  letter-spacing: .01em;
  transition: color .12s;
}
.tab-item svg { stroke-width: 1.75; }
.tab-item:hover { color: var(--text-2); }
.tab-item.active { color: var(--accent); }
.tab-item.active svg { stroke-width: 2.25; stroke: var(--accent); }

.main {
  margin-left: var(--sidebar);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  gap: 12px;
}
.topbar h1 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -.03em;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.device-toggle {
  display: flex;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 3px;
  border: 1px solid var(--border);
}
.dev-btn {
  border: none;
  background: transparent;
  padding: 7px 14px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-3);
  border-radius: 8px;
  cursor: pointer;
}
.dev-btn.active { background: var(--text); color: #fff; }

.view { display: none; padding: 20px 24px 48px; flex: 1; }
.view.active { display: block; }

/* Forms */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}
.input, .select {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: .9rem;
  color: var(--text);
  outline: none;
  transition: border-color .12s;
}
.input:focus, .select:focus { border-color: var(--text); }
.input-xs { height: 34px; width: 68px; text-align: center; padding: 0 6px; }
.select-sm { height: 36px; width: auto; min-width: 76px; font-size: .8rem; }
.search { max-width: 280px; }
.check-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
}
.check-label input { width: 18px; height: 18px; accent-color: var(--text); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 44px;
  padding: 0 18px;
  border-radius: 10px;
  border: none;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .1s, background .12s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--text); color: #fff; }
.btn-primary:hover { background: #27272a; }
.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { height: 34px; padding: 0 12px; font-size: .78rem; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-success { background: var(--green); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-amber { background: var(--amber); color: #fff; }
.btn-bronze { background: var(--bronze); color: #fff; }
.btn-bronze:hover { background: #92400e; }

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
  flex-wrap: wrap;
}
.patient-list, .stock-list, .dash-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.patient-row, .stock-row, .dash-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: box-shadow .12s;
}
.patient-row:hover, .dash-row:hover { box-shadow: var(--shadow-sm); }
.pr-name, .st-name, .dr-name { font-weight: 600; font-size: .9rem; }
.pr-meta, .st-meta, .dr-meta { font-size: .75rem; color: var(--text-3); margin-top: 3px; }
.badge {
  font-size: .65rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 7px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge-draft { background: var(--surface-2); color: var(--text-3); }
.badge-offered { background: var(--accent-soft); color: var(--accent); }
.badge-accepted { background: var(--purple-bg); color: var(--purple); }
.badge-partial { background: var(--amber-bg); color: var(--amber); }
.badge-paid { background: var(--green-bg); color: var(--green); }
.st-badge.low, .badge.low { background: var(--amber-bg); color: var(--amber); }

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.kpi-label {
  font-size: .68rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.kpi-val {
  font-size: 1.4rem;
  font-weight: 700;
  margin-top: 6px;
  letter-spacing: -.03em;
}
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.dash-card-h h3 { font-size: .88rem; font-weight: 700; margin-bottom: 12px; }
.dash-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.chart-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 18px;
  align-items: start;
}
.patient-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.pb-grow { flex: 1; min-width: 100px; }
.pb-name { font-weight: 700; font-size: 1.1rem; letter-spacing: -.02em; }
.pb-meta { font-size: .75rem; color: var(--text-3); }
.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.odontogram-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-xs);
}
.odonto-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.odonto-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-4);
}
.legend { display: flex; gap: 12px; font-size: .72rem; color: var(--text-3); }
.leg { display: flex; align-items: center; gap: 5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.planned { background: var(--accent); }
.dot.done { background: var(--green); }
.mouth-wrap { position: relative; padding: 4px 0 8px; }
.mouth-bg {
  position: absolute;
  left: 0; right: 0; top: 0;
  width: 100%; height: 70px;
  pointer-events: none;
  opacity: .85;
}
.mouth-bg-lower { top: auto; bottom: 0; }
.arch {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 2px;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: visible;
  position: relative;
  z-index: 1;
  padding: 8px 0;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.odontogram-card {
  overflow: visible;
}
.arch-gap {
  width: 8px;
  flex-shrink: 0;
  border-left: 1px dashed var(--border);
  margin: 0 3px;
  align-self: stretch;
  opacity: .55;
}
.arch-midline {
  height: 1px;
  background: var(--border);
  margin: 12px 8px;
  position: relative;
}
.arch-midline::after {
  content: '●';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface);
  padding: 0 8px;
  font-size: .45rem;
  color: var(--text-4);
}
.tooth {
  width: 34px;
  min-height: 58px;
  border: 1.5px solid #d6d3d1;
  border-radius: 6px 6px 14px 14px / 8px 8px 18px 18px;
  background: linear-gradient(180deg, #fffefb 0%, #f7f5f2 45%, #ebe8e4 100%);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 5px 1px 6px;
  transition: .12s;
  user-select: none;
  flex-shrink: 0;
  box-shadow: inset 0 2px 3px rgba(255,255,255,.9);
}
.tooth::before {
  content: '';
  width: 14px;
  height: 5px;
  border-radius: 4px 4px 2px 2px;
  background: rgba(12,12,14,.07);
  margin-bottom: 3px;
}
.tooth:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  z-index: 2;
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.18);
}
.tooth.has-plan:hover {
  border-color: #0d9488;
  box-shadow: 0 4px 14px rgba(15, 118, 110, 0.22);
}
.tooth.has-done:hover {
  border-color: #0f766e; /* teal ring, keep green fill — no bright green flash */
  box-shadow: 0 4px 14px rgba(15, 118, 110, 0.2);
}
.tooth.has-plan {
  border-color: #0f766e;
  background: linear-gradient(180deg, #f0fdfa 0%, #ccfbf1 55%, #99f6e4 100%);
  box-shadow: inset 0 0 0 1px rgba(15,118,110,.12);
}
.tooth.has-done {
  border-color: #5eead4;
  background: linear-gradient(180deg, #f0fdfa 0%, #ccfbf1 50%, #99f6e4 100%);
  box-shadow: inset 0 0 0 1px rgba(15,118,110,.1);
}
.tooth.has-done .tooth-count { color: var(--accent); }
.tooth.has-plan.has-done {
  border-color: #0f766e;
  background: linear-gradient(180deg, #f0fdfa 0%, #d1fae5 100%);
}
.tooth-num { font-size: .62rem; font-weight: 700; }
.tooth-count {
  font-size: .55rem;
  font-weight: 700;
  color: var(--accent);
  margin-top: auto;
  background: rgba(255,255,255,.75);
  padding: 1px 4px;
  border-radius: 3px;
}
.tooth.has-done .tooth-count { color: var(--green); }
.arch-lower .tooth {
  border-radius: 14px 14px 6px 6px / 18px 18px 8px 8px;
}
.arch-lower .tooth::before {
  order: 5;
  margin-top: 3px;
  margin-bottom: 0;
  border-radius: 2px 2px 4px 4px;
}
.odonto-hint {
  font-size: .72rem;
  color: var(--text-4);
  margin-top: 12px;
  text-align: center;
}

.plan-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: sticky;
  top: 68px;
  box-shadow: var(--shadow-xs);
}
.plan-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}
.plan-header h2 { font-size: .9rem; font-weight: 700; }
.plan-count { font-size: .75rem; color: var(--text-3); }
.plan-lines { max-height: 240px; overflow-y: auto; margin-bottom: 10px; }
.plan-line {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 6px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: .78rem;
}
.pl-title { font-weight: 600; }
.pl-sub { font-size: .65rem; color: var(--text-3); }
.pl-status {
  font-size: .6rem;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 5px;
  cursor: pointer;
  border: none;
}
.pl-status.planned { background: var(--accent-soft); color: var(--accent); }
.pl-status.done { background: var(--green-bg); color: var(--green); }
.pl-remove {
  background: none;
  border: none;
  color: var(--text-4);
  cursor: pointer;
  font-size: 1.1rem;
}
.plan-totals {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-bottom: 12px;
}
.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .85rem;
  margin-bottom: 6px;
}
.total-row.grand {
  font-size: 1.05rem;
  font-weight: 700;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.plan-actions { display: flex; flex-direction: column; gap: 8px; }

.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.cal-leg {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .75rem;
  color: var(--text-2);
}
.cal-leg i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}
.calendar-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.cal-slot {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 8px;
  min-height: 42px;
}
.cal-time {
  font-size: .7rem;
  font-weight: 600;
  color: var(--text-4);
  padding-top: 10px;
}
.cal-cells { display: flex; flex-wrap: wrap; gap: 6px; }
.appt {
  padding: 8px 10px;
  border-radius: 10px;
  font-size: .75rem;
  cursor: pointer;
  border-left: 3px solid;
  min-width: 140px;
  background: var(--surface-2);
}
.appt-name { font-weight: 600; }
.appt-meta { font-size: .65rem; color: var(--text-3); margin-top: 2px; }
.appt-fee { font-size: .65rem; font-weight: 600; margin-top: 2px; }
.appt-fee.waived { color: var(--amber); text-decoration: line-through; }

/* Settings — single column on mobile via media / preview */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.settings-card h3 {
  font-size: .9rem;
  font-weight: 700;
  margin-bottom: 14px;
  letter-spacing: -.01em;
}
.settings-wide { grid-column: 1 / -1; }
.tariff-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}
.tariff-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 10px;
  font-size: .8rem;
}
.tariff-item input { width: 88px; height: 36px; }
.dentist-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.dentist-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .875rem;
  padding: 8px 0;
}
.dentist-row .swatch {
  width: 12px;
  height: 12px;
  border-radius: 4px;
}
.inline-add { display: flex; gap: 8px; }
.inline-add .input { flex: 1; }
.logo-row { display: flex; align-items: center; gap: 12px; }
.logo-preview {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .65rem;
  color: var(--text-4);
  overflow: hidden;
}
.logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.logo-actions { display: flex; flex-direction: column; gap: 6px; }
.file-btn { cursor: pointer; margin: 0; }
.field-hint { font-size: .7rem; color: var(--text-4); margin-top: 6px; }
.brand-mark-img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: contain;
  background: #fff;
}
.future-list {
  list-style: none;
  font-size: .85rem;
  color: var(--text-2);
  line-height: 1.65;
}
.future-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.future-card {
  background: linear-gradient(180deg, #fafafa, #f4f4f5);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(12,12,14,.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal-card {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 24px 20px calc(24px + var(--safe-bottom));
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-md);
  max-height: 88dvh;
  overflow-y: auto;
}
@media (min-width: 640px) {
  .modal {
    align-items: center;
    padding: 20px;
  }
  .modal-card {
    border-radius: 18px;
    padding: 24px;
    max-width: 400px;
  }
}
.modal-card h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 4px; }
.modal-sub { font-size: .8rem; color: var(--text-3); margin-bottom: 14px; }
.proc-options { display: flex; flex-direction: column; gap: 8px; }
.proc-opt {
  display: flex;
  justify-content: space-between;
  padding: 14px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  font-size: .875rem;
  text-align: left;
  width: 100%;
}
.proc-opt:hover { border-color: var(--text); background: var(--surface-2); }
.proc-opt span { color: var(--text-3); font-size: .8rem; }

.toast {
  position: fixed;
  bottom: calc(var(--bottom-h) + 20px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: .85rem;
  font-weight: 500;
  z-index: 200;
  box-shadow: var(--shadow-md);
  max-width: 90%;
}

/* —— Real mobile / narrow screens —— */
@media (max-width: 900px) {
  .sidebar { display: none !important; }
  .bottom-nav { display: flex; }
  .main { margin-left: 0; }
  .view {
    padding: 14px 14px calc(var(--bottom-h) + 28px);
  }
  .chart-layout,
  .dash-grid,
  .settings-grid {
    grid-template-columns: 1fr !important;
  }
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .plan-card { position: static; }
  .topbar { padding: 12px 14px; }
  .search { max-width: none; flex: 1; min-width: 0; }
  .toolbar { width: 100%; }
  .toolbar .btn-primary { flex-shrink: 0; }
  .settings-wide { grid-column: 1; }
  .tariff-list { grid-template-columns: 1fr; }
  .dash-actions { width: 100%; margin-top: 8px; }
  .dash-row { flex-direction: column; align-items: flex-start; }
  .device-toggle { display: none; } /* real phone: no PC/Mobile switch clutter */

  /* Teeth: fit full arch without cutoff */
  .odontogram-card { padding: 12px 6px; overflow: hidden; }
  .arch {
    width: 100%;
    justify-content: space-between;
    gap: 0;
    overflow-x: visible;
    flex-wrap: nowrap;
  }
  .arch-gap { width: 3px; margin: 0 1px; }
  .tooth {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    max-width: 24px;
    min-height: 48px;
    padding: 4px 0 5px;
  }
  .tooth-num { font-size: .55rem; }
  .mouth-bg { height: 58px; }
  .patient-bar .pb-name { font-size: 1rem; }
  .select-sm { min-width: 62px; }
  .plan-actions .btn { height: 42px; }
  .modal-card { max-width: 100%; }
}

@media (max-width: 400px) {
  .tooth { max-width: 20px; min-height: 42px; }
  .kpi-val { font-size: 1.15rem; }
  .tab-item { font-size: .58rem; }
  .tab-item svg { width: 20px; height: 20px; }
}

/* Desktop: never show bottom tabs unless mobile-preview */
@media (min-width: 901px) {
  body:not(.mobile-preview) .bottom-nav { display: none !important; }
}

/* Accounting */
.period-bar { margin-bottom: 14px; }
.period-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
  width: 100%;
  max-width: 420px;
}
.period-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 8px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-3);
  border-radius: 9px;
  cursor: pointer;
}
.period-btn.active { background: var(--text); color: #fff; }
.efatura-card .efatura-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.efatura-actions a { text-decoration: none; }

/* Modals stay inside phone frame in Mobile preview */
body.mobile-preview .device-shell {
  isolation: isolate;
}
body.mobile-preview .modal {
  position: absolute !important;
  inset: 0 !important;
  z-index: 200;
  border-radius: 28px;
  overflow: hidden;
  align-items: flex-end !important;
  padding: 0 !important;
}
body.mobile-preview .modal-card {
  max-width: 100% !important;
  width: 100% !important;
  max-height: 85% !important;
  border-radius: 18px 18px 0 0 !important;
  margin: 0;
}
body.mobile-preview .toast {
  position: absolute !important;
  z-index: 210;
}

/* —— Dent365 brand mark —— */
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}
.login-brand .brand-mark,
.brand .mark,
.mark.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--accent);
  flex-shrink: 0;
}
.login-brand .brand-mark svg,
.mark svg { display: block; }


/* —— Crown-shaped teeth (inspired, not copy) —— */
.tooth {
  border-radius: 8px 8px 12px 12px / 6px 6px 16px 16px !important;
  position: relative;
}
.tooth::after {
  content: '';
  position: absolute;
  left: 15%;
  right: 15%;
  bottom: -3px;
  height: 6px;
  background: inherit;
  border: inherit;
  border-top: none;
  border-radius: 0 0 6px 6px;
  opacity: 0.85;
  pointer-events: none;
}
.arch-lower .tooth {
  border-radius: 12px 12px 8px 8px / 16px 16px 6px 6px !important;
}
.arch-lower .tooth::after {
  bottom: auto;
  top: -3px;
  border-radius: 6px 6px 0 0;
  border-bottom: none;
  border-top: inherit;
}

/* Hover: teal focus ring — never flash neon green */
.tooth:hover {
  border-color: var(--accent) !important;
  transform: translateY(-2px);
  z-index: 2;
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.18);
}
.tooth.has-plan:hover,
.tooth.has-done:hover,
.tooth.has-plan.has-done:hover {
  border-color: #0d9488 !important;
  box-shadow: 0 4px 14px rgba(15, 118, 110, 0.22);
}

.dot.planned { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dot.done { background: var(--accent-mid); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Icons */
.nav-item svg, .tab-item svg {
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tab-item svg { width: 24px; height: 24px; }
.nav-item svg { width: 22px; height: 22px; }

/* X-ray gallery */
.xray-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  padding-bottom: 24px;
}
.xray-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: box-shadow .12s, border-color .12s;
}
.xray-card:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.xray-thumb {
  aspect-ratio: 4/3;
  background: #0c0c0e;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.xray-thumb img { width: 100%; height: 100%; object-fit: cover; }
.xray-file-icon {
  color: #a8a29e;
  font-weight: 700;
  font-size: .85rem;
  letter-spacing: .04em;
}
.xray-meta {
  padding: 10px 12px 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: .75rem;
}
.xray-meta strong { font-size: .8rem; color: var(--text); }
.xray-meta span { color: var(--text-3); }
.xray-date { font-size: .68rem; }
.xray-card .xray-del { margin: 4px 8px 10px; align-self: flex-start; }
.empty-hint {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-3);
  padding: 40px 16px;
  font-size: .9rem;
}
.cal-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.cal-legend span {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .75rem; font-weight: 600; color: var(--text-2);
}
.cal-legend i {
  width: 10px; height: 10px; border-radius: 3px; display: inline-block;
}

/* Multi-dentist calendar board */
.cal-legend {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  margin-bottom: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}
.cal-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-3);
  cursor: pointer;
  opacity: .55;
}
.cal-chip i {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--chip, var(--accent));
}
.cal-chip.on {
  opacity: 1;
  color: var(--text);
  border-color: var(--chip, var(--accent));
  background: color-mix(in srgb, var(--chip, var(--accent)) 12%, white);
}
.cal-filter-all { flex-shrink: 0; }

.calendar-grid {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  max-height: min(70dvh, 640px);
  overflow-y: auto;
}
.cal-board { min-width: min-content; }
.cal-head, .cal-row {
  display: grid;
  grid-template-columns: var(--cal-cols, 56px 1fr);
  border-bottom: 1px solid var(--border);
}
.cal-head { position: sticky; top: 0; z-index: 2; background: var(--surface); }
.cal-corner, .cal-time {
  position: sticky;
  left: 0;
  z-index: 4;
  background: var(--surface-2);
  font-size: .68rem;
  font-weight: 700;
  color: var(--text-3);
  padding: 8px 6px;
  border-right: 1px solid var(--border);
  text-align: center;
}
.cal-head .cal-corner { z-index: 3; }
.cal-col-h {
  padding: 8px 6px;
  font-size: .68rem;
  font-weight: 700;
  border-bottom: 3px solid;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-col-h .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.cal-cell {
  min-height: 52px;
  padding: 3px;
  border-left: 1px solid var(--border);
  cursor: pointer;
  vertical-align: top;
}
.cal-cell:hover { background: var(--accent-soft); }
.cal-board .appt {
  min-width: 0;
  width: 100%;
  margin-bottom: 3px;
  padding: 5px 6px;
  border-left-width: 3px;
  font-size: .68rem;
}
.appt-st {
  font-size: .58rem;
  font-weight: 700;
  margin-top: 2px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .02em;
}
.appt.st-arrived { box-shadow: inset 0 0 0 1px #0f766e55; }
.appt.st-confirmed .appt-st { color: var(--accent); }
.appt.st-noshow { opacity: .55; text-decoration: line-through; }
.appt.st-done { opacity: .75; }

@media (max-width: 640px), body.mobile-preview {
  .calendar-grid { max-height: min(58dvh, 520px); }
  .cal-col-h { font-size: .62rem; padding: 6px 4px; }
  .cal-board .appt { font-size: .62rem; }
}

.tourism-box { margin-top: 8px; padding: 12px; background: var(--accent-soft); border-radius: 12px; border: 1px solid var(--border); }
.profile-grid { display: flex; flex-direction: column; gap: 8px; }
.med-list, .team-list { display: flex; flex-direction: column; gap: 6px; }
.med-row, .team-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; background: var(--surface-2); border-radius: 10px; }
.team-add { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.team-add .input, .team-add .select { flex: 1; min-width: 120px; }
.logo-preview { margin-top: 8px; }
.logo-preview img { border-radius: 8px; border: 1px solid var(--border); }
textarea.input { min-height: 56px; resize: vertical; }
.step-form { display: flex; flex-direction: column; gap: 10px; }
.step-form .field { margin: 0; }

#view-chart.active .chart-extra .dash-card { margin-top: 0; }

.pf-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.pf-actions .btn { flex: 1; min-width: 140px; }
#chartWhatsApp { white-space: nowrap; }




/* Accordion panels — collapsed by default, teeth stay free */
.acc-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.acc-panel summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  font-weight: 700;
  font-size: .9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  user-select: none;
}
.acc-panel summary::-webkit-details-marker { display: none; }
.acc-panel summary::after {
  content: '+';
  font-weight: 700;
  color: var(--text-3);
  font-size: 1.1rem;
}
.acc-panel[open] summary::after { content: '−'; }
.acc-hint {
  font-weight: 500;
  font-size: .72rem;
  color: var(--text-4);
  margin-right: auto;
  margin-left: 8px;
}
.acc-body { padding: 0 16px 16px; }
.pf-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.pf-actions .btn { flex: 1; min-width: 120px; }

/* Mobile: odontogram first, extras compact */
@media (max-width: 900px), body.mobile-preview {
  .chart-layout {
    display: flex !important;
    flex-direction: column !important;
  }
  .chart-left { order: 1; }
  .chart-right { order: 2; }
  .chart-extra { order: 3; margin-top: 12px !important; }
  .odontogram-card {
    position: relative;
    z-index: 2;
  }
  .patient-bar {
    flex-wrap: wrap;
    gap: 8px;
  }
  #chartWhatsApp { width: 100%; }
  .plan-card { position: static !important; }
}


/* ===== HASTA KARTI: only on individual patient chart ===== */
#chartExtra,
.chart-extra {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
  pointer-events: none !important;
}
#view-chart.active #chartExtra,
#view-chart.active .chart-extra {
  display: flex !important;
  visibility: visible !important;
  height: auto !important;
  overflow: visible !important;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px !important;
  padding: 0 0 24px !important;
  pointer-events: auto !important;
}

/* Accordion panels */
.acc-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.acc-panel summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  font-weight: 700;
  font-size: .9rem;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.acc-panel summary::-webkit-details-marker { display: none; }
.acc-panel summary::after {
  content: '+';
  margin-left: auto;
  font-weight: 700;
  color: var(--text-3);
}
.acc-panel[open] summary::after { content: '−'; }
.acc-hint {
  font-weight: 500;
  font-size: .72rem;
  color: var(--text-4);
}
.acc-body { padding: 0 16px 16px; }

/* Modal action bar — product style */
.modal-card {
  display: flex;
  flex-direction: column;
  max-height: min(90dvh, 720px);
  padding: 0 !important;
  overflow: hidden;
}
.modal-card > h3,
.modal-head {
  padding: 18px 20px 12px;
  margin: 0;
  border-bottom: 1px solid var(--border);
  font-size: 1.05rem;
  font-weight: 700;
}
.modal-body-scroll {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  bottom: 0;
}
.modal-actions .btn { flex: 1; min-width: 0; margin: 0 !important; width: auto !important; }
.modal-actions .btn-block { width: auto !important; }
.modal-actions .btn-wa {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  font-weight: 600;
}
.modal-actions .btn-wa:hover { background: #d1fae5; }
.modal-actions .btn-danger-ghost {
  color: var(--red);
  background: transparent;
  border: 1px solid transparent;
  flex: 0 0 auto;
  padding-left: 12px;
  padding-right: 12px;
}
.modal-actions .btn-primary { flex: 1.2; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-head h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background .12s, color .12s;
}
.modal-close:hover {
  background: #0c0c0e;
  color: #fff;
}
.modal-card > h3 { display: none; } /* prefer modal-head */

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 520px), body.mobile-preview {
  .field-row { grid-template-columns: 1fr; }
}
.modal-card-md {
  width: min(440px, 100%);
}
.modal-card {
  width: min(420px, calc(100vw - 24px));
  max-height: min(90dvh, 720px);
  display: flex;
  flex-direction: column;
  padding: 0 !important;
  overflow: hidden;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(12,12,14,.18);
}
.modal-body-scroll {
  padding: 16px 20px 8px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.modal-actions {
  display: flex;
  gap: 10px;
  padding: 14px 16px 16px;
  border-top: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
}
.modal-actions .btn {
  flex: 1;
  margin: 0 !important;
  width: auto !important;
  height: 44px;
  border-radius: 12px;
  font-weight: 600;
}
.modal-actions .btn-primary { flex: 1.4; }
.tourism-check {
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: 12px;
  margin-top: 4px;
}
.tourism-check .check-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: .875rem;
  cursor: pointer;
}
.modal {
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.visit-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.visit-card {
  display: grid;
  grid-template-columns: 88px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 12px 12px;
  background: var(--surface-2);
  border-radius: 12px;
  border: 1px solid var(--border);
}
.visit-date {
  font-size: .78rem;
  font-weight: 700;
  color: var(--accent);
  padding-top: 2px;
}
.visit-main strong { font-size: .875rem; display: block; margin-bottom: 2px; }
.visit-note {
  margin-top: 6px;
  font-size: .8rem;
  color: var(--text-2);
  line-height: 1.4;
}
@media (max-width: 520px), body.mobile-preview {
  .visit-card { grid-template-columns: 1fr auto; }
  .visit-date { grid-column: 1 / -1; }
}

.cal-board-span .cal-body-span {
  display: grid;
  grid-template-columns: var(--cal-cols, 52px 1fr);
  position: relative;
  min-height: var(--cal-h, 600px);
}
.cal-times-col { border-right: 1px solid var(--border); background: var(--surface-2); }
.cal-time-slot {
  font-size: .68rem;
  font-weight: 700;
  color: var(--text-3);
  padding: 4px 4px 0;
  border-bottom: 1px solid var(--border);
  box-sizing: border-box;
}
.cal-col-track {
  position: relative;
  border-left: 1px solid var(--border);
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(66px - 1px),
    var(--border) calc(66px - 1px),
    var(--border) 66px
  );
  cursor: crosshair;
}
.cal-hour-line {
  position: absolute;
  left: 0; right: 0;
  height: 1px;
  background: var(--border);
  pointer-events: none;
}
.appt-block {
  position: absolute;
  /* left/width set inline for overlap columns */
  right: auto;
  border-left: 3px solid;
  border-radius: 8px;
  padding: 5px 6px;
  overflow: hidden;
  font-size: .68rem;
  cursor: pointer;
  z-index: 2;
  background: #ffffff !important;
  box-sizing: border-box;
  box-shadow:
    0 0 0 1px rgba(12,12,14,.06),
    0 2px 8px rgba(12,12,14,.08);
}
.appt-block::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--appt-tint, rgba(15,118,110,.18));
  pointer-events: none;
  border-radius: inherit;
}
.appt-block > * { position: relative; z-index: 1; }
.appt-block:hover { z-index: 3; box-shadow: 0 0 0 1px rgba(12,12,14,.1), 0 4px 12px rgba(12,12,14,.12); }
.appt-block .appt-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.appt-block .appt-meta { font-size: .62rem; color: var(--text-2); }
.appt-block .appt-st { color: var(--text-3); }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--accent);
  display: grid;
  place-items: center;
}
.sidebar-brand .mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.sidebar-brand .name {
  font-weight: 700;
  font-size: .95rem;
  letter-spacing: -.02em;
  line-height: 1.2;
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-brand .tag {
  font-size: .7rem;
  color: var(--text-3);
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Mobile top clinic chip */
.mobile-clinic-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 0;
}
.mobile-clinic-bar .m-mark {
  width: 32px; height: 32px; border-radius: 9px; overflow: hidden;
  background: var(--accent); flex-shrink: 0;
  display: grid; place-items: center;
}
.mobile-clinic-bar .m-mark img { width: 100%; height: 100%; object-fit: cover; }
.mobile-clinic-bar .m-name { font-weight: 700; font-size: .85rem; }
.mobile-clinic-bar .m-tag { font-size: .65rem; color: var(--text-3); }
@media (max-width: 900px), body.mobile-preview {
  .mobile-clinic-bar { display: flex; }
}

.sidebar-brand .mark:not(.has-logo),
.mobile-clinic-bar .m-mark {
  background: #f0fdfa;
  border: 1.5px dashed #99f6e4;
}
.sidebar-brand .mark.has-logo {
  background: transparent;
  border: 1px solid var(--border);
}
.logo-ph {
  color: #0f766e;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1;
  opacity: .7;
}
.sidebar-brand .name {
  font-weight: 700;
  font-size: .95rem;
}
.sidebar-brand .tag {
  font-size: .65rem;
  color: var(--text-4);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.cal-mode-toggle {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--border);
}
.cal-mode {
  border: none;
  background: transparent;
  padding: 6px 12px;
  font-size: .78rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-3);
  font-family: inherit;
}
.cal-mode.on {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(12,12,14,.08);
}
.cal-week { border: 1px solid var(--border); border-radius: 12px; overflow: auto; }
.cal-week-head, .cal-week-body {
  display: grid;
  grid-template-columns: 52px repeat(7, minmax(90px, 1fr));
  min-width: 700px;
}
.cal-week-head { position: sticky; top: 0; z-index: 4; background: #fff; border-bottom: 1px solid var(--border); }
.cal-week-dayh {
  padding: 10px 6px;
  text-align: center;
  border-left: 1px solid var(--border);
  cursor: pointer;
}
.cal-week-dayh .wd { display: block; font-size: .65rem; color: var(--text-3); text-transform: uppercase; }
.cal-week-dayh .dn { font-weight: 700; font-size: 1rem; }
.cal-week-dayh.today .dn { color: var(--accent); }
.cal-week-col {
  position: relative;
  border-left: 1px solid var(--border);
  cursor: crosshair;
}
.appt-week { left: 2px !important; right: 2px !important; width: auto !important; }
.cal-month { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.cal-month-head {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--surface-2);
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-3);
  text-align: center;
  padding: 8px 0;
  text-transform: uppercase;
}
.cal-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: minmax(88px, auto);
}
.cal-month-cell {
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
  padding: 6px;
  cursor: pointer;
  min-height: 88px;
  transition: background .12s;
}
.cal-month-cell:nth-child(7n+1) { border-left: none; }
.cal-month-cell:hover { background: #f8fafc; }
.cal-month-cell.muted { opacity: .45; }
.cal-month-cell.today { background: #f0fdfa; }
.cm-day { font-weight: 700; font-size: .8rem; margin-bottom: 4px; }
.cal-month-cell.today .cm-day { color: var(--accent); }
.cm-events { display: flex; flex-direction: column; gap: 2px; }
.cm-evt {
  border: none;
  border-left: 3px solid;
  border-radius: 4px;
  padding: 2px 4px;
  font-size: .62rem;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: inherit;
}
.cm-more { font-size: .62rem; color: var(--text-3); padding: 0 4px; }
@media (max-width: 900px), body.mobile-preview {
  .cal-mode { padding: 6px 8px; font-size: .72rem; }
  .cal-month-grid { grid-auto-rows: minmax(64px, auto); }
  .cm-evt { font-size: .58rem; }
}

/* Calendar scroll isolation — headers never covered by events */
#calendarGrid {
  overflow: visible;
}
.cal-week {
  display: flex;
  flex-direction: column;
  max-height: min(70vh, 720px);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.cal-week-head {
  display: grid;
  grid-template-columns: 52px repeat(7, minmax(90px, 1fr));
  min-width: 700px;
  flex-shrink: 0;
  position: relative;
  z-index: 20;
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(12,12,14,.04);
}
.cal-week-scroll {
  flex: 1;
  overflow: auto;
  min-height: 0;
  position: relative;
  z-index: 1;
}
.cal-week-body {
  display: grid;
  grid-template-columns: 52px repeat(7, minmax(90px, 1fr));
  min-width: 700px;
  position: relative;
}
.cal-week-col {
  position: relative;
  overflow: hidden;
  border-left: 1px solid var(--border);
  cursor: crosshair;
}
.cal-board-span {
  display: flex;
  flex-direction: column;
  max-height: min(70vh, 720px);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.cal-board-span .cal-head,
.cal-board-span .sticky-head {
  flex-shrink: 0;
  position: relative;
  z-index: 20;
  background: #fff;
  box-shadow: 0 1px 0 rgba(12,12,14,.04);
}
.cal-day-scroll {
  flex: 1;
  overflow: auto;
  min-height: 0;
  position: relative;
  z-index: 1;
}
.appt-block {
  z-index: 2 !important;
}
.cal-week-dayh.today {
  background: #f0fdfa;
}
.cal-week-dayh.today .dn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
}


/* ===== Modal scroll fix (mobile + PC) ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(12,12,14,.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  overscroll-behavior: contain;
}
.modal-card {
  display: flex !important;
  flex-direction: column !important;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 440px;
  max-height: min(92dvh, 720px) !important;
  padding: 0 !important;
  overflow: hidden !important;
  box-shadow: var(--shadow-md);
}
.modal-head {
  flex-shrink: 0 !important;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px !important;
  border-bottom: 1px solid var(--border);
  background: #fff;
  z-index: 2;
}
.modal-body-scroll {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px 12px !important;
  overscroll-behavior: contain;
}
.modal-actions {
  flex-shrink: 0 !important;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px)) !important;
  border-top: 1px solid var(--border);
  background: #fff;
  z-index: 2;
  position: relative !important;
}
@media (min-width: 640px) {
  .modal {
    align-items: center;
    padding: 20px;
  }
  .modal-card {
    border-radius: 16px !important;
    max-height: min(88vh, 680px) !important;
  }
}
body.mobile-preview .modal {
  position: absolute !important;
  inset: 0 !important;
  z-index: 200;
  border-radius: inherit;
  overflow: hidden;
  align-items: flex-end !important;
  padding: 0 !important;
}
body.mobile-preview .modal-card {
  max-width: 100% !important;
  width: 100% !important;
  max-height: 88% !important;
  border-radius: 18px 18px 0 0 !important;
  margin: 0;
}
.stock-alert {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: .85rem;
  font-weight: 600;
}
.stock-alert ul { margin: 6px 0 0; padding-left: 18px; font-weight: 500; }
.backup-box {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px;
}


.stock-row-low { border-color: #fecaca !important; background: #fff1f2; }
.st-badge.low, .badge.low { background: #fecaca; color: #991b1b; }

/* Form must fill modal-card for scroll + sticky actions */
.modal-card > form {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow: hidden !important;
  margin: 0;
}
.modal-body-scroll {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
}
.modal-actions {
  flex-shrink: 0 !important;
}
/* PC: center modal with room to scroll */
@media (min-width: 640px) {
  .modal-card {
    max-height: min(85vh, 640px) !important;
  }
}
body.mobile-preview .modal-card {
  max-height: 90% !important;
}

/* Settings logo preview — full logo, not cropped */
.logo-preview {
  margin-top: 10px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 64px;
}
.logo-preview img {
  max-height: 72px !important;
  max-width: 100% !important;
  width: auto !important;
  height: auto !important;
  object-fit: contain !important;
  border-radius: 8px;
  display: block;
}
/* Sidebar brand mark — contain full logo */
.sidebar-brand .mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.sidebar-brand .mark.has-logo {
  background: #fff;
  border: 1px solid var(--border);
  padding: 4px;
}
.sidebar-brand .mark img {
  width: 100%;
  height: 100%;
  object-fit: contain !important;
  object-position: center;
  display: block;
}
/* Mobile: small logo chip top-left, not busy */
.mobile-clinic-bar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 4px;
}
.mobile-clinic-bar .m-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--border);
  padding: 2px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.mobile-clinic-bar .m-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain !important;
}
.mobile-clinic-bar .m-name {
  font-weight: 700;
  font-size: .8rem;
  line-height: 1.2;
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mobile-clinic-bar .m-tag {
  display: none; /* less clutter on mobile */
}
@media (max-width: 900px), body.mobile-preview {
  .mobile-clinic-bar { display: flex; }
  .sidebar-brand .mark { width: 40px; height: 40px; }
}


.check.auth-stay {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .82rem;
  color: var(--text-2);
  margin: 4px 0 14px;
  cursor: pointer;
}

/* Home hub */
#app.home-mode .sidebar,
#app.home-mode .bottom-nav,
#app.home-mode .topbar {
  display: none !important;
}
#app.home-mode .main {
  margin-left: 0 !important;
  width: 100%;
  padding: 0 !important;
}
#app.home-mode .content,
#app.home-mode .main > .content {
  padding: 0 !important;
  max-width: none !important;
}
.view-home {
  padding: 0 !important;
  min-height: 100%;
}
.home-stage {
  position: relative;
  min-height: 100dvh;
  background: #0c0a12 url("assets/login-bg.jpg") center / cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 20px 40px;
}
.home-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, rgba(12,12,14,.68) 0%, rgba(15,118,110,.38) 48%, rgba(12,12,14,.78) 100%);
  pointer-events: none;
}
.home-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 960px;
}
.home-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}
.home-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.home-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  font-weight: 800;
  color: #0f766e;
  font-size: 1.1rem;
}
.home-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}
.home-header h1 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.02em;
}
.home-sub {
  margin: 2px 0 0;
  font-size: .78rem;
  color: rgba(255,255,255,.72);
}
.home-user {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,.88);
  font-size: .85rem;
  font-weight: 600;
}
.home-out {
  background: rgba(255,255,255,.12) !important;
  border: 1px solid rgba(255,255,255,.22) !important;
  color: #fff !important;
}
.home-lead {
  color: rgba(255,255,255,.92);
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 16px;
}
.home-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.home-card {
  appearance: none;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.94);
  border-radius: 18px;
  padding: 22px 18px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 132px;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s;
}
.home-card:hover {
  transform: translateY(-4px);
  border-color: rgba(15,118,110,.5);
  box-shadow: 0 18px 48px rgba(0,0,0,.3);
}
.hc-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: #f0fdfa;
  color: #0f766e;
  display: grid;
  place-items: center;
}
.hc-title {
  font-size: 1.02rem;
  font-weight: 800;
  color: #0c0c0e;
  letter-spacing: -.02em;
}
.hc-desc {
  font-size: .78rem;
  color: #78716c;
  line-height: 1.4;
  font-weight: 500;
}
@media (max-width: 900px) {
  .home-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .home-card { min-height: 118px; padding: 16px 14px; }
}
@media (max-width: 480px) {
  .home-grid { grid-template-columns: 1fr; }
}
body.mobile-preview #app.home-mode .home-stage {
  min-height: 100%;
}
body.mobile-preview #app.home-mode .home-grid {
  grid-template-columns: 1fr 1fr;
}


/* Hub clicks must work — content above overlay */
.home-stage { z-index: 1; }
.home-overlay { z-index: 0; pointer-events: none !important; }
.home-content {
  z-index: 2 !important;
  position: relative !important;
  pointer-events: auto !important;
}
.home-card {
  position: relative;
  z-index: 3;
  pointer-events: auto !important;
  cursor: pointer !important;
  -webkit-tap-highlight-color: transparent;
}
#app.home-mode .main,
#app.home-mode .content {
  pointer-events: auto !important;
  overflow: auto !important;
}
#app.home-mode .mobile-clinic-bar {
  display: none !important;
}

.home-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none !important;
  background: linear-gradient(160deg, rgba(12,12,14,.68) 0%, rgba(15,118,110,.38) 48%, rgba(12,12,14,.78) 100%);
}
.home-overlay { display: none !important; pointer-events: none !important; }
.home-content, .home-grid, .home-card {
  position: relative;
  z-index: 5 !important;
  pointer-events: auto !important;
}

.ai-plan-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow: auto; }
.ai-plan-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
.ai-plan-item label { flex: 1; cursor: pointer; font-size: .85rem; }
.ai-plan-item strong { display: block; margin-bottom: 2px; }
.ai-plan-item .meta { color: var(--text-3); font-size: .75rem; }
.modal-wide { max-width: 520px; width: 100%; }
#aiSuggestPlan { white-space: nowrap; }
.modal-x{border:0;background:var(--surface-2);width:32px;height:32px;border-radius:8px;cursor:pointer;font-size:1.2rem}

/* —— Handover additions: auth links, PWA, privacy, sub banner, dentist color —— */
.auth-links {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
  font-size: .85rem;
}
.auth-links a { color: var(--accent); font-weight: 600; text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }
.auth-support, .auth-privacy {
  text-align: center;
  font-size: .78rem;
  color: var(--text-3);
  margin-top: 10px;
}
.auth-privacy a, .auth-support a { color: var(--accent); }
.pwa-guide {
  margin-top: 14px;
  font-size: .8rem;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  background: var(--surface-2, #fafaf9);
}
.pwa-guide summary { cursor: pointer; font-weight: 600; }
.pwa-guide-body { margin-top: 8px; color: var(--text-3); }
.pwa-guide-body p { margin: 4px 0; }

.sub-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: #fff7ed;
  border-bottom: 1px solid #fed7aa;
  color: #9a3412;
  font-size: .85rem;
  font-weight: 600;
}
.sub-banner.warn { background: #fff7ed; color: #9a3412; }
.sub-banner.lock { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.sub-banner.visible { display: flex; flex-wrap: wrap; }
.sub-banner .btn { flex-shrink: 0; }

.dentist-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.dentist-row .swatch {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border);
  flex-shrink: 0;
}
.dentist-row input[type="color"] {
  width: 36px; height: 28px; padding: 0; border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer; background: transparent;
}
.dentist-row .dent-name { flex: 1; min-width: 100px; font-size: .9rem; }

/* Calendar mobile horizontal scroll safety */
@media (max-width: 900px), body.mobile-preview {
  .cal-day-scroll, .cal-week-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .cal-board { min-width: min(100%, 520px); }
  .cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: 100%;
  }
}

/* Content never clipped on desktop panels */
@media (min-width: 901px) {
  .view.active {
    overflow: auto;
    max-height: calc(100dvh - 56px);
  }
  .settings-grid { align-items: start; }
}
