/* phos-shell.css — Chrome canónico de la suite Phos: sidebar, topbar, nav,
   botones y toggle de tema. Fuente de verdad: PHOS_FLOW/src/PhosFlow.Web/phos-shell.css.
   Cargar después de theme-light.css + theme-dark.css + theme-accent.css.
   Requiere estructura HTML: <body class="app-shell"><aside class="sidebar">...
   <header class="topbar">... más <div class="sidebar-overlay"> para mobile. */

body {
  background: var(--bg);
  padding-left: var(--sidebar-w);
  transition: padding-left .25s ease;
}

/* Controles canónicos — baseline real de PhosFlow (styles.css:832-853): height 34px,
   border 1.5px, radius var(--radius-sm), font-size 12.5px, focus ring con --accent.
   Una app puede ampliar un control por necesidad funcional, pero no redefinir el tamaño
   base del sistema. */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
select, textarea, .form-control {
  height: 34px;
  padding: 0 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
  background: var(--panel);
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 34px; resize: vertical; }
input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus, textarea:focus, .form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

body.sidebar-collapsed { padding-left: 0; }

/* ── Sidebar ─────────────────────────────────────── */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  z-index: 30;
  transform: translateX(0);
  transition: transform .25s cubic-bezier(.4,0,.2,1), background .25s ease;
  border-right: 1px solid var(--sb-line);
}

body.sidebar-collapsed .sidebar {
  transform: translateX(calc(-1 * var(--sidebar-w)));
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--sb-line);
}

.brand-mark {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .04em;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-xs);
  text-decoration: none;
}

.brand-text { display: flex; flex-direction: column; gap: 2px; }
.brand-name { color: var(--sb-text); font-size: 15px; font-weight: 500; letter-spacing: -.01em; }
.brand-name strong { font-weight: 700; }
.brand-tagline { color: var(--sb-text-dim); font-size: 11px; letter-spacing: .03em; text-transform: uppercase; }

.sidebar-nav {
  flex: 1;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
}

.nav-group-label {
  padding: 10px 10px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--sb-text-dim);
  user-select: none;
}
.nav-group-label:first-child { padding-top: 2px; }

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--sb-text);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  transition: background .15s, color .15s;
}

.nav-item [data-lucide] { width: 17px; height: 17px; stroke-width: 2; flex: 0 0 auto; opacity: .85; transition: opacity .15s; }
.nav-item span:not(.nav-count) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover { background: var(--sb-hover); color: var(--sb-active-text); }
.nav-item:hover [data-lucide] { opacity: 1; }
.nav-item.active { background: var(--sb-active-bg); color: var(--sb-active-text); font-weight: 600; }
.nav-item.active [data-lucide] { opacity: 1; }

.nav-count { flex: 0 0 auto; margin-left: auto; font-size: 12px; font-weight: 500; color: var(--sb-text-dim); font-variant-numeric: tabular-nums; }
.nav-item.active .nav-count { color: var(--sb-active-text); }

