/* Portal Prestador — Mediconecta PY */
@import url('tokens.css');

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg-canvas);
  color: var(--fg-body);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
}

/* Density tweak */
[data-density="compact"] { --pad-card: 14px; --pad-row: 7px; --gap-stack: 12px; }
[data-density="comfy"]   { --pad-card: 20px; --pad-row: 11px; --gap-stack: 20px; }
:root { --pad-card: 18px; --pad-row: 10px; --gap-stack: 16px; }

/* ========== SHELL ========== */
.shell, .app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
.main-area, .app-main { display: flex; flex-direction: column; min-width: 0; }
.main, .main-scroll {
  padding: 24px 32px 64px;
  display: flex; flex-direction: column; gap: var(--gap-stack);
  width: 100%;
  flex: 1;
}

/* ========== SIDEBAR ========== */
.sidebar {
  background: #fff;
  border-right: 1px solid var(--slate-200);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 6px 2px;
}
.sidebar-brand img { height: 22px; width: auto; }
.sidebar-role {
  padding: 0 6px 8px;
  font-size: 10px; color: var(--slate-400);
  text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600;
  border-bottom: 1px solid var(--slate-100);
  margin-bottom: 4px;
}
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-group-label {
  font-size: 10px; color: var(--slate-400);
  text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600;
  padding: 10px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 12px; border-radius: var(--radius-lg);
  color: var(--slate-600); font-size: 13px; font-weight: 500;
  text-decoration: none; cursor: pointer; user-select: none;
  transition: background var(--dur-base) var(--ease-standard), color var(--dur-base);
  border: 0; background: transparent; width: 100%; text-align: left;
  font-family: var(--font-sans);
}
.nav-item:hover { background: var(--brand-light); color: var(--brand-dark); }
.nav-item.is-active {
  background: var(--brand); color: #fff;
  box-shadow: var(--shadow-brand);
}
.nav-item.is-active svg { stroke: #fff; }
.nav-label { flex: 1; }
.nav-num {
  width: 24px; height: 22px; border-radius: var(--radius-md);
  background: var(--slate-100); color: var(--slate-500);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 10px; font-weight: 800;
}
.nav-item.is-active .nav-num { background: rgba(255,255,255,0.22); color: #fff; }
.nav-sub {
  padding: 6px 12px 6px 40px;
  font-size: 12px; color: var(--slate-500);
  cursor: pointer; border-radius: var(--radius-lg);
  display: flex; align-items: center; gap: 8px;
}
.nav-sub:hover { color: var(--brand-dark); background: var(--brand-light); }
.nav-sub.is-active { color: var(--brand-dark); font-weight: 600; }
.nav-badge {
  font-size: 10px; font-weight: 700;
  background: var(--red-500); color: #fff;
  padding: 1px 6px; border-radius: 999px;
  font-family: var(--font-mono);
}
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--slate-100); padding-top: 10px; }
.foot-user {
  display: flex; align-items: center; gap: 10px; padding: 6px;
  border-radius: var(--radius-lg); cursor: pointer;
}
.foot-user:hover { background: var(--slate-50); }
.avatar {
  width: 36px; height: 36px; border-radius: 999px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff; font-weight: 700; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; overflow: hidden;
  font-family: var(--font-sans);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 30px; height: 30px; font-size: 11px; }
.avatar.xs { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 48px; height: 48px; font-size: 15px; }
.avatar.xl { width: 72px; height: 72px; font-size: 22px; }
.u-name { font-size: 12px; font-weight: 700; color: var(--slate-800); line-height: 1.2; }
.u-role { font-size: 10px; color: var(--slate-400); line-height: 1.2; }

