
:root {
  /* Brand accent — overridable by Tweaks */
  --accent: #2563eb;
  --accent-fg: #ffffff;
  --accent-soft: color-mix(in oklab, var(--accent) 14%, transparent);
  --accent-ring: color-mix(in oklab, var(--accent) 40%, transparent);

  /* Status / priority */
  --pending: #f59e0b;
  --pending-soft: color-mix(in oklab, var(--pending) 14%, transparent);
  --progress: #3b82f6;
  --progress-soft: color-mix(in oklab, var(--progress) 14%, transparent);
  --done: #10b981;
  --done-soft: color-mix(in oklab, var(--done) 14%, transparent);

  --p-high: #ef4444;
  --p-high-soft: color-mix(in oklab, var(--p-high) 14%, transparent);
  --p-mid: #f59e0b;
  --p-mid-soft: color-mix(in oklab, var(--p-mid) 14%, transparent);
  --p-low: #64748b;
  --p-low-soft: color-mix(in oklab, var(--p-low) 14%, transparent);

  /* Geometry */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --radius-lg: 16px;

  /* Density (cell padding & gap base) */
  --pad-y: 14px;
  --pad-x: 16px;
  --gap: 16px;

  /* Fonts */
  --font-sans: "Manrope", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

/* ─── DARK (default) ─────────────────────────────────────── */
:root, [data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0e14;
  --bg-1: #11151d;
  --bg-2: #161b25;
  --bg-3: #1d2330;
  --panel: #11151d;
  --card: #161b25;
  --card-hover: #1b2230;
  --border: #232a38;
  --border-strong: #313a4d;
  --ink:   #f3f5f9;   /* casi blanco — texto principal */
  --ink-1: #d2d8e3;
  --ink-2: #a4adbf;   /* + brillante para mejor legibilidad */
  --ink-3: #7a8398;   /* hints, fechas */
  --shadow-sm: 0 1px 0 rgba(255,255,255,.03) inset, 0 2px 4px rgba(0,0,0,.35);
  --shadow-md: 0 1px 0 rgba(255,255,255,.04) inset, 0 8px 24px rgba(0,0,0,.45);
  --shadow-lg: 0 1px 0 rgba(255,255,255,.05) inset, 0 24px 60px rgba(0,0,0,.55);
  --field-bg: #0e131c;
  --field-border: #2a3243;
}

/* ─── LIGHT ──────────────────────────────────────────────── */
[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f8fa;
  --bg-1: #ffffff;
  --bg-2: #ffffff;
  --bg-3: #f1f3f7;
  --panel: #ffffff;
  --card: #ffffff;
  --card-hover: #f8fafc;
  --border: #e2e6ee;
  --border-strong: #c8cfdb;
  --ink:   #060a14;   /* negro intenso */
  --ink-1: #1f2632;
  --ink-2: #4a5160;   /* más oscuro para mejor lectura */
  --ink-3: #6b7589;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow-md: 0 4px 16px rgba(15,23,42,.08);
  --shadow-lg: 0 24px 60px rgba(15,23,42,.12);
  --field-bg: #ffffff;
  --field-border: #d8dde6;
}

/* ─── Reset & base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html, body, #app { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv11";
  letter-spacing: -0.005em;
  overflow: hidden;
}
button { font-family: inherit; }
button, input, textarea, select {
  font-family: inherit;
  color: inherit;
}
a { color: inherit; text-decoration: none; }

/* ─── App layout ─────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
/* (los breakpoints responsive están al final del archivo) */

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 4px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 18px;
}
.brand-mark {
  width: 42px; height: 42px;
  border-radius: 999px;
  background: #ffffff;
  display: grid; place-items: center;
  flex: none;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--border) inset,
              0 4px 12px rgba(0,0,0,.18);
}
.brand-mark img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-name {
  display: flex; flex-direction: column; line-height: 1.05; min-width: 0;
}
.brand-name b {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.015em;
  color: var(--ink);
}
/* Modo claro: refuerzo negro */
[data-theme="light"] .brand-name b { color: #0a0f1c; }
.brand-name span {
  font-size: 11px;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.24em;
  font-weight: 700;
  margin-top: 4px;
}
[data-theme="light"] .brand-name span { color: #2f3645; }

/* ─── Brand compacto dentro del header (mobile) ──────────── */
.header-brand {
  display: none;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.header-brand .hb-mark {
  width: 36px; height: 36px;
  border-radius: 999px;
  background: #fff;
  overflow: hidden;
  flex: none;
  box-shadow: 0 0 0 1px var(--border) inset, 0 3px 8px rgba(0,0,0,.18);
}
.header-brand .hb-mark img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.header-brand .hb-text {
  display: flex; flex-direction: column; line-height: 1.05; min-width: 0;
}
.header-brand .hb-text b {
  font-size: 15.5px; font-weight: 800; letter-spacing: 0.02em; color: var(--ink);
}
[data-theme="light"] .header-brand .hb-text b { color: #0a0f1c; }
.header-brand .hb-text span {
  font-size: 10px; color: var(--ink-2);
  text-transform: uppercase; letter-spacing: 0.22em;
  font-weight: 700; margin-top: 2px;
}
[data-theme="light"] .header-brand .hb-text span { color: #2f3645; }
.nav-section {
  font-size: 10.5px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 14px 10px 6px;
  font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-1);
  font-size: 14.5px;
  font-weight: 600;
  cursor: default;
  border: 1px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
  position: relative;
}
.nav-item:hover { background: var(--bg-3); color: var(--ink); }
.nav-item[aria-current="page"] {
  background: var(--bg-3);
  color: var(--ink);
  border-color: var(--border);
}
.nav-item[aria-current="page"]::before {
  content: "";
  position: absolute; left: -14px; top: 50%;
  width: 3px; height: 18px; transform: translateY(-50%);
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.nav-icon { width: 18px; height: 18px; flex: none; color: var(--ink-2); }
.nav-item[aria-current="page"] .nav-icon { color: var(--accent); }
.nav-count {
  margin-left: auto;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  background: var(--bg-3);
  color: var(--ink-2);
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.nav-item[aria-current="page"] .nav-count {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: color-mix(in oklab, var(--accent) 25%, transparent);
}
.sidebar-foot { margin-top: auto; padding: 10px 8px; }

/* ─── Header ─────────────────────────────────────────────── */
.main { display: flex; flex-direction: column; overflow: hidden; }
.header {
  height: 60px; flex: none;
  display: flex; align-items: center; gap: 14px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.header h1 {
  font-size: 18.5px; font-weight: 700; margin: 0;
  letter-spacing: -0.02em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.header-sub {
  color: var(--ink-2); font-size: 13px;
  margin-left: 2px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.header-right {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  flex: 0 0 auto;
  flex-wrap: nowrap;
}
.header-right .btn,
.header-right .btn-sm,
.header-right .theme-toggle { flex: 0 0 auto; }

/* Texto que acompaña al ícono en botones de toolbar.
   Base: visible en todos los viewports. Los media queries lo ocultan
   en pantallas chicas para que los botones se vuelvan icon-only y
   no se monten unos sobre otros. */
.btn-label { display: inline-block; }

/* ─── View container ─────────────────────────────────────── */
.view { flex: 1; min-height: 0; overflow: auto; }
.view-pad { padding: 24px 28px 40px; }
.view-narrow { max-width: 720px; margin: 0 auto; }

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-2);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  cursor: default;
  transition: background .15s, border-color .15s, transform .05s, color .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-3); border-color: var(--border-strong); }
.btn:active { transform: translateY(.5px); }
.btn-icon { padding: 0; width: 36px; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: var(--radius-xs); }
.btn-sm.btn-icon { width: 30px; }
.btn svg { width: 15px; height: 15px; }

.btn-primary {
  background: var(--accent);
  border-color: color-mix(in oklab, var(--accent) 60%, #000);
  color: var(--accent-fg);
  box-shadow: 0 1px 0 rgba(255,255,255,.18) inset,
              0 6px 14px color-mix(in oklab, var(--accent) 35%, transparent);
}
.btn-primary:hover {
  background: color-mix(in oklab, var(--accent) 92%, #fff);
  border-color: color-mix(in oklab, var(--accent) 70%, #000);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-1);
}
.btn-ghost:hover { background: var(--bg-3); color: var(--ink); }

.btn-danger {
  background: transparent;
  border-color: color-mix(in oklab, var(--p-high) 40%, var(--border));
  color: var(--p-high);
}
.btn-danger:hover { background: var(--p-high-soft); }

/* ─── Fields ─────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
  display: flex; gap: 6px; align-items: baseline;
}
.field-label .req { color: var(--p-high); }
.field-hint { font-size: 12px; color: var(--ink-3); }
.input, .textarea, .select {
  display: block; width: 100%;
  background: var(--field-bg);
  border: 1px solid var(--field-border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 14.5px;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s, background .15s;
  font-family: inherit;
  font-weight: 500;
}
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.input-invalid, .textarea-invalid {
  border-color: var(--p-high) !important;
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--p-high) 20%, transparent) !important;
}
.error-text {
  font-size: 11.5px;
  color: var(--p-high);
  display: flex; gap: 5px; align-items: center;
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a93a6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* Priority radios */
.priority-group {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.priority-opt {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--field-border);
  border-radius: var(--radius-sm);
  background: var(--field-bg);
  cursor: default;
  font-size: 13px;
  font-weight: 500;
  transition: border-color .12s, background .12s;
  position: relative;
}
.priority-opt input { position: absolute; opacity: 0; pointer-events: none; }
.priority-opt .dot {
  width: 8px; height: 8px; border-radius: 999px;
  background: var(--p-low);
  box-shadow: 0 0 0 3px var(--p-low-soft);
}
.priority-opt[data-p="alta"] .dot { background: var(--p-high); box-shadow: 0 0 0 3px var(--p-high-soft); }
.priority-opt[data-p="media"] .dot { background: var(--p-mid); box-shadow: 0 0 0 3px var(--p-mid-soft); }
.priority-opt:hover { background: var(--bg-3); }
.priority-opt[data-active="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

/* File upload */
.dropzone {
  border: 1.5px dashed var(--field-border);
  border-radius: var(--radius-sm);
  padding: 22px;
  text-align: center;
  background: var(--field-bg);
  transition: border-color .15s, background .15s;
}
.dropzone.dz-active { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .dz-title { font-size: 13px; font-weight: 600; }
.dropzone .dz-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }
.dropzone .dz-icon {
  width: 36px; height: 36px; margin: 0 auto 8px;
  display: grid; place-items: center;
  background: var(--bg-3);
  color: var(--ink-2);
  border-radius: 10px;
}
.dz-file {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--field-border);
  border-radius: var(--radius-sm);
  background: var(--field-bg);
}
.dz-file .dz-thumb {
  width: 36px; height: 36px; flex: none;
  background: var(--bg-3); border-radius: 8px;
  display: grid; place-items: center;
  color: var(--accent);
}
.dz-file .dz-name {
  font-size: 13px; font-weight: 500; flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dz-file .dz-size { color: var(--ink-2); font-size: 11.5px; font-variant-numeric: tabular-nums; }

/* ─── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  letter-spacing: 0.005em;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge .b-dot {
  width: 6px; height: 6px; border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 0 2px color-mix(in oklab, currentColor 18%, transparent);
}
.badge-alta    { color: var(--p-high);   background: var(--p-high-soft); border-color: color-mix(in oklab, var(--p-high) 25%, transparent); }
.badge-media   { color: var(--p-mid);    background: var(--p-mid-soft);  border-color: color-mix(in oklab, var(--p-mid) 25%, transparent); }
.badge-baja    { color: var(--p-low);    background: var(--p-low-soft);  border-color: color-mix(in oklab, var(--p-low) 25%, transparent); }
.badge-pendiente   { color: var(--pending);  background: var(--pending-soft);  border-color: color-mix(in oklab, var(--pending) 25%, transparent); }
.badge-proceso     { color: var(--progress); background: var(--progress-soft); border-color: color-mix(in oklab, var(--progress) 25%, transparent); }
.badge-finalizado  { color: var(--done);     background: var(--done-soft);     border-color: color-mix(in oklab, var(--done) 25%, transparent); }

/* ─── Inbox table ────────────────────────────────────────── */
.toolbar {
  display: flex; gap: 8px; align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

/* ───────────────────────────────────────────────────────────
   Filtros del Archivo — diseño profesional (aplica en TODOS
   los tamaños: PC, tablet y móvil)
   ─────────────────────────────────────────────────────────── */
.archive-toolbar {
  background: var(--panel) !important;
  border: 1px solid var(--border-strong) !important;
  border-radius: var(--radius) !important;
  padding: 16px 18px !important;
  margin-bottom: 16px !important;
  gap: 16px !important;
  align-items: flex-end !important;
  box-shadow: var(--shadow-md) !important;
  display: flex !important;
  flex-wrap: wrap !important;
}
.archive-toolbar .search {
  flex: 1 1 260px;
  min-width: 220px;
  max-width: 380px;
}
.archive-toolbar .search input {
  height: 42px;
  background: var(--field-bg) !important;
  border: 1.5px solid var(--field-border) !important;
  border-radius: 10px !important;
  font-weight: 500;
  font-size: 13.5px;
  padding-left: 40px;
}
.archive-toolbar .search input:hover {
  border-color: color-mix(in oklab, var(--accent) 35%, var(--field-border)) !important;
}
.archive-toolbar .search svg { left: 13px; }

.filter-field {
  display: inline-flex !important;
  flex-direction: column !important;
  gap: 6px !important;
  min-width: 0;
  flex-shrink: 0;
}
.filter-field > span {
  font-size: 11px !important;
  font-weight: 700 !important;
  color: var(--ink-1) !important;
  text-transform: uppercase !important;
  letter-spacing: 0.12em !important;
  padding-left: 2px;
}

.filter-field input[type="date"],
.filter-field select {
  height: 42px !important;
  padding: 0 14px !important;
  font-size: 13.5px !important;
  font-weight: 600 !important;
  background: var(--field-bg) !important;
  border: 1.5px solid var(--field-border) !important;
  border-radius: 10px !important;
  color: var(--ink) !important;
  font-family: inherit;
  min-width: 170px;
  transition:
    border-color .15s ease,
    box-shadow   .15s ease,
    background   .15s ease,
    transform    .08s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.filter-field input[type="date"]:hover,
.filter-field select:hover {
  border-color: color-mix(in oklab, var(--accent) 35%, var(--field-border));
  background: var(--bg-3);
}
.filter-field input[type="date"]:focus,
.filter-field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-ring);
  background: var(--panel);
}
.filter-field input[type="date"]:active,
.filter-field select:active {
  transform: translateY(0.5px);
}

/* Si tiene valor (no vacío) lo destacamos con borde de acento */
.filter-field input[type="date"]:not([value=""]):not(:placeholder-shown),
.filter-field select:not([value=""]) {
  border-color: color-mix(in oklab, var(--accent) 45%, var(--field-border));
}

/* Calendario del date (modo claro: icono oscuro nativo, opacidad media) */
.filter-field input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
  transition: opacity .15s ease, filter .15s ease;
  width: 18px;
  height: 18px;
  padding: 2px;
  border-radius: 4px;
}
.filter-field input[type="date"]:hover::-webkit-calendar-picker-indicator {
  opacity: 1;
  background: var(--bg-3);
}

/* Modo oscuro: invertimos a blanco para que destaque sobre el fondo oscuro */
[data-theme="dark"] .filter-field input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1) brightness(1.3);
  opacity: 0.85;
}
[data-theme="dark"] .filter-field input[type="date"]:hover::-webkit-calendar-picker-indicator {
  opacity: 1;
  background: color-mix(in oklab, var(--accent) 18%, transparent);
}

/* Que el campo entero respete el color-scheme para que el popup del
   calendario nativo también salga oscuro en dark mode */
.filter-field input[type="date"] { color-scheme: light; }
[data-theme="dark"] .filter-field input[type="date"] { color-scheme: dark; }

/* Select con chevron del acento */
.filter-field select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%232563eb' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

/* En móvil los filtros ocupan ancho completo */
@media (max-width: 860px) {
  .archive-toolbar {
    padding: 12px;
    gap: 10px;
  }
  .archive-toolbar .search,
  .archive-toolbar .filter-field {
    flex: 1 1 100%;
    max-width: none;
    min-width: 0;
    width: 100%;
  }
  .filter-field input[type="date"],
  .filter-field select {
    width: 100%;
    min-width: 0;
  }
}
.search {
  position: relative; flex: 1; min-width: 220px; max-width: 360px;
}
.search input {
  width: 100%; height: 36px;
  padding: 0 12px 0 36px;
  background: var(--field-bg);
  border: 1px solid var(--field-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: border-color .15s, box-shadow .15s;
}
.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.search svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--ink-3); width: 14px; height: 14px;
}
.toolbar .chip-group { display: flex; gap: 4px; }
.chip {
  padding: 6px 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 500;
  border-radius: 999px;
  cursor: default;
  transition: background .12s, color .12s, border-color .12s;
  display: inline-flex; gap: 6px; align-items: center;
}
.chip:hover { background: var(--bg-3); color: var(--ink); }
.chip[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: color-mix(in oklab, var(--accent) 30%, transparent);
}
.chip .c-dot {
  width: 7px; height: 7px; border-radius: 999px;
  background: currentColor;
}

.tablewrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl thead th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-2);
  padding: 13px 14px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 1;
}
table.tbl tbody td {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
  color: var(--ink-1);
}
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tbody tr {
  transition: background .12s;
}
table.tbl tbody tr:hover { background: var(--card-hover); }
.cell-code { font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); font-weight: 500; }
.cell-client { font-weight: 600; }
.cell-phone { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-2); }
.cell-date { color: var(--ink-2); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.row-actions-text { display: none; }  /* solo icono por defecto (Bandeja) */

/* Acciones de cada fila de la vista Archivo (Ver / Restaurar / Eliminar) */
.archive-actions {
  display: flex !important;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}
.archive-actions .btn {
  display: inline-flex !important;
  align-items: center;
  gap: 5px;
  visibility: visible !important;
  opacity: 1 !important;
}

.empty {
  padding: 56px 24px;
  text-align: center;
  color: var(--ink-2);
}
.empty .empty-ico {
  width: 44px; height: 44px;
  margin: 0 auto 14px;
  background: var(--bg-3);
  border-radius: 12px;
  display: grid; place-items: center;
  color: var(--ink-2);
}
.empty h3 { color: var(--ink); margin: 0 0 4px; font-size: 14px; }
.empty p { margin: 0; font-size: 12.5px; }

/* ─── Kanban ─────────────────────────────────────────────── */
.kanban {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 18px;
  padding: 24px 28px 28px;
  height: 100%;
  overflow: auto;
}
@media (max-width: 1100px) {
  .kanban { overflow-x: auto; grid-template-columns: repeat(2, minmax(300px, 1fr)); }
}
.col {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  min-height: 0;
  max-height: 100%;
}
.col-h {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px 10px;
}
.col-h .col-dot {
  width: 9px; height: 9px; border-radius: 999px;
}
.col[data-status="pendiente"] .col-dot { background: var(--pending); box-shadow: 0 0 0 3px var(--pending-soft); }
.col[data-status="proceso"] .col-dot   { background: var(--progress); box-shadow: 0 0 0 3px var(--progress-soft); }
.col[data-status="finalizado"] .col-dot{ background: var(--done); box-shadow: 0 0 0 3px var(--done-soft); }
.col-h h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.005em;
}
.col-h .col-count {
  font-size: 11.5px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  background: var(--bg-3);
  border: 1px solid var(--border);
  padding: 1px 8px;
  border-radius: 999px;
}
.col-add {
  margin-left: auto;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 7px;
  color: var(--ink-2);
  background: transparent;
  border: 0;
  cursor: default;
}
.col-add:hover { background: var(--bg-3); color: var(--ink); }

.col-body {
  flex: 1;
  min-height: 80px;
  padding: 6px 12px 14px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
  transition: background .15s;
  border-radius: 0 0 var(--radius) var(--radius);
}
.col-body.dz {
  background: color-mix(in oklab, var(--accent) 6%, transparent);
  outline: 1.5px dashed color-mix(in oklab, var(--accent) 50%, transparent);
  outline-offset: -8px;
}

.kcard {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 13px;
  cursor: grab;
  display: flex; flex-direction: column; gap: 8px;
  transition: transform .15s, box-shadow .2s, border-color .15s, opacity .25s;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.kcard:hover { border-color: var(--border-strong); background: var(--card-hover); box-shadow: var(--shadow-md); }
.kcard.dragging { opacity: .35; cursor: grabbing; transform: rotate(-0.5deg); }
.kcard.entering { animation: cardIn .35s ease both; }
.kcard.leaving { animation: cardOut .35s ease both; pointer-events: none; }

.spin { animation: spin .7s linear infinite; transform-origin: center; }
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(6px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
@keyframes cardOut {
  to { opacity: 0; transform: translateX(40px) scale(.92); filter: blur(2px); }
}

.kcard-row { display: flex; align-items: center; gap: 8px; }
.kcard-code { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-3); font-weight: 600; }
.kcard-client { font-weight: 700; font-size: 14.5px; letter-spacing: -0.005em; color: var(--ink); }
.kcard-desc {
  font-size: 13px; color: var(--ink-1);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}
.kcard-foot {
  display: flex; align-items: center; gap: 10px;
  color: var(--ink-2); font-size: 12px;
  font-weight: 500;
}
.kcard-foot .phone { font-family: var(--font-mono); }
.kcard-foot .age { margin-left: auto; }
.kcard .attach-pill {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--ink-2); font-size: 11px;
}

.col-done-empty {
  padding: 20px 12px;
  text-align: center;
  color: var(--ink-3);
  font-size: 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  margin: 4px 0;
}

/* ─── Modal ──────────────────────────────────────────────── */
.modal-back {
  position: fixed; inset: 0;
  background: rgba(2, 6, 16, 0.55);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  padding: 24px;
  z-index: 50;
  animation: backIn .2s ease;
}
[data-theme="light"] .modal-back { background: rgba(15, 23, 42, 0.42); }
@keyframes backIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: min(720px, 100%);
  max-height: calc(100vh - 48px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: modalIn .2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.modal-h {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-h h2 {
  margin: 0; font-size: 16px; font-weight: 700;
  letter-spacing: -0.01em;
}
.modal-h .modal-code {
  font-family: var(--font-mono); font-size: 12px; color: var(--ink-2);
  background: var(--bg-3); padding: 3px 8px; border-radius: 6px;
}
.modal-h .modal-x {
  margin-left: auto;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  background: transparent; border: 0; border-radius: 8px;
  color: var(--ink-2);
}
.modal-h .modal-x:hover { background: var(--bg-3); color: var(--ink); }
.modal-body { padding: 20px; overflow: auto; }
.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; align-items: center;
  background: var(--bg-1);
}
.modal-foot .left { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.modal-foot .right { margin-left: auto; display: flex; gap: 8px; }

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 20px;
  margin-bottom: 18px;
}
.info-cell .info-label {
  font-size: 11.5px; font-weight: 700;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 5px;
}
.info-cell .info-value { font-size: 14.5px; color: var(--ink); font-weight: 600; }
.info-cell .info-value.mono { font-family: var(--font-mono); font-weight: 500; }

.modal-desc {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 13.5px;
  color: var(--ink-1);
  line-height: 1.55;
  margin-bottom: 14px;
  white-space: pre-wrap;
}
.modal-attach {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.modal-attach .ma-thumb {
  width: 48px; height: 48px;
  background: var(--bg-3);
  border-radius: 9px;
  display: grid; place-items: center;
  color: var(--accent);
}
.section-title {
  font-size: 11px; font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 10px;
}

/* ─── Form view ──────────────────────────────────────────── */
.form-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-md);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 580px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: 1; }
}
.form-h {
  display: flex; flex-direction: column; gap: 4px;
  margin-bottom: 18px;
}
.form-h h2 {
  margin: 0; font-size: 24px; font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--ink);
}
.form-h p {
  margin: 0; color: var(--ink-2); font-size: 14px;
  font-weight: 500;
}

