/* =========================================================================
   REPORTIA — Sistema de diseño (marca Twentic)
   Cambiar la marca = editar los tokens de :root.
   ========================================================================= */

:root {
  /* Marca Twentic */
  --lime:        #bfd100;
  --lime-deep:   #98a300;
  --lime-tint:   #eef3cd;
  --lime-ink:    #3a3f00;   /* texto sobre lima */

  /* Neutros */
  --ground:      #fbfcf8;   /* fondo app (blanco cálido de marca) */
  --surface:     #ffffff;   /* paneles / tarjetas */
  --surface-2:   #f6f7f1;   /* zonas sutiles */
  --ink:         #2b2d28;   /* texto principal */
  --ink-2:       #383838;   /* chrome oscuro (sidebar) */
  --muted:       #74786d;   /* texto secundario */
  --line:        #e8e9e1;   /* bordes */
  --line-strong: #d7d9cd;

  /* Estado */
  --danger:      #c0341d;
  --danger-tint: #fbeae6;
  --info:        #2f6f7e;
  --info-tint:   #e4f1f4;
  --warn:        #b07d12;

  /* Forma */
  --radius:      14px;
  --radius-sm:   9px;
  --radius-pill: 999px;
  --shadow-sm:   0 1px 2px rgba(43,45,40,.06);
  --shadow:      0 1px 2px rgba(43,45,40,.05), 0 12px 28px -16px rgba(43,45,40,.28);
  --shadow-lg:   0 24px 60px -28px rgba(43,45,40,.42);

  --font:  "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono:  "Inconsolata", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --sidebar-w: 256px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--lime-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .4em; font-weight: 680; letter-spacing: -.015em; color: var(--ink); line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

p { margin: 0 0 1em; }
small { font-size: .82rem; }

::selection { background: var(--lime); color: var(--lime-ink); }

/* ---- Accesibilidad ---- */
:focus-visible { outline: 2px solid var(--lime-deep); outline-offset: 2px; border-radius: 4px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* =========================================================================
   Layout app (sidebar + main)
   ========================================================================= */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--ink-2);
  color: #d7d8d2;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 20px;
}
.sidebar__brand img { height: 30px; width: auto; }
.sidebar__brand .wordmark { font-weight: 720; letter-spacing: -.02em; font-size: 1.15rem; color: #fff; }
.sidebar__brand .wordmark b { color: var(--lime); }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.nav__label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .12em;
  color: #8d8f87; padding: 16px 12px 6px; font-weight: 650;
}
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: #cfd0ca; font-weight: 540; font-size: .92rem;
  text-decoration: none; transition: background .14s, color .14s;
}
.nav a .ico { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav a.is-active { background: var(--lime); color: var(--lime-ink); font-weight: 640; }
.nav a.is-active .ico { opacity: 1; }

.sidebar__foot { margin-top: auto; padding: 16px 10px 4px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar__foot .powered { display: flex; align-items: center; gap: 7px; font-size: .72rem; color: #9a9c94; }
.sidebar__foot .powered img { height: 16px; width: auto; filter: brightness(0) invert(1); opacity: .85; }

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

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 16px 32px;
  background: color-mix(in oklab, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar__title { font-weight: 680; font-size: 1.05rem; letter-spacing: -.01em; }
.topbar__user { display: flex; align-items: center; gap: 12px; font-size: .9rem; color: var(--muted); }
.avatar {
  width: 34px; height: 34px; border-radius: var(--radius-pill);
  background: var(--lime-tint); color: var(--lime-ink);
  display: grid; place-items: center; font-weight: 680; font-size: .85rem;
}

.content { padding: 28px 32px 64px; max-width: 1180px; width: 100%; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.page-head .sub { color: var(--muted); margin: 0; font-size: .95rem; }

/* =========================================================================
   Botones
   ========================================================================= */
.btn {
  --bg: var(--surface); --fg: var(--ink); --bd: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  font: inherit; font-weight: 600; font-size: .9rem; line-height: 1;
  background: var(--bg); color: var(--fg); border: 1px solid var(--bd);
  cursor: pointer; text-decoration: none; transition: transform .04s, box-shadow .14s, background .14s, border-color .14s;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn .ico { width: 16px; height: 16px; }
.btn-primary { --bg: var(--lime); --fg: var(--lime-ink); --bd: var(--lime-deep); }
.btn-primary:hover { --bg: var(--lime-deep); --fg: #fff; }
.btn-dark    { --bg: var(--ink-2); --fg: #fff; --bd: var(--ink-2); }
.btn-ghost   { --bg: transparent; --bd: var(--line-strong); }
.btn-danger  { --bg: var(--surface); --fg: var(--danger); --bd: #e6c4bd; }
.btn-danger:hover { --bg: var(--danger); --fg: #fff; --bd: var(--danger); }
.btn-sm { padding: 6px 11px; font-size: .82rem; }
.btn-icon { padding: 7px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.btn-row { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }

/* =========================================================================
   Tarjetas / paneles
   ========================================================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card__head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card__head h2, .card__head h3 { margin: 0; }
.card__body { padding: 20px; }
.card + .card { margin-top: 18px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* =========================================================================
   Tablas
   ========================================================================= */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
table.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 12px 16px; text-align: left; }
.table thead th {
  background: var(--surface-2); color: var(--muted);
  font-weight: 620; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1px solid var(--line);
}
.table tbody tr + tr { border-top: 1px solid var(--line); }
.table tbody tr:hover { background: var(--surface-2); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }
.table .row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* =========================================================================
   Formularios
   ========================================================================= */
.field { margin-bottom: 16px; }
.field > label, .label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 6px; color: var(--ink); }
.input, .select, .textarea, select, input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="datetime-local"], input[type="date"], textarea {
  width: 100%; padding: 10px 12px; font: inherit; font-size: .92rem;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  transition: border-color .14s, box-shadow .14s;
}
.input:focus, .select:focus, .textarea:focus, select:focus, input:focus, textarea:focus {
  outline: none; border-color: var(--lime-deep);
  box-shadow: 0 0 0 3px var(--lime-tint);
}
.textarea, textarea { min-height: 110px; resize: vertical; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 5px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; }
.check input { width: auto; }

.invalid { border-color: var(--danger) !important; }
.error-text { color: var(--danger); font-size: .82rem; margin-top: 5px; }

/* =========================================================================
   Badges, chips, alerts
   ========================================================================= */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--radius-pill);
  font-size: .74rem; font-weight: 640; letter-spacing: .01em;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.badge-lime  { background: var(--lime-tint); color: var(--lime-ink); border-color: #dfe6ad; }
.badge-on    { background: var(--lime-tint); color: var(--lime-ink); border-color: #dfe6ad; }
.badge-off   { background: #f0f0ee; color: var(--muted); }
.badge-danger{ background: var(--danger-tint); color: var(--danger); border-color: #e6c4bd; }
.badge-info  { background: var(--info-tint); color: var(--info); border-color: #c7e0e6; }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }

.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-2); margin-bottom: 18px; font-size: .9rem;
}
.alert-success { background: var(--lime-tint); border-color: #dfe6ad; color: var(--lime-ink); }
.alert-error   { background: var(--danger-tint); border-color: #e6c4bd; color: var(--danger); }
.alert-info    { background: var(--info-tint); border-color: #c7e0e6; color: var(--info); }

/* =========================================================================
   Estados vacíos
   ========================================================================= */
.empty {
  text-align: center; padding: 56px 24px; color: var(--muted);
  border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface);
}
.empty .ico { width: 40px; height: 40px; opacity: .4; margin-bottom: 12px; }

/* =========================================================================
   Auth (login)
   ========================================================================= */
.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1200px 600px at 80% -10%, var(--lime-tint), transparent 60%),
    var(--ground);
}
.auth__card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; box-shadow: var(--shadow-lg);
  padding: 38px 34px 30px;
}
.auth__logo { display: block; height: 46px; width: auto; margin: 0 auto 8px; }
.auth__tag { text-align: center; color: var(--muted); font-size: .9rem; margin: 0 0 26px; }
.auth__foot { text-align: center; margin-top: 24px; }
.auth__foot .powered { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: .76rem; }
.auth__foot .powered img { height: 15px; width: auto; opacity: .8; }

/* utilidades */
.mt-0{margin-top:0}.mt-1{margin-top:8px}.mt-2{margin-top:16px}.mt-3{margin-top:24px}
.mb-0{margin-bottom:0}.mb-2{margin-bottom:16px}
.muted{color:var(--muted)}.text-right{text-align:right}.nowrap{white-space:nowrap}
.flex{display:flex}.between{justify-content:space-between}.items-center{align-items:center}.gap{gap:12px}
.w-full{width:100%}

/* Menú móvil (hamburguesa + drawer) */
.nav-toggle {
  display: none; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0; flex: none;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); cursor: pointer;
}
.nav-toggle:hover { background: var(--surface-2); }
.nav-backdrop { display: none; position: fixed; inset: 0; background: rgba(43,45,40,.45); z-index: 50; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 264px; height: 100vh;
    transform: translateX(-100%); transition: transform .22s ease; z-index: 60;
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .nav-backdrop { display: block; }
  .nav-toggle { display: inline-flex; }
  .content, .topbar { padding-left: 18px; padding-right: 18px; }
  .topbar__user span:first-child { display: none; }
}

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