/* ============================================================
   TECNOADMIN · Sistema de gestión de agencia digital
   styles.css — Paleta: azul eléctrico, celeste, blanco, negro
   ============================================================ */

:root {
  /* Marca TecnoAdmin */
  --accent: #0b3dff;        /* azul eléctrico — acción principal */
  --accent-dark: #0830c9;   /* hover del accent */
  --accent-light: #e8edff;  /* fondos suaves de acento */
  --celeste: #22c3f0;       /* celeste — secundario */
  --celeste-light: #e3f7fd; /* fondo celeste suave */
  --black: #0a0e17;         /* negro TecnoAdmin */
  --black-soft: #131b2c;    /* negro para superficies (sidebar/header) */

  /* Estados */
  --green: #16a34a;
  --green-light: #e8f8ee;
  --red: #dc2626;
  --red-light: #fdecec;
  --warn: #d97706;
  --warn-light: #fef3e0;
  --purple: #7c3aed;
  --purple-light: #f1eafe;

  /* Áreas (para calendario / badges de área) */
  --area-admin: #0b3dff;
  --area-community: #22c3f0;
  --area-diseno: #7c3aed;
  --area-audiovisual: #d97706;
  --area-paid: #16a34a;

  /* Base */
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface2: #f1f4f9;
  --border: #e2e7f0;
  --text: #0a0e17;
  --muted: #64748b;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(10, 14, 23, 0.08), 0 1px 2px rgba(10, 14, 23, 0.04);
  --shadow-lg: 0 12px 32px rgba(10, 14, 23, 0.16);
  --sidebar-w: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: var(--accent); text-decoration: none; }
img { max-width: 100%; }

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #c9d2e3; border-radius: 10px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 20%, #0d1a3f 0%, var(--black) 55%, #000 100%);
  z-index: 999;
}
.login-box {
  width: 360px;
  max-width: 90vw;
  background: var(--surface);
  border-radius: 16px;
  padding: 36px 32px 28px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.login-logo {
  width: 64px; height: 64px; border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--celeste));
  color: #fff; font-weight: 800; font-size: 28px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 8px 20px rgba(11, 61, 255, 0.35);
}
.login-brand { font-size: 20px; font-weight: 800; letter-spacing: 0.5px; color: var(--black); }
.login-tag { font-size: 12px; color: var(--muted); margin-top: 2px; margin-bottom: 22px; }
.login-error {
  display: none;
  background: var(--red-light); color: var(--red);
  font-size: 12px; padding: 8px 10px; border-radius: var(--radius-sm);
  margin-bottom: 12px; text-align: left;
}
.login-error.show { display: block; }
.login-box .form-group { text-align: left; margin-bottom: 12px; }
.login-hint { margin-top: 16px; font-size: 11px; color: var(--muted); line-height: 1.5; }

/* ============================================================
   LAYOUT: SIDEBAR + HEADER + CONTENT
   ============================================================ */
