/* ==========================================================================
   Area Dental — staff console

   Shares the public site's palette so the two feel like one practice, but the
   density is deliberately different. The website is a brochure read once by a
   stranger; this is a tool used a hundred times a day by two people who already
   know what everything means. Bigger tap targets, smaller type, less air.
   ========================================================================== */

:root {
  --teal-900: #0d3b3f;
  --teal-800: #14514f;
  --teal-700: #1a6560;
  --teal-600: #217b73;
  --teal-500: #2f958a;
  --teal-200: #c3e5e0;
  --teal-100: #e3f2ef;
  --teal-50:  #f2f9f7;

  --terra-700: #8f4225;
  --terra-600: #b4512e;
  --terra-100: #fdeade;

  --sand-100: #f8f2e9;
  --sand-50:  #fdfaf5;

  --ink-900: #1b1a18;
  --ink-800: #2d2b28;
  --ink-700: #46433e;
  --ink-600: #635f58;
  --ink-500: #6f6a62;   /* lightest grey permitted for TEXT */
  --ink-400: #a8a29a;   /* DECORATIVE ONLY — borders, dots, never words */
  --ink-300: #cdc8c0;
  --ink-200: #e5e1da;
  --ink-100: #f2efea;
  --white: #fff;

  --bg: #f6f4f0;
  --card: var(--white);
  --text: var(--ink-800);
  --muted: var(--ink-600);
  --faint: var(--ink-500);
  --border: var(--ink-200);
  --brand: var(--teal-700);
  --whatsapp: #128c4a;      /* darkened from #25d366 (1.7:1) so it can carry white text */
  --success: #2f7d5c;
  --warn: #8a6100;
  --danger: #b3271b;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --font-hi: "Noto Sans Devanagari", "Nirmala UI", var(--font);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --r: 10px;
  --shadow: 0 1px 2px rgba(27,26,24,.06), 0 4px 14px rgba(27,26,24,.05);
  --nav-w: 200px;
  --top-h: 56px;
}

* { box-sizing: border-box; }

/* The HTML `hidden` attribute works through a user-agent rule of essentially zero
   specificity: [hidden] { display: none }. Any class that sets `display` beats it.
   That is not a corner case here - it broke three things at once:

     .gate         display: grid        the sign-in overlay never went away after a
                                        successful login, so the dashboard loaded
                                        underneath an opaque full-screen panel
     .pill         display: inline-block  the nav badges showed "0" instead of hiding
     .sidenav a    display: flex        the owner-only Money link stayed visible

   `!important` is deliberate. `hidden` means hidden, and nothing in this file
   should be able to argue with it. */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: var(--font);
  font-size: 15px; line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { margin: 0 0 .4rem; line-height: 1.2; font-weight: 650; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .92rem; }
p  { margin: 0 0 .6rem; }
a  { color: var(--brand); }

/* ── gate ─────────────────────────────────────────────────────────────── */

.gate {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; padding: 1.5rem;
  background: linear-gradient(160deg, var(--teal-900), var(--teal-700));
}
.gate-card {
  width: min(380px, 100%); background: var(--card);
  border-radius: 14px; padding: 1.6rem; box-shadow: 0 18px 50px rgba(0,0,0,.28);
}
.gate-mark {
  font-size: .72rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--brand); font-weight: 700; margin-bottom: .5rem;
}
.gate-note { color: var(--muted); font-size: .82rem; margin-bottom: 1.1rem; }
.gate-error {
  background: #fdeceb; color: var(--danger); border: 1px solid #f3c6c2;
  border-radius: 8px; padding: .5rem .65rem; font-size: .85rem; margin: 0 0 .7rem;
}

/* ── shell ────────────────────────────────────────────────────────────── */

