/* =============================================================================
   Pegasus Blue CRM — sistema de diseño base
   Fase 1. El kanban y el dashboard se apoyan en estos tokens.

   Paleta tomada de las cartas de navegación aeronáutica: fondo pergamino,
   tinta azul marino, magenta de espacio aéreo como acento.
   ========================================================================== */

:root {
  --ground:      #F6F3EC;
  --surface:     #FFFFFF;
  --surface-2:   #EFEAE0;
  --ink:         #151E28;
  --ink-2:       #3E4A57;
  --muted:       #77716A;
  --line:        #DBD4C7;
  --line-strong: #B9AF9E;

  --accent:      #A81A57;
  --accent-ink:  #FFFFFF;
  --accent-soft: #F7E4EC;
  --chart:       #1C4E85;
  --chart-soft:  #E2EBF5;

  --ok:   #2C6E4B;
  --warn: #9C6100;
  --crit: #9B1F22;

  --shadow-sm: 0 1px 2px rgba(21, 30, 40, .06);
  --shadow:    0 1px 2px rgba(21, 30, 40, .05), 0 8px 24px -12px rgba(21, 30, 40, .18);

  --radius: 4px;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground:      #0D1319;
    --surface:     #141C24;
    --surface-2:   #1B242E;
    --ink:         #E7EBEF;
    --ink-2:       #B6C0CA;
    --muted:       #8B959F;
    --line:        #26313C;
    --line-strong: #3A4854;

    --accent:      #F0619B;
    --accent-ink:  #1A0A11;
    --accent-soft: #2B1622;
    --chart:       #77B3E8;
    --chart-soft:  #132132;

    --ok:   #5FB98A;
    --warn: #DFA13C;
    --crit: #E8736F;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow:    0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px -16px rgba(0, 0, 0, .7);
  }
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 15px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.015em; text-wrap: balance; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 19px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
p  { margin: 0; }
a  { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

.mono { font-family: var(--mono); }
.tabular { font-variant-numeric: tabular-nums; }

.eyebrow {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}

/* --- Estructura de la aplicación ------------------------------------------ */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px; padding: 20px 12px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; flex-direction: column; gap: 2px; padding: 4px 10px 18px; }
.brand strong { font-size: 15px; font-weight: 700; letter-spacing: -.02em; }
.brand span { font-size: 11px; color: var(--muted); font-family: var(--mono); letter-spacing: .1em; text-transform: uppercase; }

.nav-section { padding: 16px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: var(--radius);
  color: var(--ink-2); text-decoration: none; font-size: 14px; font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a .ico { width: 16px; text-align: center; opacity: .75; font-size: 13px; }

.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); }

.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 30px;
  display: grid; place-items: center; color: #fff;
  font-size: 11.5px; font-weight: 700; letter-spacing: .02em;
}

