/* ============================================================
   TOKENS
   ============================================================ */
:root {
  color-scheme: light;

  --canvas:      oklch(0.973 0.004 30);
  --surface:     oklch(1 0 0);
  --surface-2:   oklch(0.958 0.005 30);   /* segunda capa: rail, toolbars */
  --surface-3:   oklch(0.945 0.006 30);   /* hover de fila */
  --line:        oklch(0.902 0.007 30);
  --line-soft:   oklch(0.938 0.005 30);

  --ink:         oklch(0.235 0.014 30);
  --ink-2:       oklch(0.455 0.012 30);   /* texto secundario, 4.5:1 sobre surface */
  --ink-3:       oklch(0.600 0.010 30);   /* solo iconos/separadores, nunca prosa */

  --brand:       oklch(0.452 0.155 25);
  --brand-hover: oklch(0.392 0.150 25);
  --brand-ink:   oklch(0.99 0 0);
  --brand-soft:  oklch(0.955 0.028 25);
  --brand-line:  oklch(0.855 0.065 25);

  --amber:       oklch(0.520 0.115 68);
  --amber-soft:  oklch(0.955 0.045 80);
  --green:       oklch(0.470 0.105 155);
  --green-soft:  oklch(0.955 0.040 155);
  --blue:        oklch(0.480 0.120 250);
  --blue-soft:   oklch(0.955 0.035 250);

  --focus:       oklch(0.55 0.16 255);

  --r-panel: 10px;
  --r-ctl: 7px;
  --r-pill: 999px;

  --shadow-1: 0 1px 2px oklch(0.2 0.02 30 / 0.05);
  --shadow-2: 0 1px 2px oklch(0.2 0.02 30 / 0.06), 0 8px 24px oklch(0.2 0.02 30 / 0.08);
  --shadow-3: 0 12px 48px oklch(0.2 0.02 30 / 0.18), 0 2px 6px oklch(0.2 0.02 30 / 0.10);

  --z-sticky: 20;
  --z-rail: 30;
  --z-backdrop: 40;
  --z-dialog: 50;
  --z-toast: 60;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 180ms;

  --rail-w: 224px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas:      oklch(0.178 0.008 30);
  --surface:     oklch(0.222 0.009 30);
  --surface-2:   oklch(0.198 0.009 30);
  --surface-3:   oklch(0.262 0.010 30);
  --line:        oklch(0.312 0.011 30);
  --line-soft:   oklch(0.268 0.010 30);

  --ink:         oklch(0.962 0.004 30);
  --ink-2:       oklch(0.762 0.010 30);
  --ink-3:       oklch(0.605 0.010 30);

  --brand:       oklch(0.700 0.150 25);
  --brand-hover: oklch(0.760 0.145 25);
  --brand-ink:   oklch(0.16 0.02 25);
  --brand-soft:  oklch(0.300 0.055 25);
  --brand-line:  oklch(0.400 0.080 25);

  --amber:       oklch(0.800 0.120 78);
  --amber-soft:  oklch(0.310 0.050 70);
  --green:       oklch(0.760 0.110 155);
  --green-soft:  oklch(0.295 0.045 155);
  --blue:        oklch(0.770 0.100 250);
  --blue-soft:   oklch(0.300 0.050 250);

  --focus:       oklch(0.72 0.13 255);

  --shadow-1: 0 1px 2px oklch(0 0 0 / 0.30);
  --shadow-2: 0 1px 2px oklch(0 0 0 / 0.35), 0 8px 24px oklch(0 0 0 / 0.35);
  --shadow-3: 0 16px 56px oklch(0 0 0 / 0.55), 0 2px 6px oklch(0 0 0 / 0.4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --canvas:      oklch(0.178 0.008 30);
    --surface:     oklch(0.222 0.009 30);
    --surface-2:   oklch(0.198 0.009 30);
    --surface-3:   oklch(0.262 0.010 30);
    --line:        oklch(0.312 0.011 30);
    --line-soft:   oklch(0.268 0.010 30);
    --ink:         oklch(0.962 0.004 30);
    --ink-2:       oklch(0.762 0.010 30);
    --ink-3:       oklch(0.605 0.010 30);
    --brand:       oklch(0.700 0.150 25);
    --brand-hover: oklch(0.760 0.145 25);
    --brand-ink:   oklch(0.16 0.02 25);
    --brand-soft:  oklch(0.300 0.055 25);
    --brand-line:  oklch(0.400 0.080 25);
    --amber:       oklch(0.800 0.120 78);
    --amber-soft:  oklch(0.310 0.050 70);
    --green:       oklch(0.760 0.110 155);
    --green-soft:  oklch(0.295 0.045 155);
    --blue:        oklch(0.770 0.100 250);
    --blue-soft:   oklch(0.300 0.050 250);
    --focus:       oklch(0.72 0.13 255);
    --shadow-1: 0 1px 2px oklch(0 0 0 / 0.30);
    --shadow-2: 0 1px 2px oklch(0 0 0 / 0.35), 0 8px 24px oklch(0 0 0 / 0.35);
    --shadow-3: 0 16px 56px oklch(0 0 0 / 0.55), 0 2px 6px oklch(0 0 0 / 0.4);
  }
}