/* ─── Toast ──────────────────────────────────────────────── */
.toast-wrap {
  position: fixed; bottom: 22px; left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  color: var(--ink);
  padding: 10px 14px 10px 12px;
  border-radius: 999px;
  display: flex; align-items: center; gap: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn .25s ease both, toastOut .25s ease 2.6s both;
}
.toast .toast-ic {
  width: 22px; height: 22px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--done-soft); color: var(--done);
}
.toast.t-info .toast-ic { background: var(--progress-soft); color: var(--progress); }
.toast.t-warn .toast-ic { background: var(--pending-soft); color: var(--pending); }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translate(-50%, 8px); }
}

/* ─── Theme toggle ───────────────────────────────────────── */
.theme-toggle {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--ink-1);
  cursor: default;
}
.theme-toggle:hover { background: var(--bg-3); color: var(--ink); }

/* ─── Sparkline / number callouts (optional flourishes) ──── */
.stat-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  margin-bottom: 18px;
}
@media (max-width: 760px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.stat-label {
  font-size: 11.5px; font-weight: 700;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.stat-val {
  font-size: 26px; font-weight: 800;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.stat-trend { font-size: 12px; color: var(--ink-2); font-weight: 500; }
.stat-trend.up { color: var(--done); }
.stat-trend.down { color: var(--p-high); }

/* Tarjeta especial: prioridad desglosada en Alta/Media/Baja con su conteo. */
.stat.stat-priority { gap: 6px; padding-top: 12px; padding-bottom: 12px; }
.stat-prio-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 13.5px;
}
.stat-prio-dot {
  width: 8px; height: 8px; border-radius: 999px; flex-shrink: 0;
}
.stat-prio-name { color: var(--ink-1); font-weight: 600; flex: 1; }
.stat-prio-count {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
}

/* Scrollbars (subtle) */
.view::-webkit-scrollbar, .col-body::-webkit-scrollbar, .modal-body::-webkit-scrollbar { width: 10px; height: 10px; }
.view::-webkit-scrollbar-thumb, .col-body::-webkit-scrollbar-thumb, .modal-body::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 6px; border: 2px solid transparent; background-clip: content-box;
}
.view::-webkit-scrollbar-track, .col-body::-webkit-scrollbar-track, .modal-body::-webkit-scrollbar-track { background: transparent; }

/* Focus ring */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Estilos del Tweaks panel eliminados (componentes ya no existen). */

/* ─────────────────────────────────────────────────────────────
   RESPONSIVE
   - ≤ 1024px (tablet landscape): paddings reducidos
   - ≤ 860px  (tablet/móvil grande): sidebar → bottom nav, header compacto,
                                     modal fullscreen, tablas con scroll-x,
                                     kanban en columna única
   - ≤ 480px  (móvil pequeño): info-grid 1 col, prioridad 1 col, stats 2 col
   ───────────────────────────────────────────────────────────── */

/* ─── Tablet landscape (≤1024px) ─────────────────────────── */
@media (max-width: 1024px) {
  .header { padding: 0 16px; gap: 10px; }
  .header-right { gap: 6px; }
  .view-pad { padding: 20px 22px 32px; }
  .kanban { padding: 18px 20px 22px; gap: 14px; }
  .form-card { padding: 22px; }
}

/* ─── Tablet / móvil grande (≤860px) ─────────────────────── */
@media (max-width: 860px) {
  /* Sidebar pasa a ser una barra inferior */
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }
  .main    { grid-row: 1; min-height: 0; }
  .sidebar {
    grid-row: 2;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--border);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    gap: 4px;
    align-items: stretch;
    height: auto;
  }
  /* Solo ocultamos los elementos del SIDEBAR. El brand del cliente
     (que está dentro de .client-header) debe seguir visible. */
  .sidebar .brand,
  .sidebar .nav-section,
  .sidebar .sidebar-foot { display: none; }
  .nav-item {
    flex: 1;
    flex-direction: column;
    gap: 2px;
    padding: 8px 4px;
    font-size: 10.5px;
    text-align: center;
    border-radius: var(--radius-sm);
    justify-content: center;
    position: relative;
  }
  .nav-item[aria-current="page"]::before { display: none; }
  .nav-icon { width: 20px; height: 20px; }
  .nav-count {
    position: absolute;
    top: 2px; right: calc(50% - 22px);
    margin-left: 0;
    font-size: 9.5px;
    padding: 1px 5px;
    min-width: 18px; line-height: 1;
  }

  /* Header compacto + brand visible (mobile/tablet)
     Los botones del header pasan a icon-only para evitar que se monten
     unos con otros cuando hay 4+ acciones (Refrescar, Contraseña,
     Tema, Salir). El brand reduce a logo + texto compacto. */
  .header {
    height: 60px;
    padding: 0 12px;
    gap: 8px;
  }
  .header h1 { display: none; }       /* el título lo da el bottom-nav */
  .header-sub { display: none; }
  .header-brand { display: flex; margin-right: auto; }

  .header-right {
    margin-left: auto;
    gap: 6px;
    flex-wrap: nowrap;
  }
  .header-right .btn-sm,
  .header-right .btn {
    width: 36px;
    min-width: 36px;
    padding: 0;
    justify-content: center;
  }
  .header-right .btn-label { display: none; }
  .theme-toggle { width: 36px; height: 36px; min-width: 36px; }

  /* View paddings */
  .view-pad { padding: 16px 14px 24px; }

  /* Kanban → una columna por fila, scroll vertical normal */
  .kanban {
    grid-template-columns: 1fr;
    padding: 14px 14px 20px;
    gap: 14px;
    overflow: auto;
  }
  .col { max-height: none; min-height: 180px; }

  /* Modal → casi fullscreen */
  .modal-back { padding: 0; }
  .modal {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  /* Header del modal: compacto en 2 líneas
     Línea 1: [TK-0001] [Estado]                    [X]
     Línea 2: Nombre cliente (h2 ancho completo) */
  .modal-h {
    padding: 12px 14px 10px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
  }
  .modal-h .modal-code { order: 1; }
  .modal-h .badge      { order: 2; }
  .modal-h .modal-x    { order: 3; margin-left: auto; }
  .modal-h h2 {
    order: 4;
    flex: 1 1 100%;
    font-size: 16.5px;
    line-height: 1.25;
    margin: 2px 0 0;
  }

  .modal-body { padding: 14px 14px 18px; }

  /* Info en 2 columnas — los valores son cortos, ahorra mucho alto */
  .info-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px 14px;
    margin-bottom: 16px;
  }
  .info-cell .info-label { margin-bottom: 3px; }
  .info-cell .info-value { font-size: 13.5px; }

  /* Sección de descripción más compacta */
  .modal-desc { padding: 11px 12px; font-size: 13px; line-height: 1.5; }

  /* Adjuntos: previews más compactos */
  .modal-attach { padding: 10px; }
  .modal-attach .ma-thumb { width: 40px; height: 40px; }

  /* Footer del modal en móvil: flex con wrap (como antes) */
  .modal-foot {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .modal-foot .left,
  .modal-foot .right {
    margin-left: 0;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .modal-foot .btn {
    flex: 1 1 auto;
    min-width: 120px;
    height: 36px;
    font-size: 12.5px;
    gap: 6px;
  }

  /* Bandeja (InboxView): tabla marcada con .tw-with-cards → ocultar en móvil */
  .tw-with-cards { display: none !important; }
  /* …y mostrar la lista de tarjetas .ib-list (gana sobre la regla base) */
  .ib-list       { display: flex !important; }

  /* En móvil/tablet: la barra de búsqueda+filtros sube ARRIBA de las stats. */
  .view-pad {
    display: flex;
    flex-direction: column;
  }
  .view-pad > .toolbar { order: -1; }

  /* Archivo (cualquier tabla SIN .tw-with-cards) → cards data-label */
  .tablewrap:not(.tw-with-cards) {
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: visible;
  }
  .tablewrap:not(.tw-with-cards) table.tbl,
  .tablewrap:not(.tw-with-cards) table.tbl tbody,
  .tablewrap:not(.tw-with-cards) table.tbl tr,
  .tablewrap:not(.tw-with-cards) table.tbl td {
    display: block;
    width: 100%;
    min-width: 0;
  }
  .tablewrap:not(.tw-with-cards) table.tbl thead { display: none; }
  .tablewrap:not(.tw-with-cards) table.tbl tr {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
  }
  .tablewrap:not(.tw-with-cards) table.tbl tbody tr:hover { background: var(--panel); }
  .tablewrap:not(.tw-with-cards) table.tbl td {
    border: none;
    border-bottom: 1px dashed var(--border);
    padding: 9px 0;
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 10px;
    align-items: center;
    font-size: 14px;
    color: var(--ink);
  }
  .tablewrap:not(.tw-with-cards) table.tbl tr td:last-child  { border-bottom: 0; padding-bottom: 4px; }
  .tablewrap:not(.tw-with-cards) table.tbl tr td:first-child { padding-top: 4px; }
  .tablewrap:not(.tw-with-cards) table.tbl td::before {
    content: attr(data-label);
    font-size: 10.5px;
    font-weight: 700;
    color: var(--ink-3);
    text-transform: uppercase;
    letter-spacing: 0.1em;
  }
  .tablewrap:not(.tw-with-cards) table.tbl td.cell-code {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--accent);
  }
  .tablewrap:not(.tw-with-cards) table.tbl td:has(.row-actions) { padding: 10px 0 2px; }
  .tablewrap:not(.tw-with-cards) .row-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 6px;
  }
  .tablewrap:not(.tw-with-cards) .row-actions .btn {
    flex: 1; min-width: 100px; justify-content: center;
  }

  /* Archivo en móvil: Ver full-width arriba, Restaurar + Eliminar lado a lado */
  .archive-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    justify-content: stretch;
    width: 100%;
  }
  .archive-actions .btn {
    width: 100%;
    justify-content: center;
    font-size: 12.5px;
    height: 36px;
  }
  /* "Ver" ocupa toda la fila de arriba */
  .archive-actions .btn:first-child {
    grid-column: 1 / -1;
  }

  /* Toolbar */
  .toolbar { gap: 6px; }
  .search  { min-width: 100%; max-width: 100%; }

  /* Stats: 2 col */
  .stat-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  /* Form */
  .form-card { padding: 18px; }
  .form-h h2 { font-size: 19px; }

  /* Client shell paddings */
  .client-header { padding: 14px 16px; }
  .client-foot   { padding: 12px 16px; font-size: 11.5px; text-align: center; }

  /* Toasts: subir para no chocar con bottom nav */
  .toast-wrap { bottom: 84px; }

}

