/* Pharmafy v2 — liquid-glass theme.
 * Translucent surfaces, soft gradients, floating panels.
 * Tuned for iPadOS 26 (WKWebView) and modern desktop browsers.
 */

:root {
  /* Brand */
  --brand-red: #e74c3c;
  --brand-red-dk: #c0392b;
  --brand-pink: #f2b8b5;
  --brand-coral: #ff7a6c;

  /* Accent */
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --ok: #059669;
  --warn: #d97706;
  --danger: #b91c1c;

  /* Neutrals */
  --bg: #f3f5fa;
  --bg-2: #e8edf6;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-strong: rgba(255, 255, 255, 0.92);
  --surface-elevated: rgba(255, 255, 255, 0.85);
  --text: #1d2230;
  --text-muted: #5b6573;
  --text-faint: #97a0ad;
  --hairline: rgba(15, 23, 42, 0.08);
  --hairline-strong: rgba(15, 23, 42, 0.14);

  /* Layout */
  --sidebar-w: 260px;
  --topbar-h: 60px;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;

  /* Shadows */
  --shadow-1: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-2: 0 6px 20px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-3: 0 18px 50px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.08);

  /* Glass */
  --glass-bg: rgba(255, 255, 255, 0.6);
  --glass-border: rgba(255, 255, 255, 0.55);
  --glass-shadow: 0 8px 32px rgba(15, 23, 42, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  --glass-blur: saturate(1.7) blur(22px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "DM Sans", system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;

  /* Soft, animated background — adds dimension behind the glass panels */
  background:
    radial-gradient(1200px 700px at 110% -10%, rgba(231, 76, 60, 0.16), transparent 60%),
    radial-gradient(900px 600px at -10% 120%, rgba(37, 99, 235, 0.10), transparent 55%),
    linear-gradient(180deg, #f6f8fc 0%, #eef1f8 100%);
  background-attachment: fixed;
}

@supports (font-variation-settings: normal) {
  body { font-family: "SF Pro Text", -apple-system, BlinkMacSystemFont, "DM Sans", system-ui, sans-serif; }
}

a { color: var(--accent); text-decoration: none; transition: color 0.15s; }
a:hover { color: #1e40af; text-decoration: underline; text-underline-offset: 3px; }
button { font: inherit; }

/* ---------------------- Shell ---------------------- */
/* Flexbox shell. Predictable on every iPad/iOS WebKit version. */
.shell {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}

aside.sidebar {
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  position: sticky;
  top: 0;
  align-self: stretch;
  height: 100vh;
  padding: 14px;
  background: transparent;
  border-right: none;
  transition: flex-basis 0.28s ease, width 0.28s ease, transform 0.28s ease;
}

main {
  flex: 1 1 auto;
  min-width: 0;            /* let main shrink instead of pushing past viewport */
  display: flex;
  flex-direction: column;
}

/* Rail mode (icons-only) — wide screens only */
.shell[data-sb="rail"] aside.sidebar { flex-basis: 78px; width: 78px; }
.shell[data-sb="rail"] .sidebar-title,
.shell[data-sb="rail"] .auth-strip,
.shell[data-sb="rail"] .nav-list .group,
.shell[data-sb="rail"] .nav-list a span { display: none; }
.shell[data-sb="rail"] .nav-list a { justify-content: center; padding: 11px 0; }
.shell[data-sb="rail"] .sidebar-brand { justify-content: center; padding: 16px 8px; }

/* Narrow / drawer mode */
@media (max-width: 899px) {
  aside.sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    flex: 0 0 auto;
    width: var(--sidebar-w);
    height: 100vh;
    z-index: 50;
    transform: translateX(-110%);
  }
  .shell[data-sb="open"] aside.sidebar { transform: translateX(0); }
  .shell[data-sb="open"] .sidebar-scrim { opacity: 1; pointer-events: auto; }
}

.sidebar-scrim {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.34);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  border: none;
  opacity: 0; pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 40;
  cursor: pointer;
}

.sidebar-inner {
  height: 100%;
  display: flex; flex-direction: column;
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  overflow: hidden;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 16px 18px;
  border-bottom: 1px solid var(--hairline);
  background: linear-gradient(180deg, rgba(255,255,255,0.4), transparent);
}
.sidebar-brand img { width: 34px; height: 34px; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.08)); }
.sidebar-brand strong { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.02em; }