.sidebar-footer {
  padding: 8px 8px;
  border-top: 1px solid var(--sb-line);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.help-link {
  margin: 2px 10px 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--sb-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
.help-link:hover { background: var(--sb-hover); color: var(--sb-active-text); }
.help-link [data-lucide] { width: 17px; height: 17px; opacity: .85; }

.user-chip { flex: 1; display: flex; align-items: center; gap: 9px; min-width: 0; color: inherit; text-decoration: none; }
.user-avatar {
  flex: 0 0 30px; width: 30px; height: 30px; border-radius: 50%;
  background: var(--sb-avatar-bg); color: var(--sb-avatar-color);
  font-size: 12px; font-weight: 700; display: grid; place-items: center;
}
.user-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.user-email, .user-info strong { color: var(--sb-text); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role, .user-info small { color: var(--sb-text-dim); font-size: 11px; text-transform: capitalize; }

.btn-sidebar-logout {
  flex: 0 0 30px; width: 30px; height: 30px; border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--sb-text-dim); cursor: pointer;
  display: grid; place-items: center; transition: background .15s, color .15s;
}
.btn-sidebar-logout:hover { background: rgba(220, 38, 38, .18); color: #ff6b6b; }
.btn-sidebar-logout [data-lucide] { width: 15px; height: 15px; }

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.50);
  z-index: 29; opacity: 0; transition: opacity .25s;
}
body.sidebar-open .sidebar-overlay { display: block; opacity: 1; }

/* ── Topbar ─────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}

.topbar-start { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-end { display: flex; align-items: center; gap: 8px; }

.hamburger {
  display: inline-flex; width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  cursor: pointer; align-items: center; justify-content: center; transition: background .15s;
}
.hamburger:hover { background: var(--surface); color: var(--accent); }
.hamburger [data-lucide] { width: 20px; height: 20px; }

.breadcrumb { font-size: 14px; font-weight: 600; color: var(--ink); letter-spacing: -.01em; }

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 0 16px; height: 36px; border: 1px solid transparent; border-radius: var(--radius-sm);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .07s;
  white-space: nowrap; text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn [data-lucide] { width: 15px; height: 15px; stroke-width: 2.2; flex: 0 0 auto; }

.btn-primary {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
  box-shadow: 0 1px 2px rgba(24,24,27,.18), 0 1px 0 rgba(255,255,255,.08) inset;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); box-shadow: 0 2px 8px rgba(24,24,27,.22); }

.btn-secondary { background: var(--panel); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: #f4f6f9; }

.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); color: var(--ink); }

.btn-sm { height: 30px; padding: 0 11px; font-size: 12.5px; }
.btn-full { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; }

.btn-icon {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  cursor: pointer; display: grid; place-items: center; transition: background .15s, color .15s;
}
.btn-icon:hover { background: var(--surface); color: var(--accent); }
.btn-icon [data-lucide] { width: 15px; height: 15px; }

.theme-toggle { width: 36px; height: 36px; }

@media (max-width: 900px) {
  body { padding-left: 0; }
  .sidebar { transform: translateX(calc(-1 * var(--sidebar-w))); }
  body.sidebar-open .sidebar { transform: translateX(0); }
}

/* ── CRUD components ──────────────────────────────────
   Patrones de CRUD compartidos por toda la suite (referencia: PhosFlow "procesos").
   Selectores de componente que antes vivían solo en el css local de PhosFlow.
   Las apps siguen definiendo sus propios .data-table / .form-card / .form-actions
   base; acá solo lo que faltaba uniformar: acciones de fila, chips de valor,
   headers de form-card y grids de formulario. */

/* Acciones de fila (iconos) */
.tbl-row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.tbl-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  height: 26px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: transparent; color: var(--muted); font: inherit; font-size: 11.5px; font-weight: 500;
  cursor: pointer; white-space: nowrap; transition: background .12s, color .12s, border-color .12s;
}
.tbl-btn:hover { background: var(--surface); color: var(--ink); }
.tbl-btn.danger:hover { background: var(--danger-dim); color: var(--danger); border-color: #fecdd3; }
.tbl-btn.primary { background: var(--accent-dim); color: var(--accent); border-color: var(--accent-dim); }
.tbl-btn.primary:hover { background: var(--accent); color: var(--accent-ink); }
.tbl-btn.success { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tbl-btn.success:hover { background: var(--accent-hover); }
.tbl-btn.warning { background: var(--surface); color: var(--ink); border-color: var(--ink); }
.tbl-btn.warning:hover { background: var(--accent-dim); }
.tbl-btn[disabled] { opacity: .4; pointer-events: none; }
.tbl-btn [data-lucide] { width: 14px; height: 14px; }

/* Badges de estado en grilla */
.tbl-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.tbl-badge.ok { background: var(--accent-dim); color: var(--accent); }
.tbl-badge.danger { background: var(--danger-dim); color: var(--danger); }
.tbl-badge.neutral { background: var(--surface); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }

/* Valor en celda */
.op-code { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--ink); }
.op-chip { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 600; background: var(--accent-dim); color: var(--accent); }
.op-muted { color: var(--muted); font-size: 12px; line-height: 1.4; }
.empty-cell { text-align: center; color: var(--muted); padding: 22px 12px; font-size: 12.5px; }

/* Formulario en grilla (dentro de .form-card colapsable) */
.field-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 9px; }
.field-group label { font-size: 12px; font-weight: 600; color: var(--ink); }
.field-group--wide { grid-column: 1 / -1; }
.req { color: var(--accent); }
.form-card-header { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.form-card-header h3 { font-size: 13.5px; font-weight: 700; color: var(--ink); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; padding: 12px; }
/* Scoped: sólo afecta a .form-actions cuando vive dentro de un .form-grid */
.form-grid .form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 6px; margin-top: 2px; padding-top: 9px; border-top: 1px solid var(--line); }

/* Contenedor de tabla con borde propio (alterna a .archivos-table-wrap) */
.data-section { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-xs); overflow: hidden; }

/* Select con flecha (utility: opt-in con class="select-input") */
.select-input {
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364707d' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px;
}

@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* ── Login de suite ──────────────────────────────────
   Pantalla de login uniforme para toda la suite. El color lo pone el
   theme-accent.css de cada producto: mismo layout, acento propio.
   Markup: <div class="login-fallback"><div class="login-fallback-card">
   con .login-brand (brand-mark + nombre) arriba del form. */