/* ========== HEADER ========== */
.hdr {
  height: var(--header-h);
  position: sticky; top: 0; z-index: 5;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--slate-200);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; gap: 16px;
}
.hdr-left, .hdr-right { display: flex; align-items: center; gap: 10px; }
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  padding: 6px 12px;
  min-width: 340px;
}
.search input { border: 0; background: transparent; outline: none; flex: 1; font-size: 13px; color: var(--slate-800); font-family: var(--font-sans); min-width: 0; }
.search input::placeholder { color: var(--slate-400); }
.search .ms { color: var(--slate-400); font-size: 18px; }
.search kbd {
  font-family: var(--font-mono); font-size: 10px; color: var(--slate-500);
  background: #fff; border: 1px solid var(--slate-200); border-radius: 4px;
  padding: 1px 5px;
}
.role-select {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px 6px 12px;
  background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius-lg);
  font-size: 12px; font-weight: 600; color: var(--slate-700);
  cursor: pointer;
  transition: all var(--dur-base);
}
.role-select:hover { border-color: var(--brand); color: var(--brand-dark); }
.role-select .ms { font-size: 16px; color: var(--slate-400); }
.role-select .tag {
  font-size: 9px; padding: 1px 6px; background: var(--brand-light); color: var(--brand-dark);
  border-radius: 999px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
}
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--radius-lg);
  border: 1px solid var(--slate-200); background: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative;
  color: var(--slate-500);
  transition: all var(--dur-base);
  font-family: var(--font-sans);
}
.icon-btn:hover { background: var(--slate-50); color: var(--slate-800); }
.icon-btn .ms { font-size: 18px; }
.icon-btn.notif .dot {
  position: absolute; top: 7px; right: 7px;
  width: 8px; height: 8px; border-radius: 999px;
  background: var(--red-500); border: 2px solid #fff;
}

/* ========== PAGE HEAD ========== */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
}
.t-display { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -0.02em; color: var(--slate-900); line-height: 1.15; }
.t-title { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -0.02em; color: var(--slate-900); }
.page-sub { margin: 4px 0 0; font-size: 13px; color: var(--slate-500); }
.page-cta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ========== BUTTONS ========== */
.btn, .btn-primary, .btn-secondary, .btn-ghost, .btn-danger {
  font-family: var(--font-sans); font-weight: 600; font-size: 13px;
  border-radius: var(--radius-lg); padding: 9px 14px;
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; border: 1px solid transparent;
  transition: all var(--dur-base) var(--ease-standard);
  white-space: nowrap;
}
.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-brand); }
.btn-primary:hover { background: var(--brand-hover); transform: translateY(-1px); }
.btn-primary:disabled { background: var(--slate-300); box-shadow: none; cursor: not-allowed; }
.btn-secondary { background: #fff; color: var(--slate-700); border-color: var(--slate-200); }
.btn-secondary:hover { background: var(--slate-50); border-color: var(--slate-300); }
.btn-ghost { background: transparent; color: var(--slate-600); }
.btn-ghost:hover { background: var(--slate-100); color: var(--slate-800); }
.btn-danger { background: #fff; color: var(--red-600); border-color: var(--red-200, #fecaca); }
.btn-danger:hover { background: var(--red-50); }
.btn .ms, .btn-primary .ms, .btn-secondary .ms, .btn-ghost .ms, .btn-danger .ms { font-size: 16px; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-lg { padding: 12px 18px; font-size: 14px; }

/* ========== CARDS ========== */
.card {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-xl);
  padding: var(--pad-card);
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-base) var(--ease-standard), box-shadow var(--dur-base) var(--ease-standard);
}
.card-plain { background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius-xl); padding: var(--pad-card); }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.card-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin-bottom: 14px;
}
.card-title {
  margin: 0; font-size: 14px; font-weight: 700; color: var(--fg-strong);
  letter-spacing: -0.01em;
  display: inline-flex; align-items: center; gap: 8px;
}
.card-sub { margin: 3px 0 0; font-size: 11px; color: var(--slate-400); }
.link { color: var(--brand-dark); font-size: 12px; font-weight: 600; text-decoration: none; cursor: pointer; background: transparent; border: 0; font-family: var(--font-sans); }
.link:hover { color: var(--brand); text-decoration: underline; }

