/* DigitalCube Clinic Console — plain CSS design system */
:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --fg: #0f172a;
  --muted: #64748b;
  --border: #e5e9f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff4ff;
  --success: #16a34a;
  --success-soft: #e7f6ec;
  --warning: #d97706;
  --warning-soft: #fdf3e3;
  --danger: #dc2626;
  --danger-soft: #fdeaea;
  --sidebar: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.05);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 14px; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 256px;
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  transition: transform 0.25s ease;
}
.sidebar__header { padding: 18px 16px; border-bottom: 1px solid var(--border); }
.sidebar__group-label {
  padding: 16px 20px 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}
.sidebar__nav { padding: 0 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--muted); font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--bg); color: var(--fg); }
.nav-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-link svg { width: 18px; height: 18px; }
.sidebar__footer { padding: 12px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px; }
.avatar {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.user-chip__name { font-weight: 600; font-size: 13px; }
.user-chip__mail { font-size: 12px; color: var(--muted); }

.brand { display: flex; align-items: center; gap: 10px; }
.brand__mark {
  width: 36px; height: 36px; border-radius: 11px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.brand__name { font-weight: 800; letter-spacing: -0.01em; line-height: 1; }
.brand__sub { font-size: 11px; color: var(--muted); font-weight: 500; }

.main { flex: 1; margin-left: 256px; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 60px; display: flex; align-items: center; gap: 12px;
  padding: 0 24px; border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.85); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 30;
}
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: #fff; display: none; align-items: center; justify-content: center; color: var(--fg);
}
.topbar__title { font-weight: 600; }
.content { padding: 24px; max-width: 1200px; width: 100%; }

.overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.4);
  z-index: 39; display: none;
}
.overlay.show { display: block; }

/* ---------- Page header ---------- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.page-header p { color: var(--muted); margin-top: 4px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; font-size: 14px; transition: background 0.15s, border 0.15s;
}
.btn svg { width: 16px; height: 16px; }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-hover); }
.btn--outline { background: #fff; border-color: var(--border); color: var(--fg); }
.btn--outline:hover { background: var(--bg); }
.btn--ghost { background: transparent; color: var(--muted); }
.btn--ghost:hover { background: var(--bg); color: var(--fg); }
.btn--sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn--success { background: var(--success); color: #fff; }
.btn--success:hover { filter: brightness(0.95); }
.btn--block { width: 100%; justify-content: center; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card__body { padding: 20px; }
.card__header { padding: 18px 20px; border-bottom: 1px solid var(--border); }
.card__title { font-weight: 600; }
.card__desc { color: var(--muted); font-size: 13px; margin-top: 2px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat { padding: 18px 20px; }
.stat__top { display: flex; align-items: center; justify-content: space-between; }
.stat__label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat__icon { width: 38px; height: 38px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; }
.stat__value { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; margin-top: 12px; }
.stat__delta { font-size: 12px; margin-top: 4px; color: var(--success); font-weight: 600; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 14px 16px; white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); }
td { border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg); }
.cell-strong { font-weight: 600; }
.cell-sub { color: var(--muted); font-size: 13px; }

/* ---------- Badge ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--pending { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge--confirmed { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge--cancelled { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* ---------- Search ---------- */
.search { position: relative; max-width: 320px; width: 100%; }
.search input { width: 100%; padding: 9px 12px 9px 36px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.search input:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.field textarea { resize: vertical; min-height: 90px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 6px; }

/* ---------- Toggle ---------- */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.switch input { display: none; }
.slider { position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px; transition: 0.2s; }
.slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.2s; }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.toggle-row:last-child { border-bottom: none; }

/* ---------- Charts ---------- */
.chart-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.chart-box { height: 300px; padding: 20px; }

