/* =====================================================================
   PIEBONI BANK — Hoja de estilos
   Bóveda doméstica: azul petróleo profundo, latón, cifras monoespaciadas.
   ===================================================================== */

:root {
  /* Color */
  --ink:      #0E1A20;   /* fondo */
  --ink-2:    #0A1418;   /* fondo más hondo */
  --surface:  #16262E;   /* tarjetas */
  --surface-2:#1B2E37;   /* filas alternas, hover */
  --line:     #263A44;   /* bordes */
  --brass:    #C9A227;   /* acento */
  --brass-dim:#8C7220;
  --paper:    #EAF0EE;   /* texto principal */
  --paper-2:  #B6C7CE;   /* texto secundario */
  --muted:    #7E9AA5;   /* texto terciario */
  --green:    #3FA37A;   /* entra */
  --red:      #C4574C;   /* sale */
  --amber:    #D89B2C;   /* atención */

  /* Tipografía */
  --display: 'Fraunces', Georgia, serif;
  --sans:    'Inter Tight', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono:    'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Métrica */
  --radius: 3px;
  --gap: 20px;
  --shell: 1280px;
}

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

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

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

h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.25; }
p { margin: 0 0 12px; }
a { color: var(--brass); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* Cifras: siempre tabulares, para que las columnas alineen. */
.num, td.num, .amount {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  letter-spacing: -0.01em;
}

.pos { color: var(--green); }
.neg { color: var(--red); }
.dim { color: var(--muted); }

/* Etiqueta pequeña recurrente */
.eyebrow {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

/* --- Estructura --------------------------------------------------- */
.shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--ink-2);
  border-right: 1px solid var(--line);
  padding: 22px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.brand {
  padding: 0 22px 22px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}

.brand-mark {
  font-family: var(--display);
  font-size: 21px;
  font-weight: 600;
  font-variation-settings: 'SOFT' 40, 'WONK' 1;
  color: var(--paper);
  letter-spacing: -0.01em;
  display: block;
}

.brand-mark .b { color: var(--brass); }
.brand-sub { font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }

.nav { list-style: none; margin: 0; padding: 0 12px; flex: 1; }
.nav li { margin-bottom: 1px; }

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: var(--paper-2);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 450;
  transition: background .12s, color .12s;
}

.nav a:hover { background: var(--surface); color: var(--paper); text-decoration: none; }

.nav a.on {
  background: var(--surface);
  color: var(--paper);
  box-shadow: inset 2px 0 0 var(--brass);
}

.nav .sep {
  margin: 14px 12px 8px;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: .7;
}

.sidebar-foot {
  padding: 14px 22px 0;
  border-top: 1px solid var(--line);
  margin-top: 14px;
}

.whoami { font-size: 13px; color: var(--paper-2); }
.whoami strong { display: block; color: var(--paper); font-weight: 500; }
.whoami .role { font-size: 11px; color: var(--muted); }

.linkish {
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 6px 0 0;
}
.linkish:hover { color: var(--brass); }

.main { padding: 26px 30px 60px; max-width: var(--shell); }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.page-head h1 {
  font-family: var(--display);
  font-size: 26px;
  font-variation-settings: 'SOFT' 30;
  letter-spacing: -0.015em;
}

.page-head .sub { color: var(--muted); font-size: 13px; margin: 2px 0 0; }

/* --- Botones ------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--paper);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .12s, background .12s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); text-decoration: none; }

.btn-primary {
  background: var(--brass);
  border-color: var(--brass);
  color: var(--ink);
  font-weight: 600;
}
.btn-primary:hover { background: #DBB233; border-color: #DBB233; }

.btn-danger { color: var(--red); border-color: rgba(196, 87, 76, .4); }
.btn-danger:hover { background: rgba(196, 87, 76, .1); border-color: var(--red); }

.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* --- Tarjetas ------------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-head h2 { font-size: 14px; font-weight: 600; letter-spacing: -0.005em; }

.grid { display: grid; gap: var(--gap); }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g-2-1 { grid-template-columns: 2fr 1fr; }

/* --- La bóveda: el saldo consolidado ------------------------------- */
/* Este es el elemento firma. El guilloché es un SVG embebido, como el
   fondo de un billete: dice "esto es un banco" sin escribirlo. */
