/* Justificaciones — Imascono. Color corporativo: gris marengo #4C5866 */
:root {
  --marengo: #4c5866;
  --bg: #f3f5f6;
  --surface: #ffffff;
  --surface-2: #edf0f2;
  --border: #d6dde1;
  --text: #232c33;
  --text-2: #5d6b75;
  --accent: #4c5866;
  --accent-soft: #e5eaee;
  --on-accent: #ffffff;
  --sidebar-bg: #4c5866;
  --sidebar-text: #c9d2d9;
  --sidebar-active: rgba(255, 255, 255, .12);
  --good: #2e7d43;
  --good-soft: #e4f2e8;
  --warn: #a26a12;
  --warn-soft: #f9efdc;
  --danger: #b03a2e;
  --danger-soft: #f9e6e4;
  --shadow: 0 1px 3px rgba(35, 44, 51, .08);
  --radius: 8px;
  --mono: "Cascadia Code", Consolas, "SF Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16191d;
    --surface: #1e232a;
    --surface-2: #262d35;
    --border: #364049;
    --text: #e2e8ec;
    --text-2: #93a1ab;
    --accent: #9fb2bf;
    --accent-soft: #2b333c;
    --on-accent: #16191d;
    --sidebar-bg: #1a1f25;
    --sidebar-text: #93a1ab;
    --sidebar-active: rgba(159, 178, 191, .16);
    --good: #5cb877;
    --good-soft: #17301e;
    --warn: #d9a441;
    --warn-soft: #33270f;
    --danger: #e0705f;
    --danger-soft: #3a1e1a;
    --shadow: 0 1px 3px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
}
.app { display: flex; min-height: 100vh; }
[hidden] { display: none !important; }
.muted { color: var(--text-2); }
.normal { font-weight: 400; text-transform: none; letter-spacing: 0; }
.error { color: var(--danger); font-size: 13px; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--sidebar-bg);
  display: flex; flex-direction: column; padding: 20px 12px; gap: 4px;
}
.brand { padding: 0 10px 18px; color: #fff; }
.brand strong { font-size: 15px; letter-spacing: .2px; }
.brand span { display: block; font-size: 11px; color: var(--sidebar-text); text-transform: uppercase; letter-spacing: .8px; margin-top: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius); border: none; background: none;
  color: var(--sidebar-text); font: inherit; cursor: pointer; text-align: left; width: 100%;
}
.nav-item:hover { background: var(--sidebar-active); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.sidebar .foot { margin-top: auto; padding: 10px; }
.sidebar .foot .btn { background: none; border-color: rgba(255,255,255,.25); color: var(--sidebar-text); width: 100%; }
.sidebar .foot .btn:hover { color: #fff; border-color: rgba(255,255,255,.5); background: none; }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 28px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; }
.topbar .who { font-size: 12px; color: var(--text-2); }
.content { padding: 24px 28px 48px; max-width: 1180px; width: 100%; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px;
}
.card h2 { font-size: 13px; margin: 0 0 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--text-2); font-weight: 600; }
.grid-editor { display: grid; grid-template-columns: 1fr 300px; gap: 18px; align-items: start; }
.col-form { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.col-rail { display: flex; flex-direction: column; gap: 18px; position: sticky; top: 20px; }
@media (max-width: 900px) { .grid-editor { grid-template-columns: 1fr; } .col-rail { position: static; } }

/* ---------- Formularios ---------- */
label.field { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
input[type="text"], input[type="password"], input[type="date"], input[type="number"], select {
  width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text); font: inherit;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px;
  border-radius: 6px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); background: var(--accent); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: none; }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn-sm { padding: 4px 10px; font-size: 12px; font-weight: 500; }
.btn-icon { padding: 2px 8px; border: none; background: none; color: var(--text-2); cursor: pointer; font-size: 14px; border-radius: 4px; }
.btn-icon:hover { color: var(--danger); background: var(--danger-soft); }

.actions-row { display: flex; gap: 10px; flex-wrap: wrap; }
.actions-col { display: flex; flex-direction: column; gap: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.cards-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; align-items: start; }
.hint { font-size: 12px; color: var(--text-2); margin-top: 8px; }
.hint code { font-family: var(--mono); font-size: 11px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

/* ---------- Barra de progreso ---------- */
.progress-box { margin-top: 12px; }
.progress-track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width .4s ease; }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 8px 4px 4px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; font-size: 12px;
}
.chip .av {
  width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700;
}
.chip small { color: var(--text-2); }
.chip .x { border: none; background: none; color: var(--text-2); cursor: pointer; font-size: 13px; padding: 0 2px; line-height: 1; }
.chip .x:hover { color: var(--danger); }
.chip.add { border-style: dashed; color: var(--accent); padding: 4px 12px; cursor: pointer; background: none; font-weight: 600; }
.chip.add:hover { background: var(--accent-soft); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-wp { background: var(--accent-soft); color: var(--accent); font-family: var(--mono); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-good { background: var(--good-soft); color: var(--good); }

/* ---------- Tablas ---------- */
.tbl-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-2); padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12px; }