/* ─── Móvil pequeño (≤480px) ─────────────────────────────── */
@media (max-width: 480px) {
  .view-pad { padding: 14px 12px 20px; }

  .stat-row { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat     { padding: 10px 12px; }
  .stat-val { font-size: 19px; }

  /* Form */
  .form-card { padding: 16px; }
  .form-h h2 { font-size: 17px; }
  .priority-group { grid-template-columns: 1fr; gap: 6px; }
  .priority-opt   { padding: 9px 10px; }

  /* Filtros chip más compactos */
  .chip { padding: 5px 9px; font-size: 11.5px; }

  /* Modal en pantallas muy chicas */
  .modal-h .modal-code { font-size: 11px; padding: 2px 6px; }
  .modal-h h2          { font-size: 15.5px; }
  .modal-body          { padding: 12px 12px 16px; }
  .modal-foot .btn     { font-size: 12px; height: 34px; }

  /* Dropzone más bajo */
  .dropzone { padding: 18px 14px; }
  .dz-file  { padding: 8px 10px; }
  .dz-name  { font-size: 12px; }

  /* Kanban cards padding */
  .kcard { padding: 10px 11px; }

  /* Header brand removido en móvil grande, asegurar tamaño */
  .header h1 { font-size: 14.5px; letter-spacing: -0.015em; }

  /* Header compacto en móvil pequeño:
     botones aún icon-only (36×36, conforme al policy de touch targets)
     y gap reducido para que las 4 acciones quepan sin desbordar. */
  .header { padding: 0 10px; gap: 6px; }
  .header-right { gap: 5px; }
  .header-right .btn-sm,
  .header-right .btn,
  .theme-toggle {
    width: 36px;
    min-width: 36px;
    height: 36px;
  }
  .header-right .btn svg,
  .header-right .btn-sm svg,
  .theme-toggle svg { width: 15px; height: 15px; }

  /* Brand del header en móvil: ligeramente más grande para verse mejor. */
  .header-brand .hb-mark { width: 40px; height: 40px; }
  .header-brand .hb-text b { font-size: 16px; }
  .header-brand .hb-text span { font-size: 10.5px; letter-spacing: .2em; }

  /* Bottom nav: tipografía más chica */
  .sidebar .nav-item { font-size: 10px; padding: 6px 2px; }
  .sidebar .nav-icon { width: 18px; height: 18px; }
}

/* ─── Touch targets: asegurar 40+ px en táctil ───────────── */
@media (pointer: coarse) {
  .btn, .btn-sm { min-height: 36px; }
  .chip { min-height: 32px; }
  .theme-toggle { min-width: 36px; min-height: 36px; }
}

/* ─────────────────────────────────────────────────────────────
   RESUMEN DE FILTROS ACTIVOS — Archivo
   ───────────────────────────────────────────────────────────── */
.filter-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: color-mix(in oklab, var(--accent) 8%, var(--panel));
  border: 1px solid color-mix(in oklab, var(--accent) 25%, var(--border));
  border-radius: var(--radius-sm);
}
.filter-summary-count {
  font-size: 13px;
  color: var(--ink-1);
  font-weight: 500;
}
.filter-summary-count b {
  color: var(--accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.filter-summary-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 4px 4px 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--ink-2);
  font-weight: 500;
}
.filter-chip b {
  color: var(--ink);
  font-weight: 700;
}
.filter-chip button {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--ink-2);
  cursor: default;
  transition: background .12s, color .12s;
}
.filter-chip button:hover {
  background: var(--p-high-soft);
  color: var(--p-high);
  border-color: var(--p-high);
}

