/* Numi · hoja de estilos base */
:root {
  --ink: #1d2a2f;
  --ink-2: #4a5a60;
  --muted: #6f7c80;
  --line: #e3e0d8;
  --bg: #f6f4ef;
  --card: #ffffff;
  --brand: #1d2a2f;
  --gold: #b0893d;
  --gold-soft: #f4ecdb;
  --ok: #2f7a4d;
  --ok-soft: #e5f2ea;
  --warn: #9a6a12;
  --warn-soft: #fbf1dc;
  --err: #b23a32;
  --err-soft: #fbe9e7;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(29, 42, 47, .06), 0 4px 16px rgba(29, 42, 47, .04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg); }
a { color: inherit; }
h1, h2 { margin: 0 0 .25rem; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.05rem; margin-bottom: .75rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); font-size: .9em; }
.nowrap { white-space: nowrap; }

/* Banda de entorno */
.env-band { background: var(--warn-soft); color: var(--warn); text-align: center; font-size: .8rem; font-weight: 600; padding: .3rem; border-bottom: 1px solid #efdcb2; }

/* Estructura */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--brand); color: #e9eef0; display: flex; flex-direction: column; padding: 1.25rem .9rem; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.25rem; text-decoration: none; padding: 0 .5rem 1.25rem; }
.brand-mark { width: 26px; height: 26px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #f1d998, var(--gold) 55%, #7d5e22); box-shadow: inset 0 0 0 2px rgba(255,255,255,.25); flex: none; }
.brand-mark.lg { width: 52px; height: 52px; margin: 0 auto .75rem; display: block; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: .7rem; padding: .6rem .7rem; border-radius: 8px; text-decoration: none; color: #c9d3d6; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(255,255,255,.1); color: #fff; }
.nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,.1); }
.me { display: flex; align-items: center; gap: .5rem; text-decoration: none; min-width: 0; }
.me-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .9rem; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--gold); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.btn-link { background: none; border: 0; color: #c9d3d6; cursor: pointer; font: inherit; font-size: .85rem; padding: .3rem; }
.btn-link:hover { color: #fff; text-decoration: underline; }
.main { padding: 1.75rem 2rem 2rem; max-width: 1180px; width: 100%; }
.foot { margin-top: 2rem; color: var(--muted); font-size: .75rem; }

/* Encabezado de página */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.back { color: var(--muted); text-decoration: none; font-size: .85rem; display: inline-block; margin-bottom: .3rem; }

/* Tarjetas */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1rem; }
.card.flush { padding: 0; overflow: hidden; }
.card.narrow { max-width: 560px; }
.card.empty { text-align: center; padding: 2.5rem 1.25rem; }
.danger-zone { border-color: #efcdc9; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-2 .card { margin: 0; }
.grid-2 + .card { margin-top: 1rem; }

/* Indicadores */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.15rem; display: flex; flex-direction: column; gap: .15rem; box-shadow: var(--shadow); }
.stat-label { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: .8rem; color: var(--muted); }
.stat-accent { background: var(--gold-soft); border-color: #ead9b3; }

/* Listas */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 1rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; white-space: nowrap; flex: none; }
.list .meta { text-align: right; flex: 0 1 auto; }
@media (max-width: 720px) { .list-stack li { flex-wrap: wrap; row-gap: .1rem; } .list-stack .meta { text-align: left; width: 100%; } }
.num-strong { font-weight: 700; font-variant-numeric: tabular-nums; }
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.bars li { display: grid; grid-template-columns: minmax(0, 1.4fr) 1fr 2.5rem; align-items: center; gap: .6rem; font-size: .85rem; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: #efece5; border-radius: 99px; height: 8px; overflow: hidden; }
.bar { display: block; height: 100%; background: var(--gold); border-radius: 99px; width: 0; transition: width .4s ease; }
.bar-n { text-align: right; font-variant-numeric: tabular-nums; }

/* Tablas */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: .7rem 1rem; background: #faf9f6; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: .7rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.row-warn td { background: #fffaf0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.25rem; margin: 0 0 .75rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* Etiquetas */
.pill { display: inline-block; font-size: .72rem; font-weight: 600; padding: .12rem .5rem; border-radius: 99px; vertical-align: middle; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-err { background: var(--err-soft); color: var(--err); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-gold { background: var(--gold-soft); color: #7d5e22; margin-left: .35rem; }

/* Formularios */
.form { display: grid; gap: 1rem; }
.form-row { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); align-items: end; }
.field { display: grid; gap: .3rem; }
.field > span { font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.field small { font-size: .78rem; }
input, select, textarea { font: inherit; color: inherit; width: 100%; padding: .65rem .75rem; border: 1px solid #d6d2c8; border-radius: 8px; background: #fff; min-height: 44px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: var(--gold); }
.check { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.check input { width: 18px; height: 18px; min-height: 0; }
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.inline { display: inline; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600; font-size: .9rem; padding: .6rem 1rem; min-height: 44px; border-radius: 8px; border: 1px solid #d6d2c8; background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; }
.btn:hover { background: #faf9f6; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #2a3b42; }
.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn-danger:hover { background: #9a2f28; }
.btn-ghost { background: transparent; }
.btn-sm { padding: .35rem .7rem; min-height: 36px; font-size: .82rem; }
.btn-block { width: 100%; }

/* Avisos */
.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; border: 1px solid transparent; }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: #c8e3d3; }
.alert-error { background: var(--err-soft); color: var(--err); border-color: #f1c9c4; }
.alert-info { background: #eaf1f6; color: #2c5d7c; border-color: #cfe0ec; }
.alert-float { position: fixed; top: 1rem; left: 50%; transform: translateX(-50%); width: min(92vw, 420px); z-index: 10; }
.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin: 1rem 0; }

/* Acceso */
body.blank { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.login { width: 100%; max-width: 380px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 2rem 1.5rem; }
.login-head { text-align: center; margin-bottom: 1.25rem; }
.login-card .pill { display: table; margin: 0 auto 1rem; }

/* Móvil */
@media (max-width: 900px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stats .stat:first-child { grid-column: 1 / -1; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .shell { display: block; }
  .sidebar { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; flex-direction: row; padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom)); z-index: 5; }
  .brand, .sidebar-foot { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; }
  .nav a { flex-direction: column; gap: .15rem; font-size: .68rem; padding: .4rem .3rem; flex: 1; }
  .nav svg { width: 21px; height: 21px; }
  .main { padding: 1.1rem 1rem 6rem; }
  h1 { font-size: 1.35rem; }
  .stat-value { font-size: 1.35rem; }
  .stats { gap: .6rem; }
  .card { padding: 1rem; }
  .table th, .table td { padding: .6rem .7rem; }
}
.mobile-account { display: none; }
@media (max-width: 720px) {
  .mobile-account { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
  .brand-sm { display: flex; align-items: center; gap: .5rem; font-weight: 700; text-decoration: none; }
  .brand-sm .brand-mark { width: 22px; height: 22px; }
  .mobile-links { display: flex; align-items: center; gap: .75rem; font-size: .85rem; }
  .btn-link.dark { color: var(--ink-2); }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.login.wide { max-width: 560px; }
a.plain { text-decoration: none; }
a.plain:hover { text-decoration: underline; }