.auth-strip {
  padding: 14px 18px;
  font-size: 0.86rem;
  border-bottom: 1px solid var(--hairline);
}
.auth-strip .name { font-weight: 600; }
.auth-strip .role {
  display: inline-block; margin-left: 6px;
  font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  background: linear-gradient(180deg, rgba(231,76,60,0.18), rgba(231,76,60,0.10));
  color: var(--brand-red-dk);
  border: 1px solid rgba(231, 76, 60, 0.28);
  border-radius: 999px;
  padding: 2px 9px;
}
.auth-strip a {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.auth-strip a:hover { color: var(--brand-red-dk); }

.nav-list { padding: 10px 8px 16px; flex: 1; overflow-y: auto; }
.nav-list .group {
  font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-faint); padding: 12px 14px 4px; font-weight: 700;
}
.nav-list a {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  margin: 2px 4px;
  font-size: 0.92rem; color: var(--text-muted);
  border-radius: 10px;
  transition: background 0.15s, color 0.15s, transform 0.08s;
  text-decoration: none;
}
.nav-list a svg {
  width: 20px; height: 20px; flex-shrink: 0;
  opacity: 0.85;
}
.nav-list a.is-active svg { opacity: 1; }
.nav-list a:hover {
  background: rgba(255, 255, 255, 0.7);
  color: var(--text);
  transform: translateY(-1px);
  text-decoration: none;
}
.nav-list a.is-active {
  color: var(--brand-red-dk);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.7));
  border: 1px solid rgba(231, 76, 60, 0.18);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.12);
}

/* ---------------------- Top bar ---------------------- */
.topbar {
  position: sticky; top: 0;
  margin: 14px 14px 0 14px;
  padding: 0 18px;
  height: var(--topbar-h);
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 14px;
  color: #fff;
  background:
    linear-gradient(135deg, var(--brand-red) 0%, var(--brand-coral) 100%);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--radius);
  box-shadow:
    0 12px 32px rgba(231, 76, 60, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  z-index: 10;
}
.topbar h1 {
  margin: 0; flex: 1;
  font-size: 1.08rem; font-weight: 700; letter-spacing: -0.02em;
}
.topbar .meta { font-size: 0.84rem; opacity: 0.95; }

.topbar-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s, transform 0.08s;
  -webkit-tap-highlight-color: transparent;
}
.topbar-btn:hover { background: rgba(255, 255, 255, 0.28); }
.topbar-btn:active { transform: scale(0.96); }
.topbar-btn svg { width: 20px; height: 20px; }

main { min-width: 0; }
main .pad { padding: 22px 26px 36px; }
@media (max-width: 820px) {
  aside.sidebar { position: static; height: auto; }
  .sidebar-inner { height: auto; }
  .topbar { margin: 14px; }
  main .pad { padding: 18px; }
}

/* ---------------------- Cards (glass) ---------------------- */
.card {
  position: relative;
  background: var(--surface);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  margin-bottom: 16px;
  overflow: hidden;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.card:hover { box-shadow: var(--shadow-3), inset 0 1px 0 rgba(255, 255, 255, 0.6); }

.card-head {
  padding: 14px 20px;
  border-bottom: 1px solid var(--hairline);
  font-weight: 700;
  font-size: 0.94rem;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.6), rgba(255,255,255,0.15));
  color: #1e3a8a;
}
.card-body { padding: 18px 20px; }

/* ---------------------- KPI tiles ---------------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  background: var(--surface);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}
.kpi .label {
  font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-muted);
}
.kpi .value {
  font-size: 1.85rem; font-weight: 700; margin: 4px 0 2px;
  letter-spacing: -0.03em;
  background: linear-gradient(180deg, #1d2230 0%, #4b5563 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.kpi .sub { font-size: 0.78rem; color: var(--text-muted); }

/* ---------------------- Tables ---------------------- */
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.9rem; }
table.data th, table.data td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--hairline);
  text-align: left;
  vertical-align: top;
}
table.data th {
  font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted);
  background: linear-gradient(180deg, rgba(255,255,255,0.7), rgba(255,255,255,0.4));
  font-weight: 700;
  position: sticky; top: 0;
}
table.data tbody tr { transition: background 0.1s; }
table.data tbody tr:hover { background: rgba(231, 76, 60, 0.04); }
table.data tbody tr:last-child td { border-bottom: none; }

/* ---------------------- Forms ---------------------- */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-muted); margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  font: inherit;
  font-size: 0.92rem;
  padding: 10px 13px;
  border: 1px solid var(--hairline-strong);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--text);
  transition: border 0.12s, box-shadow 0.15s, background 0.12s;
}
.field input:hover, .field select:hover, .field textarea:hover { background: rgba(255, 255, 255, 0.86); }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.16);
}
.field textarea { min-height: 4.5rem; resize: vertical; }
.field .hint { font-size: 0.74rem; color: var(--text-muted); margin-top: 6px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 720px) { .row { grid-template-columns: 1fr; } }

