/* ─────────────────────────────────────────────────────────────────────────
   Denty Admin — same palette as the widget, adapted for data density
   ────────────────────────────────────────────────────────────────────── */
:root {
  --bg: #FAF6F0;
  --bg-soft: #F2EBE0;
  --bg-elevated: #FFFFFF;
  --bg-hover: #F7F1E5;
  --ink: #1F1B16;
  --ink-soft: #5A5046;
  --ink-mute: #8C7F70;
  --line: #E5DCCB;
  --line-soft: #EFE8DA;
  --accent: #B05A3E;
  --accent-soft: rgba(176, 90, 62, 0.08);
  --green: #4F8B5E;
  --amber: #B8841C;
  --red: #B0413E;
  --shadow-sm: 0 1px 2px rgba(31, 27, 22, 0.04);
  --shadow-md: 0 4px 16px rgba(31, 27, 22, 0.08);
  --shadow-lift: 0 12px 32px -8px rgba(31, 27, 22, 0.18), 0 4px 12px rgba(31, 27, 22, 0.08);

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "DM Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

/* Critical: [hidden] must override display:grid/flex on shell containers */
[hidden] { display: none !important; }

body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
input, textarea { border: 0; background: transparent; outline: none; }

/* ─────────────────────────────────────────────────────────────────────────
   LOGIN
   ────────────────────────────────────────────────────────────────────── */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    radial-gradient(circle at 20% 0%, rgba(176, 90, 62, 0.05), transparent 50%),
    radial-gradient(circle at 100% 80%, rgba(176, 90, 62, 0.05), transparent 50%),
    var(--bg);
}
.login__card {
  width: 100%;
  max-width: 420px;
  padding: 48px 40px;
  background: var(--bg-elevated);
  border-radius: 22px;
  box-shadow: var(--shadow-md);
}
.login__logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}
.login__logo-mark {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: var(--ink);
  color: var(--bg);
  border-radius: 50%;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 14px;
}
.login__logo-name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.login__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 32px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}
.login__subtitle {
  color: var(--ink-soft);
  margin-bottom: 24px;
  font-size: 14px;
}
.login__form { display: flex; flex-direction: column; gap: 12px; }
.login__input {
  width: 100%;
  padding: 13px 16px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 14px;
  font-family: var(--font-mono);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.login__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.login__submit {
  padding: 13px 16px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  transition: transform 0.15s var(--ease);
}
.login__submit:hover { transform: translateY(-1px); }
.login__submit:disabled { opacity: 0.5; cursor: wait; transform: none; }
.login__error {
  color: var(--red);
  font-size: 13px;
  min-height: 18px;
}

/* ─────────────────────────────────────────────────────────────────────────
   DASHBOARD SHELL
   ────────────────────────────────────────────────────────────────────── */
.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  background: var(--bg);
}
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
}

