/* ============================================================
   MiraLaCarta — Sistema de diseño compartido
   (paleta cálida terracota/crema, Newsreader + Work Sans)
   ============================================================ */

:root {
  --accent: oklch(58% 0.16 35);
  --accent-ink: oklch(99% 0.01 35);

  --bg: oklch(97% 0.014 75);
  --bg-deep: oklch(93% 0.03 55);
  --surface: oklch(99% 0.006 75);
  --surface-2: oklch(95% 0.014 72);

  --ink: oklch(24% 0.02 50);
  --ink-soft: oklch(48% 0.018 55);
  --line: oklch(90% 0.014 70);

  --olive: oklch(48% 0.07 140);
  --wa: oklch(52% 0.1 155);
  --wa-ink: oklch(98% 0.01 155);

  --sidebar: oklch(24% 0.02 50);
  --sidebar-line: oklch(34% 0.02 50);
  --sidebar-text: oklch(88% 0.01 60);
  --sidebar-text-dim: oklch(62% 0.015 55);
  --sidebar-active: oklch(31% 0.025 50);

  --ok: oklch(52% 0.1 150);
  --ok-bg: oklch(94% 0.035 150);
  --warn: oklch(55% 0.13 70);
  --warn-bg: oklch(93% 0.05 75);
  --bad: oklch(52% 0.14 25);
  --bad-bg: oklch(93% 0.045 25);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --shadow-lg: 0 30px 60px -30px oklch(30% 0.03 50 / 0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Work Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
h1, h2, h3, .font-serif { font-family: 'Newsreader', serif; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ── Layout: sidebar + main (Admin / Master) ─────────────── */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 252px; flex: 0 0 auto; background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; padding: 22px 16px; position: sticky; top: 0; height: 100vh;
}
.brand-row { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; border-bottom: 1px solid var(--sidebar-line); margin-bottom: 18px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: flex; align-items: center; justify-content: center; font-family: 'Newsreader', serif; font-weight: 600; font-size: 14px; flex: 0 0 auto; }
.brand-name { font-size: 13px; font-weight: 600; letter-spacing: 0.01em; }
.tenant-row { padding: 6px 8px 20px; }
.tenant-name { font-family: 'Newsreader', serif; font-size: 19px; font-weight: 600; color: oklch(97% 0.008 60); }
.tenant-tag { font-size: 12px; color: var(--sidebar-text-dim); margin-top: 2px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; color: var(--sidebar-text-dim); font-size: 13.5px; font-weight: 500; border: none; background: none; width: 100%; text-align: left; }
.nav-item svg { flex: 0 0 auto; opacity: 0.85; }
.nav-item.active { background: var(--sidebar-active); color: oklch(98% 0.006 60); }
.nav-item.active svg { opacity: 1; color: var(--accent); }
.sidebar-footer { border-top: 1px solid var(--sidebar-line); padding-top: 14px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: oklch(38% 0.02 50); color: oklch(92% 0.01 60); display: flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 600; flex: 0 0 auto; }
.foot-name { font-size: 12.5px; font-weight: 600; color: oklch(94% 0.008 60); }
.foot-role { font-size: 11px; color: var(--sidebar-text-dim); background: none; border: none; padding: 0; cursor: pointer; }

.main { flex: 1; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 26px 36px 20px; border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 25px; font-weight: 600; margin: 0; }
.topbar .sub { font-size: 13px; color: var(--ink-soft); margin-top: 3px; }
.content { padding: 22px 36px 40px; }

/* ── Botones ──────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 8px; border-radius: 10px; padding: 10px 16px; font-size: 13.5px; font-weight: 600; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-sm { padding: 7px 12px; font-size: 12px; border-radius: 8px; }
.btn-danger { color: var(--bad); }

/* ── Tarjetas / stats ─────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); }
.stats-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card { padding: 18px 20px; }
.stat-label { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 8px; }
.stat-value { font-family: 'Newsreader', serif; font-size: 30px; font-weight: 600; }
.stat-value.warn { color: var(--warn); }
.stat-value.bad { color: var(--bad); }

/* ── Tabla ────────────────────────────────────────────────── */
.table-card { overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
thead th { text-align: left; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft); padding: 14px 20px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
tbody td { padding: 16px 20px; border-bottom: 1px solid var(--line); font-size: 13.5px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }

.local-cell { display: flex; align-items: center; gap: 10px; }
.local-mono { width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-family: 'Newsreader', serif; font-weight: 600; font-size: 13px; color: var(--accent-ink); flex: 0 0 auto; background: var(--accent); }
.local-name { font-weight: 600; }
.local-email { font-size: 11.5px; color: var(--ink-soft); }

.pill { display: inline-flex; align-items: center; padding: 4px 11px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.pill.ok { color: var(--ok); background: var(--ok-bg); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.bad { color: var(--bad); background: var(--bad-bg); }

.actions-cell { display: flex; gap: 8px; }
.a-btn { padding: 7px 12px; border-radius: 8px; font-size: 12px; font-weight: 600; border: 1px solid var(--line); background: var(--bg); color: var(--ink-soft); }
.a-btn.manage { border-color: var(--accent); color: var(--accent); background: oklch(97% 0.02 45); }
.a-btn.danger { color: var(--bad); }

/* ── Formularios / modal ─────────────────────────────────── */
.form-group { margin-bottom: 16px; text-align: left; }
.form-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.form-control { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 13.5px; font-family: inherit; }
.form-control:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.modal-overlay { position: fixed; inset: 0; background: oklch(20% 0.02 50 / 0.45); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-overlay.active { display: flex; }
.modal-sheet { background: var(--surface); border-radius: var(--radius-lg); padding: 28px; width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); }

.toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: var(--ink); color: oklch(96% 0.01 70); padding: 12px 18px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow-lg); }
.toast.error { background: var(--bad); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-soft); font-size: 13.5px; }