/* ============================================================
   BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv05", "ss01";
}
h1,h2,h3,p,ul,ol,figure { margin: 0; }
ul, ol { list-style: none; padding: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
:where(a, button, input, [tabindex], summary):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-ctl);
}
.tnum { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ============================================================
   SHELL
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  min-height: 100dvh;
}

/* ---------- Rail ---------- */
.rail {
  position: sticky; top: 0; z-index: var(--z-rail);
  height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--surface-2);
  border-right: 1px solid var(--line);
  padding: 14px 10px 10px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand-mark {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--brand); color: var(--brand-ink);
  font-weight: 650; font-size: 13px; letter-spacing: 0.01em;
}
.brand-name { font-weight: 600; font-size: 13.5px; letter-spacing: -0.005em; }
.brand-sub { font-size: 11.5px; color: var(--ink-2); margin-top: -1px; }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--ink-3); padding: 14px 8px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 7px 8px;
  background: none; border: 0; border-radius: var(--r-ctl);
  text-align: left; cursor: pointer;
  color: var(--ink-2); font-size: 13.5px; font-weight: 500;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav-item svg { width: 16px; height: 16px; flex: none; opacity: 0.85; }
.nav-item:hover { background: var(--surface-3); color: var(--ink); }
.nav-item[aria-current="page"] {
  background: var(--surface); color: var(--ink); font-weight: 600;
  box-shadow: var(--shadow-1);
}
.nav-item[aria-current="page"] svg { color: var(--brand); opacity: 1; }
.nav-count {
  margin-left: auto; font-size: 11.5px; font-weight: 600;
  color: var(--ink-3); font-variant-numeric: tabular-nums;
}
.nav-item[aria-current="page"] .nav-count { color: var(--ink-2); }
.nav-count[data-alert] { color: var(--brand); }