.shell { min-height: 100vh; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--top-h);
  display: flex; align-items: center; gap: .75rem;
  padding: 0 .9rem;
  background: var(--teal-800); color: #fff;
}
.brand { display: flex; align-items: center; gap: .5rem; text-decoration: none; color: #fff; }
.brand-mark {
  display: grid; place-items: center; width: 28px; height: 28px;
  border-radius: 7px; background: rgba(255,255,255,.16);
  font-weight: 700; font-size: .78rem; letter-spacing: .04em;
}
.brand-text { font-weight: 600; font-size: .95rem; }
@media (max-width: 720px) { .brand-text { display: none; } }

.topbar-search { position: relative; flex: 1; max-width: 420px; }
.topbar-search input {
  width: 100%; height: 34px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(255,255,255,.12); color: #fff;
  padding: 0 .7rem; font: inherit; font-size: .88rem;
}
.topbar-search input::placeholder { color: rgba(255,255,255,.72); }
.topbar-search input:focus { outline: 2px solid #fff; outline-offset: 1px; background: rgba(255,255,255,.2); }

.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--shadow); overflow: hidden; max-height: 60vh; overflow-y: auto;
}
.search-results a {
  display: flex; justify-content: space-between; gap: .5rem;
  padding: .55rem .7rem; text-decoration: none; color: var(--text); font-size: .88rem;
  border-bottom: 1px solid var(--ink-100);
}
.search-results a:last-child { border-bottom: 0; }
.search-results a:hover, .search-results a:focus { background: var(--teal-50); }
.search-results .empty { padding: .7rem; color: var(--faint); font-size: .85rem; }

.topbar-right { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
.whoami { font-size: .8rem; color: rgba(255,255,255,.88); }
@media (max-width: 860px) { .whoami { display: none; } }

.hamburger { display: none; background: none; border: 0; padding: .35rem; cursor: pointer; }
.hamburger span { display: block; width: 20px; height: 2px; background: #fff; margin: 4px 0; border-radius: 2px; }

.sidenav {
  position: fixed; top: var(--top-h); bottom: 0; left: 0; width: var(--nav-w);
  background: var(--card); border-right: 1px solid var(--border);
  padding: .7rem .5rem; display: flex; flex-direction: column; gap: 2px; z-index: 20;
}
.sidenav a {
  display: flex; align-items: center; gap: .5rem;
  padding: .55rem .7rem; border-radius: 8px;
  color: var(--ink-700); text-decoration: none; font-size: .9rem; font-weight: 500;
}
.sidenav a:hover { background: var(--ink-100); }
.sidenav a[aria-current="page"] { background: var(--teal-100); color: var(--teal-800); font-weight: 650; }
.sidenav-foot { margin-top: auto; padding: .6rem .7rem; font-size: .72rem; color: var(--faint); }
.muted-xs { font-size: .7rem; color: var(--faint); margin-top: .2rem; }

.view { padding: 1.1rem 1.2rem 4rem; margin-left: var(--nav-w); }
.view:focus { outline: none; }

@media (max-width: 860px) {
  .hamburger { display: block; }
  .sidenav { transform: translateX(-100%); transition: transform .18s ease; box-shadow: var(--shadow); }
  .sidenav.open { transform: none; }
  .view { margin-left: 0; padding: .9rem .8rem 5rem; }
}

/* ── layout bits ──────────────────────────────────────────────────────── */

.page-head {
  display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap;
  margin-bottom: .9rem;
}
.page-head .sub { color: var(--muted); font-size: .85rem; }
.page-head .spacer { flex: 1; }

.grid { display: grid; gap: .8rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r); padding: .85rem; box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; gap: .5rem; margin-bottom: .6rem;
}
.card-head h2 { margin: 0; }
.card-head .spacer { flex: 1; }

.section { margin-bottom: 1.3rem; }

/* ── stats ────────────────────────────────────────────────────────────── */

.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--r); padding: .75rem .85rem; }
.stat .label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.stat .value { font-size: 1.5rem; font-weight: 680; letter-spacing: -.01em; margin-top: .15rem; }
.stat .value.small { font-size: 1.15rem; }
.stat .foot { font-size: .78rem; color: var(--muted); margin-top: .2rem; }

/* An estimated figure must never look like a banked one. Dashed border, tinted
   ground, explicit label — the difference has to survive a glance across a room. */