.vault {
  position: relative;
  overflow: hidden;
  background: linear-gradient(150deg, #16262E 0%, #10202A 60%, #0C1A22 100%);
  border: 1px solid var(--line);
  border-top: 2px solid var(--brass);
  border-radius: var(--radius);
  padding: 26px 28px;
}

.vault::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240'%3E%3Cg fill='none' stroke='%23C9A227' stroke-width='.5' opacity='.5'%3E%3Ccircle cx='120' cy='120' r='30'/%3E%3Ccircle cx='120' cy='120' r='46'/%3E%3Ccircle cx='120' cy='120' r='62'/%3E%3Ccircle cx='120' cy='120' r='78'/%3E%3Ccircle cx='120' cy='120' r='94'/%3E%3Ccircle cx='120' cy='120' r='110'/%3E%3Cellipse cx='120' cy='120' rx='110' ry='40'/%3E%3Cellipse cx='120' cy='120' rx='40' ry='110'/%3E%3Cellipse cx='120' cy='120' rx='95' ry='60' transform='rotate(30 120 120)'/%3E%3Cellipse cx='120' cy='120' rx='95' ry='60' transform='rotate(-30 120 120)'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 300px;
  background-position: right -60px center;
  background-repeat: no-repeat;
  opacity: .13;
  pointer-events: none;
}

.vault > * { position: relative; }

.vault-amount {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(30px, 5vw, 46px);
  font-weight: 700;
  letter-spacing: -0.035em;
  color: var(--paper);
  margin: 8px 0 6px;
  line-height: 1;
}

.vault-note { font-size: 13px; color: var(--muted); margin: 0; }

.vault-meta {
  display: flex;
  gap: 26px;
  flex-wrap: wrap;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(201, 162, 39, .18);
}

.vault-meta div { min-width: 92px; }
.vault-meta .k { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.vault-meta .v { font-family: var(--mono); font-size: 15px; font-weight: 600; margin-top: 3px; }

/* --- Estadística simple -------------------------------------------- */
.stat .k { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.stat .v {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 21px;
  font-weight: 600;
  margin-top: 5px;
  letter-spacing: -0.02em;
}
.stat .note { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* --- Tablas -------------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.table th {
  text-align: left;
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  padding: 0 10px 9px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table td {
  padding: 10px;
  border-bottom: 1px solid rgba(38, 58, 68, .55);
  vertical-align: middle;
}

.table tbody tr:hover { background: var(--surface-2); }
.table .r { text-align: right; }
.table tr.void td { opacity: .45; text-decoration: line-through; }

.table-wrap { overflow-x: auto; margin: 0 -18px -18px; padding: 0 18px; }

/* --- Chips e insignias --------------------------------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--line);
  color: var(--paper-2);
  white-space: nowrap;
}

.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip-income   { color: var(--green); border-color: rgba(63, 163, 122, .35); }
.chip-expense  { color: var(--red);   border-color: rgba(196, 87, 76, .35); }
.chip-transfer { color: var(--muted); }
.chip-adjustment, .chip-opening { color: var(--amber); border-color: rgba(216, 155, 44, .3); }

/* --- Sobres del presupuesto ---------------------------------------- */
.envelope {
  padding: 14px 0;
  border-bottom: 1px solid rgba(38, 58, 68, .55);
}
.envelope:last-child { border-bottom: 0; }

.envelope-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.envelope-name { font-size: 14px; font-weight: 500; }
.envelope-nums { font-family: var(--mono); font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.envelope-nums b { color: var(--paper); font-weight: 600; }

.meter {
  height: 5px;
  background: var(--ink);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid rgba(38, 58, 68, .8);
}

.meter span {
  display: block;
  height: 100%;
  background: var(--green);
  border-radius: 3px;
  transition: width .3s ease;
}

.meter.warn span { background: var(--amber); }
.meter.over span { background: var(--red); }
.meter.empty span { background: var(--line); }

/* --- Gráfica de barras (flujo mensual) ----------------------------- */
.flow {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 150px;
  padding-top: 8px;
}

.flow-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 3px; }
.flow-bars { display: flex; gap: 3px; align-items: flex-end; height: 100%; }

.flow-bar {
  flex: 1;
  min-height: 2px;
  border-radius: 1px 1px 0 0;
  transition: opacity .12s;
}
.flow-bar.in  { background: var(--green); opacity: .85; }
.flow-bar.out { background: var(--red); opacity: .85; }
.flow-col:hover .flow-bar { opacity: 1; }

.flow-label {
  text-align: center;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.legend { display: flex; gap: 14px; font-size: 11px; color: var(--muted); }
.legend i { width: 8px; height: 8px; border-radius: 1px; display: inline-block; margin-right: 5px; }

/* --- Formularios --------------------------------------------------- */
.field { margin-bottom: 14px; }

.field label,
.label {
  display: block;
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 5px;
}

input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], input[type=month], input[type=search], select, textarea {
  width: 100%;
  padding: 9px 11px;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--paper);
  font: inherit;
  font-size: 14px;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--brass);
  outline: none;
  box-shadow: 0 0 0 2px rgba(201, 162, 39, .16);
}

input::placeholder { color: #4E6B76; }
textarea { resize: vertical; min-height: 66px; }

input.money, input.amount-input {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.help { font-size: 12px; color: var(--muted); margin-top: 5px; }

.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--paper-2); cursor: pointer; }
.check input { width: 15px; height: 15px; accent-color: var(--brass); flex-shrink: 0; }

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 130px; }

fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 16px; }
legend { padding: 0 8px; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--brass); font-weight: 600; }

