:root {
  color-scheme: light;
  --ink: #18263d;
  --muted: #758198;
  --line: #e8edf3;
  --canvas: #f5f7fb;
  --white: #fff;
  --teal: #147d78;
  --teal-dark: #0e625e;
  --teal-soft: #e7f4f2;
  --blue: #7893c2;
  --blue-soft: #eef2fb;
  --gold: #dba65e;
  --red: #bf535a;
  --shadow: 0 18px 45px rgba(33, 51, 79, .07);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); font: 14px/1.5 "DM Sans", "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.loading-screen { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); }
.brand-mark { width: 42px; height: 42px; border-radius: 15px 15px 15px 5px; display: grid; place-items: center; color: #fff; background: var(--teal); font: 800 24px Manrope, sans-serif; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 246px minmax(0, 1fr); }
.sidebar { background: #fff; border-right: 1px solid var(--line); padding: 25px 16px 18px; display: flex; flex-direction: column; gap: 30px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px; }
.brand-copy strong { display: block; font: 800 17px Manrope, sans-serif; letter-spacing: -.5px; }
.brand-copy span { color: var(--muted); font-size: 11px; }
.side-label { padding: 0 12px; color: #a0aabc; font-size: 10px; font-weight: 700; letter-spacing: 1.3px; text-transform: uppercase; }
.nav-list { display: grid; gap: 5px; margin-top: -20px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 13px; border: 0; border-radius: 10px; color: #7b8799; background: transparent; text-align: left; transition: .18s ease; }
.nav-item:hover { color: var(--teal); background: #f6faf9; }
.nav-item.active { color: var(--teal-dark); background: var(--teal-soft); font-weight: 700; }
.nav-icon { width: 20px; height: 20px; display: inline-grid; place-items: center; font-size: 16px; }
.side-bottom { margin-top: auto; padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: #fafbfd; }
.side-bottom strong { display: block; font-size: 12px; }
.side-bottom p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.workspace { min-width: 0; }
.topbar { height: 76px; padding: 0 clamp(20px, 4vw, 56px); display: flex; align-items: center; justify-content: space-between; gap: 20px; background: rgba(255,255,255,.84); border-bottom: 1px solid var(--line); }
.clinic-select-wrap { display: flex; align-items: center; gap: 11px; color: var(--muted); font-size: 12px; }
.clinic-select-wrap select { min-width: 205px; border: 0; background: transparent; color: var(--ink); font-weight: 700; outline: none; }
.user-menu { display: flex; align-items: center; gap: 11px; }
.avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: #e7eef8; color: #50698d; font-weight: 700; }
.user-copy strong { display: block; font-size: 12px; }
.user-copy span { color: var(--muted); font-size: 11px; }
.page { width: min(1280px, 100%); margin: 0 auto; padding: 35px clamp(20px, 4vw, 56px) 60px; }
.eyebrow { color: var(--teal); font-size: 10px; font-weight: 700; letter-spacing: 1.3px; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin: 7px 0 6px; font: 800 clamp(24px, 3vw, 32px)/1.2 Manrope, sans-serif; letter-spacing: -1px; }
h2 { margin: 0; font: 700 17px Manrope, sans-serif; letter-spacing: -.3px; }
h3 { margin: 0; font: 700 14px Manrope, sans-serif; }
.subtitle { margin: 0; color: var(--muted); }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 26px; }
.head-actions { display: flex; gap: 10px; }
.btn { min-height: 40px; padding: 0 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 9px; font-weight: 700; transition: .18s ease; }
.btn-primary { color: #fff; background: var(--teal); box-shadow: 0 5px 12px rgba(20,125,120,.15); }
.btn-primary:hover { background: var(--teal-dark); transform: translateY(-1px); }
.btn-quiet { color: #647188; background: #fff; border-color: var(--line); }
.btn-quiet:hover { color: var(--ink); background: #f9fafc; }
.btn-danger { color: var(--red); background: #fff7f7; border-color: #f1dada; }
.btn-small { min-height: 32px; padding: 0 10px; font-size: 12px; }
.icon-btn { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 9px; color: #718096; background: #fff; }
.icon-btn:hover { color: var(--teal); border-color: #b8d8d5; }
.grid { display: grid; gap: 18px; }
.stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 23px; }
.stat-card, .card { background: #fff; border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 4px 18px rgba(33,51,79,.025); }
.stat-card { padding: 19px 21px; display: flex; align-items: center; justify-content: space-between; }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { display: block; margin-top: 8px; font: 800 27px Manrope, sans-serif; letter-spacing: -1px; }
.stat-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; background: var(--teal-soft); color: var(--teal); font-size: 19px; }
.stat-card:nth-child(2) .stat-icon { color: #617cac; background: var(--blue-soft); }
.stat-card:nth-child(3) .stat-icon { color: #b17a37; background: #fbf3e8; }
.dashboard-grid { grid-template-columns: minmax(0, 1.45fr) minmax(260px, .8fr); align-items: start; }
.card { padding: 21px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 17px; }
.card-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.welcome-card { position: relative; overflow: hidden; min-height: 170px; padding: 26px; border: 0; color: #fff; background: linear-gradient(116deg, #176f70 0%, #258f86 70%, #72b2a1 100%); }
.welcome-card::after { content: ""; position: absolute; width: 240px; height: 240px; right: -58px; top: -100px; border: 1px solid rgba(255,255,255,.17); border-radius: 50%; box-shadow: 0 0 0 25px rgba(255,255,255,.035), 0 0 0 55px rgba(255,255,255,.03); }
.welcome-card .eyebrow { color: #b9e2d9; }
.welcome-card h2 { max-width: 470px; margin: 9px 0 8px; font-size: 23px; }
.welcome-card p { margin: 0; color: #d4ece6; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 10px 11px; color: #929eb0; border-bottom: 1px solid var(--line); font-size: 10px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; }
td { padding: 13px 11px; color: #526078; border-bottom: 1px solid #f0f2f6; font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
.primary-text { display: block; color: var(--ink); font-weight: 700; }
.secondary-text { display: block; margin-top: 2px; color: #98a2b2; font-size: 11px; }
.badge { display: inline-flex; padding: 4px 9px; border-radius: 20px; color: #4e709e; background: #edf2fa; font-size: 10px; font-weight: 700; }
.badge-success { color: #287769; background: #e8f5ef; }
.badge-warning { color: #9c702f; background: #fbf3e4; }
.badge-muted { color: #7d8490; background: #f0f2f5; }
.empty-state { padding: 28px 16px; color: var(--muted); text-align: center; }
.empty-icon { width: 42px; height: 42px; margin: 0 auto 10px; display: grid; place-items: center; border-radius: 14px; color: var(--teal); background: var(--teal-soft); font-size: 18px; }
.empty-state strong { display: block; margin-bottom: 3px; color: var(--ink); }
.content-grid { grid-template-columns: minmax(280px, .75fr) minmax(0, 1.5fr); align-items: start; }
.appointment-filters { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; margin: 4px 0 14px; }
.appointment-filters label { min-width: 135px; display: grid; gap: 5px; color: #536078; font-size: 10px; font-weight: 700; }
.appointment-filters input, .appointment-filters select { min-height: 36px; padding: 7px 9px; border: 1px solid #e3e8ef; border-radius: 8px; color: var(--ink); background: #fff; font: inherit; }
.table-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; min-width: 145px; }
.form-card { position: static; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.duration-control { display: flex; align-items: center; gap: 7px; }
.duration-control input { max-width: 110px; }
.appointment-history { display: grid; gap: 9px; }
.appointment-history-item { display: grid; gap: 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: #fbfcfe; }
.appointment-history-item span { color: var(--ink); font-size: 11px; font-weight: 700; }
.appointment-history-item small { color: var(--muted); font-size: 10px; }
.badge + .badge { margin-left: 4px; }
.working-hours-table { min-width: 720px; }
.working-hours-table th, .working-hours-table td { padding: 9px 8px; text-align: left; }
.working-hours-table th[scope="row"] { color: var(--ink); white-space: nowrap; }
.working-hours-table input[type="time"] { min-width: 125px; min-height: 38px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: #fff; font: inherit; }
.working-hours-table input:disabled { background: #f4f6f9; }
.field { display: grid; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { color: #536078; font-size: 11px; font-weight: 700; }
.field input, .field select, .field textarea, .toolbar input, .toolbar select, .auth-card input, .auth-card select { width: 100%; min-height: 39px; padding: 9px 11px; border: 1px solid #e3e8ef; border-radius: 8px; outline: none; color: var(--ink); background: #fff; transition: border .15s, box-shadow .15s; }
.field textarea { min-height: 85px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .toolbar input:focus, .auth-card input:focus { border-color: #7ab8b1; box-shadow: 0 0 0 3px rgba(20,125,120,.09); }
.patient-combobox { position: relative; }
.combobox-input-wrap { position: relative; }
.combobox-input-wrap input[type="search"] { padding-right: 38px; }
.combobox-clear { position: absolute; top: 50%; right: 9px; width: 26px; height: 26px; transform: translateY(-50%); border: 0; border-radius: 50%; color: #728096; background: #f1f4f7; font-size: 18px; line-height: 1; }
.combobox-results { position: absolute; z-index: 6; top: calc(100% + 5px); left: 0; right: 0; max-height: 245px; overflow: auto; border: 1px solid #e2e8ef; border-radius: 10px; background: #fff; box-shadow: 0 12px 28px rgba(28,43,63,.14); }
.combobox-option { width: 100%; padding: 10px 12px; display: grid; gap: 3px; border: 0; border-bottom: 1px solid #eff2f6; color: var(--ink); background: #fff; text-align: left; }
.combobox-option:last-child { border-bottom: 0; }
.combobox-option:hover, .combobox-option:focus { outline: 0; background: #eff8f5; }
.combobox-option span, .combobox-help { color: #8792a3; font-size: 10px; }
.combobox-help { padding: 13px; }
.form-note { color: #929eb0; font-size: 10px; }
.form-actions { grid-column: 1 / -1; display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding-top: 5px; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 15px; }
.toolbar input { max-width: 320px; }
.toolbar .spacer { flex: 1; }
.record-layout { grid-template-columns: minmax(245px, .65fr) minmax(0, 1.4fr); align-items: start; }
.patient-pick { margin-bottom: 16px; }
.patient-summary { padding: 14px; border-radius: 11px; background: #f5f8fb; }
.patient-summary strong { display: block; }
.patient-summary span { color: var(--muted); font-size: 11px; }
.record-main { grid-template-columns: 1fr; align-content: start; }
.odontogram-card { overflow: hidden; }
.odontogram-legend { display: flex; align-items: center; flex-wrap: wrap; gap: 13px; margin: -5px 0 17px; color: #77849a; font-size: 10px; }
.odontogram-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 9px; height: 9px; display: inline-block; border-radius: 50%; background: #52a79b; }
.legend-selected { background: #176f70; box-shadow: 0 0 0 3px #d7eeea; }
.arch-row { display: grid; grid-template-columns: 55px minmax(0, 1fr); align-items: center; gap: 8px; }
.arch-label { color: #94a0b1; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.tooth-row { min-width: 0; display: grid; grid-template-columns: repeat(16, minmax(25px, 1fr)); gap: 5px; padding: 5px 1px; overflow-x: auto; }
.tooth { position: relative; min-width: 25px; height: 42px; display: grid; place-items: center; border: 1px solid #e3e8ef; border-radius: 13px 13px 9px 9px; color: #68758b; background: linear-gradient(180deg,#fff 0 68%,#f9fafc 68% 100%); font-size: 10px; font-weight: 700; transition: .15s ease; }
.tooth i { position: absolute; width: 5px; height: 5px; right: 3px; top: 3px; border-radius: 50%; background: transparent; }
.tooth:hover { border-color: #7cb8b0; transform: translateY(-2px); }
.tooth.has-records { color: #176f70; border-color: #8ec8bd; background: linear-gradient(180deg,#edf8f5 0 68%,#e3f2ee 68% 100%); }
.tooth.has-records i { background: #42a295; }
.tooth.selected { color: #fff; border-color: #176f70; background: linear-gradient(180deg,#258b81 0 68%,#176f70 68% 100%); box-shadow: 0 0 0 3px #d9efea; }
.tooth.selected i { background: #d9f2ec; }
.tooth-midline { margin: 3px 0; padding: 7px 8px 7px 63px; display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: center; color: #9ba5b4; text-align: center; font-size: 9px; }
.tooth-midline b { font-size: 9px; font-weight: 600; }
.tooth-filter-note { margin-top: 12px; padding: 9px 11px; display: flex; align-items: center; gap: 5px; border-radius: 8px; color: #58667d; background: #f5f8fb; font-size: 11px; }
.tooth-filter-note .text-button { margin-left: auto; }
.timeline { display: grid; gap: 0; }
.timeline-item { position: relative; padding: 0 0 22px 24px; border-left: 1px solid #e1e7ee; }
.timeline-item:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline-item::before { content: ""; position: absolute; left: -5px; top: 4px; width: 9px; height: 9px; border: 2px solid #fff; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 1px #87beb6; }
.timeline-date { color: #97a1b0; font-size: 10px; }
.timeline-title { margin: 3px 0 6px; font-weight: 700; }
.timeline-text { margin: 0; color: #647188; font-size: 12px; white-space: pre-wrap; }
.toast { position: fixed; z-index: 10; right: 22px; bottom: 22px; max-width: min(420px, calc(100vw - 44px)); padding: 13px 17px; border: 1px solid #c8e5dc; border-radius: 11px; color: #226b5b; background: #f0faf6; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { color: #a13f48; border-color: #f0cdd0; background: #fff5f5; }
.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr); background: #fff; }
.auth-art { position: relative; overflow: hidden; min-height: 100vh; padding: clamp(35px, 7vw, 90px); display: flex; flex-direction: column; justify-content: space-between; color: #fff; background: linear-gradient(145deg, #155f66, #18847d 62%, #72ad9b); }
.auth-art::before, .auth-art::after { content: ""; position: absolute; width: 460px; height: 460px; right: -130px; top: 13%; border: 1px solid rgba(255,255,255,.16); border-radius: 50%; box-shadow: 0 0 0 28px rgba(255,255,255,.035), 0 0 0 62px rgba(255,255,255,.025); }
.auth-art::after { width: 180px; height: 180px; top: auto; bottom: -60px; right: 35%; }
.auth-art > * { position: relative; z-index: 1; }
.auth-art .brand { padding: 0; }
.auth-art .brand-copy span { color: #c0e3dc; }
.art-copy { max-width: 510px; }
.art-copy .eyebrow { color: #b4e2d8; }
.art-copy h1 { margin: 15px 0; font-size: clamp(32px, 4.7vw, 52px); }
.art-copy p { max-width: 440px; color: #dbefeb; font-size: 16px; }
.art-foot { color: #cae7e0; font-size: 11px; }
.auth-panel { padding: 30px; display: grid; place-items: center; }
.auth-card { width: min(390px, 100%); }
.auth-card h2 { margin: 12px 0 5px; font-size: 25px; }
.auth-card > p { margin-bottom: 25px; color: var(--muted); }
.auth-card form { display: grid; gap: 14px; }
.auth-card .btn { width: 100%; margin-top: 5px; }
.auth-switch { margin-top: 19px; color: var(--muted); text-align: center; }
.text-button { padding: 0; border: 0; color: var(--teal); background: transparent; font-weight: 700; }
.hint { margin-top: 8px; color: #96a0b0; font-size: 10px; }
.setup-wrap { width: min(760px, 100%); margin: 6vh auto; padding: 0 20px; }
.setup-card { margin-top: 22px; padding: 28px; }
.setup-card .form-grid { grid-template-columns: 1fr; }
.invite-link-field { margin-top: 18px; }
.invite-link-row { display: flex; gap: 8px; }
.invite-link-row input { min-width: 0; flex: 1; }
.mobile-menu { display: none; }
@media (max-width: 1000px) {
  .shell { grid-template-columns: 210px minmax(0, 1fr); }
  .sidebar { padding-inline: 12px; }
  .content-grid, .record-layout { grid-template-columns: 1fr; }
  .form-card { position: static; }
  .record-main { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; z-index: 5; top: 0; padding: 10px 13px; border-right: 0; border-bottom: 1px solid var(--line); flex-direction: row; align-items: center; justify-content: space-between; gap: 8px; }
  .sidebar .brand { padding: 0 3px; }
  .brand-mark { width: 36px; height: 36px; }
  .brand-copy strong { font-size: 14px; }
  .brand-copy span, .side-label, .side-bottom { display: none; }
  .nav-list { display: flex; margin: 0; gap: 3px; }
  .nav-item { width: auto; padding: 9px; }
  .nav-item .nav-text { display: none; }
  .nav-icon { font-size: 18px; }
  .topbar { height: 60px; padding: 0 17px; }
  .clinic-select-wrap { gap: 6px; }
  .clinic-select-wrap select { min-width: 125px; max-width: 44vw; }
  .user-copy { display: none; }
  .page { padding: 26px 16px 45px; }
  .page-head { align-items: start; flex-direction: column; }
  .stats-grid { grid-template-columns: 1fr; gap: 10px; }
  .stat-card { padding: 14px 16px; }
  .stat-value { font-size: 23px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .arch-row { grid-template-columns: 1fr; gap: 2px; }
  .tooth-row { grid-template-columns: repeat(16, 31px); }
  .tooth-midline { padding-left: 0; }
  .card { padding: 16px; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .auth-panel { min-height: 100vh; padding: 25px; }
}
