:root {
  color-scheme: light;
  --theme-primary: #0f766e;
  --theme-accent: #2563eb;
  --theme-accent-strong: #1e40af;
  --theme-sidebar: #102229;
  --theme-sidebar-mid: #15313a;
  --theme-sidebar-end: #10252c;
  --theme-surface: #eef4f2;
  --theme-surface-strong: #dde9e6;
  --brand-gradient-start: #a8f0d2;
  --brand-gradient-end: #7cc7ff;
  --surface-tint-a: rgba(57, 182, 166, 0.12);
  --surface-tint-b: rgba(37, 99, 235, 0.05);
  --surface-tint-c: rgba(217, 154, 39, 0.08);
  --ink: #142128;
  --muted: #62727c;
  --line: #d8e3e1;
  --panel: #ffffff;
  --surface: var(--theme-surface);
  --surface-strong: var(--theme-surface-strong);
  --blue: var(--theme-accent);
  --blue-dark: var(--theme-accent-strong);
  --green: #16805a;
  --amber: #a16207;
  --red: #c24136;
  --teal: var(--theme-primary);
  --violet: #6d5bd0;
  --aqua: var(--brand-gradient-start);
  --gold: #d99a27;
  --rose: #e15d52;
  --shadow: 0 18px 45px rgba(20, 33, 40, 0.12);
  --shadow-soft: 0 10px 26px rgba(20, 33, 40, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, var(--surface-tint-a), var(--surface-tint-b) 42%, var(--surface-tint-c)),
    var(--surface);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.auth-layer {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--theme-sidebar) 92%, black), color-mix(in srgb, var(--theme-sidebar-mid) 88%, black)),
    var(--surface);
  z-index: 80;
}