#app-shell { display: none; min-height: 100vh; }
#app-shell.active { display: flex; }

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--black-soft);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 50;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo .mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--celeste));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff; font-size: 15px; flex: none;
}
.sidebar-logo .name { font-weight: 800; color: #fff; font-size: 14.5px; line-height: 1.2; }
.sidebar-logo .sub { font-size: 10.5px; color: #8b96ad; }

.nav-group-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: #6b7690; padding: 16px 16px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; margin: 1px 8px; border-radius: 8px;
  cursor: pointer; font-size: 13px; color: #c3cbdb;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.nav-item .ic { width: 18px; text-align: center; flex: none; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active {
  background: linear-gradient(90deg, var(--accent), #1550ff);
  color: #fff; font-weight: 600;
}
.sidebar-footer {
  margin-top: auto; padding: 12px 16px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-user { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sidebar-user .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--celeste); color: var(--black); font-weight: 700;
  display: flex; align-items: center; justify-content: center; font-size: 12px; flex: none;
}
.sidebar-user .un { font-size: 12.5px; font-weight: 600; color: #fff; }
.sidebar-user .ur { font-size: 10.5px; color: #8b96ad; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 58px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 20px;
  position: sticky; top: 0; z-index: 40;
}
.topbar .menu-toggle {
  display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text);
}
.topbar .view-title { font-size: 16px; font-weight: 800; }
.topbar .view-sub { font-size: 11.5px; color: var(--muted); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.sync-status { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.sync-dot.pending { background: var(--warn); }
.sync-dot.error { background: var(--red); }

.content { padding: 20px 22px 60px; flex: 1; }

/* ============================================================
   VISTAS
   ============================================================ */
.view { display: none; animation: fadeIn 0.15s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px);} to { opacity:1; transform: translateY(0);} }

/* ============ BREADCRUMB ============ */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-bottom: 14px; flex-wrap: wrap; }
.bc-item { cursor: pointer; }
.bc-item:hover { color: var(--accent); }
.bc-item.current { color: var(--text); font-weight: 600; cursor: default; }
.bc-sep { color: #c3cbdb; }

/* ============ SECTION TITLES ============ */
.section-title { font-size: 14.5px; font-weight: 800; margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; }
.section-title:first-child { margin-top: 0; }
.section-sub { font-size: 11.5px; font-weight: 400; color: var(--muted); }
.row-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 22px 0 10px; flex-wrap: wrap; }
.row-header .section-title { margin: 0; }

/* ============================================================
   KPI CARDS
   ============================================================ */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.kpi-label { font-size: 11.5px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.kpi-value { font-size: 24px; font-weight: 800; line-height: 1.1; }
.kpi-value.ka { color: var(--accent); }
.kpi-value.kg { color: var(--green); }
.kpi-value.kw { color: var(--warn); }
.kpi-value.kr { color: var(--red); }
.kpi-value.kp { color: var(--purple); }
.kpi-value.kc { color: var(--celeste); }
.kpi-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }
.kpi-progress { height: 6px; background: var(--surface2); border-radius: 6px; margin-top: 8px; overflow: hidden; }
.kpi-progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--celeste)); border-radius: 6px; transition: width 0.3s; }
.kpi-progress-fill.warn { background: var(--warn); }
.kpi-progress-fill.danger { background: var(--red); }
.kpi-progress-fill.ok { background: var(--green); }

/* ============================================================
   ALERTAS / RECOMENDACIONES
   ============================================================ */