/* ─────────────────────────────────────────────────────────────
   PAGINACIÓN — funciona en todos los dispositivos
   ───────────────────────────────────────────────────────────── */
.pagination {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}
.pagination-info {
  font-size: 12.5px;
  color: var(--ink-2);
  font-weight: 500;
}
.pagination-info b {
  color: var(--ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.pagination-ctrls {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pg-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--ink-1);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: default;
  transition: background .12s, border-color .12s, color .12s;
}
.pg-btn:hover:not(:disabled):not(.pg-active) {
  background: var(--bg-3);
  border-color: color-mix(in oklab, var(--accent) 35%, var(--border-strong));
  color: var(--ink);
}
.pg-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pg-active {
  background: var(--accent) !important;
  color: var(--accent-fg) !important;
  border-color: color-mix(in oklab, var(--accent) 60%, #000) !important;
  box-shadow: 0 2px 6px color-mix(in oklab, var(--accent) 35%, transparent);
}
.pg-ellipsis {
  min-width: 24px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
  user-select: none;
}
@media (max-width: 560px) {
  .pagination {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
  .pagination-info { text-align: center; }
  .pagination-ctrls { justify-content: center; flex-wrap: wrap; }
  .pg-btn { min-width: 34px; height: 34px; font-size: 12.5px; }
}

/* ─────────────────────────────────────────────────────────────
   IB-CARD — Bandeja muestra tarjetas solo en móvil/tablet.
   En desktop está oculto (se ve la tabla en su lugar).
   ───────────────────────────────────────────────────────────── */
.ib-list {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.ib-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, background .15s, border-color .15s;
  cursor: pointer;
}
.ib-card:hover {
  background: var(--card-hover);
  border-color: var(--border-strong);
}
.ib-card:active { transform: scale(0.997); }

/* Franja izquierda de color según prioridad */
.ib-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--p-low);
}
.ib-card[data-priority="alta"]::before  { background: var(--p-high); }
.ib-card[data-priority="media"]::before { background: var(--p-mid); }
.ib-card[data-priority="baja"]::before  { background: var(--p-low); }

.ib-card-body {
  padding: 12px 14px 14px;
}

/* Fila superior: código + prioridad + edad */
.ib-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.ib-code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-3);
}
.ib-age {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}