.login-fallback {
  position: fixed;
  inset: 0;
  z-index: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(600px 420px at 12% 0%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
    radial-gradient(700px 520px at 92% 100%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
    var(--bg);
}

.login-fallback[hidden] {
  display: none;
}
.login-fallback::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(color-mix(in srgb, var(--ink) 5%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--ink) 5%, transparent) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 40%, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 90% 70% at 50% 40%, #000 30%, transparent 75%);
}
.login-fallback-card {
  position: relative;
  width: min(384px, 100%);
  padding: 32px 30px 26px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
  border-radius: 16px;
  box-shadow:
    0 24px 60px -18px color-mix(in srgb, var(--accent) 35%, rgba(0,0,0,.35)),
    var(--shadow);
  animation: login-card-in .45s cubic-bezier(.22,1,.36,1) both;
}
.login-fallback-card::before {
  content: "";
  position: absolute;
  inset: -1px -1px auto -1px;
  height: 3px;
  border-radius: 16px 16px 0 0;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
@keyframes login-card-in {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to   { opacity: 1; transform: none; }
}
.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 20px; }
.login-brand .brand-mark {
  box-shadow: 0 6px 18px -6px color-mix(in srgb, var(--accent) 60%, transparent);
}
.login-brand .brand-name { color: var(--ink); font-size: 17px; }
.login-brand .brand-tagline { color: var(--muted); }
.login-fallback-card h1 { margin: 0 0 2px; font-size: 18px; letter-spacing: -.01em; }
.login-fallback-card .login-sub { margin: 0 0 18px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.login-fallback-card form { display: flex; flex-direction: column; gap: 13px; }
.login-fallback-card label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 12px; font-weight: 600; color: var(--muted);
  letter-spacing: .02em;
}
.login-fallback-card input {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.login-fallback-card input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.login-fallback-card button[type="submit"] {
  margin-top: 4px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, #fff), var(--accent));
  color: var(--accent-ink);
  font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--accent) 70%, transparent);
  transition: filter .15s, transform .07s, box-shadow .15s;
}
.login-fallback-card button[type="submit"]:hover {
  filter: brightness(1.06);
  box-shadow: 0 10px 26px -8px color-mix(in srgb, var(--accent) 80%, transparent);
}
.login-fallback-card button[type="submit"]:active { transform: scale(.985); }
.login-fallback-error { color: var(--danger, #dc2626); font-size: 13px; min-height: 1em; margin: 0 0 8px; }
.login-fallback-hint {
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.login-fallback-hint a { color: var(--accent); font-weight: 600; text-decoration: none; }
.login-fallback-hint a:hover { text-decoration: underline; }
@media (prefers-reduced-motion: reduce) {
  .login-fallback-card { animation: none; }
}
/* Suite: ayuda, centro operativo, historiales y notificaciones. */
.help-link{margin:2px 10px 6px;display:flex;align-items:center;gap:10px;min-height:32px;padding:7px 10px;border-radius:8px;color:var(--sb-text);text-decoration:none;font-size:13px;font-weight:500}.help-link:hover{background:var(--sb-hover);color:var(--sb-active-text)}.help-link svg{width:17px;height:17px}.notif-bell{position:relative}.notif-badge{position:absolute;right:-3px;top:-4px;min-width:16px;height:16px;padding:0 4px;border-radius:8px;background:#ef4444;color:#fff;font-size:10px;line-height:16px}.ops-metrics{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;margin-bottom:10px}.ops-metric{min-width:0;padding:10px 14px 9px;border:1px solid var(--line);border-top:3px solid var(--line);border-radius:var(--radius);background:var(--panel);box-shadow:var(--shadow-sm)}.ops-metric--blue{border-top-color:#3b82f6}.ops-metric--red{border-top-color:#ef4444}.ops-metric--purple{border-top-color:#8b5cf6}.ops-metric--amber{border-top-color:#f59e0b}.ops-metric-head{display:flex;align-items:center;gap:6px;margin-bottom:6px}.ops-metric-head svg{width:15px;height:15px}.ops-metric-head span,.ops-metric small{display:block;color:var(--muted);font-size:11px}.ops-metric-head span{font-weight:700;letter-spacing:.04em;text-transform:uppercase}.ops-metric strong{display:block;margin:0 0 2px;font-size:26px;line-height:1;font-weight:800}.notif-overlay{position:fixed;inset:0;z-index:599;background:rgba(0,0,0,.25)}.notif-drawer{position:fixed;z-index:600;right:0;top:0;width:min(420px,100%);height:100vh;padding:18px;background:var(--panel);border-left:1px solid var(--line);box-shadow:var(--shadow-lg)}.notif-drawer-header{display:flex;align-items:center;justify-content:space-between}.notif-drawer-header h3{display:flex;gap:8px;align-items:center}.notif-list{display:grid;gap:8px;margin-top:16px}
