:root {
  --sidebar-bg: #142a3d;
  --sidebar-bg-active: #1c3a53;
  --sidebar-text: #9fb4c7;
  --sidebar-text-active: #ffffff;
  --sidebar-border: rgba(255,255,255,0.08);

  --accent: #00b899;
  --accent-hover: #00a187;
  --accent-soft: #e3f8f4;
  --accent-text: #00795f;

  --bg-app: #f4f6f8;
  --bg-card: #ffffff;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;

  --danger: #e5484d;
  --danger-soft: #fdeceb;
  --success: #12b76a;
  --success-soft: #e6f9ef;
  --warning: #f79009;
  --warning-soft: #fef3e2;
  --info-soft: #e6f0fd;
  --info-text: #1c64f2;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16,24,40,0.06), 0 1px 3px rgba(16,24,40,0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
  background: var(--bg-app);
  color: var(--text);
  font-size: 14px;
}

.pantalla { min-height: 100vh; }
/* #pantalla-login fija su propio "display", que por especificidad de ID le
   gana a la regla [hidden] del navegador (basada en clase/atributo) — sin
   este selector (ID + atributo, misma especificidad que gana) el atributo
   hidden por sí solo no ocultaba la pantalla de login. */
#pantalla-login[hidden], #pantalla-app[hidden] { display: none; }

/* --- Login --- */
#pantalla-login {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(0,184,153,0.25), transparent 45%),
    linear-gradient(160deg, #0f2233, #142a3d 60%, #16324a);
}
.login-box {
  background: var(--bg-card);
  padding: 2.4rem 2.2rem;
  border-radius: 14px;
  width: 340px;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.login-logo { height: 52px; width: auto; align-self: flex-start; margin-bottom: 0.3rem; }
.login-box h1 { margin: 0; font-size: 1.25rem; }
.login-box .subtitulo { margin: -0.6rem 0 0.4rem; color: var(--text-muted); font-size: 0.85rem; }

label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }
input, select, textarea, button {
  font: inherit;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 4.5rem; font-family: inherit; }