/* Nombre del cliente */
.ib-card-name {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}

/* Proyecto */
.ib-card-proj {
  margin: 2px 0 8px;
  font-size: 12.5px;
  color: var(--ink-2);
  font-weight: 500;
}

/* Descripción — máximo 2 líneas */
.ib-card-desc {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--ink-1);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Fila inferior */
.ib-card-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.ib-phone {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2);
}
.ib-attach {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: var(--ink-2);
  font-weight: 600;
  background: var(--bg-3);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 999px;
}

/* Acciones — "Ver detalles" + Restaurar (si aplica) */
.ib-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.ib-card-actions .btn { flex: 1; height: 36px; font-size: 12.5px; }

/* ─────────────────────────────────────────────────────────────
   VISTA DE PROYECTOS (admin)
   ───────────────────────────────────────────────────────────── */

/* Cabecera de página: título + descripción + CTA a la derecha */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.page-head-info { min-width: 0; }
.page-head-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.page-head-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-head-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--ink-1);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .02em;
}
.page-head-sub {
  margin: 0;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.45;
}
.page-head-cta { flex: 0 0 auto; }

/* Toolbar: solo búsqueda full-width */
.proj-toolbar {
  display: flex;
  margin-bottom: 14px;
}
.proj-search {
  flex: 1;
  max-width: none;
}

