/* Clinic AI OS - Jane-inspired design system
   Calm, clean, lots of white, soft blue accent, rounded corners, subtle depth. */

:root {
  --blue: #2f6fed;
  --blue-dark: #1e4fc4;
  --blue-soft: #eaf1fe;
  --teal: #0e9f8a;
  --ink: #1c2434;
  --muted: #64748b;
  --faint: #94a3b8;
  --bg: #f6f8fb;
  --card: #ffffff;
  --border: #e5eaf1;
  --danger: #d64545;
  --danger-soft: #fdeeee;
  --warn: #b4690e;
  --warn-soft: #fdf3e4;
  --ok: #2e8b57;
  --ok-soft: #e9f6ef;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 30, 54, 0.04), 0 4px 16px rgba(16, 30, 54, 0.06);
  --shadow-lg: 0 8px 40px rgba(16, 30, 54, 0.16);
  --sidebar-w: 232px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px; width: 100%; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 12px 0 4px; }
a { color: var(--blue); text-decoration: none; }

/* ── Layout ─────────────────────────────────────────── */
#app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--card);
  border-right: 1px solid var(--border); padding: 20px 12px;
  display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 10px; background: var(--blue);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; letter-spacing: -.5px;
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -.2px; }
.brand-name small { display: block; font-weight: 500; font-size: 11px; color: var(--faint); }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px;
  border-radius: var(--radius-sm); color: var(--muted); font-weight: 500;
  transition: background .12s, color .12s; text-align: left; width: 100%;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg); color: var(--ink); }
.nav-item.active { background: var(--blue-soft); color: var(--blue); font-weight: 600; }
.nav-spacer { flex: 1; }
.nav-user {
  display: flex; align-items: center; gap: 10px; padding: 10px 11px;
  border-top: 1px solid var(--border); margin-top: 8px;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--blue-soft);
  color: var(--blue); font-weight: 700; font-size: 12px;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.nav-user-name { font-weight: 600; font-size: 13px; }
.nav-user-role { font-size: 11px; color: var(--faint); }

