/* Corify Intranet — base styles */

:root {
  --color-bg: #f5f7fb;
  --color-surface: #ffffff;
  --color-surface-2: #f1f4f9;
  --color-surface-3: #e9eef5;
  --color-border: #e2e8f0;
  --color-border-strong: #cbd5e1;
  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-text-soft: #94a3b8;
  --color-primary: #0f766e;
  --color-primary-dark: #115e59;
  --color-accent: #2563eb;
  --color-warning: #b45309;
  --color-danger: #b91c1c;
  --color-success: #15803d;
  --color-info: #1d4ed8;

  --sidebar-w: 240px;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.07);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  /* Emails, URLs y slugs largos parten de linea en vez de ensanchar la pagina. */
  overflow-wrap: break-word;
}

/* Ninguna imagen puede desbordar su contenedor en pantallas estrechas. */
img, video { max-width: 100%; height: auto; }

a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 8px; line-height: 1.25; color: var(--color-text); font-weight: 600; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
h4 { font-size: 13px; }

code, pre { font-family: var(--font-mono); font-size: 12.5px; }
.small { font-size: 12px; }
.muted { color: var(--color-text-muted); }

/* ===================== Sidebar ===================== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #0b3a37 0%, #0f4a47 50%, #0d2a52 100%);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  z-index: 20;
  box-shadow: 2px 0 10px rgba(15, 23, 42, 0.08);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px 18px;
  color: white;
}
.sidebar-brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-block;
  width: 32px;
  height: 32px;
  background: url("../img/favicon-corify.svg") center / contain no-repeat;
  flex-shrink: 0;
}
.brand-mark-lg { width: 56px; height: 56px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: 0.2px; color: #f8fafc; }
.brand-tag { font-size: 11px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.8px; }

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  overflow-y: auto;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: white;
  text-decoration: none;
}
.nav-item.active, .nav-item[aria-current="page"] {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.nav-item:hover svg { opacity: 1; }
.nav-item-admin { color: #5eead4; }
.nav-item-admin:hover { color: #99f6e4; }
.nav-divider {
  margin: 14px 12px 6px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #64748b;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(0, 0, 0, 0.15);
}
.sidebar-user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #14b8a6 0%, #3b82f6 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.sidebar-user-meta { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: 12.5px;
  color: #f1f5f9;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-user-email {
  font-size: 11px;
  color: #94a3b8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.logout-form { margin: 0; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: #94a3b8;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.08); color: white; }
.icon-btn svg { width: 16px; height: 16px; }

/* ===================== App shell ===================== */
.app-shell {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.app-shell-anon { margin-left: 0; }

.demo-banner {
  background: linear-gradient(90deg, #fff7ed 0%, #fffbeb 100%);
  color: #9a3412;
  border-bottom: 1px solid #fed7aa;
  text-align: center;
  font-size: 12px;
  padding: 6px 12px;
  letter-spacing: 0.1px;
}

.layout {
  flex: 1;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 36px;
}

.footer {
  text-align: center;
  color: var(--color-text-soft);
  font-size: 11.5px;
  padding: 18px 12px 28px;
}
.footer-sep { margin: 0 6px; opacity: 0.5; }

/* ===================== Page header (hero) ===================== */
.page-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: end;
  margin-bottom: 22px;
}
.eyebrow {
  display: inline-block;
  font-size: 11px;
  color: var(--color-primary);
  background: rgba(15, 118, 110, 0.1);
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.page-header h1 { margin-bottom: 6px; }
.page-sub { color: var(--color-text-muted); max-width: 580px; margin: 0; }
.hero-roles { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 5px; }

.stat-row { display: flex; gap: 10px; flex-wrap: wrap; }
.stat-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px 16px;
  text-align: center;
  min-width: 88px;
}
.stat-num { font-size: 22px; font-weight: 700; color: var(--color-text); line-height: 1.1; }
.stat-lbl { font-size: 10.5px; color: var(--color-text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.stat-available { border-color: rgba(21, 128, 61, 0.25); background: rgba(21, 128, 61, 0.04); }
.stat-pending { border-color: rgba(180, 83, 9, 0.25); background: rgba(180, 83, 9, 0.04); }
.stat-requestable { border-color: rgba(37, 99, 235, 0.2); background: rgba(37, 99, 235, 0.03); }

/* ===================== Sections ===================== */
.section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-head h2, .section-head h3, .section-head h4 { margin: 0; }

/* ===================== Onboarding ===================== */
.onboarding-list { list-style: none; padding: 0; margin: 0; }
.onboarding-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--color-border);
}
.onboarding-item:last-child { border-bottom: none; }
.onboarding-body { flex: 1; min-width: 0; }
.onboarding-title { font-weight: 600; font-size: 13.5px; }
.onboarding-desc { color: var(--color-text-muted); font-size: 12.5px; }

/* Marcar/desmarcar un paso: el circulo del numero es el propio boton, y cada
   paso es su formulario (no se pueden anidar forms). */
.onboarding-toggle { display: flex; flex-shrink: 0; margin: 0; }
.onboarding-check {
  width: 26px; height: 26px; border-radius: 50%;
  border: 1.5px solid var(--color-border-strong);
  background: var(--color-surface);
  color: var(--color-text-muted);
  display: flex; align-items: center; justify-content: center;
  font-family: inherit; font-size: 12px; font-weight: 700;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.onboarding-check:hover { border-color: var(--color-primary); color: var(--color-primary); }
.onboarding-check:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.onboarding-item.is-done .onboarding-check {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
  border-color: transparent;
  color: white;
  font-size: 14px;
}
.onboarding-item.is-done .onboarding-title {
  text-decoration: line-through;
  color: var(--color-text-muted);
}
.onboarding-item.is-done .onboarding-desc { color: var(--color-text-soft); }
.onboarding-done-at { font-size: 11.5px; color: var(--color-success); font-weight: 500; }

/* Contador y barra de progreso de la checklist. */
.onboarding-progress {
  display: flex; align-items: center; gap: 10px;
  margin: -4px 0 10px;
}
.onboarding-bar {
  flex: 1; height: 6px; min-width: 60px;
  border-radius: 999px;
  background: var(--color-surface-3);
  overflow: hidden;
}
.onboarding-bar-fill {
  display: block; height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-accent) 100%);
  transition: width 0.2s;
}
.onboarding-count {
  font-size: 12.5px; font-weight: 600; color: var(--color-text-muted);
  white-space: nowrap;
}