.stat.is-estimate {
  border-style: dashed; border-color: var(--ink-300); background: var(--sand-50);
}
.stat.is-estimate .value { color: var(--ink-700); }
.tag-estimate {
  display: inline-block; font-size: .64rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--terra-700); background: var(--terra-100);
  border-radius: 4px; padding: .1rem .3rem; vertical-align: 2px; margin-left: .35rem;
}

/* ── buttons ──────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-height: 36px; padding: .4rem .8rem;
  border: 1px solid transparent; border-radius: 8px;
  font: inherit; font-size: .87rem; font-weight: 560; line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  background: var(--white); color: var(--ink-700); border-color: var(--border);
}
.btn:hover { background: var(--ink-100); }
.btn:focus-visible { outline: 2px solid var(--teal-600); outline-offset: 2px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--teal-800); }
.btn-wa { background: var(--whatsapp); color: #fff; border-color: var(--whatsapp); }
.btn-wa:hover { background: #0f7a40; }
.btn-danger { color: var(--danger); border-color: #edc8c4; background: #fff; }
.btn-danger:hover { background: #fdeceb; }
.btn-ghost { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.26); }
.btn-ghost:hover { background: rgba(255,255,255,.24); }
.btn-sm { min-height: 30px; padding: .25rem .55rem; font-size: .8rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: .4rem; }

/* ── forms ────────────────────────────────────────────────────────────── */

.field { display: block; margin-bottom: .7rem; }
.field > span { display: block; font-size: .78rem; font-weight: 600; color: var(--ink-700); margin-bottom: .22rem; }
.field .hint { display: block; font-weight: 400; font-size: .74rem; color: var(--faint); margin-top: .2rem; }
input[type=text], input[type=email], input[type=password], input[type=search],
input[type=tel], input[type=date], input[type=time], input[type=number],
input[type=datetime-local], select, textarea {
  width: 100%; min-height: 38px; padding: .4rem .55rem;
  border: 1px solid var(--ink-300); border-radius: 8px;
  font: inherit; font-size: .9rem; background: #fff; color: var(--text);
}
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--teal-600); outline-offset: -1px; border-color: var(--teal-600);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }
.check { display: flex; gap: .5rem; align-items: flex-start; margin-bottom: .5rem; font-size: .86rem; }
.check input { width: 18px; height: 18px; min-height: 0; margin-top: 1px; flex: none; }

/* ── table / rows ─────────────────────────────────────────────────────── */