/* ---------------------- Buttons (glass-on-color) ---------------------- */
.btn, button.btn, input[type="submit"].btn {
  font-weight: 700;
  padding: 11px 18px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 12px;
  cursor: pointer;
  letter-spacing: -0.01em;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.18), rgba(255,255,255,0.05)),
    linear-gradient(180deg, var(--accent), #1d4ed8);
  color: #fff;
  box-shadow:
    0 6px 16px rgba(37, 99, 235, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: transform 0.08s, box-shadow 0.15s, filter 0.15s;
}
.btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.btn-secondary {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.9), rgba(255,255,255,0.6));
  color: var(--text);
  border: 1px solid var(--hairline-strong);
  box-shadow: var(--shadow-1);
}
.btn.btn-secondary:hover { background: rgba(255, 255, 255, 1); }
.btn.btn-danger {
  background: linear-gradient(180deg, #ef4444, #b91c1c);
  box-shadow: 0 6px 16px rgba(185, 28, 28, 0.28), inset 0 1px 0 rgba(255,255,255,0.3);
}

/* ---------------------- Tags ---------------------- */
.tag {
  display: inline-flex; align-items: center;
  font-size: 0.72rem; font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(37, 99, 235, 0.15);
}
.tag.ok { background: rgba(5, 150, 105, 0.10); color: var(--ok); border-color: rgba(5, 150, 105, 0.20); }
.tag.warn { background: rgba(217, 119, 6, 0.10); color: var(--warn); border-color: rgba(217, 119, 6, 0.20); }
.tag.danger { background: rgba(185, 28, 28, 0.10); color: var(--danger); border-color: rgba(185, 28, 28, 0.20); }
.tag.muted { background: rgba(15, 23, 42, 0.05); color: var(--text-muted); border-color: var(--hairline); }

/* ---------------------- Flash banners ---------------------- */
.flash {
  padding: 12px 16px;
  border-radius: 14px;
  margin-bottom: 14px;
  font-size: 0.92rem;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid;
}
.flash.ok { background: rgba(220, 252, 231, 0.7); color: #065f46; border-color: rgba(5, 150, 105, 0.25); }
.flash.err { background: rgba(254, 226, 226, 0.7); color: #991b1b; border-color: rgba(185, 28, 28, 0.25); }
.flash.info { background: rgba(219, 234, 254, 0.7); color: #1e3a8a; border-color: rgba(37, 99, 235, 0.22); }

/* ---------------------- Auth pages ---------------------- */
.auth-wrap {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 600px at 50% -10%, rgba(231, 76, 60, 0.30), transparent 60%),
    radial-gradient(700px 500px at 50% 110%, rgba(37, 99, 235, 0.18), transparent 60%),
    linear-gradient(180deg, #fff 0%, #eef1f8 100%);
}
.auth-card {
  width: 100%;
  max-width: 440px;
  padding: 28px 28px 26px;
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.auth-card .brand {
  display: flex; align-items: center; gap: 0.6rem; margin-bottom: 1rem;
}
.auth-card .brand img { width: 40px; height: 40px; }
.auth-card h1 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}
.auth-card p.help {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 0.4rem 0 1.1rem;
  line-height: 1.5;
}

.muted { color: var(--text-muted); }
small { color: var(--text-muted); }

code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 0.86em;
  background: rgba(15, 23, 42, 0.06);
  padding: 1px 6px;
  border-radius: 5px;
}

/* ---------------------- Dashboard tweaks ---------------------- */
.kpi-grid + .card .card-head { background: linear-gradient(180deg, rgba(255,255,255,0.7), rgba(255,255,255,0.15)); }

/* Avatar fallbacks */
img[src^="/photo/"] {
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
}

/* Compact mini-maps */
.mini-map {
  background: linear-gradient(135deg, #e2e8f0, #f1f5f9);
}

/* Smooth scrolling */
html { scroll-behavior: smooth; }

/* iPad / mobile: bigger tap targets */
@media (max-width: 1024px) {
  .nav-list a { padding: 11px 14px; font-size: 0.96rem; }
  .field input, .field select, .field textarea { padding: 12px 14px; font-size: 1rem; }
  .btn { padding: 13px 18px; font-size: 0.98rem; }
}

/* ---------------------- Toolbar (search + filters) ---------------------- */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--surface);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}
.toolbar form { display: flex; flex-wrap: wrap; gap: 10px; flex: 1; align-items: center; }
.toolbar .toolbar-search { flex: 1; min-width: 200px; }
.toolbar input[type="search"], .toolbar input[type="text"], .toolbar select {
  height: 40px;
  font: inherit; font-size: 0.92rem;
  padding: 0 12px;
  border: 1px solid var(--hairline-strong);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
  transition: border 0.12s, box-shadow 0.15s, background 0.12s;
}
.toolbar input[type="search"]:focus, .toolbar input[type="text"]:focus, .toolbar select:focus {
  outline: none; background: #fff; border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.16);
}
.toolbar input[type="search"] { width: 100%; }
.toolbar .btn { height: 40px; padding: 0 18px; }
.toolbar-clear {
  font-size: 0.85rem; color: var(--text-muted); text-decoration: underline;
}

/* View switcher (list | map) */
.view-switch {
  display: inline-flex; gap: 0; padding: 4px;
  background: rgba(15, 23, 42, 0.06);
  border: 1px solid var(--hairline);
  border-radius: 12px;
}
.view-switch a {
  padding: 6px 14px;
  font-size: 0.84rem; font-weight: 600;
  color: var(--text-muted);
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.view-switch a.is-active {
  background: linear-gradient(180deg, #fff, rgba(255,255,255,0.7));
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.view-switch a:hover { color: var(--text); }

/* Big map */
.big-map {
  height: 70vh; min-height: 480px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-2);
}

/* ---------------------- Engagement-type icons ---------------------- */
.type-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(37, 99, 235, 0.18);
}
.type-icon svg { width: 18px; height: 18px; }
.type-icon.ok { background: rgba(5, 150, 105, 0.10); color: var(--ok); border-color: rgba(5, 150, 105, 0.22); }
.type-icon.warn { background: rgba(217, 119, 6, 0.10); color: var(--warn); border-color: rgba(217, 119, 6, 0.22); }
.type-icon.muted { background: rgba(15, 23, 42, 0.05); color: var(--text-muted); border-color: var(--hairline); }

/* ---------------------- Collapsible card (details/summary) ---------------------- */
.card.collapsible { padding: 0; }
.card.collapsible > summary,
.card > details > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.card.collapsible > summary::-webkit-details-marker,
.card > details > summary::-webkit-details-marker { display: none; }
.card.collapsible > summary .card-head,
.card > details > summary .card-head { margin: 0; }
.card.collapsible > summary .card-head::after {
  content: "›";
  font-size: 1.5rem; line-height: 0.5;
  color: var(--text-muted);
  transform: rotate(0deg);
  transition: transform 0.18s ease;
  margin-left: 8px;
}
.card.collapsible[open] > summary .card-head::after { transform: rotate(90deg); }

/* ---------------------- Compact list cards ---------------------- */
.list {
  display: grid;
  gap: 8px;
  padding: 14px;
}
.list-empty {
  padding: 22px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.row-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 14px;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  text-decoration: none;
  color: inherit;
  transition: transform 0.1s ease, box-shadow 0.12s ease, border-color 0.12s;
  cursor: pointer;
}
.row-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
  border-color: rgba(231, 76, 60, 0.22);
  text-decoration: none;
}
.row-card .avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--text-muted); font-size: 0.85rem;
  border: 1px solid var(--hairline);
  overflow: hidden;
  flex-shrink: 0;
}
.row-card .avatar.icon-tile { color: var(--brand-red-dk); background: linear-gradient(135deg, rgba(255,255,255,0.95), rgba(255,255,255,0.6)); }
.row-card .avatar img { width: 100%; height: 100%; object-fit: cover; }
.row-card .avatar svg { width: 18px; height: 18px; }
.row-card .body { min-width: 0; }
.row-card .body strong {
  display: block;
  font-size: 0.96rem; font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-card .body .sub {
  font-size: 0.8rem; color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-card .right {
  display: flex; gap: 8px; align-items: center;
  font-size: 0.84rem; color: var(--text-muted);
  white-space: nowrap;
}
.row-card .arrow {
  color: var(--text-faint);
  font-size: 1.5rem;
  line-height: 1;
  margin-right: -4px;
  flex-shrink: 0;
}
.row-card:hover .arrow { color: var(--brand-red); }

/* ---------------------- Modal (dialog) ---------------------- */
dialog.modal {
  border: none; padding: 0;
  background: transparent;
  color: inherit;
  max-width: 760px;
  width: min(92vw, 760px);
  border-radius: var(--radius-lg);
  margin: auto;  /* let dialog center vertically + horizontally */
}
dialog.modal::backdrop {
  background: rgba(15, 23, 42, 0.42);
  -webkit-backdrop-filter: blur(8px) saturate(1.3);
  backdrop-filter: blur(8px) saturate(1.3);
}
.modal-card {
  background: var(--surface-strong);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  overflow: hidden;
}
.modal-head {
  padding: 16px 22px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-bottom: 1px solid var(--hairline);
  background: linear-gradient(180deg, rgba(255,255,255,0.7), rgba(255,255,255,0.2));
}
.modal-head h2 { margin: 0; font-size: 1.05rem; font-weight: 700; letter-spacing: -0.02em; }
.modal-head .modal-close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: rgba(15, 23, 42, 0.06);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.25rem; line-height: 1;
  transition: background 0.12s, color 0.12s;
}
.modal-head .modal-close:hover { background: rgba(15, 23, 42, 0.1); color: var(--text); }
.modal-body { padding: 20px 22px; max-height: 70vh; overflow-y: auto; }
.modal-foot {
  padding: 14px 22px;
  display: flex; gap: 10px; align-items: center; justify-content: flex-end;
  border-top: 1px solid var(--hairline);
  background: linear-gradient(180deg, rgba(255,255,255,0.15), rgba(255,255,255,0.6));
}

/* Wizard (steps inside a modal) */
.wizard-steps {
  display: flex; gap: 8px; align-items: center;
  padding: 12px 22px 0;
  font-size: 0.78rem; color: var(--text-muted);
}
.wizard-steps .step {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.05);
  border: 1px solid var(--hairline);
  font-weight: 600;
}
.wizard-steps .step .dot {
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.1);
  font-size: 0.7rem; font-weight: 700;
  color: var(--text-muted);
}
.wizard-steps .step.is-active {
  color: var(--brand-red-dk);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.7));
  border-color: rgba(231, 76, 60, 0.30);
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.12);
}
.wizard-steps .step.is-active .dot {
  background: linear-gradient(180deg, var(--brand-red), var(--brand-red-dk));
  color: #fff;
}
.wizard-steps .step.is-done .dot {
  background: var(--ok);
  color: #fff;
}
.wizard-steps .sep {
  flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, var(--hairline-strong), transparent);
}
.wizard-step { display: none; }
.wizard-step.is-active { display: block; animation: fadeStep 0.18s ease-out; }
@keyframes fadeStep {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.modal-foot .spacer { flex: 1; }
@media (max-width: 720px) {
  .modal-body { max-height: 64vh; }
  dialog.modal { width: 96vw; }
}

/* "Add" / primary action button next to titles */
.btn-add {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.85rem; font-weight: 700;
  padding: 8px 14px;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  cursor: pointer;
  background: linear-gradient(180deg, rgba(255,255,255,0.18), rgba(255,255,255,0.05)),
              linear-gradient(180deg, var(--brand-red), var(--brand-red-dk));
  box-shadow: 0 6px 16px rgba(231, 76, 60, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: transform 0.08s, filter 0.15s;
  text-decoration: none;
}
.btn-add:hover { filter: brightness(1.06); transform: translateY(-1px); text-decoration: none; color: #fff; }
.btn-add svg { width: 16px; height: 16px; }

/* ---------------------- Calendar grid (appointments) ---------------------- */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.cal-h {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); text-align: center; padding: 4px 0;
}
.cal-day {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 8px;
  min-height: 96px;
  display: flex; flex-direction: column; gap: 6px;
}
.cal-day.is-today { border-color: rgba(231, 76, 60, 0.45); box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.10); }
.cal-day.is-past { opacity: 0.65; }
.cal-date { font-size: 0.78rem; font-weight: 700; color: var(--text-muted); }
.cal-day.is-today .cal-date { color: var(--brand-red-dk); }
.cal-events { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cal-event {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 6px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  font-size: 0.74rem;
  text-decoration: none; color: var(--text);
  white-space: nowrap; overflow: hidden;
}
.cal-event:hover { background: #fff; text-decoration: none; }
.cal-event .type-icon { width: 18px; height: 18px; border-radius: 4px; }
.cal-event .type-icon svg { width: 12px; height: 12px; }
.cal-event span { overflow: hidden; text-overflow: ellipsis; }
.cal-more { font-size: 0.7rem; color: var(--accent); margin-top: 2px; }

@media (max-width: 720px) {
  .cal-grid { grid-template-columns: repeat(7, minmax(60px, 1fr)); overflow-x: auto; }
  .cal-day { min-height: 80px; }
}

/* iOS safe areas (Dynamic Island / home indicator) */
@supports (padding: env(safe-area-inset-top)) {
  .topbar { margin-top: max(8px, env(safe-area-inset-top)); }
  aside.sidebar { padding-top: max(8px, env(safe-area-inset-top)); }
}