/* ===================== Service cards (compact) ===================== */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
  gap: 12px;
}
.service-card {
  --accent: var(--color-accent);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.08s ease, box-shadow 0.12s ease;
  min-height: 140px;
}
.service-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.service-card-pending { background: #fffbeb; }
.service-card-requestable { background: #fafbfd; }
.service-card-disabled { opacity: 0.55; }

.service-card-head {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: 9px;
  align-items: start;
}
.service-icon {
  width: 30px; height: 30px;
  border-radius: 7px;
  background: var(--accent);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
}
.service-meta { min-width: 0; }
.service-name { margin: 0 0 2px; font-size: 13.5px; font-weight: 600; }
.service-short {
  color: var(--color-text-muted);
  font-size: 12px;
  margin: 0;
  line-height: 1.4;
}
.service-status {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 999px;
  letter-spacing: 0.5px;
  white-space: nowrap;
  align-self: start;
}
.service-status-available { background: rgba(21, 128, 61, 0.12); color: var(--color-success); }
.service-status-pending { background: rgba(180, 83, 9, 0.12); color: var(--color-warning); }
.service-status-requestable { background: rgba(37, 99, 235, 0.1); color: var(--color-info); }
.service-status-disabled { background: rgba(100, 116, 139, 0.15); color: var(--color-text-muted); }
.service-status-documented,
.service-status-structure-reviewed,
.service-status-locally-configured,
.service-status-sso-pending,
.service-status-integrated {
  background: rgba(15, 118, 110, 0.1);
  color: var(--color-primary);
}

.service-card-body { display: flex; flex-direction: column; gap: 6px; }
.service-env {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--color-surface-2);
  border-radius: 5px;
  font-size: 11px;
  align-self: flex-start;
}
.service-env-test { background: #fef3c7; color: #92400e; }
.env-kind { font-weight: 700; color: var(--color-text-muted); font-size: 9.5px; letter-spacing: 0.4px; }
.service-env-test .env-kind { color: var(--color-warning); }
.env-name { color: var(--color-text); }
.service-env-test .env-name { color: #92400e; }
.service-roles { display: flex; flex-wrap: wrap; gap: 3px; }

.service-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 6px;
}

/* ===================== Buttons ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.1s ease, border-color 0.1s ease;
  font-family: inherit;
  white-space: nowrap;
}
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--color-primary); color: white; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border-strong);
}
.btn-secondary:hover { background: var(--color-surface-2); }
.btn-ghost { background: transparent; color: var(--color-text-muted); }
.btn-ghost:hover { background: var(--color-surface-2); color: var(--color-text); }
.btn-link {
  color: var(--color-accent);
  font-weight: 500;
  font-size: 12.5px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}
.btn-link-danger { color: var(--color-danger); }
.btn-link:hover { text-decoration: underline; }

/* ===================== Roles / badges ===================== */
.role-chip {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--color-surface-2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.role-chip-sm { font-size: 10px; padding: 1px 7px; }
.role-chip-strong { background: rgba(15, 118, 110, 0.1); color: var(--color-primary); border-color: rgba(15, 118, 110, 0.2); }
.badge {
  display: inline-block;
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  margin-right: 3px;
}
.badge-ok { background: rgba(21, 128, 61, 0.12); color: var(--color-success); }
.badge-warn { background: rgba(180, 83, 9, 0.12); color: var(--color-warning); }
.badge-info { background: rgba(37, 99, 235, 0.1); color: var(--color-info); }

/* ===================== Login ===================== */
.is-anon { background: linear-gradient(160deg, #f5f7fb 0%, #e7edf6 100%); }
.is-anon .app-shell-anon { background: transparent; }
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.login-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 36px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}
.login-brand { text-align: center; margin-bottom: 22px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.login-brand h1 { margin: 6px 0 4px; font-size: 22px; }
.login-brand p { color: var(--color-text-muted); margin: 0; }
.login-section { margin-top: 22px; }
.btn-sso { width: 100%; }
.login-section h2 { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--color-text-muted); margin-bottom: 10px; font-weight: 600; }
.demo-user-list { display: flex; flex-direction: column; gap: 8px; }
.demo-user-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: background 0.1s ease;
}
.demo-user-row:hover { background: #e7edf6; }
.demo-user-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.demo-user-name { font-weight: 600; font-size: 13.5px; }
.demo-user-email { font-size: 11.5px; }
.demo-user-roles { display: flex; gap: 4px; flex-wrap: wrap; }

/* ===================== Forms ===================== */
.form-grid { display: flex; flex-direction: column; gap: 11px; }
.form-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 14px;
}
.form-card h4 { margin-bottom: 8px; }
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--color-text);
}
.form-grid label.checkbox { flex-direction: row; align-items: center; gap: 8px; font-weight: normal; }
.form-grid input[type="text"],
.form-grid input[type="email"],
.form-grid input[type="password"],
.form-grid input[type="url"],
.form-grid input[type="number"],
.form-grid input[type="color"],
.form-grid select,
.form-grid textarea {
  padding: 7px 10px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: white;
  color: var(--color-text);
}
.form-grid textarea { min-height: 64px; resize: vertical; }
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}
.form-grid fieldset {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
}
.form-grid fieldset legend { font-size: 11px; text-transform: uppercase; color: var(--color-text-muted); padding: 0 6px; letter-spacing: 0.4px; font-weight: 600; }
.form-grid fieldset label { font-size: 12.5px; }
/* Lista larga de pasos de onboarding: dos columnas y scroll para que la
   ficha del usuario no crezca sin control cuando hay muchos pasos. */