/* ========== KPI ========== */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi { position: relative; }
.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.kpi-ic {
  width: 40px; height: 40px; border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.kpi-ic .ms { font-size: 22px; }
.kpi-trend {
  font-size: 10px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 2px;
}
.kpi-trend.up { background: var(--emerald-50); color: var(--emerald-700); }
.kpi-trend.dn { background: var(--red-50); color: var(--red-700); }
.kpi-trend.nu { background: var(--slate-100); color: var(--slate-600); }
.kpi-val {
  font-size: 30px; font-weight: 800; color: var(--slate-900);
  letter-spacing: -0.025em; font-variant-numeric: tabular-nums;
  margin-top: 14px; line-height: 1.1;
}
.kpi-val small { font-size: 16px; font-weight: 700; color: var(--slate-500); margin-left: 2px; }
.kpi-lab {
  font-size: 11px; color: var(--slate-500);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
  margin-top: 6px;
}
.kpi-sub { font-size: 11px; color: var(--slate-500); margin-top: 3px; }
.kpi-cta { font-size: 11px; font-weight: 700; color: var(--brand-dark); margin-top: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 2px; }
.kpi-cta:hover { color: var(--brand); }

/* ========== BADGES / CHIPS ========== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
  white-space: nowrap;
}
.badge.sm { font-size: 10px; padding: 2px 7px; }
.badge-ok    { background: var(--emerald-50); color: var(--emerald-700); }
.badge-warn  { background: var(--amber-50); color: var(--amber-700); }
.badge-err   { background: var(--red-50); color: var(--red-700); }
.badge-info  { background: var(--violet-50); color: var(--violet-700); }
.badge-brand { background: var(--brand-light); color: var(--brand-dark); }
.badge-neutral { background: var(--slate-100); color: var(--slate-600); }
.badge-teal  { background: var(--teal-50); color: var(--teal-700); }
.badge-dot::before {
  content: ''; width: 6px; height: 6px; border-radius: 999px;
  background: currentColor; opacity: 0.9;
}
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: var(--radius-md);
  font-size: 11px; font-weight: 600;
  background: var(--slate-100); color: var(--slate-700);
}
.chip.primary { background: var(--brand-light); color: var(--brand-dark); }

/* ========== AGENDA / TIMELINE ========== */
.timeline {
  display: flex; flex-direction: column; gap: 2px;
}
.tl-group-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 0 6px; margin-top: 8px;
  font-size: 10px; font-weight: 700; color: var(--slate-500);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.tl-group-head:first-child { margin-top: 0; padding-top: 0; }
.tl-group-head .ms { font-size: 14px; color: var(--slate-400); }
.tl-row {
  display: grid; grid-template-columns: 76px 4px 1fr auto; gap: 12px;
  align-items: center;
  padding: var(--pad-row) 6px var(--pad-row) 0;
  border-bottom: 1px solid var(--slate-100);
  transition: background var(--dur-fast);
  cursor: pointer;
}
.tl-row:hover { background: var(--slate-50); }
.tl-row:last-child { border-bottom: 0; }
.tl-row.is-active { background: var(--brand-light); }
.tl-time { font-size: 12px; font-weight: 700; color: var(--slate-800); font-variant-numeric: tabular-nums; }
.tl-time small { display: block; color: var(--slate-400); font-weight: 500; font-size: 10px; }
.tl-bar { width: 4px; height: 36px; border-radius: 2px; background: var(--slate-200); }
.tl-bar.ok { background: var(--emerald-500); }
.tl-bar.warn { background: var(--amber-500); }
.tl-bar.live { background: var(--brand); box-shadow: 0 0 0 2px rgba(76,177,220,0.25); }
.tl-bar.done { background: var(--slate-300); }
.tl-bar.cancel { background: var(--red-500); }
.tl-name { font-size: 13px; font-weight: 700; color: var(--slate-900); }
.tl-meta { font-size: 11px; color: var(--slate-500); display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.tl-meta .ms { font-size: 13px; }

/* ========== TABLE ========== */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-size: 10px; font-weight: 700; color: var(--slate-500);
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 10px 12px; border-bottom: 1px solid var(--slate-200);
  background: var(--slate-50);
}
.tbl td {
  padding: 12px; font-size: 13px; color: var(--slate-700);
  border-bottom: 1px solid var(--slate-100);
}
.tbl tr:hover td { background: var(--slate-50); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl.compact td { padding: 8px 12px; font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.num-right { text-align: right; font-variant-numeric: tabular-nums; }

/* ========== PROGRESS / BARS ========== */
.track { height: 6px; border-radius: 3px; background: var(--slate-100); overflow: hidden; }
.track > span { display: block; height: 100%; background: var(--brand); border-radius: 3px; animation: slideRight 800ms var(--ease-out) both; }
.track.ok > span { background: var(--emerald-500); }
.track.warn > span { background: var(--amber-500); }

/* ========== INPUTS ========== */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 11px; font-weight: 600; color: var(--slate-600);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.field input, .field select, .field textarea {
  font-family: var(--font-sans); font-size: 13px; color: var(--slate-800);
  background: #fff; border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg); padding: 10px 12px;
  transition: border-color var(--dur-base), box-shadow var(--dur-base);
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(76,177,220,0.15);
}
.field textarea { min-height: 80px; resize: vertical; }
.field .hint { font-size: 11px; color: var(--slate-500); }
.field .err { font-size: 11px; color: var(--red-600); }
.inline-fields { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }

/* Radio cards */
.radio-group { display: flex; flex-direction: column; gap: 8px; }
.radio-card {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg); cursor: pointer;
  transition: all var(--dur-base);
}
.radio-card:hover { border-color: var(--brand); background: var(--brand-50); }
.radio-card.is-on { border-color: var(--brand); background: var(--brand-50); box-shadow: 0 0 0 3px rgba(76,177,220,0.1); }
.radio-card input { margin-top: 2px; accent-color: var(--brand); }
.radio-card .rc-title { font-size: 13px; font-weight: 700; color: var(--slate-900); }
.radio-card .rc-sub { font-size: 11px; color: var(--slate-500); margin-top: 2px; }

/* Toggle */
.toggle {
  display: inline-flex; align-items: center; cursor: pointer;
  width: 36px; height: 20px; background: var(--slate-300);
  border-radius: 999px; position: relative;
  transition: background var(--dur-base);
  border: 0; padding: 0;
}
.toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 999px; background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  transition: transform var(--dur-base);
}
.toggle.is-on { background: var(--brand); }
.toggle.is-on::after { transform: translateX(16px); }

/* Tabs */
.tabs {
  display: inline-flex; background: var(--slate-100);
  border-radius: var(--radius-lg); padding: 3px;
  gap: 2px;
}
.tabs button {
  border: 0; background: transparent;
  font-family: var(--font-sans); font-size: 12px; font-weight: 600;
  color: var(--slate-500);
  padding: 6px 14px; border-radius: 6px; cursor: pointer;
  transition: all var(--dur-base);
}
.tabs button.is-on { background: #fff; color: var(--brand-dark); box-shadow: var(--shadow-sm); }
.tabs button:hover:not(.is-on) { color: var(--slate-800); }

/* Stepper */
.stepper { display: flex; align-items: center; gap: 0; margin: 4px 0 20px; }
.stepper-item { display: flex; align-items: center; gap: 10px; flex: 1; }
.stepper-item:last-child { flex: 0; }
.step-num {
  width: 28px; height: 28px; border-radius: 999px;
  background: var(--slate-200); color: var(--slate-600);
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
}
.step-num.is-on { background: var(--brand); color: #fff; box-shadow: var(--shadow-brand); }
.step-num.is-done { background: var(--emerald-500); color: #fff; }
.step-label { font-size: 12px; font-weight: 600; color: var(--slate-600); white-space: nowrap; }
.step-label.is-on { color: var(--slate-900); }
.step-line { flex: 1; height: 2px; background: var(--slate-200); margin: 0 4px; }
.step-line.is-done { background: var(--emerald-500); }

/* Grid helpers */
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: flex-start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-split { display: grid; grid-template-columns: 30% 1fr; gap: 16px; align-items: flex-start; }
.stack { display: flex; flex-direction: column; gap: var(--gap-stack); }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* ========== CALENDAR ========== */
.cal-shell { display: grid; grid-template-columns: 48px 1fr; background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius-xl); overflow: hidden; }
.cal-hrs { background: var(--slate-50); border-right: 1px solid var(--slate-100); }
.cal-hr { height: 48px; padding: 4px 6px; font-size: 10px; font-weight: 600; color: var(--slate-500); text-align: right; font-variant-numeric: tabular-nums; }
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); position: relative; }
.cal-day { border-right: 1px solid var(--slate-100); position: relative; }
.cal-day:last-child { border-right: 0; }
.cal-day-head {
  padding: 10px 8px; border-bottom: 1px solid var(--slate-200);
  font-size: 11px; font-weight: 700; color: var(--slate-600);
  text-transform: uppercase; letter-spacing: 0.06em; background: var(--slate-50);
  position: sticky; top: 0; z-index: 1;
}
.cal-day-head.is-today { color: var(--brand-dark); }
.cal-day-head .dno { display: block; font-size: 18px; font-weight: 800; color: var(--slate-900); margin-top: 2px; letter-spacing: -0.02em; }
.cal-day-head.is-today .dno { color: var(--brand-dark); }
.cal-hour-row { height: 48px; border-bottom: 1px solid var(--slate-100); position: relative; }
.cal-hour-row.mid { border-bottom-style: dashed; border-bottom-color: var(--slate-100); }
.cal-event {
  position: absolute; left: 3px; right: 3px;
  padding: 5px 7px; border-radius: var(--radius-md);
  font-size: 11px; font-weight: 600;
  cursor: pointer; overflow: hidden;
  transition: box-shadow var(--dur-base), transform var(--dur-base);
  border-left: 3px solid;
}
.cal-event:hover { box-shadow: var(--shadow-md); transform: translateX(1px); z-index: 3; }
.cal-event .ev-time { font-size: 10px; font-weight: 700; opacity: 0.8; }
.cal-event .ev-name { font-size: 11px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-event .ev-sub  { font-size: 10px; opacity: 0.75; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-event.c-ok    { background: #ecfdf5; color: #065f46; border-left-color: var(--emerald-500); }
.cal-event.c-warn  { background: #fffbeb; color: #92400e; border-left-color: var(--amber-500); }
.cal-event.c-live  { background: #e8f4fa; color: var(--brand-dark); border-left-color: var(--brand); box-shadow: 0 0 0 2px rgba(76,177,220,0.2); }
.cal-event.c-done  { background: var(--slate-50); color: var(--slate-600); border-left-color: var(--slate-400); }
.cal-event.c-cancel{ background: #fef2f2; color: var(--red-700); border-left-color: var(--red-500); text-decoration: line-through; }
.cal-blocked {
  position: absolute; left: 0; right: 0;
  background: repeating-linear-gradient(45deg, #f1f5f9 0 8px, #f8fafc 8px 16px);
  border-left: 3px solid var(--slate-400);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: var(--slate-500);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.cal-nowline { position: absolute; left: 0; right: 0; height: 2px; background: var(--red-500); z-index: 2; }
.cal-nowline::before { content: ''; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 999px; background: var(--red-500); }

/* ========== SIDE DRAWER ========== */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,0.35);
  z-index: 20; animation: fadeIn 200ms var(--ease-out) both;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 480px; max-width: 100vw;
  background: #fff; box-shadow: var(--shadow-xl);
  z-index: 21; display: flex; flex-direction: column;
  animation: drawerIn 300ms var(--ease-out) both;
}
.drawer.lg { width: 640px; }
.drawer-head {
  padding: 18px 22px; border-bottom: 1px solid var(--slate-200);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 22px; }
.drawer-foot { padding: 14px 22px; border-top: 1px solid var(--slate-200); display: flex; justify-content: flex-end; gap: 8px; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes drawerIn { from { transform: translateX(24px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ========== MODAL ========== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,0.45);
  z-index: 30; display: flex; align-items: center; justify-content: center;
  animation: fadeIn 200ms var(--ease-out) both; padding: 32px;
}
.modal {
  background: #fff; border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  width: 100%; max-width: 480px;
  animation: modalIn 250ms var(--ease-out) both;
}
.modal.lg { max-width: 640px; }
@keyframes modalIn { from { transform: scale(0.96) translateY(8px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
.modal-head { padding: 20px 22px 6px; }
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 800; color: var(--slate-900); }
.modal-head p { margin: 6px 0 0; font-size: 13px; color: var(--slate-500); }
.modal-body { padding: 16px 22px; }
.modal-foot { padding: 14px 22px 20px; display: flex; justify-content: flex-end; gap: 8px; }

/* ========== TOAST ========== */
.toast-stack { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius-lg);
  color: #fff; font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg); min-width: 280px;
  animation: toastIn 260ms var(--ease-out) both;
}
.toast.primary { background: var(--brand-dark); }
.toast.ok      { background: var(--emerald-600); }
.toast.warn    { background: var(--amber-600); }
.toast.err     { background: var(--red-600); }
.toast .ms { font-size: 18px; }

/* ========== CALLOUT ========== */
.callout {
  display: flex; gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius-xl);
  background: var(--violet-50);
  border: 1px solid var(--violet-100);
}
.callout .ic {
  width: 36px; height: 36px; border-radius: var(--radius-lg);
  background: var(--violet-100); color: var(--violet-700);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.callout strong { color: var(--violet-700); font-weight: 800; }
.callout.warn { background: var(--amber-50); border-color: var(--amber-100); }
.callout.warn .ic { background: var(--amber-100); color: var(--amber-700); }
.callout.warn strong { color: var(--amber-700); }
.callout.brand { background: var(--brand-light); border-color: #cfe7f4; }
.callout.brand .ic { background: #cfe7f4; color: var(--brand-dark); }
.callout.brand strong { color: var(--brand-dark); }

/* ========== UTIL ========== */
.fade-up { animation: fadeInUp 400ms var(--ease-out) both; }
.divider { height: 1px; background: var(--slate-100); margin: 6px 0; }
.mute { color: var(--slate-500); }
.mono { font-family: var(--font-mono); }
.right { text-align: right; }
.spacer { flex: 1; }
.pg { padding: 8px 0; }
.g-8 { gap: 8px; } .g-12 { gap: 12px; } .g-16 { gap: 16px; } .g-20 { gap: 20px; }

/* ========== MATERIAL SYMBOLS ========== */
.ms {
  font-family: 'Material Symbols Rounded';
  font-weight: normal; font-style: normal;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  font-size: 20px; line-height: 1; vertical-align: middle;
  user-select: none; text-transform: none;
  letter-spacing: normal; word-wrap: normal; white-space: nowrap;
  direction: ltr; -webkit-font-feature-settings: 'liga'; font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
}
.ms.fill { font-variation-settings: 'FILL' 1, 'wght' 500; }

/* ========== LOGIN ========== */
.login-shell {
  min-height: 100vh;
  background: var(--bg-login);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  position: relative; overflow: hidden;
}
.login-shell::before, .login-shell::after {
  content: ''; position: absolute; border-radius: 50%;
  filter: blur(80px); opacity: 0.25;
}
.login-shell::before { width: 400px; height: 400px; background: var(--brand); top: -100px; left: -100px; }
.login-shell::after { width: 500px; height: 500px; background: var(--brand-dark); bottom: -150px; right: -100px; }
.login-card {
  width: 100%; max-width: 420px;
  background: #fff; border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  padding: 40px 36px;
  position: relative; z-index: 1;
  animation: fadeInUp 600ms var(--ease-out) both;
}
.login-logo {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  margin-bottom: 28px;
}
.login-logo img { height: 32px; }
.login-logo .tag { font-size: 11px; color: var(--slate-500); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.login-foot { margin-top: 24px; display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--slate-400); }
.or-sep { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--slate-400); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.or-sep::before, .or-sep::after { content: ''; flex: 1; height: 1px; background: var(--slate-200); }

/* ========== RECEIPT / RECETA PREVIEW ========== */
.doc-preview {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-xl);
  padding: 28px 24px;
  font-size: 12px;
  box-shadow: var(--shadow-sm);
  position: sticky; top: 72px;
}
.doc-hdr { display: flex; align-items: center; gap: 12px; padding-bottom: 16px; border-bottom: 2px solid var(--slate-200); margin-bottom: 16px; }
.doc-hdr img { height: 22px; }
.doc-meta { flex: 1; font-size: 10px; color: var(--slate-500); line-height: 1.4; }
.doc-num { font-family: var(--font-mono); font-size: 10px; color: var(--slate-500); }
.doc-patient { background: var(--slate-50); border-radius: var(--radius-md); padding: 10px 12px; margin-bottom: 14px; }
.doc-section { margin: 14px 0; }
.doc-section h4 { margin: 0 0 8px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--slate-500); font-weight: 700; }
.doc-rx { padding: 10px 12px; border-left: 3px solid var(--brand); background: var(--brand-50); border-radius: 0 6px 6px 0; margin-bottom: 8px; }
.doc-rx strong { color: var(--slate-900); font-weight: 700; }
.doc-foot { margin-top: 24px; padding-top: 16px; border-top: 1px dashed var(--slate-200); display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.doc-sig { flex: 1; text-align: center; }
.doc-sig .line { width: 100%; border-top: 1px solid var(--slate-300); margin-bottom: 4px; }
.doc-sig .name { font-size: 11px; font-weight: 700; color: var(--slate-800); }
.doc-sig .mp { font-size: 10px; color: var(--slate-500); }
.doc-qr {
  width: 64px; height: 64px; display: grid; grid-template-columns: repeat(8, 1fr);
  border: 1px solid var(--slate-200); border-radius: 4px; padding: 3px;
}
.doc-qr span { aspect-ratio: 1; }

/* ========== TELECONSULTA ========== */
.tc-shell { display: grid; grid-template-columns: 1fr 360px; height: calc(100vh - var(--header-h)); background: #0f172a; }
.tc-video { position: relative; background: #1e293b; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.tc-video-main { width: 100%; height: 100%; object-fit: cover; display: block; }
.tc-video-placeholder {
  width: 100%; height: 100%; background: radial-gradient(circle at 50% 40%, #334155 0%, #0f172a 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
}
.tc-video-placeholder .avatar.huge { width: 140px; height: 140px; font-size: 48px; }
.tc-pip {
  position: absolute; bottom: 88px; right: 20px;
  width: 180px; height: 120px;
  background: #334155; border-radius: var(--radius-lg);
  border: 2px solid rgba(255,255,255,0.1);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; color: #fff;
  box-shadow: var(--shadow-lg);
}
.tc-pip .ms { font-size: 36px; opacity: 0.7; }
.tc-pip .avatar { width: 56px; height: 56px; font-size: 18px; }
.tc-pip .label { position: absolute; bottom: 6px; left: 8px; font-size: 10px; color: #fff; opacity: 0.85; font-weight: 600; }
.tc-status {
  position: absolute; top: 20px; left: 20px;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; background: rgba(15,23,42,0.7);
  border-radius: 999px; color: #fff; font-size: 12px; font-weight: 600; backdrop-filter: blur(8px);
}
.tc-status .live-d { width: 8px; height: 8px; background: var(--red-500); border-radius: 999px; animation: pulseDot 1.5s infinite; }
.tc-quality { position: absolute; top: 20px; right: 20px; display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: rgba(15,23,42,0.7); border-radius: 999px; color: #fff; font-size: 11px; font-weight: 600; backdrop-filter: blur(8px); }
.tc-controls {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; align-items: center;
  background: rgba(15,23,42,0.9); padding: 10px; border-radius: 999px;
  box-shadow: var(--shadow-xl); backdrop-filter: blur(8px);
}
.tc-ctl { width: 44px; height: 44px; border-radius: 999px; background: #475569; color: #fff; border: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background var(--dur-base); }
.tc-ctl:hover { background: #64748b; }
.tc-ctl.off { background: #1e293b; color: var(--slate-400); }
.tc-ctl.end { background: var(--red-600); }
.tc-ctl.end:hover { background: var(--red-700); }
.tc-ctl .ms { font-size: 20px; }
.tc-side { background: #fff; border-left: 1px solid var(--slate-200); display: flex; flex-direction: column; overflow: hidden; }
.tc-side-tabs { display: flex; border-bottom: 1px solid var(--slate-200); }
.tc-side-tab { flex: 1; padding: 12px 8px; background: transparent; border: 0; font-family: var(--font-sans); font-size: 11px; font-weight: 700; color: var(--slate-500); cursor: pointer; border-bottom: 2px solid transparent; transition: all var(--dur-base); }
.tc-side-tab.is-on { color: var(--brand-dark); border-bottom-color: var(--brand); background: var(--brand-50); }
.tc-side-body { flex: 1; overflow-y: auto; padding: 16px; }

/* ========== MAPLET ========== */
.maplet {
  width: 100%; height: 160px;
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(76,177,220,0.06) 0%, rgba(76,177,220,0.02) 100%),
    repeating-linear-gradient(0deg, #e2e8f0 0 1px, transparent 1px 36px),
    repeating-linear-gradient(90deg, #e2e8f0 0 1px, transparent 1px 36px),
    #f1f5f9;
  border: 1px solid var(--slate-200);
  position: relative;
  overflow: hidden;
}
.maplet::before {
  content: ''; position: absolute; left: 30%; top: 40%;
  width: 40%; height: 6px; background: var(--brand); border-radius: 999px;
  transform: rotate(-18deg);
}
.maplet .pin {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -100%);
  width: 26px; height: 26px; color: var(--red-500);
}
.maplet .pin .ms { font-size: 28px; color: var(--red-600); filter: drop-shadow(0 2px 3px rgba(0,0,0,0.25)); }

/* ========== SCROLLBAR ========== */
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--slate-200); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: var(--slate-300); }

/* ========== RESPONSIVE ========== */
@media (max-width: 1240px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .main { padding: 20px 16px 40px; }
  .search { min-width: 0; flex: 1; }
  .drawer, .drawer.lg { width: 100vw; }
  .tc-shell { grid-template-columns: 1fr; height: auto; }
}
