/* ============================================================================
   EHERO Gestión — Design System (sin build step). Inspirado en SaaS modernos.
   Marca: #017cba / #00b2e2
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --brand: #017cba;
  --brand-600: #0269a0;
  --brand-700: #015a87;
  --brand-50: #e8f4fb;
  --brand-100: #cfe9f7;
  --cyan: #00b2e2;
  --cyan-50: #e0f6fd;

  --ink: #0f1b2d;
  --ink-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e9edf3;
  --line-2: #f1f4f8;
  --bg: #f4f6fa;
  --card: #ffffff;
  --sidebar: #0c2233;          /* navy profundo */
  --sidebar-2: #0a1c2a;

  --ok: #12a150;
  --ok-bg: #e7f7ee;
  --warn: #b7791f;
  --warn-bg: #fcf3e2;
  --err: #e02424;
  --err-bg: #fdeaea;
  --info: #0369a1;
  --info-bg: #e6f3fb;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --sh-sm: 0 1px 2px rgba(15,27,45,.06);
  --sh: 0 2px 8px rgba(15,27,45,.06), 0 1px 2px rgba(15,27,45,.04);
  --sh-lg: 0 12px 32px rgba(15,27,45,.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-700); }
h1,h2,h3,h4 { margin: 0 0 .4rem; font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
h1 { font-size: 1.55rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .6rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.tnum { font-variant-numeric: tabular-nums; }
svg.ic { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ── App shell ──────────────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex: none; background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  color: #cdd9e3; position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 14px;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; font-weight: 800; font-size: 1.12rem; letter-spacing: -.02em; }
.sidebar .brand .logo { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--brand), var(--cyan)); display: grid; place-items: center; color: #fff; font-weight: 800; box-shadow: 0 4px 12px rgba(0,178,226,.35); }
.sidebar .grp { font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; color: #607c91; padding: 16px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 10px; color: #b9c8d4; font-size: .92rem; font-weight: 500; margin-bottom: 2px; transition: background .12s, color .12s; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: linear-gradient(135deg, rgba(1,124,186,.95), rgba(0,178,226,.85)); color: #fff; box-shadow: 0 6px 16px rgba(0,178,226,.25); }
.nav-item.active svg { stroke: #fff; }
.sidebar .foot { margin-top: 18px; padding: 12px 10px; border-top: 1px solid rgba(255,255,255,.08); font-size: .76rem; color: #7e95a6; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: rgba(255,255,255,.85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding: 12px 26px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 20; }
.topbar .crumbs { font-size: .9rem; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.topbar .crumbs b { color: var(--ink); font-weight: 600; }
.topbar .right { display: flex; align-items: center; gap: 14px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--brand), var(--cyan)); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.usermeta { text-align: right; line-height: 1.15; }
.usermeta .n { font-weight: 600; font-size: .85rem; }
.usermeta .a { font-size: .76rem; color: var(--muted); }
.content { padding: 26px; max-width: 1240px; width: 100%; margin: 0 auto; }

@media (max-width: 900px) { .sidebar { display: none; } .content { padding: 16px; } }

/* ── Page header ────────────────────────────────────────────────────────── */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh-sm); }
.card-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-head h2, .card-head h3 { margin: 0; }
.card-body { padding: 18px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2,1fr); }
.cols-3 { grid-template-columns: repeat(3,1fr); }
.cols-4 { grid-template-columns: repeat(4,1fr); }
@media (max-width: 980px){ .cols-3,.cols-4 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 640px){ .cols-2,.cols-3,.cols-4 { grid-template-columns: 1fr; } }

/* ── KPI ────────────────────────────────────────────────────────────────── */
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--sh-sm); display: flex; flex-direction: column; gap: 8px; position: relative; overflow: hidden; }
.kpi .ico { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); }
.kpi .ico.green { background: var(--ok-bg); color: var(--ok); }
.kpi .ico.amber { background: var(--warn-bg); color: var(--warn); }
.kpi .ico.cyan { background: var(--cyan-50); color: #0892b8; }
.kpi .label { color: var(--muted); font-size: .8rem; font-weight: 500; }
.kpi .value { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; }
.kpi .delta { font-size: .78rem; font-weight: 600; }
.kpi .delta.up { color: var(--ok); } .kpi .delta.down { color: var(--err); }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th, table.tbl td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line-2); font-size: .9rem; }
table.tbl thead th { color: var(--muted); font-weight: 600; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; background: #fafbfd; border-bottom: 1px solid var(--line); }
table.tbl tbody tr { transition: background .1s; }
table.tbl tbody tr:hover { background: #f9fbfe; }
table.tbl tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-strong { font-weight: 600; color: var(--ink); }

/* ── Pills / badges ─────────────────────────────────────────────────────── */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: .74rem; font-weight: 600; line-height: 1.4; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.pill.gray { background: #eef1f5; color: #5b6b7d; }
.pill.blue { background: var(--brand-50); color: var(--brand); }
.pill.cyan { background: var(--cyan-50); color: #0892b8; }
.pill.green { background: var(--ok-bg); color: var(--ok); }
.pill.amber { background: var(--warn-bg); color: var(--warn); }
.pill.red { background: var(--err-bg); color: var(--err); }
.pill.plain::before { display: none; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; border-radius: 10px; border: 1px solid transparent; font-size: .88rem; font-weight: 600; font-family: inherit; cursor: pointer; transition: all .12s; white-space: nowrap; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(1,124,186,.25); }
.btn-primary:hover { background: var(--brand-600); color: #fff; box-shadow: 0 6px 16px rgba(1,124,186,.3); }
.btn-cyan { background: var(--cyan); color: #06384a; }
.btn-light { background: #eef2f7; color: var(--ink-2); }
.btn-light:hover { background: #e2e8f0; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--muted-2); }
.btn-danger { background: var(--err); color: #fff; }
.btn-danger:hover { background: #c81e1e; color: #fff; }
.btn-sm { padding: 6px 11px; font-size: .8rem; border-radius: 8px; }
.btn-icon { padding: 7px; border-radius: 8px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; box-shadow: none; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field > label { display: block; font-weight: 600; font-size: .84rem; margin-bottom: 6px; color: var(--ink-2); }
.field .hint { color: var(--muted); font-size: .8rem; margin-top: 5px; }
input[type=text],input[type=email],input[type=password],input[type=number],input[type=date],input[type=file],select,textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #d7dde7; border-radius: 10px; font-size: .9rem; font-family: inherit; background: #fff; color: var(--ink); transition: border .12s, box-shadow .12s;
}
input:focus,select:focus,textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(1,124,186,.13); }
input::placeholder, textarea::placeholder { color: var(--muted-2); }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
.check { display: flex; align-items: center; gap: 9px; font-size: .88rem; }
.check input { width: auto; }
.input-group { display: flex; gap: 8px; }

/* ── Flash ──────────────────────────────────────────────────────────────── */
.flash { display: flex; align-items: center; gap: 10px; padding: 12px 15px; border-radius: 11px; margin-bottom: 16px; font-size: .9rem; border: 1px solid; font-weight: 500; }
.flash svg { width: 18px; height: 18px; flex: none; }
.flash-success { background: var(--ok-bg); border-color: #b9e6cc; color: #0a7038; }
.flash-error { background: var(--err-bg); border-color: #f6c5c5; color: #b91c1c; }
.flash-warning { background: var(--warn-bg); border-color: #f0dcb0; color: #92600c; }
.errors { background: var(--err-bg); border: 1px solid #f6c5c5; color: #b91c1c; padding: 12px 15px; border-radius: 11px; margin-bottom: 16px; font-size: .86rem; }
.errors ul { margin: 6px 0 0; padding-left: 18px; }

/* ── Empty state ────────────────────────────────────────────────────────── */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .ico { width: 56px; height: 56px; border-radius: 16px; background: var(--brand-50); color: var(--brand); display: grid; place-items: center; margin: 0 auto 14px; }
.empty .ico svg { width: 26px; height: 26px; }
.empty h3 { color: var(--ink); }

/* ── Chart (barras SVG server-side) ─────────────────────────────────────── */
.chart { width: 100%; height: 200px; display: block; }
.chart .bar { fill: url(#barGrad); rx: 4; transition: opacity .15s; }
.chart .bar:hover { opacity: .82; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .lbl { fill: var(--muted-2); font-size: 10px; font-family: 'Inter',sans-serif; }

/* ── Auth (split screen) ────────────────────────────────────────────────── */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
.auth .promo { background: linear-gradient(150deg, var(--brand-700), var(--brand) 45%, var(--cyan)); color: #fff; padding: 56px 52px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth .promo::after { content: ''; position: absolute; right: -120px; bottom: -120px; width: 380px; height: 380px; border-radius: 50%; background: rgba(255,255,255,.08); }
.auth .promo .logo { width: 44px; height: 44px; border-radius: 12px; background: rgba(255,255,255,.16); display: grid; place-items: center; font-weight: 800; font-size: 1.2rem; }
.auth .promo h1 { color: #fff; font-size: 2.1rem; line-height: 1.15; max-width: 460px; }
.auth .promo p { color: rgba(255,255,255,.85); max-width: 440px; font-size: 1.02rem; }
.auth .promo .feats { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.auth .promo .feats .f { display: flex; align-items: center; gap: 11px; font-size: .96rem; }
.auth .promo .feats .f .tick { width: 26px; height: 26px; border-radius: 8px; background: rgba(255,255,255,.18); display: grid; place-items: center; flex: none; }
.auth .form-side { display: flex; align-items: center; justify-content: center; padding: 40px 28px; background: var(--bg); }
.auth .form-card { width: 100%; max-width: 400px; }
.auth .form-card h2 { font-size: 1.5rem; }
.auth .form-card .lead { color: var(--muted); margin-bottom: 22px; }
@media (max-width: 860px){ .auth { grid-template-columns: 1fr; } .auth .promo { display: none; } }

/* utils */
.flex { display: flex; } .items-center { align-items: center; } .gap { gap: 10px; } .between { justify-content: space-between; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; } .mb-lg { margin-bottom: 24px; }
.right { text-align: right; } .center { text-align: center; }
.text-ok { color: var(--ok); } .text-warn { color: var(--warn); } .text-err { color: var(--err); } .text-brand { color: var(--brand); }
.divider { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.verifactu-leyenda { font-weight: 800; color: var(--brand); letter-spacing: .04em; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 4px; }
.tag-soft { background: var(--line-2); color: var(--muted); padding: 2px 8px; border-radius: 6px; font-size: .76rem; font-weight: 600; }

/* ── Checklist de onboarding ─────────────────────────────────────────────── */
.checklist { display: flex; flex-direction: column; gap: 2px; }
.check-row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line-2); }
.check-row:last-child { border-bottom: 0; }
.check-row .mark { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 700; }
.check-row .mark.done { background: var(--ok-bg); color: var(--ok); }
.check-row .mark.todo { background: var(--line-2); color: var(--muted-2); border: 2px dashed var(--muted-2); }
.check-row .txt { flex: 1; }
.check-row .txt .t { font-weight: 600; }
.check-row.is-done .txt .t { color: var(--muted); text-decoration: line-through; }
.progress { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--cyan)); }

/* ── Modo oscuro ─────────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --ink: #e6edf3; --ink-2: #c2cdd8; --muted: #8b9bab; --muted-2: #647688;
  --line: #1f2e3d; --line-2: #16222e; --bg: #0a141d; --card: #0f1d2a;
  --sidebar: #060f17; --sidebar-2: #04090f;
  --brand-50: #0e2a3c; --brand-100: #103247; --cyan-50: #0a2530;
  --ok-bg: #0e2a1c; --warn-bg: #2a2410; --err-bg: #2c1616; --info-bg: #0d2436;
  --sh-sm: 0 1px 2px rgba(0,0,0,.3); --sh: 0 2px 8px rgba(0,0,0,.35);
}
[data-theme="dark"] body { background: var(--bg); color: var(--ink); }
[data-theme="dark"] .topbar { background: rgba(15,29,42,.85); }
[data-theme="dark"] table.tbl thead th { background: #0c1925; }
[data-theme="dark"] table.tbl tbody tr:hover { background: #122231; }
[data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea { background: #0c1925; border-color: #25394c; color: var(--ink); }
[data-theme="dark"] .btn-light { background: #1a2a3a; color: var(--ink-2); }
[data-theme="dark"] .btn-ghost { background: #0f1d2a; color: var(--ink-2); }
[data-theme="dark"] .kpi .value, [data-theme="dark"] h1, [data-theme="dark"] h2, [data-theme="dark"] h3 { color: var(--ink); }
[data-theme="dark"] .chart .lbl { fill: var(--muted); }
[data-theme="dark"] .topbar-search input { background: #0c1925; }

/* ── Búsqueda en topbar ──────────────────────────────────────────────────── */
.topbar-search { flex: 1; max-width: 440px; margin: 0 24px; position: relative; display: flex; align-items: center; }
.topbar-search svg { position: absolute; left: 12px; width: 16px; height: 16px; color: var(--muted-2); pointer-events: none; }
.topbar-search input { padding-left: 38px; border-radius: 10px; background: var(--line-2); border-color: transparent; }
.topbar-search input:focus { background: var(--card); }
@media (max-width: 760px){ .topbar-search { display: none; } }

/* ── Toasts (flash con animación + auto-cierre) ──────────────────────────── */
.flash { animation: ehero-slide .28s cubic-bezier(.2,.8,.2,1); }
@keyframes ehero-slide { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.flash.ehero-hide { opacity: 0; transform: translateY(-8px); transition: opacity .3s, transform .3s; }
