/* Highland Route Garage · Finanzas — verde militar sobre negro (combinación 06 del logo) */
:root {
  /* Colores de la hoja de logos de HRG */
  --black: #0E0F11;      /* negro */
  --gunmetal: #2B2E31;   /* gris metal */
  --steel: #A7A9AC;      /* acero */
  --silver: #C6C8CA;     /* plateado */
  --sand: #C2B49A;       /* arena */
  --gold: #C9A54E;       /* dorado suave */
  --army: #7A8450;       /* verde militar */
  --army-dk: #5E6838;    /* verde militar oscuro */

  --bg: var(--black);
  --panel: #1A1C1F;
  --panel2: #232629;
  --line: var(--gunmetal);
  --text: #E4E5E3;
  --text2: var(--steel);
  --text3: #74777b;
  --green: var(--army);
  --green-hi: #A3AF6B;
  --green-bg: rgba(122, 132, 80, .16);
  --orange: var(--gold);
  --orange-bg: rgba(201, 165, 78, .12);
  --radius: 12px;
  --side: 264px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 Inter, system-ui, -apple-system, 'Segoe UI', sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--green-hi); text-decoration: none; }
h1, h2, h3, .brand b, .tab, .kpi .lbl, th, .pill, button { font-family: 'Chakra Petch', Inter, sans-serif; }
h1 { font-size: 30px; font-weight: 700; letter-spacing: .5px; }
h2 { font-size: 18px; font-weight: 600; letter-spacing: .5px; color: var(--silver); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--green-hi); } .neg { color: var(--orange); } .muted { color: var(--text2); } .faint { color: var(--text3); }