.onboarding-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
  gap: 2px 16px;
  margin-top: 6px;
  max-height: 260px;
  overflow-y: auto;
}

.inline-form { display: inline; margin: 0; }

/* Editor de "First steps" de la ficha del usuario: una tarjeta por paso, con
   sus campos en rejilla para que en movil caigan en una columna. */
.step-editor { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.step-row {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  background: var(--color-surface);
}
.step-row.is-hidden { background: var(--color-surface-2); }
.step-row-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 13.5px; }
.step-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: 11px;
}
.step-row-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.step-row-actions label.checkbox { margin-right: auto; }

/* ===================== Tables ===================== */
/* Las tablas del admin van envueltas en `.table-scroll`: si no caben (movil)
   se desplazan dentro de su propio contenedor y nunca ensanchan la pagina. */
.table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-scroll > .data-table { min-width: 560px; }

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 18px;
}
.data-table th, .data-table td {
  text-align: left;
  padding: 9px 13px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--color-border);
}
.data-table th {
  background: var(--color-surface-2);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  font-weight: 600;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fafbfd; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; margin-right: 6px; }

/* ===================== Admin (tabs) ===================== */
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.admin-title { font-size: 22px; margin: 0; }
.admin-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 18px;
}
.admin-tabs a {
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.admin-tabs a:hover { color: var(--color-text); background: var(--color-surface-2); text-decoration: none; }
.admin-tabs a.active, .admin-tabs a[aria-current="page"] {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}
.admin-body { min-width: 0; }
.admin-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }

/* ===================== Admin (service categories) ===================== */
/* Cada categoria es un formulario propio (varios submit con name="action"),
   asi que la fila es flex en vez de una <tr>: no se pueden anidar forms. */
.cat-help { font-size: 12.5px; margin: -4px 0 14px; }
.field-hint { font-size: 11.5px; font-weight: normal; color: var(--color-text-muted); }
.cat-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 8px;
}
.cat-pos {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-text-soft);
  min-width: 18px;
  padding-bottom: 7px;
}
.cat-moves { display: flex; flex-direction: column; gap: 1px; padding-bottom: 4px; }
.cat-moves .btn-link { font-size: 13px; line-height: 1.1; padding: 0 4px; }
.cat-moves .btn-link[disabled] { color: var(--color-text-soft); cursor: default; }
.cat-field { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; font-weight: 500; }
.cat-lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--color-text-muted);
  font-weight: 600;
}
.cat-row input[type="text"],
.cat-row input[type="number"],
.cat-row input[type="color"] {
  padding: 6px 8px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: white;
  color: var(--color-text);
}
.cat-row input[type="color"] { width: 46px; padding: 2px; height: 30px; }
.cat-row input, .ord-row input { max-width: 100%; }
.cat-field-label input { min-width: 190px; }
.cat-field-order input { width: 78px; }
.cat-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; padding-bottom: 2px; }
.cat-renumber { display: block; margin: 0 0 16px 2px; }
/* ===================== Card order (prioridad por usuario) ===================== */
/* Reutiliza los controles de las filas de categoria (.cat-pos, .cat-moves,
   .cat-field, .cat-actions): misma fila-formulario, otro contenido. */
.ord-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 8px;
}
.ord-row input[type="number"] {
  padding: 6px 8px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: white;
  color: var(--color-text);
  width: 78px;
}
.ord-name { font-size: 13px; font-weight: 500; padding-bottom: 6px; min-width: 200px; }
.ord-envs { font-size: 11.5px; margin-left: 6px; font-weight: normal; }
.ord-flag { display: flex; align-items: center; gap: 6px; font-size: 12px; padding-bottom: 6px; }
.grid-actions { display: flex; align-items: center; gap: 10px; margin: 14px 0 0; font-size: 12.5px; }

.cat-preview { margin: 4px 0 0; padding-left: 20px; font-size: 13px; }
.cat-preview li { margin-bottom: 4px; }
.cat-preview .muted { font-size: 12px; margin-left: 6px; }