.userbox { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.userbox .meta { min-width: 0; }
.userbox .meta strong { display: block; font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userbox .meta span { display: block; font-size: 11.5px; color: var(--muted); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 28px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.content { padding: 28px; max-width: 1200px; width: 100%; }

/* --- Tarjetas ------------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px 22px; }
.card-head { padding: 15px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.grid { display: grid; gap: 16px; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.stat { padding: 16px 18px; }
.stat .v { display: block; font-size: 26px; font-weight: 700; letter-spacing: -.03em; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* --- Formularios ---------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12.5px; color: var(--muted); }

input[type="text"], input[type="email"], input[type="password"],
input[type="search"], select, textarea {
  width: 100%; padding: 9px 12px; font: inherit; font-size: 14.5px;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: var(--muted); }

.code-input {
  font-family: var(--mono); font-size: 26px; letter-spacing: .5em;
  text-align: center; padding: 14px 12px 14px 24px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; font: inherit; font-size: 14.5px; font-weight: 600;
  border-radius: var(--radius); border: 1px solid transparent; cursor: pointer;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 11px; font-size: 13px; }

/* --- Avisos --------------------------------------------------------------- */
.alert {
  padding: 12px 15px; border-radius: var(--radius); border: 1px solid;
  font-size: 14px; margin-bottom: 18px; line-height: 1.55;
}
.alert-error   { color: var(--crit); border-color: var(--crit); background: color-mix(in srgb, var(--crit) 8%, transparent); }
.alert-ok      { color: var(--ok);   border-color: var(--ok);   background: color-mix(in srgb, var(--ok) 8%, transparent); }
.alert-warn    { color: var(--warn); border-color: var(--warn); background: color-mix(in srgb, var(--warn) 8%, transparent); }
.alert-info    { color: var(--chart); border-color: var(--chart); background: var(--chart-soft); }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

/* --- Píldoras ------------------------------------------------------------- */
.pill {
  display: inline-block; font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: .07em; text-transform: uppercase; padding: 3px 7px;
  border-radius: 2px; border: 1px solid; white-space: nowrap;
}
.pill-ok   { color: var(--ok);   border-color: var(--ok);   background: color-mix(in srgb, var(--ok) 9%, transparent); }
.pill-warn { color: var(--warn); border-color: var(--warn); background: color-mix(in srgb, var(--warn) 9%, transparent); }
.pill-crit { color: var(--crit); border-color: var(--crit); background: color-mix(in srgb, var(--crit) 9%, transparent); }
.pill-info { color: var(--chart); border-color: var(--chart); background: var(--chart-soft); }
.pill-mut  { color: var(--muted); border-color: var(--line-strong); }

/* --- Tablas --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; padding: 10px 16px; background: var(--surface-2);
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--line-strong); white-space: nowrap;
}
tbody td { padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.cell-strong { font-weight: 600; }
.cell-mut { color: var(--muted); font-size: 13px; }

/* --- Pantallas de autenticación ------------------------------------------- */
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-head { text-align: center; margin-bottom: 26px; }
.auth-head h1 { font-size: 22px; margin-bottom: 6px; }
.auth-head p { color: var(--muted); font-size: 14px; }
.auth-mark {
  width: 44px; height: 44px; margin: 0 auto 16px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 20px;
}
.auth-foot { text-align: center; margin-top: 20px; font-size: 12.5px; color: var(--muted); line-height: 1.6; }

/* --- Banner de suplantación ----------------------------------------------- */
.impersonating {
  background: var(--warn); color: #fff; padding: 8px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  font-size: 13.5px; font-weight: 600;
}
.impersonating form { margin: 0; }
.impersonating .btn { background: rgba(255, 255, 255, .18); color: #fff; border-color: rgba(255, 255, 255, .4); }

/* --- Códigos de recuperación ---------------------------------------------- */
.codes {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px;
  margin: 18px 0;
}
.codes li {
  list-style: none; font-family: var(--mono); font-size: 15px; letter-spacing: .04em;
  padding: 9px 12px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); text-align: center;
}
.secret-box {
  font-family: var(--mono); font-size: 16px; letter-spacing: .12em; word-break: break-all;
  padding: 13px 15px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); text-align: center; margin: 12px 0;
}

.steps { counter-reset: s; margin: 0 0 18px; padding: 0; list-style: none; }
.steps li { counter-increment: s; position: relative; padding-left: 30px; margin-bottom: 12px; font-size: 14px; color: var(--ink-2); }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 1px;
  width: 20px; height: 20px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 11px; font-weight: 700; font-family: var(--mono);
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mb-0 { margin-bottom: 0; }
.mt-3 { margin-top: 18px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }

/* --- Responsive ----------------------------------------------------------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; align-items: center;
    overflow-x: auto; border-right: none; border-bottom: 1px solid var(--line);
    padding: 10px 14px; gap: 8px;
  }
  .brand { padding: 0 12px 0 0; border-right: 1px solid var(--line); }
  .nav { display: flex; gap: 4px; }
  .nav-section, .sidebar-foot { display: none; }
  .content, .topbar { padding: 18px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