/* Lista de proyectos */
.proj-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.proj-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color .15s, background .15s, transform .05s;
}
.proj-row:hover {
  border-color: var(--border-strong);
  background: color-mix(in oklab, var(--bg-3) 30%, var(--panel));
}
.proj-row-icon {
  width: 40px; height: 40px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  background: color-mix(in oklab, var(--accent) 14%, var(--bg-3));
  color: var(--accent);
  border-radius: var(--radius-sm);
}
.proj-row-icon svg { width: 20px; height: 20px; }
.proj-row-body  { flex: 1; min-width: 0; }
.proj-row-name {
  font-weight: 600;
  color: var(--ink);
  font-size: 14.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.proj-row-meta {
  font-size: 11.5px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  margin-top: 2px;
}
.proj-row-actions {
  display: flex; align-items: center; gap: 6px;
  flex: 0 0 auto;
}
/* Botones de acción de cada proyecto: WhatsApp / editar / eliminar */
.proj-action-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  padding: 0;
}
.proj-action-icon.proj-action-active {
  color: var(--done);
  border-color: color-mix(in oklab, var(--done) 35%, var(--border));
}
.proj-confirm-text {
  font-size: 12.5px;
  color: var(--ink-2);
  font-weight: 600;
  white-space: nowrap;
}