.main { flex: 1; min-width: 0; padding: 22px 28px 60px; }
.topbar { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar h1 { font-size: 21px; font-weight: 700; letter-spacing: -.4px; }
.topbar .spacer { flex: 1; }

/* ── Buttons, badges, cards ─────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px;
  border-radius: var(--radius-sm); font-weight: 600; font-size: 13px;
  border: 1px solid var(--border); background: var(--card); color: var(--ink);
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: var(--bg); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.danger { color: var(--danger); border-color: #f3cdcd; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); background: var(--bg); }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px;
  border-radius: 20px; font-size: 11.5px; font-weight: 600;
}
.badge.blue { background: var(--blue-soft); color: var(--blue-dark); }
.badge.green { background: var(--ok-soft); color: var(--ok); }
.badge.amber { background: var(--warn-soft); color: var(--warn); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.gray { background: #eef1f6; color: var(--muted); }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-pad { padding: 18px 20px; }
.card h3 { font-size: 14px; font-weight: 700; margin-bottom: 12px; }

.grid-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { padding: 16px 18px; }
.kpi .kpi-num { font-size: 26px; font-weight: 700; letter-spacing: -.8px; margin: 6px 0 2px; }
.kpi .kpi-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.kpi .kpi-sub { font-size: 11.5px; color: var(--faint); }

/* ── Tables ─────────────────────────────────────────── */
table.list { width: 100%; border-collapse: collapse; }
table.list th {
  text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; color: var(--faint); padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
table.list td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.list tr:last-child td { border-bottom: none; }
table.list tbody tr { transition: background .1s; }
table.list tbody tr:hover { background: #fafbfd; }
table.list tbody tr.clickable { cursor: pointer; }

/* ── Calendar ───────────────────────────────────────── */
.cal-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cal-date { font-size: 15px; font-weight: 700; min-width: 210px; text-align: center; }
.seg { display: inline-flex; background: #eef1f6; border-radius: var(--radius-sm); padding: 3px; }
.seg button { padding: 5px 14px; border-radius: 6px; font-weight: 600; font-size: 12.5px; color: var(--muted); }
.seg button.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(16,30,54,.12); }

.cal-wrap { overflow-x: auto; }
.cal { display: grid; min-width: 640px; position: relative; }
.cal-head {
  position: sticky; top: 0; z-index: 5; background: var(--card);
  border-bottom: 1px solid var(--border); padding: 10px 8px;
  font-weight: 600; font-size: 13px; text-align: center;
}
.cal-head .cal-head-sub { font-size: 11px; color: var(--faint); font-weight: 500; }
.cal-head .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.cal-timecol { border-right: 1px solid var(--border); }
.time-label {
  height: 48px; font-size: 10.5px; color: var(--faint); text-align: right;
  padding-right: 8px; transform: translateY(-6px); font-weight: 600;
}
.cal-col { position: relative; border-right: 1px solid var(--border); }
.cal-col:last-child { border-right: none; }
.hour-line { height: 48px; border-bottom: 1px solid #eef1f6; }
.hour-line.closed { background: repeating-linear-gradient(-45deg, #f4f6f9 0 6px, #fafbfd 6px 12px); }
.chip {
  position: absolute; left: 4px; right: 4px; border-radius: 7px; padding: 4px 7px;
  font-size: 11.5px; overflow: hidden; cursor: pointer; z-index: 2;
  border-left: 3px solid; box-shadow: 0 1px 3px rgba(16,30,54,.08);
  transition: box-shadow .12s, transform .12s;
}
.chip:hover { box-shadow: var(--shadow-lg); z-index: 3; transform: translateY(-1px); }
.chip .chip-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip .chip-sub { color: rgba(28,36,52,.72); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 10.5px; }
.chip.st-completed { opacity: .55; }
.chip.st-arrived { outline: 2px solid var(--warn); outline-offset: -2px; }
.chip.st-booked { border-style: dashed; border-width: 1px 1px 1px 3px; }

/* ── Modal ──────────────────────────────────────────── */
.modal-back {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px;
  animation: fade .15s ease;
}
.modal {
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px; max-height: 86vh; overflow-y: auto;
  animation: pop .18s cubic-bezier(.2, .9, .3, 1.2);
}
.modal.wide { max-width: 720px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 0;
}
.modal-head h2 { font-size: 17px; font-weight: 700; letter-spacing: -.3px; }
.modal-body { padding: 8px 22px 22px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 0 22px 20px; }
.x-btn { color: var(--faint); font-size: 22px; line-height: 1; padding: 4px 8px; border-radius: 6px; }
.x-btn:hover { background: var(--bg); color: var(--ink); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(8px); } }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.slot-pills { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 6px; }
.slot-pill {
  padding: 6px 12px; border-radius: 20px; border: 1px solid var(--border);
  font-weight: 600; font-size: 12.5px; background: var(--card);
}
.slot-pill:hover { border-color: var(--blue); color: var(--blue); }
.slot-pill.active { background: var(--blue); border-color: var(--blue); color: #fff; }

/* ── Patient detail ─────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab {
  padding: 9px 16px; font-weight: 600; font-size: 13px; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.patient-head { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.patient-head .avatar { width: 52px; height: 52px; font-size: 18px; border-radius: 16px; }
.patient-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -.4px; }
.patient-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* Odontogram */
.odo { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; padding: 10px 0 16px; overflow-x: auto; }
.odo-row { display: flex; gap: 4px; flex-shrink: 0; margin: 0 auto; }
.tooth { flex-shrink: 0; }
.odo-gap { width: 14px; }
.tooth {
  width: 34px; height: 40px; border: 1px solid var(--border); border-radius: 7px;
  background: var(--card); font-size: 10.5px; font-weight: 700; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  transition: border-color .1s, background .1s;
}
.tooth:hover { border-color: var(--blue); }
.tooth .t-dot { width: 8px; height: 8px; border-radius: 50%; }
.tooth.planned { background: var(--warn-soft); border-color: #ecd4ae; }
.tooth.completed { background: var(--ok-soft); border-color: #bfe3cf; }
.tooth.selected { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }

/* ── Chat panel ─────────────────────────────────────── */
.chat-fab {
  position: fixed; right: 26px; bottom: 26px; z-index: 40;
  width: 54px; height: 54px; border-radius: 50%; background: var(--blue); color: #fff;
  box-shadow: var(--shadow-lg); display: flex; align-items: center; justify-content: center;
  transition: transform .12s;
}
.chat-fab:hover { transform: scale(1.06); }
.chat-panel {
  position: fixed; right: 26px; bottom: 92px; z-index: 40; width: 360px; max-width: calc(100vw - 40px);
  height: 480px; display: flex; flex-direction: column; overflow: hidden;
  border-radius: 16px; animation: pop .18s cubic-bezier(.2,.9,.3,1.2);
}
.chat-head { padding: 14px 16px; background: var(--blue); color: #fff; font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.chat-head small { display: block; font-weight: 500; opacity: .85; font-size: 11px; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 9px; background: var(--bg); }
.msg { max-width: 82%; padding: 9px 12px; border-radius: 14px; font-size: 13px; line-height: 1.45; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--card); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.typing { color: var(--faint); font-style: italic; }
.chat-input { display: flex; gap: 8px; padding: 10px; background: var(--card); border-top: 1px solid var(--border); }

/* ── Login ──────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card { width: 380px; padding: 34px; }
.login-card .brand { justify-content: center; padding-bottom: 8px; }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 10px; }

/* ── Misc ───────────────────────────────────────────── */
.empty { text-align: center; color: var(--faint); padding: 34px 10px; font-size: 13px; }
.section-gap { margin-top: 20px; }
.two-col { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
@media (max-width: 1080px) { .two-col { grid-template-columns: 1fr; } }
.demo-banner {
  background: var(--warn-soft); color: var(--warn); border: 1px solid #ecd4ae;
  border-radius: var(--radius-sm); padding: 8px 14px; font-size: 12.5px; font-weight: 600;
  margin-bottom: 16px;
}
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); z-index: 100;
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px;
  font-weight: 600; font-size: 13px; box-shadow: var(--shadow-lg); animation: pop .2s;
}
.search-results {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 10; margin-top: 4px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); max-height: 220px; overflow-y: auto;
}
.search-item { padding: 9px 12px; cursor: pointer; }
.search-item:hover { background: var(--blue-soft); }
.search-item small { color: var(--faint); display: block; }
.rel { position: relative; }