/* ===================== Misc ===================== */
.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: 14px;
  margin-top: 8px;
}
.profile-grid > div > div { font-weight: 500; margin-top: 2px; }
.empty-state {
  background: var(--color-surface-2);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  color: var(--color-text-muted);
}
.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash {
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  border-left: 3px solid;
  font-size: 12.5px;
}
.flash-info { background: #eff6ff; border-color: var(--color-info); color: var(--color-info); }
.flash-success { background: #ecfdf5; border-color: var(--color-success); color: var(--color-success); }
.flash-warning { background: #fffbeb; border-color: var(--color-warning); color: var(--color-warning); }
.flash-error { background: #fef2f2; border-color: var(--color-danger); color: var(--color-danger); }

.info-list { padding-left: 18px; color: var(--color-text); }
.info-list li { margin-bottom: 5px; }
/* ===================== Remote help ===================== */
/* El texto ocupa el ancho y el instalador es un cuadrado pegado al borde
   derecho del recuadro. En movil el cuadrado baja debajo, centrado. */
.remote-help { display: flex; align-items: flex-start; gap: 22px; }
.remote-help-text { flex: 1; min-width: 0; }
.remote-help-text > :last-child { margin-bottom: 0; }
.remote-help-download {
  flex: none;
  width: 176px;
  height: 176px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px;
  text-align: center;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
  background: var(--color-surface);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.remote-help-download:hover {
  text-decoration: none;
  background: var(--color-surface-2);
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}
.remote-help-download-logo { width: 108px; height: auto; }
.remote-help-download-label { font-size: 12px; font-weight: 600; color: var(--color-text-muted); }
.remote-help-download:hover .remote-help-download-label { color: var(--color-primary); }
.remote-help-missing { width: 220px; }
.remote-help-aside { flex: none; width: 220px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.remote-help-external { font-size: 12px; color: var(--color-text-muted); }
.remote-help-external p { margin: 4px 0 6px; }
.remote-help-external a { word-break: break-all; }

.roles-list { display: flex; flex-direction: column; gap: 7px; }
.role-row { padding: 7px 11px; background: var(--color-surface-2); border-radius: var(--radius-sm); }

/* ===================== Responsive ===================== */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 8px;
    gap: 8px;
  }
  .sidebar-brand { padding: 6px 10px; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; padding: 0; }
  .nav-divider { display: none; }
  .sidebar-user {
    margin-left: auto;
    border-top: none;
    background: transparent;
    padding: 4px 8px;
  }
  .app-shell { margin-left: 0; }
  .layout { padding: 18px; }
  .page-header { grid-template-columns: 1fr; }
}

/* =====================================================================
   Dashboard redesign — mesh background, app window, top bar, color grid
   ===================================================================== */

body.theme-corify { font-family: "Poppins", var(--font-sans); }

/* Mesh gradient canvas (authenticated app only; anon keeps login bg) */
body.theme-corify:not(.is-anon) {
  min-height: 100vh;
  background:
    radial-gradient(58% 48% at 14% 8%, rgba(129, 140, 248, 0.14), transparent 60%),
    radial-gradient(50% 45% at 88% 6%, rgba(45, 212, 191, 0.12), transparent 60%),
    radial-gradient(55% 55% at 82% 92%, rgba(167, 139, 250, 0.12), transparent 62%),
    radial-gradient(52% 50% at 8% 96%, rgba(110, 231, 183, 0.10), transparent 60%),
    linear-gradient(180deg, #f6f7f9 0%, #f0f2f6 100%);
  background-attachment: fixed;
}

/* The rounded "desktop window" that holds the whole intranet */
.app-window {
  max-width: 1340px;
  margin: 18px auto;
  min-height: calc(100vh - 36px);
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.80);
  -webkit-backdrop-filter: blur(16px) saturate(120%);
  backdrop-filter: blur(16px) saturate(120%);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 24px;
  box-shadow: 0 24px 70px rgba(30, 41, 59, 0.16), 0 2px 8px rgba(30, 41, 59, 0.05);
  overflow: hidden;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 22px;
  background: rgba(255, 255, 255, 0.55);
  border-bottom: 1px solid rgba(15, 23, 42, 0.07);
}
.topbar-brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; color: #0f1e3d; }
.topbar-brand:hover { text-decoration: none; }
.brand-iso { width: 30px; height: 30px; color: #0f1e3d; display: block; }
.brand-iso svg { width: 100%; height: 100%; display: block; }
.brand-logo { width: 30px; height: 30px; display: block; object-fit: contain; }
.brand-word { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; color: #0f1e3d; }

.topbar-search {
  flex: 1 1 auto;
  max-width: 440px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px 16px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.topbar-search:focus-within { border-color: #a5b4fc; box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.18); }
.search-ico { width: 17px; height: 17px; color: var(--color-text-soft); flex-shrink: 0; }
.topbar-search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 13.5px;
  color: var(--color-text);
}
.topbar-search input::placeholder { color: var(--color-text-soft); }

/* Menu colapsable: en escritorio es transparente (`display: contents`) y sus
   hijos siguen siendo hijos flex de `.topbar`; en movil pasa a ser una columna
   desplegable que abre `.nav-toggle` (ver bloque responsive). */
.topbar-menu { display: contents; }
/* Botones de la barra en movil: hamburguesa del menu y lupa del buscador.
   En escritorio los dos estan ocultos (ver bloque responsive). */
.nav-toggle, .search-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--color-text);
  cursor: pointer;
}
.nav-toggle:hover, .search-toggle:hover { background: #fff; }
.nav-toggle:focus-visible, .search-toggle:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.nav-toggle svg, .search-toggle svg { width: 20px; height: 20px; }
.topbar.is-search-open .search-toggle { background: #fff; border-color: #a5b4fc; }

.topbar-nav { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.topnav-link {
  padding: 7px 12px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-text-muted);
}
.topnav-link:hover { background: rgba(15, 23, 42, 0.05); color: var(--color-text); text-decoration: none; }
.topnav-link-admin { color: var(--color-primary); }

.topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.bell-btn {
  position: relative;
  width: 38px; height: 38px;
  border: none;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.04);
  color: var(--color-text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, color 0.12s ease;
}
.bell-btn:hover { background: rgba(15, 23, 42, 0.09); color: var(--color-text); }
.bell-btn svg { width: 18px; height: 18px; }
.bell-dot {
  position: absolute; top: 9px; right: 10px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #f43f5e;
  border: 2px solid #fff;
}
.user-chip { display: flex; align-items: center; gap: 9px; padding: 2px; }
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: #586a9e;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-chip-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.user-chip-name {
  font-size: 13px; font-weight: 600; color: var(--color-text);
  max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-chip-date { font-size: 11.5px; color: var(--color-text-soft); }
.topbar .icon-btn { color: var(--color-text-soft); }
.topbar .icon-btn:hover { background: rgba(15, 23, 42, 0.08); color: var(--color-text); }

/* ---------- Main content area inside the window ---------- */
.app-main { flex: 1; padding: 30px 34px; }
.app-window .footer { padding: 16px 12px 24px; }

/* ---------- Welcome ---------- */
.welcome { margin: 4px 0 26px; }
.welcome-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #0f1e3d;
  margin: 0 0 6px;
}
.welcome-brand { color: #d6453d; }
.welcome-sub { font-size: 15px; color: var(--color-text-muted); margin: 0; }

/* ---------- Service grid (5 x 3) ---------- */
.services-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
}

.svc-card {
  --accent: var(--color-accent);
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 158px;
  padding: 18px;
  border-radius: 14px;
  color: var(--color-text);
  overflow: hidden;
  background: linear-gradient(160deg,
    color-mix(in srgb, var(--accent) 16%, #fff),
    color-mix(in srgb, var(--accent) 6%, #fff));
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--color-border));
  border-top: 3px solid var(--accent);
  box-shadow: var(--shadow-sm);
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}
.svc-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--color-border));
  border-top-color: var(--accent);
}
.svc-card:focus-within { outline: 2px solid color-mix(in srgb, var(--accent) 55%, #fff); outline-offset: 2px; }

/* Background symbol: tinted to the category color at low opacity (Notion-like) */
.svc-bg-sym {
  position: absolute;
  right: -6px;
  bottom: -8px;
  z-index: 0;
  width: 118px;
  height: 118px;
  background-color: var(--accent);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: bottom right;
  mask-position: bottom right;
  -webkit-mask-size: contain;
  mask-size: contain;
  opacity: 0.20;
  pointer-events: none;
}
.svc-bg-glyph {
  position: absolute;
  right: -10px;
  bottom: -16px;
  z-index: 0;
  color: var(--accent);
  opacity: 0.20;
  pointer-events: none;
  line-height: 0;
}
.svc-bg-glyph .svc-glyph { width: 126px; height: 126px; stroke-width: 1.3; }

/* Whole-card primary click (stretched link) */
.svc-open { position: absolute; inset: 0; z-index: 1; }

/* Details button, top-right corner, above the stretched link */
.svc-detail-btn {
  position: absolute;
  top: 12px; right: 12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 999px;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.svc-detail-btn:hover {
  background: color-mix(in srgb, var(--accent) 10%, #fff);
  color: color-mix(in srgb, var(--accent) 62%, #1a1a1a);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--color-border));
  text-decoration: none;
}
/* En escritorio se lee "Details"; en movil la tarjeta es un cubito y solo cabe
   la i (ver el bloque responsive). */
.svc-detail-ico { display: none; }

.svc-card-body {
  position: relative;
  z-index: 1;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none; /* clicks fall through to the stretched link */
}
.svc-flag {
  align-self: flex-start;
  font-size: 10px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, #fff);
  color: color-mix(in srgb, var(--accent) 65%, #1a1a1a);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, #fff);
}
.svc-flag-test { background: #fff7ed; color: #9a3412; border-color: #fed7aa; }
.svc-name {
  font-size: 15px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase;
  line-height: 1.18;
  color: color-mix(in srgb, var(--accent) 68%, #14202e);
}
.svc-desc { font-size: 12px; line-height: 1.45; color: var(--color-text-muted); }

/* Non-available services */
.svc-card.svc-requestable,
.svc-card.svc-pending { background: var(--color-surface); }
.svc-disabled { opacity: 0.6; }

.svc-card.is-filtered-out { display: none; }
.search-empty { text-align: center; color: var(--color-text-muted); padding: 24px; }

.grid-section { margin-bottom: 8px; }
.onboarding-section { margin-top: 28px; }

/* ---------- Bottom tab bar (movil) ----------
   Navegacion tipo app: en escritorio no existe (display: none) y solo aparece
   en el breakpoint de movil, donde toma el relevo de la barra superior. Va
   fuera de `.app-window` porque el `backdrop-filter` de la ventana crearia un
   bloque contenedor y recortaria un elemento `fixed`. */
.tabbar { display: none; }

/* ---------- Responsive ----------
   Escritorio (>=1024px) se queda como estaba: todo lo de abajo son solo
   media queries para tablet y movil. Objetivo: sin scroll horizontal a
   360/390/414 px, controles usables con el dedo y, en movil, apariencia de
   app: cabecera fija, pestanas abajo, servicios en cubitos y listas en
   tarjetas (sin scroll lateral). */
@media (max-width: 1100px) { .services-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

@media (max-width: 900px) {
  .app-window { margin: 0; border-radius: 0; min-height: 100vh; border: none; }

  /* La barra pasa a marca + lupa + hamburguesa, y el resto cae a filas
     siguientes: el buscador (orden 2) y el menu colapsable (orden 3). */
  .topbar { flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
  .nav-toggle { display: inline-flex; margin-left: auto; }
  .topbar-menu {
    display: flex;
    order: 3;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  /* Solo se colapsa si el JS puede volver a abrirlo (ver nav-toggle.js). */
  body.has-nav-toggle .topbar-menu { display: none; }
  body.has-nav-toggle .topbar.is-menu-open .topbar-menu { display: flex; }

  /* El buscador no se esconde dentro del menu: la lupa se queda siempre en la
     barra y despliega el campo a lo ancho (ver search-toggle.js). Sin JS no hay
     boton y el campo se ve directamente. */
  .topbar-search { flex: 0 0 auto; order: 2; flex-basis: 100%; max-width: none; }
  body.has-search-toggle .search-toggle { display: inline-flex; margin-left: auto; }
  body.has-search-toggle .nav-toggle { margin-left: 0; }
  body.has-search-toggle .topbar-search { display: none; }
  body.has-search-toggle .topbar.is-search-open .topbar-search { display: flex; }
  .topbar-nav { flex-wrap: wrap; }
  .topnav-link { padding: 9px 12px; }
  .topbar-actions { margin-left: 0; justify-content: space-between; }

  .app-main { padding: 22px 16px; }
  .welcome-title { font-size: 24px; }
  .services-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  /* Ayuda remota: el cuadrado de descarga no cabe al lado del texto. */
  .remote-help { flex-direction: column; }
  .remote-help-aside { align-self: center; }

  /* ----- Carcasa de app: cabecera fija arriba, pestanas fijas abajo -----
     `overflow: visible` es imprescindible para que la cabecera pueda quedarse
     pegada: con el `overflow: hidden` de escritorio, `position: sticky` no
     tiene efecto dentro de `.app-window`. */
  .app-window {
    overflow: visible;
    padding-bottom: calc(66px + env(safe-area-inset-bottom));
  }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: rgba(255, 255, 255, 0.93);
    -webkit-backdrop-filter: blur(14px) saturate(120%);
    backdrop-filter: blur(14px) saturate(120%);
  }
  /* El pie decorativo sobra: abajo estan las pestanas. */
  .app-window .footer { display: none; }

  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: flex;
    align-items: stretch;
    gap: 2px;
    margin: 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(16px) saturate(120%);
    backdrop-filter: blur(16px) saturate(120%);
    border-top: 1px solid rgba(15, 23, 42, 0.09);
    box-shadow: 0 -6px 22px rgba(15, 23, 42, 0.08);
  }
  .tabbar-form { display: flex; flex: 1 1 0; min-width: 0; margin: 0; }
  .tabbar-item {
    flex: 1 1 0;
    min-width: 0;
    min-height: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 2px;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: var(--color-text-muted);
    font-family: inherit;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.2px;
    cursor: pointer;
  }
  .tabbar-item:hover { color: var(--color-text); text-decoration: none; }
  .tabbar-item:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
  .tabbar-item svg { width: 21px; height: 21px; flex-shrink: 0; }
  .tabbar-item.is-active { color: var(--color-primary); background: rgba(15, 118, 110, 0.1); }
  .tabbar-label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  /* Un admin tiene seis pestanas: letra algo menor para que no se corten. */
  .tabbar:has(> :nth-child(6)) .tabbar-label { font-size: 10px; letter-spacing: -0.01em; }

  /* ----- Servicios en cubitos pequenos -----
     La rejilla llena la fila con cuadrados de ~104-120 px: a 360 px caben 3.
     El simbolo del servicio deja de ser marca de agua y pasa a ser el icono. */
  .services-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(104px, 100%), 1fr));
    gap: 10px;
  }
  .svc-card {
    display: grid;
    grid-template-rows: 1fr auto;
    justify-items: center;
    gap: 4px;
    aspect-ratio: 1 / 1;
    min-height: 0;
    padding: 10px 6px 9px;
    border-radius: 18px;
    text-align: center;
  }
  .svc-card:hover { transform: none; }
  .svc-bg-sym, .svc-bg-glyph {
    position: static;
    align-self: center;
    inset: auto;
    margin: 0;
    opacity: 1;
  }
  .svc-bg-sym {
    width: 38px;
    height: 38px;
    -webkit-mask-position: center;
    mask-position: center;
  }
  .svc-bg-glyph { color: var(--accent); }
  .svc-bg-glyph .svc-glyph { width: 38px; height: 38px; stroke-width: 1.6; }
  .svc-card-body { margin-top: 0; align-items: center; gap: 3px; width: 100%; }
  .svc-name {
    font-size: 10.5px;
    letter-spacing: 0.01em;
    line-height: 1.15;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }
  .svc-desc { display: none; }
  .svc-flag { align-self: center; font-size: 8.5px; padding: 1px 6px; letter-spacing: 0.3px; }
  /* Las tarjetas de entorno (ficha de servicio) llevan boton propio: se apilan
     a una columna en vez de convertirse en cubitos. */
  .services-grid.env-grid { grid-template-columns: 1fr; }

  /* ----- Listas del admin completas, sin scroll lateral -----
     Cada fila pasa a ser una tarjeta etiqueta/valor, asi que la tabla ya no
     necesita desplazarse dentro de `.table-scroll`. */
  .table-scroll { overflow-x: visible; }
  .table-scroll > .data-table { min-width: 0; }
  .data-table {
    display: block;
    border: none;
    border-radius: 0;
    background: transparent;
    margin-bottom: 14px;
  }
  .data-table thead { display: none; }
  .data-table tbody, .data-table tr, .data-table td { display: block; }
  .data-table tr {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 8px 13px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
  }
  .data-table td, .data-table tr:hover td { background: transparent; }
  .data-table td {
    padding: 7px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--color-border);
  }
  .data-table tr td:last-child { border-bottom: none; }
  .data-table td[data-label] {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    text-align: right;
  }
  .data-table td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 36%;
    text-align: left;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--color-text-muted);
  }
  /* En la tarjeta el valor tiene que leerse: lo apagado es la etiqueta. */
  .data-table td.muted[data-label] { color: var(--color-text); }

  /* Pestanas del admin como chips: caben en dos filas y se pulsan bien. */
  .admin-tabs { flex-wrap: wrap; gap: 6px; border-bottom: none; }
  .admin-tabs a {
    padding: 8px 13px;
    margin-bottom: 0;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-surface);
  }

  .section-head, .admin-header { flex-wrap: wrap; row-gap: 8px; }
  .grid-actions { flex-wrap: wrap; }
  /* 16px evita el zoom automatico de iOS al enfocar un campo. */
  .form-grid input, .form-grid select, .form-grid textarea,
  .cat-row input, .ord-row input, .topbar-search input { font-size: 16px; }
  /* Objetivos tactiles: los botones dejan de ser lineas de 24-28px. */
  .btn { min-height: 40px; }
  .btn-sm { min-height: 34px; }
  .icon-btn { width: 38px; height: 38px; }
  .cat-moves .btn-link { padding: 4px 10px; font-size: 15px; }
  /* Enlaces-boton de las tablas y de las filas-formulario (Edit, Remove,
     Reset...): sin hover en movil, asi que necesitan area que pulsar. */
  .btn-link { padding: 6px 0; }
  /* En el cubito no cabe la palabra: "Details" queda como un circulo con la i,
     con area suficiente para el dedo. */
  .svc-detail-btn {
    top: 6px;
    right: 6px;
    width: 27px;
    height: 27px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
  }
  .svc-detail-ico { display: block; font-size: 13px; font-weight: 700; line-height: 1; }
  .svc-detail-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

@media (max-width: 560px) {
  .app-main { padding: 18px 14px; }
  .layout { padding: 18px 14px; }
  .welcome-title { font-size: 21px; }
  .welcome-sub { font-size: 14px; }

  /* Las cajas dejan de comerse el ancho util (portal, admin, formularios). */
  .section { padding: 16px 14px; }
  .form-card { padding: 14px; }
  .cat-row, .ord-row { padding: 10px 12px; }

  /* Login: la tarjeta ocupa el ancho util sin margenes de escritorio. */
  .login-shell { padding: 24px 14px; }
  .login-card { padding: 24px 18px; }
  .demo-user-row { flex-wrap: wrap; }
  .demo-user-row .btn { width: 100%; }

  /* First steps: numero + texto en una fila, CTA a la siguiente y a lo ancho. */
  .onboarding-item { flex-wrap: wrap; gap: 12px; }
  .onboarding-item > .btn { flex-basis: 100%; }
  .onboarding-check { width: 34px; height: 34px; }
  .onboarding-progress { flex-wrap: wrap; }

  /* Filas-formulario de categorias y de orden de tarjetas. */
  .cat-actions, .ord-flag { margin-left: 0; }
  .cat-field-label input, .cat-field-order input, .ord-row input[type="number"] { min-width: 0; width: 100%; }
  .cat-field-label, .cat-field-order { flex: 1 1 140px; }
  .ord-name { min-width: 0; flex: 1 1 100%; }

  .stat-box { min-width: 0; flex: 1 1 96px; }
  .admin-title { font-size: 19px; }

  /* A 360-414 px caben tres cubitos por fila con margenes comodos. */
  .services-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
  .data-table tr { padding: 6px 11px; }
  .data-table td[data-label]::before { flex-basis: 40%; }
}

/* ===================== Help center ===================== */
/* Indice de guias agrupado por tema y pagina de guia paso a paso. Cada guia
   toma el color de la categoria de su servicio (--accent). */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.help-hero { margin-bottom: 22px; }
.help-hero-admin { margin: 12px 0 0; }

.help-topic { margin-bottom: 26px; }
/* Con el buscador, un tema sin ninguna guia visible desaparece entero. */
.help-topic:not(:has(.help-card:not(.is-filtered-out))) { display: none; }
.help-topic-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin: 0 0 12px;
}
.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: 14px;
}
.help-card {
  --accent: var(--color-primary);
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 18px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--color-text);
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}
.help-card:hover {
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--color-border));
  border-left-color: var(--accent);
}
.help-card.is-filtered-out { display: none; }
.help-card-featured { --accent: #0f766e; background: linear-gradient(160deg, #f0fdfa, #fff); }
.help-card-logo {
  flex: none;
  width: 48px; height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 10%, #fff);
  color: var(--accent);
}
.help-card-logo img { width: 30px; height: 30px; object-fit: contain; }
.help-card-logo .svc-glyph { width: 26px; height: 26px; }
.help-card-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.help-card-title { font-weight: 600; font-size: 15px; line-height: 1.3; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.help-card-summary { color: var(--color-text-muted); font-size: 13px; }
.help-card-meta { color: var(--color-text-soft); font-size: 12px; margin: 2px 0 0; }

.help-breadcrumb {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12.5px;
  color: var(--color-text-muted);
  margin: 0 0 14px;
}
.help-draft-note { margin-bottom: 14px; }

.help-article-head {
  --accent: var(--color-primary);
  display: flex;
  gap: 18px;
  align-items: flex-start;
  padding: 22px 24px;
  margin-bottom: 22px;
  background: linear-gradient(160deg,
    color-mix(in srgb, var(--accent) 10%, #fff),
    var(--color-surface));
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--color-border));
  border-top: 3px solid var(--accent);
  border-radius: var(--radius-lg);
}
.help-article-logo { width: 60px; height: 60px; background: #fff; box-shadow: var(--shadow-sm); }
.help-article-logo img { width: 38px; height: 38px; }
.help-article-intro { flex: 1; min-width: 0; }
.help-article-intro h1 { font-size: 26px; margin-bottom: 6px; }
.help-article-summary { color: var(--color-text-muted); font-size: 14.5px; max-width: 760px; }
.help-edit-btn { flex: none; }

.help-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}
.help-toc {
  position: sticky;
  top: 18px;
  padding: 14px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 12.5px;
}
.help-toc-title { font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; font-size: 11px; color: var(--color-text-muted); margin-bottom: 8px; }
.help-toc ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.help-toc a { display: flex; gap: 8px; align-items: baseline; padding: 4px 6px; border-radius: var(--radius-sm); color: var(--color-text); }
.help-toc a:hover { background: var(--color-surface-2); text-decoration: none; }
.help-toc li.is-section a { color: var(--color-text-muted); padding-left: 32px; }
.help-toc-num {
  flex: none;
  min-width: 18px;
  font-weight: 700;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
}

.help-body { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.help-section {
  scroll-margin-top: 16px;
  padding: 20px 24px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.help-section-section { background: var(--color-surface-2); }
.help-section-title { display: flex; align-items: center; gap: 12px; font-size: 18px; margin-bottom: 12px; }
.help-step-num {
  flex: none;
  width: 32px; height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent, var(--color-primary));
  color: #fff;
  font-size: 15px;
  font-weight: 700;
}
.help-rich { font-size: 14px; line-height: 1.65; }
.help-rich > :first-child { margin-top: 0; }
.help-rich > :last-child { margin-bottom: 0; }
.help-rich p { margin: 0 0 10px; }
.help-rich ul, .help-rich ol { margin: 0 0 10px; padding-left: 22px; }
.help-rich li { margin-bottom: 4px; }
.help-rich code {
  background: var(--color-surface-3);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12.5px;
}
.help-section-link { margin: 14px 0 0; }
.help-section-link .btn { display: inline-flex; align-items: center; gap: 8px; }

.help-callout {
  margin-top: 14px;
  padding: 11px 14px 11px 16px;
  border-radius: var(--radius-sm);
  border-left: 4px solid;
  font-size: 13.5px;
}
.help-callout > :last-child { margin-bottom: 0; }
.help-callout p { margin: 0 0 6px; }
.help-callout-info { background: #eff6ff; border-color: var(--color-info); color: #1e3a8a; }
.help-callout-warning { background: #fffbeb; border-color: var(--color-warning); color: #78350f; }
.help-callout-danger { background: #fef2f2; border-color: var(--color-danger); color: #7f1d1d; }
.help-callout-success { background: #ecfdf5; border-color: var(--color-success); color: #14532d; }

.help-figure { margin: 16px 0 0; }
.help-figure a { display: inline-block; max-width: 100%; }
.help-figure img {
  display: block;
  max-width: 100%;
  max-height: 560px;
  width: auto;
  height: auto;
  object-fit: contain;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  background: #fff;
}
.help-footer-note {
  padding: 14px 18px;
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius);
  color: var(--color-text-muted);
  font-size: 13px;
}

/* Admin del centro de ayuda */
.help-admin-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 11px; }
.help-admin-section { scroll-margin-top: 16px; }
.help-admin-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.help-admin-section-head h4 { margin: 0; }
.help-admin-move { display: flex; gap: 4px; }
.help-admin-move .btn[disabled] { opacity: 0.35; cursor: default; }
.help-admin-thumb { display: flex; align-items: center; gap: 14px; }
.help-admin-thumb img { max-height: 120px; width: auto; border: 1px solid var(--color-border); border-radius: var(--radius-sm); }
.help-admin-format summary { cursor: pointer; font-weight: 600; font-size: 12.5px; }
.help-admin-format .info-list { margin: 10px 0 0; font-size: 12.5px; }
.help-admin-delete { display: block; margin: 8px 0 0; }

@media (max-width: 900px) {
  .help-layout { grid-template-columns: minmax(0, 1fr); }
  .help-toc { position: static; }
}
@media (max-width: 700px) {
  /* En movil el indice de pasos queda lejos del contenido: se oculta. */
  .help-toc { display: none; }
}
@media (max-width: 560px) {
  .help-article-head { flex-wrap: wrap; padding: 18px 16px; }
  .help-article-intro { flex: 1 1 100%; order: 3; }
  .help-edit-btn { margin-left: auto; }
  .help-article-intro h1 { font-size: 21px; }
  .help-section { padding: 16px 14px; }
  .help-section-title { font-size: 16px; }
}