.rail-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); }
.user {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 7px 8px; border: 0; background: none; border-radius: var(--r-ctl);
  cursor: pointer; text-align: left;
  transition: background var(--dur) var(--ease);
}
.user:hover { background: var(--surface-3); }
.avatar {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 650; letter-spacing: 0.01em;
  background: var(--surface-3); color: var(--ink-2);
  border: 1px solid var(--line);
}
.avatar[data-who="ie"] { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-line); }
.avatar[data-who="sr"] { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.user-name { font-size: 13px; font-weight: 550; }
.user-role { font-size: 11.5px; color: var(--ink-2); margin-top: -2px; }

/* ---------- Main ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  display: flex; align-items: center; gap: 12px;
  padding: 12px 24px;
  background: color-mix(in oklab, var(--canvas) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.page-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.page-date { font-size: 13px; color: var(--ink-2); }
.topbar-sep { width: 1px; height: 16px; background: var(--line); }

.search {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  min-width: 210px; padding: 6px 8px 6px 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-ctl);
  color: var(--ink-2); font-size: 13px; cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.search:hover { border-color: var(--ink-3); background: var(--surface-3); }
.search svg { width: 15px; height: 15px; opacity: 0.7; }
.kbd {
  margin-left: auto; display: inline-flex; gap: 1px;
  font-size: 11px; font-weight: 550; color: var(--ink-3);
  border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px;
  background: var(--surface-2);
}

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: var(--r-ctl);
  border: 1px solid transparent; cursor: pointer;
  font-size: 13px; font-weight: 550; white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-hover); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-quiet { background: none; color: var(--ink-2); padding: 6px 8px; }
.btn-quiet:hover { background: var(--surface-3); color: var(--ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.icon-btn {
  display: grid; place-items: center; width: 32px; height: 32px;
  border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; color: var(--ink-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn svg { width: 16px; height: 16px; }

/* ---------- Status line (no KPI cards) ---------- */
.statusline {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0 18px;
  padding: 14px 24px 0;
  font-size: 13px; color: var(--ink-2);
}
.stat { display: inline-flex; align-items: baseline; gap: 6px; }
.stat b {
  font-size: 15px; font-weight: 650; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.stat[data-tone="alert"] b { color: var(--brand); }
.stat[data-tone="warn"] b { color: var(--amber); }
.stat-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--ink-3); opacity: 0.6; }

/* ---------- Content grid ---------- */
.view { padding: 18px 24px 40px; }
.cols {
  display: grid; gap: 18px;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  align-items: start;
}
.stack { display: grid; gap: 18px; }

/* ---------- Panel ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  box-shadow: var(--shadow-1);
  overflow: clip;
}
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.panel-title { font-size: 13.5px; font-weight: 620; letter-spacing: -0.005em; }
.panel-note { font-size: 12px; color: var(--ink-2); }
.panel-head .spacer { margin-left: auto; }
.panel-foot {
  padding: 9px 14px; border-top: 1px solid var(--line-soft);
  background: var(--surface-2);
  font-size: 12.5px;
}
.link {
  color: var(--brand); font-weight: 550; text-decoration: none;
  border-radius: 4px;
}
.link:hover { text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Agenda / timeline ---------- */
.daygroup + .daygroup { border-top: 1px solid var(--line-soft); }
.dayhead {
  position: sticky; top: 57px; z-index: 2;
  display: flex; align-items: baseline; gap: 8px;
  padding: 8px 14px;
  background: color-mix(in oklab, var(--surface) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line-soft);
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase;
  color: var(--ink-2);
}
.dayhead .rel { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--ink-3); }
.dayhead[data-today="true"] { color: var(--brand); }

.slot {
  display: grid;
  grid-template-columns: 62px 14px minmax(0, 1fr);
  gap: 0 4px;
  width: 100%;
  padding: 11px 14px 11px 10px;
  border: 0; background: none; text-align: left; cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.slot:hover { background: var(--surface-3); }
.slot + .slot { border-top: 1px solid var(--line-soft); }
.slot-time {
  font-size: 13px; font-weight: 600; color: var(--ink);
  font-variant-numeric: tabular-nums; padding-top: 1px;
}
.slot-dur { display: block; font-size: 11.5px; font-weight: 450; color: var(--ink-3); }
.slot-rail { position: relative; display: grid; justify-items: center; }
.slot-rail::before {
  content: ""; position: absolute; top: 0; bottom: -12px; width: 1px;
  background: var(--line);
}
.slot:last-child .slot-rail::before { bottom: 6px; }
.slot-dot {
  position: relative; z-index: 1; margin-top: 5px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--ink-3);
}
.slot[data-kind="audiencia"] .slot-dot { border-color: var(--brand); background: var(--brand); }
.slot[data-kind="fiscalia"] .slot-dot { border-color: var(--amber); }
.slot[data-kind="interno"]  .slot-dot { border-color: var(--blue); }