/* ---------- Conversations ---------- */
.convo { display: grid; grid-template-columns: 320px 1fr; height: calc(100vh - 60px - 48px); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: #fff; }
.convo__list { border-right: 1px solid var(--border); overflow-y: auto; }
.convo__item { display: flex; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.convo__item:hover { background: var(--bg); }
.convo__item.active { background: var(--primary-soft); }
.convo__meta { flex: 1; min-width: 0; }
.convo__name { font-weight: 600; display: flex; justify-content: space-between; }
.convo__time { font-size: 12px; color: var(--muted); font-weight: 400; }
.convo__last { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unread { background: var(--primary); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px; }
.chat { display: flex; flex-direction: column; min-width: 0; }
.chat__header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.chat__body { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.bubble { max-width: 75%; padding: 9px 13px; border-radius: 14px; font-size: 14px; }
.bubble--patient { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.bubble--bot { align-self: flex-start; background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble__time { display: block; font-size: 10px; opacity: 0.7; margin-top: 3px; }
.chat__input { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; }
.chat__input input { flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: 999px; }

/* ---------- Code snippet ---------- */
.code-box { position: relative; background: #0f172a; color: #e2e8f0; border-radius: var(--radius); padding: 20px; overflow-x: auto; font-family: "SFMono-Regular", ui-monospace, Menlo, monospace; font-size: 13px; line-height: 1.7; }
.code-box .copy { position: absolute; top: 12px; right: 12px; }
.code-box .tok { color: #7dd3fc; }
.code-box .str { color: #86efac; }

/* ---------- Topbar extras ---------- */
.topbar__clinic { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.topbar__spacer { flex: 1; }
.plan-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; border: 1px solid transparent; }
.plan-badge--pro { background: var(--primary-soft); color: var(--primary); }
.plan-badge--trial { background: var(--warning-soft); color: var(--warning); }
.plan-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- User menu ---------- */
.usermenu { position: relative; }
.usermenu__btn { display: flex; align-items: center; gap: 8px; padding: 5px 8px 5px 5px; border-radius: 999px; border: 1px solid var(--border); background: #fff; }
.usermenu__btn .avatar { width: 30px; height: 30px; border-radius: 999px; font-size: 12px; }
.usermenu__name { font-weight: 600; font-size: 13px; }
.usermenu__chev { width: 16px; height: 16px; color: var(--muted); }
.usermenu__pop { position: absolute; right: 0; top: calc(100% + 8px); width: 220px; background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; display: none; z-index: 50; }
.usermenu__pop.show { display: block; }
.usermenu__head { padding: 10px 10px 8px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.usermenu__item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 8px; border: none; background: transparent; color: var(--fg); font-weight: 500; text-align: left; }
.usermenu__item:hover { background: var(--bg); }
.usermenu__item svg { width: 16px; height: 16px; }
.usermenu__item--danger { color: var(--danger); }

/* ---------- Toolbar / filter tabs ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .search { max-width: 300px; }
.toolbar__spacer { flex: 1; }
.seg { display: inline-flex; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 4px; gap: 2px; }
.seg button { border: none; background: transparent; padding: 6px 14px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--muted); }
.seg button.active { background: var(--primary-soft); color: var(--primary); }
.seg button:hover:not(.active) { color: var(--fg); }
.seg .count { font-size: 11px; opacity: 0.7; margin-left: 4px; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 56px 24px; }
.empty__icon { width: 56px; height: 56px; border-radius: 16px; background: var(--primary-soft); color: var(--primary); display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.empty__icon svg { width: 26px; height: 26px; }
.empty h3 { font-size: 16px; font-weight: 700; }
.empty p { color: var(--muted); margin-top: 6px; max-width: 360px; margin-left: auto; margin-right: auto; }
.empty .btn { margin-top: 16px; }

/* ---------- Skeleton loaders ---------- */
@keyframes shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }
.skel { background: #eef2f7; background-image: linear-gradient(90deg, #eef2f7 0px, #f7f9fc 200px, #eef2f7 400px); background-size: 800px 100%; animation: shimmer 1.2s infinite linear; border-radius: 8px; }
.skel-line { height: 12px; margin: 8px 0; }
.skel-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.skel-circle { width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0; }

/* ---------- Color swatches ---------- */
.swatches { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.swatch { width: 30px; height: 30px; border-radius: 8px; border: 2px solid transparent; cursor: pointer; }
.swatch.active { border-color: var(--fg); box-shadow: 0 0 0 2px #fff inset; }

/* ---------- Weekday checkboxes ---------- */
.weekdays { display: flex; gap: 8px; flex-wrap: wrap; }
.weekday { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--border); border-radius: 999px; font-weight: 600; font-size: 13px; cursor: pointer; user-select: none; }
.weekday input { accent-color: var(--primary); }
.weekday.on { background: var(--primary-soft); border-color: transparent; color: var(--primary); }

/* ---------- Platform logos ---------- */
.platforms { display: flex; gap: 10px; flex-wrap: wrap; }
.platform { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1px solid var(--border); border-radius: 10px; font-weight: 600; font-size: 13px; background: #fff; }
.platform .dot { width: 22px; height: 22px; border-radius: 6px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 800; }

/* ---------- Section grid ---------- */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.list-badge { display: inline-flex; align-items: center; gap: 4px; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth__aside { background: linear-gradient(160deg, #2563eb, #1e40af); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth__aside h2 { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; margin-top: 24px; }
.auth__aside p { opacity: 0.85; margin-top: 12px; max-width: 380px; }
.auth__features { display: flex; flex-direction: column; gap: 14px; margin-top: 32px; }
.auth__feature { display: flex; gap: 12px; align-items: center; }
.auth__feature .dot { width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,0.15); display: flex; align-items: center; justify-content: center; }
.auth__main { display: flex; align-items: center; justify-content: center; padding: 32px; }
.auth__card { width: 100%; max-width: 400px; }
.tabs { display: flex; background: var(--bg); border-radius: 10px; padding: 4px; margin-bottom: 24px; }
.tab { flex: 1; text-align: center; padding: 8px; border-radius: 8px; font-weight: 600; color: var(--muted); cursor: pointer; border: none; background: transparent; }
.tab.active { background: #fff; color: var(--fg); box-shadow: var(--shadow); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.hidden { display: none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth__aside { display: none; }
  .convo { grid-template-columns: 1fr; }
  .convo__list { display: none; }
  .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .icon-btn { display: flex; }
}
@media (max-width: 520px) {
  .stats-grid { grid-template-columns: 1fr; }
}