.rows { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem .1rem; border-bottom: 1px solid var(--ink-100);
}
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .name { font-weight: 600; }
.row .meta { font-size: .8rem; color: var(--muted); }
.row .when { font-variant-numeric: tabular-nums; font-weight: 650; min-width: 74px; }
.row.is-urgent { background: linear-gradient(90deg, #fff6f2, transparent 60%); }

.table { width: 100%; border-collapse: collapse; font-size: .87rem; }
.table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
            color: var(--faint); padding: .3rem .5rem .3rem 0; border-bottom: 1px solid var(--border); }
.table td { padding: .45rem .5rem .45rem 0; border-bottom: 1px solid var(--ink-100); vertical-align: top; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; padding-right: 0; }

/* ── badges ───────────────────────────────────────────────────────────── */

.badge {
  display: inline-block; font-size: .7rem; font-weight: 650; letter-spacing: .02em;
  padding: .12rem .4rem; border-radius: 5px;
  background: var(--ink-100); color: var(--ink-700);
}
.badge-scheduled { background: var(--teal-100); color: var(--teal-800); }
.badge-confirmed { background: var(--teal-200); color: var(--teal-900); }
.badge-arrived   { background: #fff2cc; color: #6b4e00; }
.badge-in_chair  { background: #ffe0c2; color: #7a3d00; }
.badge-completed { background: #ddf0e5; color: #1d5c3f; }
.badge-no_show   { background: #fde3e0; color: #8f231a; }
.badge-cancelled { background: var(--ink-100); color: var(--ink-600); }
.badge-unpaid    { background: #fde3e0; color: #8f231a; }
.badge-partial   { background: #fff2cc; color: #6b4e00; }
.badge-paid      { background: #ddf0e5; color: #1d5c3f; }
.badge-urgent    { background: var(--terra-100); color: var(--terra-700); }
.badge-hi        { background: #ece4f7; color: #4a2f7a; }

/* ── message cards ────────────────────────────────────────────────────── */

.msg { border: 1px solid var(--border); border-radius: var(--r); background: var(--card); padding: .7rem; }
.msg + .msg { margin-top: .6rem; }
.msg-top { display: flex; align-items: center; gap: .5rem; margin-bottom: .45rem; flex-wrap: wrap; }
.msg-body {
  white-space: pre-wrap; font-size: .85rem; color: var(--ink-700);
  background: var(--sand-100); border-radius: 8px; padding: .55rem .65rem;
  max-height: 8.5rem; overflow: auto;
}
.msg-body.hi { font-family: var(--font-hi); }
.msg-foot { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .55rem; align-items: center; }
.msg.is-opened { border-color: var(--teal-500); box-shadow: 0 0 0 2px var(--teal-100); }
.msg.is-done { opacity: .62; }

/* Opening WhatsApp is not evidence a message was delivered. The console keeps the
   two states visually apart so nobody reads "opened" as "sent". */
.await-confirm {
  font-size: .78rem; color: var(--teal-800); background: var(--teal-50);
  border: 1px dashed var(--teal-500); border-radius: 7px; padding: .3rem .5rem;
}

/* ── misc ─────────────────────────────────────────────────────────────── */

.empty { padding: 1.4rem .8rem; text-align: center; color: var(--faint); font-size: .88rem; }
.empty strong { display: block; color: var(--ink-700); font-size: .95rem; margin-bottom: .2rem; }
.error-box {
  background: #fdeceb; border: 1px solid #f3c6c2; color: #8f231a;
  border-radius: var(--r); padding: .7rem .8rem; font-size: .87rem;
}
.note {
  font-size: .78rem; color: var(--muted); background: var(--sand-100);
  border-radius: 7px; padding: .4rem .55rem; margin-top: .4rem;
}
.pill {
  display: inline-block; min-width: 20px; text-align: center;
  font-size: .7rem; font-weight: 700; border-radius: 999px;
  background: var(--teal-600); color: #fff; padding: .05rem .35rem; margin-left: auto;
}
.pill-urgent { background: var(--terra-600); }
.mono { font-family: var(--mono); font-size: .78rem; color: var(--muted); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.spinner {
  width: 18px; height: 18px; border: 2px solid var(--ink-300); border-top-color: var(--brand);
  border-radius: 50%; animation: spin .7s linear infinite; margin: 1.4rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--border); margin-bottom: .8rem; overflow-x: auto; }
.tabs button {
  background: none; border: 0; border-bottom: 2px solid transparent;
  padding: .45rem .7rem; font: inherit; font-size: .87rem; font-weight: 550;
  color: var(--muted); cursor: pointer; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--teal-800); border-bottom-color: var(--teal-600); }

/* ── toasts & modal ───────────────────────────────────────────────────── */

.toasts { position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); z-index: 80;
          display: flex; flex-direction: column; gap: .4rem; align-items: center; width: min(440px, 92vw); }
.toast {
  background: var(--ink-900); color: #fff; border-radius: 9px;
  padding: .5rem .8rem; font-size: .86rem; box-shadow: 0 8px 24px rgba(0,0,0,.24);
  width: 100%;
}
.toast.err { background: #8f231a; }
.toast.ok  { background: #1d5c3f; }

.modal {
  border: 0; border-radius: 14px; padding: 0; width: min(560px, 94vw);
  box-shadow: 0 24px 60px rgba(0,0,0,.3); color: var(--text);
}
.modal::backdrop { background: rgba(27,26,24,.45); }
.modal-inner { padding: 1rem 1.1rem 1.1rem; }
.modal-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .7rem; }
.modal-head h2 { margin: 0; flex: 1; }
.modal-foot { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .9rem; }
.modal-scroll { max-height: 58vh; overflow-y: auto; }