.slot-body { min-width: 0; }
.slot-title {
  font-size: 13.5px; font-weight: 570; color: var(--ink);
  text-wrap: pretty;
}
.slot-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  margin-top: 3px; font-size: 12.5px; color: var(--ink-2);
}
.slot-meta .dotsep { width: 3px; height: 3px; border-radius: 50%; background: var(--ink-3); opacity: 0.5; }
.slot-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }

/* ---------- Chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 7px; border-radius: 5px;
  font-size: 11.5px; font-weight: 560; letter-spacing: 0.005em;
  background: var(--surface-3); color: var(--ink-2);
  white-space: nowrap;
}
.chip[data-tone="brand"] { background: var(--brand-soft); color: var(--brand); }
.chip[data-tone="amber"] { background: var(--amber-soft); color: var(--amber); }
.chip[data-tone="green"] { background: var(--green-soft); color: var(--green); }
.chip[data-tone="blue"]  { background: var(--blue-soft);  color: var(--blue); }
.chip-src { border: 1px solid var(--line); background: transparent; color: var(--ink-2); }
.chip-src::before {
  content: ""; width: 6px; height: 6px; border-radius: 2px; background: var(--ink-3);
}
.chip-src[data-src="gcal"]::before { background: var(--blue); }
.chip-src[data-src="manual"]::before { background: var(--ink-3); }

/* ---------- Task rows ---------- */
.row {
  display: grid; grid-template-columns: 22px minmax(0,1fr) auto; gap: 10px;
  align-items: start; padding: 10px 14px;
  transition: background var(--dur) var(--ease);
}
.row + .row { border-top: 1px solid var(--line-soft); }
.row:hover { background: var(--surface-3); }
.check {
  appearance: none; margin: 2px 0 0; width: 16px; height: 16px;
  border: 1.5px solid var(--ink-3); border-radius: 5px; background: var(--surface);
  cursor: pointer; display: grid; place-items: center;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.check:hover { border-color: var(--ink-2); }
.check:checked { background: var(--green); border-color: var(--green); }
.check:checked::after {
  content: ""; width: 9px; height: 5px;
  border-left: 2px solid var(--surface); border-bottom: 2px solid var(--surface);
  transform: rotate(-45deg) translate(1px, -1px);
}
.row-title { font-size: 13.5px; font-weight: 530; text-wrap: pretty; }
.check:checked ~ .row-main .row-title { color: var(--ink-3); text-decoration: line-through; }
.row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 3px; font-size: 12.5px; color: var(--ink-2); }
.row-side { display: flex; align-items: center; gap: 8px; padding-top: 1px; }
.avatar-xs {
  width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  font-size: 9.5px; font-weight: 650;
  background: var(--surface-3); color: var(--ink-2); border: 1px solid var(--line);
}
.avatar-xs[data-who="ie"] { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-line); }
.avatar-xs[data-who="sr"] { background: var(--blue-soft); color: var(--blue); border-color: transparent; }

/* ---------- Table (causas) ---------- */
/* contenedor de scroll propio: el thead se pega dentro de él, no a la página */
.tablewrap { overflow: auto; max-height: calc(100dvh - 190px); overscroll-behavior: contain; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  position: sticky; top: 0; z-index: 2;
  text-align: left; font-size: 11.5px; font-weight: 600;
  letter-spacing: 0.03em; text-transform: uppercase; color: var(--ink-2);
  padding: 9px 14px; background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td {
  padding: 9px 14px; border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
table.data tbody tr { transition: background var(--dur) var(--ease); cursor: pointer; }
table.data tbody tr:hover { background: var(--surface-3); }
table.data tbody tr:last-child td { border-bottom: 0; }
.cell-strong { font-weight: 560; }
.cell-mono { font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; }
.cell-muted { color: var(--ink-2); }
.empty-val { color: var(--ink-3); }

.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
}
.field {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 10px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-ctl);
  min-width: 200px; flex: 1 1 240px; max-width: 340px;
}
.field svg { width: 15px; height: 15px; color: var(--ink-3); flex: none; }
.field input { border: 0; background: none; outline: none; width: 100%; font-size: 13px; }
.field input::placeholder { color: var(--ink-2); }
.field:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in oklab, var(--focus) 18%, transparent); }
select.sel {
  padding: 6px 10px; border-radius: var(--r-ctl);
  border: 1px solid var(--line); background: var(--surface-2);
  font-size: 13px; cursor: pointer;
}