/* Sidebar */
.sidebar {
  background: var(--bg-soft);
  padding: 24px 16px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
@media (max-width: 800px) {
  .sidebar {
    position: relative;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: 16px;
    gap: 12px;
  }
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 28px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
@media (max-width: 800px) {
  .sidebar__brand { padding: 0; border: 0; margin: 0; }
}

.sidebar__brand-mark {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--ink);
  color: var(--bg);
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  flex-shrink: 0;
}
.sidebar__brand-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.sidebar__brand-clinic {
  font-size: 12px;
  color: var(--ink-mute);
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
@media (max-width: 800px) {
  .sidebar__nav {
    flex-direction: row;
    flex: 1;
    overflow-x: auto;
  }
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  width: 100%;
  white-space: nowrap;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.sidebar__link:hover { background: var(--bg-hover); color: var(--ink); }
.sidebar__link--active {
  background: var(--bg-elevated);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.sidebar__icon {
  width: 18px;
  text-align: center;
  font-size: 10px;
  color: var(--ink-mute);
}
.sidebar__link--active .sidebar__icon { color: var(--accent); }

.sidebar__badge {
  margin-left: auto;
  padding: 2px 8px;
  background: var(--bg);
  color: var(--ink-soft);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
}
.sidebar__badge--alert { background: var(--red); color: var(--bg); }

.sidebar__bottom { padding: 16px 8px 0; border-top: 1px solid var(--line); }
@media (max-width: 800px) { .sidebar__bottom { padding: 0; border: 0; } }

.sidebar__logout {
  width: 100%;
  padding: 10px 12px;
  color: var(--ink-mute);
  font-size: 13px;
  text-align: left;
  border-radius: 8px;
  transition: color 0.15s var(--ease);
}
.sidebar__logout:hover { color: var(--ink); }

/* Main panel */
.main {
  padding: 40px 48px;
  min-width: 0; /* allow children to shrink */
  overflow-x: hidden;
}
@media (max-width: 800px) { .main { padding: 24px; } }

.main__header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 32px;
}
.main__eyebrow {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 4px;
}
.main__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 36px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.main__stats {
  display: flex;
  gap: 16px;
}
.stat {
  padding: 12px 20px;
  background: var(--bg-elevated);
  border-radius: 12px;
  min-width: 88px;
  box-shadow: var(--shadow-sm);
}
.stat--alert .stat__value { color: var(--red); }
.stat__value {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1;
}
.stat__label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-top: 6px;
}

/* ─────────────────────────────────────────────────────────────────────────
   LEADS TABLE
   ────────────────────────────────────────────────────────────────────── */
.leads__loading {
  padding: 40px 0;
  text-align: center;
  color: var(--ink-mute);
  font-size: 14px;
}

.leads__empty {
  padding: 80px 24px;
  text-align: center;
}
.leads__empty-eyebrow {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 400;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}
.leads__empty-body {
  color: var(--ink-soft);
  max-width: 420px;
  margin: 0 auto;
}

.leads__table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elevated);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.leads__table thead th {
  text-align: left;
  padding: 14px 20px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 500;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.leads__table tbody tr {
  transition: background 0.1s var(--ease);
  cursor: pointer;
}
.leads__table tbody tr:hover { background: var(--bg-hover); }
.leads__table tbody tr:not(:last-child) { border-bottom: 1px solid var(--line-soft); }
.leads__table td {
  padding: 14px 20px;
  vertical-align: top;
}

.lead-name { font-weight: 500; color: var(--ink); }
.lead-contact { font-size: 12px; color: var(--ink-mute); margin-top: 2px; font-family: var(--font-mono); }
.lead-reason { color: var(--ink-soft); max-width: 260px; }
.lead-time { color: var(--ink-mute); font-size: 13px; white-space: nowrap; }

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.pill--urgent { background: rgba(176, 65, 62, 0.12); color: var(--red); }
.pill--normal { background: var(--bg); color: var(--ink-mute); }
.pill--new { background: rgba(79, 139, 94, 0.14); color: var(--green); }
.pill--contacted { background: rgba(184, 132, 28, 0.14); color: var(--amber); }
.pill--booked { background: var(--accent-soft); color: var(--accent); }
.pill--closed { background: var(--bg); color: var(--ink-mute); }

.has-photo {
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  color: var(--accent);
}

/* ─────────────────────────────────────────────────────────────────────────
   PHOTOS GRID
   ────────────────────────────────────────────────────────────────────── */
.photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.photo-card {
  background: var(--bg-elevated);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.photo-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.photo-card__img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--bg-soft);
  display: block;
}
.photo-card__meta { padding: 12px 14px; }
.photo-card__name { font-weight: 500; font-size: 13px; }
.photo-card__time { font-size: 12px; color: var(--ink-mute); margin-top: 2px; }

/* ─────────────────────────────────────────────────────────────────────────
   DRAWER (lead detail)
   ────────────────────────────────────────────────────────────────────── */
.drawer {
  position: fixed; inset: 0;
  z-index: 100;
}
.drawer[hidden] { display: none; }

.drawer__backdrop {
  position: absolute; inset: 0;
  background: rgba(31, 27, 22, 0.4);
  backdrop-filter: blur(2px);
  animation: drawerFade 0.2s var(--ease);
}
@keyframes drawerFade { from { opacity: 0; } to { opacity: 1; } }

.drawer__panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(560px, 100vw);
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  animation: drawerSlide 0.35s var(--ease);
}
@keyframes drawerSlide { from { transform: translateX(100%); } to { transform: translateX(0); } }

.drawer__header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 24px 28px;
  border-bottom: 1px solid var(--line);
}
.drawer__close {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--ink-soft);
  transition: background 0.15s var(--ease);
  flex-shrink: 0;
}
.drawer__close:hover { background: var(--bg-soft); color: var(--ink); }
.drawer__eyebrow {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 4px;
}
.drawer__title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 40px;
}
.drawer__loading { color: var(--ink-mute); padding: 24px 0; }

.detail-section { margin-bottom: 32px; }
.detail-section__title {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 12px;
  font-weight: 500;
}
.detail-table {
  width: 100%;
  border-collapse: collapse;
}
.detail-table td {
  padding: 8px 0;
  font-size: 14px;
  vertical-align: top;
}
.detail-table td:first-child {
  width: 130px;
  color: var(--ink-mute);
  font-size: 13px;
}
.detail-table td a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}
.detail-table td a:hover { border-color: var(--accent); }

/* Status switcher */
.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.status-btn {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  background: var(--bg-elevated);
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.status-btn:hover { border-color: var(--ink-mute); color: var(--ink); }
.status-btn--active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

/* Notes box */
.notes-box {
  width: 100%;
  min-height: 80px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  font-family: var(--font-body);
  resize: vertical;
  transition: border-color 0.15s var(--ease);
}
.notes-box:focus { border-color: var(--accent); }

/* Transcript */
.transcript-msg {
  max-width: 90%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  margin-bottom: 8px;
}
.transcript-msg--user {
  align-self: flex-end;
  background: var(--ink);
  color: var(--bg);
  border-bottom-right-radius: 4px;
  margin-left: auto;
}
.transcript-msg--assistant {
  align-self: flex-start;
  background: var(--bg-soft);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}
.transcript-list {
  display: flex;
  flex-direction: column;
}
.transcript-img {
  max-width: 200px;
  border-radius: 10px;
  margin-top: 4px;
}

/* Photos in drawer */
.detail-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
.detail-photo {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  background: var(--bg-soft);
}