/* Estado vacío */
.proj-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 24px;
  background: var(--panel);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.proj-empty-icon {
  width: 56px; height: 56px;
  display: grid; place-items: center;
  border-radius: 999px;
  background: color-mix(in oklab, var(--accent) 12%, var(--bg-3));
  color: var(--accent);
  margin-bottom: 14px;
}
.proj-empty-icon svg { width: 26px; height: 26px; }
.proj-empty-title {
  font-size: 15.5px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}
.proj-empty-sub {
  font-size: 13px;
  color: var(--ink-2);
  max-width: 360px;
  line-height: 1.5;
}

/* ── Tablet / móvil grande (≤860px) ── */
@media (max-width: 860px) {
  .page-head {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .page-head-title { font-size: 19px; }
  .page-head-cta { width: 100%; justify-content: center; }
}

/* ── Móvil pequeño (≤480px) ── */
@media (max-width: 480px) {
  .page-head { margin-bottom: 14px; }
  .page-head-title { font-size: 17.5px; }
  .page-head-sub { font-size: 12.5px; }

  .proj-row {
    gap: 10px;
    padding: 12px;
  }
  .proj-row-icon { width: 36px; height: 36px; }
  .proj-row-icon svg { width: 18px; height: 18px; }
  .proj-row-name { font-size: 13.5px; }
  .proj-row-actions { gap: 6px; }
  .proj-row-actions .btn-label { display: none; }
  .proj-row-actions .btn-sm { padding: 0 10px; }
  .proj-confirm-text { font-size: 11.5px; }

  .proj-empty { padding: 32px 16px; }
  .proj-empty-icon { width: 48px; height: 48px; }
  .proj-empty-icon svg { width: 22px; height: 22px; }
  .proj-empty-title { font-size: 14.5px; }
  .proj-empty-sub { font-size: 12.5px; }
}