/* ---------- Empty states ---------- */
.empty { padding: 26px 18px 28px; text-align: center; }
.empty-mark {
  width: 34px; height: 34px; margin: 0 auto 10px;
  display: grid; place-items: center; border-radius: 9px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-3);
}
.empty-mark svg { width: 17px; height: 17px; }
.empty h3 { font-size: 13.5px; font-weight: 600; }
.empty p {
  font-size: 12.5px; color: var(--ink-2); margin: 4px auto 12px;
  max-width: 42ch; text-wrap: pretty;
}

/* ---------- Command palette ---------- */
dialog.cmdk {
  width: min(620px, calc(100vw - 32px));
  padding: 0; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-3);
  margin-top: 12vh;
}
dialog.cmdk::backdrop { background: oklch(0.2 0.02 30 / 0.32); backdrop-filter: blur(2px); }
.cmdk-field { display: flex; align-items: center; gap: 10px; padding: 13px 15px; border-bottom: 1px solid var(--line-soft); }
.cmdk-field svg { width: 17px; height: 17px; color: var(--ink-3); }
.cmdk-field input { flex: 1; border: 0; background: none; outline: none; font-size: 15px; }
.cmdk-list { max-height: 46vh; overflow-y: auto; padding: 6px; }
.cmdk-group { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); padding: 9px 9px 5px; }
.cmdk-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 9px; border: 0; background: none; border-radius: 7px;
  text-align: left; cursor: pointer; font-size: 13.5px;
}
.cmdk-item[data-active="true"] { background: var(--surface-3); }
.cmdk-item .sub { margin-left: auto; font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.cmdk-foot {
  display: flex; gap: 14px; padding: 9px 15px; border-top: 1px solid var(--line-soft);
  background: var(--surface-2); font-size: 11.5px; color: var(--ink-2);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: var(--z-toast); left: 50%; bottom: 26px;
  transform: translate(-50%, 12px);
  display: flex; align-items: center; gap: 9px;
  padding: 10px 14px; border-radius: 9px;
  background: var(--ink); color: var(--canvas);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-2);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.toast[data-show="true"] { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Skeleton ---------- */
.sk { background: var(--surface-3); border-radius: 5px; height: 11px; animation: pulse 1.4s var(--ease) infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: 0.45 } }

/* ---------- Formularios ---------- */
.formwrap {
  display: grid; gap: 18px; align-items: start;
  grid-template-columns: minmax(0, 1fr) 316px;
  max-width: 1080px;
}
.formsec { padding: 16px 18px; }
.formsec + .formsec { border-top: 1px solid var(--line-soft); }
.formsec h3 { font-size: 13px; font-weight: 620; letter-spacing: -0.005em; }
.formsec > p { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; text-wrap: pretty; }
.fgrid { display: grid; gap: 13px; margin-top: 13px; }
.fgrid.two { grid-template-columns: 1fr 1fr; }
.fgrid.three { grid-template-columns: 1fr 1fr 1fr; }
.lbl { display: block; font-size: 12.5px; font-weight: 560; margin-bottom: 5px; }
.lbl .opt { font-weight: 450; color: var(--ink-3); }
.inp {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: var(--r-ctl);
  background: var(--surface); font-size: 13.5px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.inp::placeholder { color: var(--ink-2); }
.inp:hover { border-color: var(--ink-3); }
.inp:focus {
  outline: none; border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--focus) 18%, transparent);
}
.inp:disabled { background: var(--surface-2); color: var(--ink-2); cursor: not-allowed; }
.inp[aria-invalid="true"] {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--brand) 15%, transparent);
}
textarea.inp { resize: vertical; min-height: 68px; line-height: 1.5; }
.hint { font-size: 12px; color: var(--ink-2); margin-top: 5px; text-wrap: pretty; }
.err { font-size: 12px; color: var(--brand); font-weight: 530; margin-top: 5px; display: none; }
.err[data-show="true"] { display: block; }