.auth-panel {
  display: grid;
  gap: 22px;
  width: min(420px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  padding: 24px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.auth-panel .brand {
  color: var(--ink);
}

.auth-panel .brand span {
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.auth-message {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 0.9rem;
  font-weight: 700;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.mobile-menu-toggle,
.mobile-menu-backdrop {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 28px;
  height: 100vh;
  max-height: 100vh;
  overflow-y: auto;
  padding: 24px;
  background:
    linear-gradient(180deg, var(--theme-sidebar) 0%, var(--theme-sidebar-mid) 52%, var(--theme-sidebar-end) 100%);
  color: #f8fbfb;
  z-index: 20;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.08), 10px 0 28px rgba(20, 33, 40, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-media {
  position: relative;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
}

.brand strong {
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--brand-gradient-start), var(--brand-gradient-end));
  color: #11252b;
  font-weight: 800;
  box-shadow: 0 10px 22px color-mix(in srgb, var(--brand-gradient-end) 26%, transparent);
}

.brand-logo {
  position: absolute;
  inset: 0;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #ffffff;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 2px;
  color: #bcd0d2;
  font-size: 0.84rem;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #dbe8e9;
  text-align: left;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-item span {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  color: var(--brand-gradient-start);
}

.nav-item:hover,
.nav-item.is-active {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  transform: translateX(2px);
}

.nav-item.is-active {
  box-shadow: inset 3px 0 0 var(--brand-gradient-start);
}

.role-panel {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.role-panel label {
  display: block;
  margin-bottom: 8px;
  color: #bcd0d2;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.role-panel select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  padding: 10px;
  background: #18333b;
  color: #ffffff;
}

.role-panel p {
  min-height: 52px;
  margin: 10px 0 0;
  color: #bcd0d2;
  font-size: 0.9rem;
  line-height: 1.45;
}

.role-panel .backend-status {
  min-height: auto;
  margin-top: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #dbe8e9;
  font-size: 0.78rem;
  font-weight: 800;
}

.logout-action {
  width: 100%;
  margin-top: 10px;
}

.main-content {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(20, 33, 40, 0.08);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.1;
}

h1 {
  font-size: clamp(1.8rem, 3vw, 2.8rem);
}

h2 {
  font-size: 1.05rem;
}

h3 {
  font-size: 0.96rem;
}

.summary-strip,
.finance-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 10px;
}

.summary-strip div,
.finance-metrics div {
  position: relative;
  overflow: hidden;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.summary-strip div::before,
.finance-metrics div::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--teal);
}

.summary-strip div:nth-child(2)::before,
.finance-metrics div:nth-child(2)::before {
  background: var(--gold);
}

.summary-strip div:nth-child(3)::before,
.finance-metrics div:nth-child(3)::before {
  background: var(--blue);
}

.finance-metrics div:nth-child(4)::before {
  background: var(--violet);
}

.summary-strip span,
.finance-metrics span {
  display: block;
  font-size: 1.25rem;
  font-weight: 800;
}

.summary-strip small,
.finance-metrics small {
  color: var(--muted);
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(390px, 0.96fr);
  gap: 20px;
  align-items: start;
}

.agenda-panel,
.calendar-panel,
.patient-list-panel,
.patient-profile,
.finance-overview,
.ledger-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.agenda-panel,
.calendar-panel,
.finance-overview,
.ledger-panel,
.patient-list-panel,
.patient-profile {
  padding: 18px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(20, 33, 40, 0.07);
}

.section-header.compact {
  margin-bottom: 12px;
  padding-bottom: 10px;
}

.primary-action,
.secondary-action,
.danger-action,
.icon-button {
  min-height: 38px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 9px 13px;
  font-weight: 800;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.primary-action {
  background: linear-gradient(135deg, var(--blue), color-mix(in srgb, var(--blue) 72%, white));
  color: #ffffff;
  box-shadow: 0 10px 20px color-mix(in srgb, var(--blue) 22%, transparent);
}

.primary-action:hover {
  background: linear-gradient(135deg, var(--blue-dark), var(--blue));
  transform: translateY(-1px);
}

.secondary-action {
  border-color: var(--line);
  background: #ffffff;
  color: var(--ink);
}

.secondary-action:hover {
  border-color: #b8c7e8;
  background: #f8fbff;
  transform: translateY(-1px);
}

.secondary-action.compact {
  min-height: 34px;
  padding: 6px 10px;
}

.danger-action {
  margin-right: auto;
  border-color: #f0b7b3;
  background: #fff5f4;
  color: #9f2420;
}

.danger-action:hover {
  background: #fee2e2;
}

.icon-button {
  display: grid;
  width: 38px;
  padding: 0;
  place-items: center;
  border-color: var(--line);
  background: #ffffff;
  color: var(--ink);
  font-size: 1.3rem;
  box-shadow: 0 4px 10px rgba(20, 33, 40, 0.06);
}

.icon-button:hover {
  border-color: #b8c7e8;
  background: #f8fbff;
}

.icon-button.small {
  width: 34px;
  min-height: 34px;
  font-size: 1.1rem;
}

.agenda-actions,
.calendar-tools,
.month-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.agenda-actions,
.calendar-tools {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.calendar-panel .section-header {
  align-items: flex-start;
}

.calendar-tools {
  flex-direction: column;
  align-items: flex-end;
}

.compact-field {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.compact-field select {
  min-height: 38px;
  min-width: 170px;
  text-transform: none;
}

.timeline {
  display: grid;
  gap: 0;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(238, 244, 242, 0.55), rgba(255, 255, 255, 0));
}

.time-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  min-height: 76px;
  border-top: 1px solid var(--line);
}

.time-row:first-child {
  border-top: 0;
}

.time-label {
  padding-top: 14px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.slot {
  min-width: 0;
  padding: 8px 0 8px 12px;
  border-left: 1px solid var(--line);
}

.appointment {
  display: grid;
  gap: 8px;
  min-height: 58px;
  padding: 10px 12px;
  border-left: 4px solid var(--blue);
  border-radius: var(--radius);
  background: linear-gradient(135deg, #ffffff, #f4f9ff);
  box-shadow: 0 8px 18px rgba(20, 33, 40, 0.07);
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.appointment:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(20, 33, 40, 0.1);
}

.appointment.is-empty {
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--muted);
  align-content: center;
}

.appointment-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.patient-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--blue-dark);
  font-weight: 850;
  text-align: left;
}

.appointment-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
}

.status,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.76rem;
  font-weight: 800;
}

.status.confirmed {
  background: #dceafe;
  color: #1d4ed8;
}

.status.checked-in {
  background: #d8f4e8;
  color: #166534;
}

.status.completed {
  background: #e7e5ff;
  color: #5b21b6;
}

.status.canceled {
  background: #fee2e2;
  color: #991b1b;
}

.status-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.status-controls button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 750;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.status-controls button:hover {
  border-color: #b8c7e8;
  background: #f8fbff;
  transform: translateY(-1px);
}

.status-controls button[data-edit-appointment] {
  border-color: #b9c8ee;
  color: var(--blue-dark);
}

.appointment-note {
  color: var(--muted);
  font-size: 0.83rem;
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.8rem;
}

.calendar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.calendar-legend i {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.volume-low {
  background: #e9f4f2;
}

.volume-mid {
  background: #99ddd3;
}

.volume-high {
  background: #0f766e;
}

.weekday-row,
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekday-row {
  gap: 6px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-align: center;
}

.month-grid {
  gap: 6px;
}

.day-button {
  display: grid;
  align-content: space-between;
  aspect-ratio: 1;
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}

.day-button:hover,
.day-button.is-selected {
  border-color: var(--teal);
  box-shadow: inset 0 0 0 1px var(--teal);
}

.day-button:hover {
  transform: translateY(-1px);
}

.day-button.is-muted {
  opacity: 0.35;
}

.day-button.volume-1 {
  background: #e9f4f2;
}

.day-button.volume-2 {
  background: #c4eee6;
}

.day-button.volume-3 {
  background: #7fd6c9;
}

.day-button.volume-4 {
  background: #0f766e;
  color: #ffffff;
}

.day-number {
  font-weight: 850;
}

.day-load {
  font-size: 0.72rem;
  font-weight: 800;
}

.patient-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.search-input,
input,
select,
textarea {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 10px;
  background: #ffffff;
  color: var(--ink);
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 0;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

textarea {
  resize: vertical;
}

.search-input {
  width: 100%;
}

.patient-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.patient-list button,
.match-button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
  transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.patient-list button.is-active,
.patient-list button:hover,
.match-button:hover {
  border-color: var(--teal);
  background: #f0fbf8;
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.1);
  transform: translateY(-1px);
}

.patient-list strong,
.match-button strong {
  display: block;
}

.patient-list span,
.match-button span {
  color: var(--muted);
  font-size: 0.84rem;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.profile-section {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.profile-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.profile-form,
.clinical-entry-form {
  display: grid;
  gap: 12px;
}

.profile-form.is-hidden,
.inline-entry-form.is-hidden {
  display: none;
}

.profile-form label,
.clinical-entry-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.profile-form input,
.profile-form textarea,
.clinical-entry-form input,
.clinical-entry-form select,
.clinical-entry-form textarea {
  width: 100%;
  color: var(--ink);
  font-weight: 500;
}

.phone-field {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}

.phone-field:focus-within {
  border-color: rgba(15, 118, 110, 0.35);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.phone-prefix {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  border-right: 1px solid var(--line);
  background: #f6faf9;
  color: var(--muted);
  font-weight: 800;
}

.phone-field input {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.inline-entry-form {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(90px, 0.6fr) minmax(120px, 0.7fr) auto;
  gap: 8px;
  margin-bottom: 10px;
}

.inline-entry-form[data-file-form] {
  grid-template-columns: minmax(0, 1fr) auto;
}

.inline-entry-form input,
.inline-entry-form select {
  width: 100%;
}

.plan-entry-form {
  grid-template-columns: minmax(0, 1.2fr) minmax(90px, 0.45fr) minmax(120px, 0.6fr) minmax(0, 1fr) auto;
}

.settings-subsection {
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #edf3f2;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
}

.status-pill.is-success {
  background: rgba(15, 118, 110, 0.12);
  color: var(--theme-primary);
}

.status-pill.is-warning {
  background: rgba(180, 83, 9, 0.12);
  color: #9a5a08;
}

.muted-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.inline-actions.align-end {
  align-items: end;
}

.inline-feedback {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.inline-feedback.is-visible {
  color: var(--ink);
}

.reminder-rules {
  display: grid;
  gap: 10px;
}

.reminder-rule-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(90px, 0.45fr) minmax(120px, 0.6fr);
  gap: 10px;
  align-items: center;
}

.reminder-rule-row .check-row {
  margin: 0;
}

.editable-record {
  display: grid;
  gap: 10px;
}

.editable-record label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.editable-record input,
.editable-record select,
.editable-record textarea {
  width: 100%;
}

.record-edit-grid {
  display: grid;
  grid-template-columns: minmax(90px, 0.45fr) minmax(130px, 0.55fr);
  gap: 8px;
}

.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.record-actions .secondary-action,
.record-actions .danger-action {
  min-height: 32px;
  padding: 6px 10px;
}

.file-upload-form {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

.file-upload-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.file-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.file-actions .secondary-action,
.file-actions .danger-action {
  min-height: 32px;
  padding: 6px 10px;
}

.info-grid,
.treatment-grid {
  display: grid;
  gap: 10px;
}

.info-row,
.history-item,
.invoice-item,
.expense-item,
.plan-item,
.file-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px;
  background: linear-gradient(180deg, #ffffff, #fbfdfd);
  box-shadow: 0 6px 14px rgba(20, 33, 40, 0.045);
}

.info-row span,
.history-item span,
.invoice-item span,
.expense-item span,
.plan-item span,
.file-item span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 3px;
}

.alert-box {
  border-radius: var(--radius);
  border: 1px solid #f5c2c0;
  background: #fff2f2;
  color: #8f1d19;
  padding: 10px;
  font-weight: 800;
}

.subsection-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.secondary-action.is-on {
  border-color: var(--teal);
  background: color-mix(in srgb, var(--teal) 12%, white);
  color: var(--teal);
}

.tooth-chart {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid #deebe8;
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(15, 118, 110, 0.04) 1px, transparent 1px),
    #f7fbfa;
  background-size: 24px 24px;
}

.tooth-chart.is-editing {
  outline: 2px solid #99ddd3;
  outline-offset: 2px;
}

.tooth-quadrant {
  display: grid;
  gap: 6px;
}

.tooth-quadrant > span,
.active-teeth-list span,
.tooth-detail span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.tooth-row {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
}

.tooth {
  display: grid;
  min-height: 38px;
  width: 100%;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50% 50% 44% 44%;
  background: linear-gradient(180deg, #ffffff, #edf4f3);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  box-shadow: inset 0 -3px 0 rgba(20, 33, 40, 0.04), 0 4px 8px rgba(20, 33, 40, 0.04);
  transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease, color 150ms ease, transform 150ms ease;
}

.tooth:hover,
.tooth.is-selected {
  border-color: var(--blue);
  color: var(--blue-dark);
  box-shadow: inset 0 0 0 1px var(--blue);
  transform: translateY(-1px);
}

.tooth.needs-work {
  border-color: #e2a13a;
  background: #fff7df;
  color: #7a4b00;
}

.tooth.needs-work.is-selected {
  border-color: #a76b00;
  box-shadow: inset 0 0 0 2px #a76b00;
}

.tooth-detail,
.active-teeth-list {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.tooth-detail p,
.active-teeth-list strong {
  margin: 0;
}

.accounting-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.86fr) minmax(420px, 1.14fr);
  gap: 20px;
  align-items: start;
}

.settings-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.settings-panel:first-child {
  grid-row: span 2;
}

.settings-form {
  display: grid;
  gap: 12px;
}

.settings-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.settings-form input[type="color"] {
  width: 100%;
  min-height: 44px;
  padding: 4px;
}

.branding-tools {
  display: grid;
  gap: 12px;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.branding-preview {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--brand-gradient-start) 14%, white), color-mix(in srgb, var(--brand-gradient-end) 10%, white)),
    #ffffff;
}

.inline-actions {
  display: flex;
  align-items: end;
}

.palette-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.palette-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 0 4px 10px rgba(20, 33, 40, 0.05);
}

.palette-chip:hover,
.palette-chip.is-active {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
}

.palette-chip span {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid rgba(20, 33, 40, 0.08);
  background: var(--swatch);
}

.color-grid {
  align-items: end;
}

.check-row {
  display: flex !important;
  align-items: center;
  gap: 8px;
}

.check-row input {
  min-height: auto;
  width: auto;
}

.settings-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.settings-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px;
  background: linear-gradient(180deg, #ffffff, #fbfdfd);
  box-shadow: 0 6px 14px rgba(20, 33, 40, 0.045);
}

.settings-item span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.audit-list .settings-item {
  grid-template-columns: 1fr;
}

.audit-list code {
  width: max-content;
  max-width: 100%;
  border-radius: 6px;
  padding: 2px 6px;
  background: #edf4f3;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.settings-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.finance-overview {
  grid-column: 1 / -1;
}

.finance-metrics {
  grid-template-columns: repeat(4, minmax(130px, 1fr));
}

.report-band {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid #cce8e3;
  background: linear-gradient(135deg, #eff8f6, #fffaf0);
}

.report-band span {
  color: var(--muted);
}

.ledger-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.ledger-actions {
  display: grid;
  grid-template-columns: minmax(90px, 0.7fr) minmax(110px, 0.7fr) auto auto;
  gap: 8px;
  margin-top: 10px;
}

.payment-history {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.payment-history div {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border-radius: 6px;
  padding: 7px 8px;
  background: #f5faf8;
  color: var(--muted);
  font-size: 0.82rem;
}

.payment-history .danger-action {
  min-height: 28px;
  padding: 5px 8px;
}

.expense-item .ledger-actions {
  grid-template-columns: auto;
  justify-content: start;
}

.ledger-actions input {
  width: 100%;
}

.modal-layer {
  position: fixed;
  inset: 0;
  display: none;
  justify-content: flex-end;
  background: rgba(17, 37, 43, 0.32);
  backdrop-filter: blur(6px);
  z-index: 30;
}

.modal-layer.is-open {
  display: flex;
}

.booking-panel,
.expense-panel {
  width: min(520px, 100%);
  min-height: 100%;
  overflow-y: auto;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(57, 182, 166, 0.08), rgba(255, 255, 255, 0) 180px),
    #ffffff;
  box-shadow: var(--shadow);
}

.booking-form,
.new-patient {
  display: grid;
  gap: 14px;
}

.inline-add-button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: max-content;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 10px;
  background: #ffffff;
  color: var(--blue-dark);
  font-weight: 850;
  transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.inline-add-button:hover {
  border-color: #b9c8ee;
  background: #f8fbff;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.1);
  transform: translateY(-1px);
}

.inline-add-button span {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 50%;
  background: var(--blue);
  color: #ffffff;
  line-height: 1;
}

.inline-add-button[aria-expanded="true"] span {
  background: var(--red);
}

.booking-form label,
.new-patient label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.booking-form input,
.booking-form select,
.booking-form textarea {
  width: 100%;
  color: var(--ink);
  font-weight: 500;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.patient-profile .form-grid,
.patient-profile .inline-entry-form,
.patient-profile .inline-entry-form[data-file-form] {
  grid-template-columns: 1fr;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.search-results {
  display: grid;
  gap: 8px;
}

.new-patient {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #f8fbfb, #ffffff);
}

input[type="file"]::file-selector-button {
  min-height: 34px;
  margin-right: 10px;
  border: 1px solid #c8d5d3;
  border-radius: var(--radius);
  padding: 7px 10px;
  background: #f7fbfa;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.access-hidden {
  display: none !important;
}

@media (max-width: 1040px) {
  .app-shell,
  .dashboard-grid,
  .patient-layout,
  .profile-grid,
  .accounting-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-panel:first-child {
    grid-row: auto;
  }

  .sidebar {
    position: sticky;
    top: 0;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    height: auto;
    max-height: none;
    overflow-y: visible;
  }

  .nav-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    flex: 1 1 360px;
  }

  .role-panel {
    flex: 1 1 220px;
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }
}

@media (max-width: 720px) {
  .main-content {
    padding: 16px;
    padding-top: 94px;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 70;
    display: flex;
    width: min(86vw, 340px);
    height: 100dvh;
    max-height: none;
    padding: 18px;
    overflow-y: auto;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    gap: 12px;
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .mobile-menu-toggle {
    position: fixed;
    top: 14px;
    left: 16px;
    z-index: 75;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    border: 1px solid rgba(150, 235, 220, 0.36);
    border-radius: var(--radius);
    padding: 9px 12px;
    background: var(--theme-sidebar);
    color: #ecfffb;
    box-shadow: var(--shadow-soft);
    font-weight: 900;
  }

  .mobile-menu-toggle span {
    font-size: 1.05rem;
    line-height: 1;
  }

  .mobile-menu-toggle.is-open {
    left: auto;
    right: 8px;
    width: 42px;
    justify-content: center;
    padding: 9px;
  }

  .mobile-menu-toggle.is-open .menu-label {
    display: none;
  }

  .mobile-menu-toggle.is-open .menu-icon {
    font-size: 1.35rem;
  }

  .mobile-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 65;
    display: block;
    background: rgba(7, 18, 22, 0.48);
    backdrop-filter: blur(2px);
  }

  .mobile-menu-backdrop[hidden] {
    display: none !important;
  }

  .sidebar .brand {
    gap: 10px;
  }

  .topbar,
  .section-header {
    align-items: stretch;
    flex-direction: column;
  }

  .summary-strip,
  .finance-metrics,
  .ledger-actions,
  .form-grid,
  .reminder-rule-row,
  .inline-entry-form,
  .inline-entry-form[data-file-form] {
    grid-template-columns: 1fr;
  }

  .agenda-panel,
  .calendar-panel,
  .finance-overview,
  .ledger-panel,
  .patient-list-panel,
  .patient-profile,
  .settings-panel {
    padding: 14px;
  }

  .summary-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .finance-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .summary-strip div {
    min-height: 74px;
    padding: 10px 8px 10px 11px;
  }

  .finance-metrics div {
    min-height: 78px;
    padding: 10px 8px 10px 12px;
  }

  .summary-strip span,
  .finance-metrics span {
    font-size: 1.05rem;
  }

  .summary-strip small,
  .finance-metrics small {
    display: block;
    font-size: 0.74rem;
    line-height: 1.2;
  }

  .report-band {
    margin-top: 10px;
    padding: 11px;
    gap: 6px;
    font-size: 0.88rem;
  }

  .finance-overview .agenda-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .finance-overview .agenda-actions button {
    width: 100%;
    padding-inline: 10px;
  }

  .patient-profile {
    padding: 14px;
  }

  .patient-profile .profile-grid,
  .patient-profile .info-grid,
  .patient-profile .profile-section,
  .patient-profile form,
  .patient-profile label,
  .patient-profile input,
  .patient-profile select,
  .patient-profile textarea,
  .patient-profile .treatment-grid,
  .patient-profile .record-edit-grid,
  .patient-profile .record-actions,
  .patient-profile .tooth-chart,
  .patient-profile .tooth-detail,
  .patient-profile .active-teeth-list {
    min-width: 0;
    max-width: 100%;
  }

  .patient-profile .profile-grid,
  .patient-profile .info-grid {
    width: 100%;
  }

  .patient-profile .record-edit-grid {
    grid-template-columns: 1fr;
  }

  .patient-profile .active-teeth-list strong,
  .patient-profile .history-item,
  .patient-profile .plan-item,
  .patient-profile .file-item {
    overflow-wrap: anywhere;
  }

  .settings-item {
    grid-template-columns: 1fr;
  }

  .ledger-actions {
    gap: 7px;
  }

  .ledger-actions input,
  .ledger-actions select,
  .ledger-actions button {
    width: 100%;
  }

  .payment-history div {
    align-items: stretch;
  }

  .calendar-tools,
  .month-actions,
  .agenda-actions {
    gap: 8px;
  }

  .nav-list {
    grid-template-columns: 1fr;
    flex: none;
  }

  .nav-item {
    min-height: 44px;
    padding: 10px 12px;
  }

  .role-panel {
    flex: none;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    gap: 8px;
    font-size: 0.9rem;
  }

  .role-panel p {
    margin: 0;
  }

  .time-row {
    grid-template-columns: 58px minmax(0, 1fr);
  }
}