.alert-box {
  display: flex; gap: 10px; align-items: flex-start;
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px;
  border: 1px solid var(--border); background: var(--surface);
}
.alert-box .ai { font-size: 18px; flex: none; }
.alert-box .at { font-size: 12.5px; font-weight: 700; margin-bottom: 2px; }
.alert-box .ad { font-size: 11.5px; color: var(--muted); }
.alert-box.ok { background: var(--green-light); border-color: #bfe8cd; }
.alert-box.warn { background: var(--warn-light); border-color: #f5dba8; }
.alert-box.danger { background: var(--red-light); border-color: #f3bcbc; }
.alert-box.info { background: var(--accent-light); border-color: #c3d1ff; }

/* ============================================================
   TABLAS
   ============================================================ */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
table.top-table { width: 100%; border-collapse: collapse; min-width: 640px; }
table.top-table thead th {
  background: var(--black-soft); color: #cbd5e1; text-align: left; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700;
  padding: 10px 14px; white-space: nowrap;
}
table.top-table td { padding: 10px 14px; border-top: 1px solid var(--border); font-size: 12.5px; vertical-align: middle; }
table.top-table tbody tr { cursor: default; transition: background 0.1s; }
table.top-table tbody tr.clickable { cursor: pointer; }
table.top-table tbody tr:hover { background: var(--surface2); }
table.top-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.top-table th.num { text-align: right; }

/* ============================================================
   BADGES
   ============================================================ */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge.ok { background: var(--green-light); color: var(--green); }
.badge.warn { background: var(--warn-light); color: var(--warn); }
.badge.danger { background: var(--red-light); color: var(--red); }
.badge.neu { background: var(--surface2); color: var(--muted); }
.badge.info { background: var(--celeste-light); color: #0f7fa3; }
.badge.accent { background: var(--accent-light); color: var(--accent); }
.badge.purple { background: var(--purple-light); color: var(--purple); }

/* Badges de área */
.badge.area-admin { background: var(--accent-light); color: var(--area-admin); }
.badge.area-community { background: var(--celeste-light); color: #0f7fa3; }
.badge.area-diseno { background: var(--purple-light); color: var(--area-diseno); }
.badge.area-audiovisual { background: var(--warn-light); color: var(--area-audiovisual); }
.badge.area-paid { background: var(--green-light); color: var(--area-paid); }

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer;
  font-weight: 700; font-size: 12.5px; padding: 9px 16px; transition: all 0.15s; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-outline { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 6px 11px; font-size: 11.5px; }
.btn-lg { padding: 12px 22px; font-size: 14px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.filter-active { background: var(--accent-light) !important; color: var(--accent) !important; border-color: var(--accent) !important; }

.icon-btn {
  width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; transition: all 0.15s;
}
.icon-btn:hover { border-color: var(--accent); background: var(--accent-light); }
.icon-btn.icon-danger:hover { border-color: var(--red); background: var(--red-light); }

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filter-count { background: rgba(0,0,0,0.08); border-radius: 999px; padding: 1px 6px; font-size: 10px; margin-left: 4px; }
.filter-active .filter-count { background: rgba(11,61,255,0.15); }
.search-input { padding: 8px 12px; font-size: 12.5px; border: 1px solid var(--border); border-radius: var(--radius-sm); width: 220px; background: var(--surface); }
.search-input:focus { outline: none; border-color: var(--accent); }
.filter-select { padding: 8px 10px; font-size: 12.5px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }

/* ============================================================
   FORMULARIOS
   ============================================================ */
.form-group { margin-bottom: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-label { display: block; font-size: 12px; font-weight: 700; margin-bottom: 5px; color: var(--text); }
.form-label .req { color: var(--red); }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.form-input.invalid, .form-select.invalid, .form-textarea.invalid { border-color: var(--red); background: var(--red-light); }
.form-textarea { min-height: 70px; resize: vertical; }
.form-hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
.form-error-text { font-size: 11px; color: var(--red); margin-top: 4px; display: none; }
.form-error-text.show { display: block; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }

/* ============================================================
   MODALES
   ============================================================ */
.modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(10,14,23,0.55);
  align-items: center; justify-content: center; z-index: 500; padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-backdrop.active { display: flex; }
.modal {
  background: var(--surface); border-radius: 14px; width: 560px; max-width: 100%;
  max-height: 88vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
}
.modal.modal-lg { width: 780px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 15px; font-weight: 800; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }

/* ============================================================
   ENTITY CARDS
   ============================================================ */
.entity-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.entity-card {
  position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; cursor: pointer; box-shadow: var(--shadow); transition: transform 0.12s, box-shadow 0.12s;
}
.entity-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.entity-actions { position: absolute; top: 10px; right: 10px; display: flex; gap: 5px; opacity: 0; transition: opacity 0.15s; }
.entity-card:hover .entity-actions { opacity: 1; }
.entity-title { font-size: 14.5px; font-weight: 800; margin-bottom: 4px; padding-right: 50px; }
.entity-meta { font-size: 11.5px; color: var(--muted); margin-bottom: 10px; }
.entity-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.entity-progress-label { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); margin-bottom: 3px; }

/* ============================================================
   DETAIL HEADER
   ============================================================ */
.entity-detail-header {
  background: linear-gradient(120deg, var(--black-soft), #1c2947);
  color: #fff; border-radius: 14px; padding: 22px 24px; margin-bottom: 20px;
}
.edh-kicker { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--celeste); font-weight: 700; }
.edh-title { font-size: 22px; font-weight: 800; margin: 4px 0 4px; }
.edh-subtitle { font-size: 12.5px; color: #b7c2db; }
.edh-meta { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 14px; font-size: 12px; color: #d7deee; }
.edh-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty-icon { font-size: 38px; margin-bottom: 10px; }
.empty-title { font-size: 14.5px; font-weight: 800; color: var(--text); margin-bottom: 5px; }
.empty-desc { font-size: 12px; margin-bottom: 18px; max-width: 360px; margin-left: auto; margin-right: auto; }

/* ============================================================
   TOAST
   ============================================================ */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--black-soft); color: #fff; padding: 11px 16px; border-radius: 9px; font-size: 12.5px;
  box-shadow: var(--shadow-lg); animation: toastIn 0.2s ease; min-width: 200px;
}
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
@keyframes toastIn { from { opacity:0; transform: translateY(10px);} to {opacity:1; transform: translateY(0);} }

/* ============================================================
   CALENDARIO
   ============================================================ */
.cal-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-title { font-weight: 800; font-size: 15px; min-width: 160px; text-align: center; }
.cal-legend { display: flex; gap: 12px; flex-wrap: wrap; margin-left: auto; font-size: 11px; }
.cal-legend span { display: flex; align-items: center; gap: 5px; }
.cal-dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.cal-view-toggle { display: flex; gap: 4px; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 10.5px; font-weight: 700; color: var(--muted); padding: 4px 0; text-transform: uppercase; }
.cal-cell {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; min-height: 92px;
  padding: 6px; font-size: 11px; display: flex; flex-direction: column; gap: 3px;
}
.cal-cell.other-month { background: var(--surface2); opacity: 0.55; }
.cal-cell.today { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-light); }
.cal-daynum { font-weight: 700; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.cal-event {
  border-radius: 5px; padding: 2px 6px; font-size: 10px; font-weight: 600; color: #fff; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cal-event.area-admin { background: var(--area-admin); }
.cal-event.area-community { background: var(--area-community); color: #06323f; }
.cal-event.area-diseno { background: var(--area-diseno); }
.cal-event.area-audiovisual { background: var(--area-audiovisual); }
.cal-event.area-paid { background: var(--area-paid); }
.cal-more { font-size: 9.5px; color: var(--muted); cursor: pointer; }

.cal-week-list { display: flex; flex-direction: column; gap: 8px; }
.cal-day-row { display: flex; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; }
.cal-day-row .cdr-date { width: 90px; flex: none; font-weight: 700; font-size: 12px; }
.cal-day-row .cdr-events { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }

/* ============================================================
   PROGRESS BAR GENÉRICA (avance por cliente / área)
   ============================================================ */
.progress-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); }
.progress-row:first-child { border-top: none; }
.progress-row .pr-label { width: 150px; flex: none; font-size: 12px; font-weight: 600; }
.progress-row .pr-bar { flex: 1; height: 8px; background: var(--surface2); border-radius: 6px; overflow: hidden; }
.progress-row .pr-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--accent), var(--celeste)); }
.progress-row .pr-fill.warn { background: var(--warn); }
.progress-row .pr-fill.danger { background: var(--red); }
.progress-row .pr-pct { width: 42px; flex: none; text-align: right; font-size: 11.5px; font-weight: 700; color: var(--muted); }

/* Capacidad de carga (semáforo) */
.capacity-card { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.capacity-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--accent-light); color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; flex: none; }
.capacity-info { flex: 1; min-width: 0; }
.capacity-name { font-size: 12.5px; font-weight: 700; }
.capacity-role { font-size: 10.5px; color: var(--muted); }
.capacity-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.capacity-dot.ok { background: var(--green); }
.capacity-dot.warn { background: var(--warn); }
.capacity-dot.danger { background: var(--red); }

/* ============================================================
   TABS
   ============================================================ */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tab-btn { padding: 9px 14px; font-size: 12.5px; font-weight: 700; color: var(--muted); background: none; border: none; cursor: pointer; border-bottom: 2px solid transparent; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-color: var(--accent); }

/* ============================================================
   UTILIDADES
   ============================================================ */
.muted { color: var(--muted); }
.text-right { text-align: right; }
.mt-0 { margin-top: 0 !important; }
.hidden { display: none !important; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.w-full { width: 100%; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.stage-chain { display: flex; flex-wrap: wrap; gap: 6px; }
.stage-chip {
  font-size: 10.5px; font-weight: 700; padding: 5px 9px; border-radius: 999px;
  background: var(--surface2); color: var(--muted); border: 1px solid var(--border);
}
.stage-chip.done { background: var(--green-light); color: var(--green); border-color: #bfe8cd; }
.stage-chip.active-stage { background: var(--accent-light); color: var(--accent); border-color: #c3d1ff; }
.stage-chip.blocked { background: var(--red-light); color: var(--red); border-color: #f3bcbc; }

/* ============================================================
   RESPONSIVE — móvil desde 900px
   ============================================================ */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; height: 100vh; transform: translateX(-100%);
    transition: transform 0.2s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .topbar .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .content { padding: 14px 12px 50px; }
  .form-row, .form-row.cols-3, .grid-2 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .cal-grid { grid-template-columns: repeat(7, minmax(40px,1fr)); }
  .cal-cell { min-height: 66px; padding: 4px; font-size: 9.5px; }
  .cal-legend { margin-left: 0; }
  .modal { width: 100%; }
  .progress-row .pr-label { width: 96px; font-size: 11px; }

  /* Tablas -> tarjetas apiladas */
  table.top-table thead { display: none; }
  table.top-table, table.top-table tbody, table.top-table tr, table.top-table td { display: block; width: 100%; }
  table.top-table tr { border-top: 1px solid var(--border); padding: 8px 14px; }
  table.top-table td { border-top: none; padding: 4px 0; display: flex; justify-content: space-between; gap: 10px; text-align: right; }
  table.top-table td::before { content: attr(data-label); font-weight: 700; color: var(--muted); text-align: left; }
  table.top-table td.num { text-align: right; }
}

@media (max-width: 520px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .entity-grid { grid-template-columns: 1fr; }
}

/* ============ IMPRESIÓN ============ */
@media print {
  .sidebar, .topbar, .filter-bar, .btn, .modal-backdrop, #toast-container { display: none !important; }
  @page { size: A4 landscape; margin: 12mm; }
  body { background: #fff; }
}