.seg {
  display: inline-flex; gap: 2px; padding: 2px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-ctl);
}
.seg button {
  border: 0; background: none; cursor: pointer;
  padding: 5px 11px; border-radius: 5px;
  font-size: 13px; color: var(--ink-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] {
  background: var(--surface); color: var(--ink); font-weight: 560; box-shadow: var(--shadow-1);
}

.switchrow {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 11px 13px; margin-top: 13px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-ctl);
}
.switch {
  appearance: none; flex: none; position: relative;
  width: 34px; height: 20px; margin: 1px 0 0;
  border-radius: var(--r-pill); border: 1px solid var(--line);
  background: var(--surface-3); cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--surface); box-shadow: var(--shadow-1);
  transition: transform var(--dur) var(--ease);
}
.switch:checked { background: var(--green); border-color: var(--green); }
.switch:checked::after { transform: translateX(14px); }
.switchrow .txt { display: block; font-size: 13px; font-weight: 530; }
.switchrow .sub { display: block; font-size: 12px; color: var(--ink-2); margin-top: 2px; text-wrap: pretty; }

.formbar {
  position: sticky; bottom: 0; z-index: 3;
  display: flex; align-items: center; gap: 8px;
  padding: 11px 18px; border-top: 1px solid var(--line);
  background: color-mix(in oklab, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
}
.formbar .note { margin-left: auto; font-size: 12px; color: var(--ink-2); }

.preview { position: sticky; top: 74px; }
.preview .slot { cursor: default; }
.preview .slot:hover { background: none; }

/* ============================================================
   RESPONSIVE (estructural, no tipográfico)
   ============================================================ */
@media (max-width: 1180px) {
  .cols { grid-template-columns: minmax(0, 1fr); }
  .formwrap { grid-template-columns: minmax(0, 1fr); }
  .preview { position: static; }
}
@media (max-width: 640px) {
  .fgrid.two, .fgrid.three { grid-template-columns: minmax(0, 1fr); }
  /* la barra de acciones se apila en vez de cortarse */
  .formbar { flex-wrap: wrap; }
  .formbar .btn { flex: 1 1 auto; justify-content: center; }
  .formbar .note { display: none; }
  .panel-head { flex-wrap: wrap; row-gap: 2px; }
  .panel-head .panel-note { flex: 1 0 100%; }
  .panel-head .spacer { display: none; }
  .seg { width: 100%; }
  .seg button { flex: 1; }
  /* iOS hace zoom al enfocar un input de menos de 16px */
  .inp, .field input, .cmdk-field input { font-size: 16px; }
}
@media (max-width: 900px) {
  :root { --rail-w: 60px; }
  .brand-text, .nav-item span:not(.nav-count), .user-text, .nav-label { display: none; }
  .nav-item { justify-content: center; padding: 9px 0; }
  .nav-count { display: none; }
  .rail { padding: 12px 8px 8px; align-items: center; }
  .brand { padding: 4px 0 14px; }
  .user { justify-content: center; }
  .view, .topbar, .statusline { padding-inline: 14px; }
  .search { min-width: 0; }
  .search span, .kbd { display: none; }
  .page-date, .topbar-sep { display: none; }
}
@media (max-width: 560px) {
  .btn-primary span { display: none; }
  .slot { grid-template-columns: 54px 12px minmax(0,1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}