button {
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  border: none;
  font-weight: 600;
  transition: background 0.15s, transform 0.05s;
}
button:hover { background: var(--accent-hover); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secundario { background: #eef1f4; color: var(--text); }
.btn-secundario:hover { background: #e2e6ea; }
.btn-peligro { background: var(--danger); }
.btn-peligro:hover { background: #c4383d; }
.btn-block { width: 100%; }

.error-msg { color: var(--danger); font-size: 0.82rem; }
.msg { font-size: 0.82rem; padding: 0.55rem 0.7rem; border-radius: var(--radius-sm); font-weight: 500; }
.msg.ok { background: var(--success-soft); color: #067647; }
.msg.warn { background: var(--warning-soft); color: #b54708; }
.msg.error { background: var(--danger-soft); color: #b42318; }

/* --- App shell --- */
.shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  padding: 1.1rem 0.8rem;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.4rem 0.5rem 1.2rem;
  border-bottom: 1px solid var(--sidebar-border);
  margin-bottom: 0.9rem;
}
.brand-logo { height: 26px; width: auto; flex-shrink: 0; }
.brand-text { color: var(--sidebar-text); font-size: 0.72rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tabs { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; }
.tab-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--sidebar-text);
  text-decoration: none;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
}
.tab-icon { width: 18px; height: 18px; flex-shrink: 0; }
.tab-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.tab-link.active { background: var(--accent); color: #fff; }

.sidebar-footer {
  border-top: 1px solid var(--sidebar-border);
  padding-top: 0.9rem;
  margin-top: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.user-chip { display: flex; align-items: center; gap: 0.6rem; padding: 0 0.5rem; }
.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700;
  flex-shrink: 0;
}
.user-chip-text { overflow: hidden; }
#usuario-actual { color: #fff; font-size: 0.8rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.sidebar-footer .btn-secundario { background: rgba(255,255,255,0.08); color: var(--sidebar-text); }
.sidebar-footer .btn-secundario:hover { background: rgba(255,255,255,0.14); color: #fff; }

/* --- Content area --- */
.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.6rem;
  flex-shrink: 0;
}
.topbar h1 { margin: 0; font-size: 1.05rem; font-weight: 700; }

main { flex: 1; overflow-y: auto; padding: 1.4rem 1.6rem; }
.tab-panel.oculto { display: none; }

.tarjeta {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-width: 560px;
}
.tarjeta-inline { flex-direction: row; flex-wrap: wrap; align-items: center; max-width: none; }
.tarjeta-inline input, .tarjeta-inline select { flex: 1; min-width: 140px; }
.tarjeta-ancha { max-width: 720px; }
.tarjeta h3 { margin: 0; font-size: 0.95rem; }

/* --- Tipos de solicitud: constructor dinámico de campos --- */
.tipos-header { margin-bottom: 1rem; }
.checkbox-label { flex-direction: row; align-items: center; gap: 0.45rem; font-size: 0.85rem; color: var(--text); font-weight: 500; }
.checkbox-label input[type="checkbox"] { width: auto; padding: 0; }
.builder { display: flex; flex-direction: column; gap: 0.6rem; padding: 0.9rem; background: var(--bg-app); border-radius: var(--radius-sm); border: 1px dashed var(--border); }
.builder-header { display: flex; align-items: center; justify-content: space-between; }
.builder-header strong { font-size: 0.82rem; }
.builder-header button { font-size: 0.78rem; padding: 0.35rem 0.6rem; }
.builder-lista { display: flex; flex-direction: column; gap: 0.5rem; }
.campo-row, .columna-row, .checklist-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr auto auto;
  gap: 0.5rem;
  align-items: start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem;
}
.columna-row { grid-template-columns: 1fr 1.2fr auto; }
.checklist-row { grid-template-columns: 1fr auto; }
.campo-row input, .campo-row select, .campo-row textarea,
.columna-row input, .checklist-row input { font-size: 0.82rem; padding: 0.4rem 0.55rem; }
.campo-row textarea { grid-column: 1 / -1; min-height: 3rem; }
.campo-row .btn-peligro, .columna-row .btn-peligro, .checklist-row .btn-peligro { font-size: 0.75rem; padding: 0.4rem 0.6rem; white-space: nowrap; }
.tipo-form-acciones { display: flex; gap: 0.6rem; }
.tipo-form-acciones .btn-secundario { flex: none; }

/* Nueva solicitud es una sola tarjeta como contenido de la pantalla: se
   centra en vez de quedar pegada al borde izquierdo. :not(.oculto) evita que
   esto compita en especificidad con la regla .tab-panel.oculto que oculta el
   panel al cambiar de pestaña. */
#tab-nueva:not(.oculto) { display: flex; justify-content: center; }
#tab-nueva .tarjeta { width: 100%; }

.ajustes-grid { display: flex; flex-wrap: wrap; gap: 1.2rem; align-items: flex-start; }
.ajustes-grid .tarjeta { flex: 1 1 320px; }
.ayuda { font-size: 0.78rem; color: var(--text-muted); margin: 0; line-height: 1.5; }
.ayuda a { color: var(--accent-text); font-weight: 600; text-decoration: none; }
.ayuda a:hover { text-decoration: underline; }

#bloque-excel { display: flex; flex-direction: column; gap: 0.5rem; padding: 0.85rem; background: var(--bg-app); border-radius: var(--radius-sm); border: 1px dashed var(--border); }
#excel-info { margin: 0; font-size: 0.8rem; color: var(--text-muted); }
#link-plantilla { color: var(--accent-text); font-weight: 600; font-size: 0.82rem; text-decoration: none; }
#link-plantilla:hover { text-decoration: underline; }

.filtros { display: flex; gap: 0.6rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filtros select, .filtros button { width: auto; }

.tabla-wrap { overflow-x: auto; background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: 0.83rem; }
th, td { text-align: left; padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: #fafbfc; color: var(--text-muted); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }

.badge { padding: 0.2rem 0.65rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600; display: inline-block; }
.badge-nueva { background: var(--info-soft); color: var(--info-text); }
.badge-en_proceso { background: var(--warning-soft); color: #b54708; }
.badge-completada { background: var(--success-soft); color: #067647; }

.progreso { display: flex; align-items: center; gap: 0.5rem; }
.progreso-bar { width: 64px; height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; flex-shrink: 0; }
.progreso-bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.progreso small { color: var(--text-muted); font-size: 0.75rem; white-space: nowrap; }

.acciones-cell { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.acciones-cell button, .acciones-cell select { font-size: 0.78rem; padding: 0.32rem 0.55rem; }
a.link-trello, a.link-meet { color: var(--accent-text); font-weight: 600; text-decoration: none; }
a.link-trello:hover, a.link-meet:hover { text-decoration: underline; }

.toast {
  position: fixed;
  bottom: 1.2rem;
  right: 1.2rem;
  background: var(--sidebar-bg);
  color: #fff;
  padding: 0.7rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  z-index: 50;
}
.toast.ok { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warn { background: var(--warning); }

@media (max-width: 760px) {
  .shell { flex-direction: column; height: auto; min-height: 100vh; overflow: visible; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 0.6rem 0.8rem; overflow-x: auto; flex-shrink: 0; }
  .sidebar-brand { border-bottom: none; margin: 0; padding: 0 0.8rem 0 0; flex-shrink: 0; }
  .tabs { flex-direction: row; flex: none; }
  .tab-link { flex-shrink: 0; }
  .tab-link .tab-label { display: none; }
  .sidebar-footer { flex-direction: row; border-top: none; margin: 0 0 0 auto; padding: 0; flex-shrink: 0; }
  .user-chip-text { display: none; }
  .content-area { min-height: 0; overflow: visible; }
  main { padding: 1rem; overflow-y: visible; }
  .topbar { padding: 0.8rem 1rem; }
  .topbar h1 { font-size: 0.95rem; }

  .login-box { width: min(340px, calc(100vw - 2.5rem)); padding: 1.8rem 1.6rem; }

  .ajustes-grid { flex-direction: column; }
  .ajustes-grid .tarjeta { flex-basis: auto; }

  .filtros { flex-direction: column; align-items: stretch; }
  .filtros select, .filtros button { width: 100%; }
}

@media (max-width: 560px) {
  .campo-row, .columna-row, .checklist-row { grid-template-columns: 1fr; }
  .campo-row .checkbox-label, .campo-row .btn-peligro,
  .columna-row .btn-peligro, .checklist-row .btn-peligro { grid-column: 1 / -1; }
  .tarjeta-inline { flex-direction: column; align-items: stretch; }
  .tarjeta-inline input, .tarjeta-inline select, .tarjeta-inline button { width: 100%; }
  table { font-size: 0.78rem; }
  th, td { padding: 0.5rem 0.6rem; }
}