/* Estructura */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--line); padding: 28px 18px 20px; display: flex; flex-direction: column; gap: 26px; background: #0b0c0e; overflow-y: auto; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 4px 6px 22px; border-bottom: 1px solid var(--line); }
.brand .ico { width: 132px; height: auto; }
.brand .wm { width: 100%; max-width: 210px; height: auto; }
.brand small { font-size: 11px; letter-spacing: 3px; color: var(--sand); font-family: 'Chakra Petch'; }
#nav { display: flex; flex-direction: column; gap: 4px; }
#nav a { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 10px; color: var(--text2); font-weight: 500; font-size: 15px; }
#nav a svg, .tabbar a svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#nav a:hover { background: var(--panel); color: var(--text); }
#nav a.on { background: var(--green-bg); color: var(--green-hi); box-shadow: inset 3px 0 0 var(--army); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; font-size: 12px; color: var(--text3); word-break: break-all; }
main { padding: 36px 44px 72px; max-width: 1240px; width: 100%; min-width: 0; outline: none; }
.two > * { min-width: 0; margin-top: 0 !important; }
.tabbar { display: none; }
.topbar { display: none; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #0b0c0e; position: sticky; top: 0; z-index: 30; }
.topbar .ico { width: 54px; height: auto; }
.topbar .wm { width: 190px; height: auto; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
.head .sub { color: var(--sand); font-size: 14px; margin-top: 4px; letter-spacing: .3px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.loading { color: var(--text3); padding: 40px; }

/* Tarjetas */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.card > h2:first-child, .card > .row:first-child { margin-bottom: 14px; }
.card + .card { margin-top: 22px; }
.cards { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 22px; }
.cards > .card { margin-top: 0; }
.kpi .lbl { font-size: 12px; letter-spacing: 1.6px; color: var(--sand); text-transform: uppercase; }
.kpi .val { font-size: 30px; font-weight: 700; margin-top: 10px; }
.kpi .note { font-size: 12px; color: var(--steel); margin-top: 6px; }
.kpi.hl { border-color: var(--army-dk); background: #1d2117; }
.kpi.hl .lbl { color: var(--gold); }
.two { display: grid; grid-template-columns: 1.45fr 1fr; gap: 22px; }
.warn { background: var(--orange-bg); border: 1px solid rgba(201,165,78,.45); color: #E3CC8F; padding: 12px 16px; border-radius: 10px; margin-bottom: 22px; font-size: 14px; }

/* Botones y formularios */
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--green); background: var(--green); color: #0E0F11; font-weight: 600; font-size: 14px; letter-spacing: .6px; padding: 10px 18px; border-radius: 9px; cursor: pointer; }
button:hover { background: var(--green-hi); border-color: var(--green-hi); }
button.ghost { background: transparent; color: var(--green-hi); }
button.ghost:hover { background: var(--green-bg); }
button.danger { background: transparent; border-color: var(--orange); color: var(--orange); }
button.small { padding: 5px 10px; font-size: 12px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { width: 100%; background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 9px; padding: 10px 12px; font: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green); outline-offset: -1px; border-color: transparent; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--sand); }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form .full { grid-column: 1 / -1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: transparent; color: var(--text2); padding: 8px 14px; }
.seg button.on { background: var(--green-bg); color: var(--green-hi); }
.filters { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }

/* Tablas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 11px; letter-spacing: 1.6px; color: var(--sand); font-weight: 600; text-transform: uppercase; padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 13px 12px; border-bottom: 1px solid #25282b; vertical-align: middle; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--panel2); }
td.r, th.r { text-align: right; }
.pill { display: inline-block; font-size: 11px; letter-spacing: 1px; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--text2); text-transform: uppercase; }
.pill.paid, .pill.income { color: var(--green-hi); border-color: var(--green); }
.pill.sent { color: #CFC08A; border-color: #8a7f52; }
.pill.void, .pill.expense { color: var(--orange); border-color: rgba(217,137,91,.5); }
.clip { display: inline-flex; width: 16px; height: 16px; vertical-align: -3px; color: var(--green-hi); }
.empty { text-align: center; color: var(--text3); padding: 34px 10px; }

/* Barras del reporte */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 10px; }
.bars .m { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.bars .pair { display: flex; align-items: flex-end; gap: 2px; height: 140px; width: 100%; justify-content: center; }
.bars .b { width: 42%; max-width: 16px; border-radius: 3px 3px 0 0; min-height: 1px; }
.bars .bi { background: var(--green-hi); } .bars .be { background: var(--orange); }
.bars .lbl { font-size: 10px; color: var(--text3); font-family: 'Chakra Petch'; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--text2); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.catbar { height: 6px; background: var(--panel2); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.catbar span { display: block; height: 100%; background: var(--orange); }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal[hidden] { display: none; }
.sheet { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; width: min(640px, 100%); max-height: 92vh; overflow: auto; padding: 26px; }
.sheet .head { margin-bottom: 14px; }
.sheet .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.sheet .actions .left { margin-right: auto; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--green); color: var(--text); padding: 10px 16px; border-radius: 8px; z-index: 60; font-size: 14px; }
.toast.bad { border-color: var(--orange); }
.receipt-thumb { max-width: 100%; max-height: 260px; border-radius: 8px; border: 1px solid var(--line); display: block; margin-top: 8px; }

/* Factura imprimible */
.invoice-doc { background: #fff; color: #111; border-radius: 10px; padding: 36px; font-size: 14px; }
.invoice-doc h1 { font-size: 28px; color: #111; }
.invoice-doc .top { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.invoice-doc .top img { width: 70px; height: 70px; filter: brightness(.55); }
.invoice-doc table th { color: #555; border-color: #ddd; }
.invoice-doc table td { border-color: #eee; }
.invoice-doc .tot { margin-left: auto; width: 260px; margin-top: 16px; }
.invoice-doc .tot div { display: flex; justify-content: space-between; padding: 4px 0; }
.invoice-doc .tot .grand { border-top: 2px solid #111; font-weight: 700; font-size: 16px; padding-top: 8px; margin-top: 4px; }
.items-edit td { padding: 6px 4px; }
.items-edit input, .items-edit select { padding: 7px 8px; }

@media print {
  body { background: #fff; }
  .side, .tabbar, .no-print, .head { display: none !important; }
  .shell { display: block; } main { padding: 0; max-width: none; }
  .invoice-doc { border-radius: 0; padding: 0; }
}

/* Celular */
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .side { display: none; }
  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 14px; }
  .kpi .lbl { font-size: 11px; letter-spacing: 1px; }
  main { padding: 20px 16px 100px; }
  .topbar { display: flex; }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: #0b0c0e; border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 40; }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--text3); font-size: 10px; font-family: 'Chakra Petch'; letter-spacing: .5px; padding: 4px 0; }
  .tabbar a.on { color: var(--green-hi); }
  .two { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .form { grid-template-columns: 1fr; }
  .hide-m { display: none; }
  .kpi .val { font-size: 22px; }
  .invoice-doc { padding: 20px; }
}