/* --- Selector de tipo de movimiento -------------------------------- */
.kinds { display: flex; gap: 8px; margin-bottom: 22px; flex-wrap: wrap; }

.kinds a {
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--paper-2);
  font-size: 13.5px;
  font-weight: 500;
}
.kinds a:hover { border-color: var(--muted); text-decoration: none; }
.kinds a.on { background: var(--surface); border-color: var(--brass); color: var(--paper); }

/* --- Avisos -------------------------------------------------------- */
.flash { margin-bottom: 16px; display: grid; gap: 8px; }

.alert {
  padding: 11px 14px;
  border-radius: var(--radius);
  border-left: 3px solid;
  font-size: 13.5px;
  background: var(--surface);
}
.alert-ok    { border-color: var(--green); color: #A9DCC6; }
.alert-error { border-color: var(--red);   color: #E7B0AA; }
.alert-warn  { border-color: var(--amber); color: #E8CE98; }

.notice {
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--brass);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--paper-2);
}
.notice.danger { border-left-color: var(--red); }

/* --- Estado vacío -------------------------------------------------- */
.empty {
  text-align: center;
  padding: 44px 20px;
  color: var(--muted);
}
.empty h3 { font-family: var(--display); font-size: 17px; color: var(--paper-2); margin-bottom: 6px; }
.empty p { font-size: 13.5px; max-width: 380px; margin: 0 auto 14px; }

/* --- Árbol de cuentas ---------------------------------------------- */
.tree { list-style: none; margin: 0; padding: 0; }
.tree ul { list-style: none; margin: 0; padding-left: 20px; border-left: 1px solid var(--line); }

.tree-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius);
}
.tree-row:hover { background: var(--surface-2); }
.tree-row .name { flex: 1; font-size: 13.5px; }
.tree-row .code { font-family: var(--mono); font-size: 11px; color: var(--muted); min-width: 42px; }
.tree-row.group .name { font-weight: 600; }
.tree-row.off { opacity: .45; }

/* --- Bitácora ------------------------------------------------------ */
.log-row td { font-size: 13px; }
.log-time { font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.log-hash { font-family: var(--mono); font-size: 10px; color: #47626D; }

details.payload summary { cursor: pointer; font-size: 11px; color: var(--muted); }
details.payload pre {
  margin: 6px 0 0;
  padding: 9px;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 2px;
  font-size: 11px;
  color: var(--paper-2);
  overflow-x: auto;
}

/* --- Paginación ---------------------------------------------------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
.pager .count { font-size: 12.5px; color: var(--muted); }

/* --- Pantalla de acceso -------------------------------------------- */
.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 0%, rgba(201, 162, 39, .07), transparent 55%),
    var(--ink);
}

.gate-card {
  width: 100%;
  max-width: 366px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 2px solid var(--brass);
  border-radius: var(--radius);
  padding: 32px 30px;
}

.gate-brand { text-align: center; margin-bottom: 26px; }
.gate-brand .brand-mark { font-size: 28px; }
.gate-brand p { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

/* --- Responsive ---------------------------------------------------- */
@media (max-width: 1080px) {
  .g4 { grid-template-columns: repeat(2, 1fr); }
  .g-2-1 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 16px 0;
  }

  .brand { padding-bottom: 14px; margin-bottom: 10px; }
  .nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .nav .sep { display: none; }
  .nav a.on { box-shadow: inset 0 -2px 0 var(--brass); }
  .sidebar-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

  .main { padding: 20px 16px 48px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .vault-amount { font-size: 32px; }
  .table-wrap { margin: 0 -18px; }
}

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

@media print {
  .sidebar, .btn, .kinds, .pager { display: none; }
  body { background: #fff; color: #000; }
  .card, .vault { border-color: #ccc; background: #fff; }
}