/* ---------- Roles ---------- */
.roles-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.role-box { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; background: var(--surface-2); }
.role-box .role-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.role-box .role-head input { font-weight: 600; font-size: 12px; letter-spacing: .5px; text-transform: uppercase; }
.role-members label { display: flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 0; cursor: pointer; }

/* ---------- Tareas ---------- */
.tasks-list { display: flex; flex-direction: column; gap: 12px; }
.task-box { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.task-head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.task-head input { flex: 1; }
.task-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.task-roles { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.task-roles .rh { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.task-roles .rh input { width: 70px; }
.task-roles .rh .rname { font-weight: 600; letter-spacing: .3px; }

/* ---------- Validación ---------- */
.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.checks li { display: flex; gap: 8px; align-items: baseline; }
.checks .ic { font-weight: 700; flex-shrink: 0; }
.checks .ok .ic, li.ok .ic { color: var(--good); }
.checks li.warn .ic { color: var(--warn); }
.checks li.err .ic { color: var(--danger); }

/* ---------- Resultado ---------- */
.bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: var(--good); border-radius: 3px; }
.bar i.warn { background: var(--warn); }
.cover { margin-bottom: 10px; }
.cover .row { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; }
.cover .row b { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.result-log {
  background: var(--surface-2); border-radius: 6px; padding: 10px 12px; margin-top: 12px;
  font-family: var(--mono); font-size: 12px; overflow-x: auto; white-space: pre-wrap; line-height: 1.7;
}
.result-log .w { color: var(--warn); font-weight: 700; }

/* ---------- Login ---------- */
.login-overlay {
  position: fixed; inset: 0; background: var(--bg);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.login-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 32px; width: 320px;
  display: flex; flex-direction: column; gap: 10px;
}
.login-box h1 { margin: 0; font-size: 20px; }
.login-box p { margin: 0 0 10px; font-size: 12px; }
.login-box .btn { margin-top: 8px; }

/* ---------- Modales ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20, 25, 30, .55);
  display: flex; align-items: center; justify-content: center; z-index: 40; padding: 20px;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; width: 460px; max-width: 100%; max-height: 85vh;
  display: flex; flex-direction: column; gap: 12px;
}
.modal h2 { margin: 0; font-size: 15px; }
.modal-body { overflow-y: auto; min-height: 120px; }
.modal-body label { display: flex; align-items: center; gap: 8px; padding: 6px 4px; font-size: 13px; cursor: pointer; border-radius: 6px; }
.modal-body label:hover { background: var(--surface-2); }
.modal-body small { color: var(--text-2); }
.modal-foot { justify-content: flex-end; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 8px;
  font-size: 13px; z-index: 60; box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
.toast.err { background: var(--danger); color: #fff; }

@media (prefers-reduced-motion: no-preference) {
  .view.active { animation: fadein .15s ease; }
  @keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
}
