/* Nomina Pro. Look taken from Zoho Books: navy top bar, light sidebar with a
   blue active item, white forms with the label on the left. */
:root {
  --navy: #21263c;
  --navy-2: #2d3350;
  --blue: #408dfb;
  --blue-d: #2f78e0;
  --blue-l: #eaf2ff;
  --side: #f7f7fa;
  --side-hover: #ebecf2;
  --line: #dcdde3;
  --line-l: #ececf1;
  --text: #21263c;
  --muted: #6c718a;
  --red: #e0473b;
  --green: #1f9d63;
  --amber: #b7791f;
  --bg-soft: #f9f9fb;
  --radius: 6px;
  --side-w: 230px;
  --top-h: 56px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: #fff; line-height: 1.45; -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
a { color: var(--blue-d); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 500; margin: 0; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- buttons and inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 6px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; color: var(--text); font: inherit; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--bg-soft); text-decoration: none; }
.btn:focus-visible, .icon-btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-d); }
.btn-danger { color: var(--red); }
.btn-link { border: 0; background: none; color: var(--blue-d); padding: 4px 6px; min-height: 0; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; cursor: default; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 0; border-radius: var(--radius); background: none; color: inherit; cursor: pointer; }

input, select, textarea {
  width: 100%; min-height: 34px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius);
  font: inherit; color: var(--text); background: #fff;
}
textarea { min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(64, 141, 251, .15); }
input[readonly] { background: var(--bg-soft); }
.invalid { border-color: var(--red) !important; }

/* ---------- login ---------- */
.login { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: linear-gradient(180deg, var(--navy) 0 38%, #f1f2f6 38%); }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 10px; padding: 28px 26px; box-shadow: 0 10px 30px rgba(20, 24, 45, .18); }
.login-card label { display: block; margin: 14px 0 6px; font-weight: 500; }
.login-card .btn { margin-top: 20px; min-height: 40px; }
.login-brand { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 600; }
.login-sub { color: var(--muted); margin: 8px 0 4px; }
.login-error { color: var(--red); margin: 12px 0 0; }

/* ---------- layout ---------- */
.app { min-height: 100%; }
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--top-h); z-index: 30;
  display: flex; align-items: center; gap: 12px; padding: 0 14px; background: var(--navy); color: #fff;
}
.brand { display: flex; align-items: center; gap: 8px; color: #fff; font-size: 17px; font-weight: 500; }
.brand:hover { text-decoration: none; }
.top-empresa { color: #c9cce0; border-left: 1px solid #4a5070; padding-left: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.top-spacer { flex: 1; }
.tasa-chip { color: #fff; background: var(--navy-2); border: 1px solid #454c6d; border-radius: 16px; padding: 4px 12px; font-size: 13px; white-space: nowrap; }
.tasa-chip:hover { text-decoration: none; background: #394065; }
.tasa-chip.warn { border-color: #d9a441; }
.menu-btn { display: none; color: #fff; }
.user-menu { position: relative; }
.avatar { width: 32px; height: 32px; border-radius: 50%; border: 2px solid #8d93b4; background: var(--blue); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-transform: uppercase; }
.user-pop { position: absolute; right: 0; top: 42px; width: 220px; background: #fff; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, .12); }
.user-name { font-weight: 600; margin-bottom: 10px; word-break: break-all; }

.sidebar {
  position: fixed; top: var(--top-h); bottom: 0; left: 0; width: var(--side-w); z-index: 20;
  background: var(--side); border-right: 1px solid var(--line-l); padding: 12px 8px; overflow-y: auto;
}
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin: 2px 0; border-radius: var(--radius); color: var(--text); }
.nav-item:hover { background: var(--side-hover); text-decoration: none; }
.nav-item.active { background: var(--blue); color: #fff; }
.nav-sep { height: 1px; background: var(--line-l); margin: 10px 6px; }
.scrim { display: none; }

.content { margin-left: var(--side-w); padding-top: var(--top-h); min-height: 100vh; }
.page-head { display: flex; align-items: center; gap: 10px; padding: 16px 24px; border-bottom: 1px solid var(--line-l); }
.page-head h1 { font-size: 20px; }
.page-head .grow { flex: 1; }
.page-body { padding: 20px 24px 100px; max-width: 1200px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- forms: label left, input right ---------- */
.form { max-width: 820px; }
.field { display: grid; grid-template-columns: 220px minmax(0, 420px); gap: 8px 24px; align-items: start; margin-bottom: 16px; }
.field > label { padding-top: 7px; }
.field.req > label { color: var(--red); }
.field.req > label::after { content: "*"; }
.field .hint { grid-column: 2; margin-top: -4px; color: var(--muted); font-size: 12.5px; }
.form-group { border-top: 1px solid var(--line-l); margin: 22px 0 16px; padding-top: 18px; }
.form-group > h3, details.form-group > summary { font-size: 15px; font-weight: 600; margin-bottom: 14px; }
details.form-group > summary { cursor: pointer; color: var(--blue-d); list-style: revert; }
.form-error { color: var(--red); margin: 8px 0; }
.band { background: var(--bg-soft); border-bottom: 1px solid var(--line-l); padding: 16px 24px; }
.band .field { margin-bottom: 10px; }
.inline-fields { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-start; }
.inline-fields > div { display: flex; flex-direction: column; gap: 4px; min-width: 140px; flex: 1 1 160px; max-width: 280px; }
.inline-fields label { font-size: 12.5px; color: var(--muted); }
.inline-fields > .btn-row { flex-direction: row; flex: 0 0 auto; min-width: 0; align-self: flex-end; }
.band-box { border: 1px solid var(--line-l); border-radius: 8px; margin-bottom: 14px; }
.inline-fields .wide { max-width: 360px; flex-basis: 260px; }

details.extras { margin-top: 12px; }
details.extras > summary { cursor: pointer; color: var(--blue-d); }
details.extras .inline-fields { margin-top: 10px; }

/* Sticky action bar, as in the theme */
.actions {
  position: fixed; left: var(--side-w); right: 0; bottom: 0; z-index: 10;
  display: flex; gap: 8px; align-items: center; padding: 10px 24px; background: #fff; border-top: 1px solid var(--line);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, .04);
}
.actions .grow { flex: 1; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line-l); border-radius: 8px; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th { text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line-l); background: #fff; white-space: nowrap; }
table.grid td { padding: 10px 12px; border-bottom: 1px solid var(--line-l); vertical-align: top; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid th.num, table.grid td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.grid tbody tr.link { cursor: pointer; }
table.grid tbody tr.link:hover td { background: var(--bg-soft); }
table.grid tfoot td { font-weight: 600; border-top: 1px solid var(--line); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 26px 0 16px; overflow-x: auto; }
.tab { border: 0; background: none; padding: 9px 14px; font: inherit; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--blue-d); border-bottom-color: var(--blue); }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.card { border: 1px solid var(--line-l); border-radius: 8px; padding: 16px; background: #fff; }
a.card { color: var(--text); display: flex; gap: 12px; align-items: flex-start; }
a.card:hover { border-color: var(--blue); text-decoration: none; box-shadow: 0 2px 10px rgba(64, 141, 251, .12); }
a.card svg.i { color: var(--blue); width: 22px; height: 22px; margin-top: 2px; }
.card h3 { font-size: 15px; margin-bottom: 4px; }
.stat { font-size: 22px; font-weight: 600; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: var(--line-l); color: var(--muted); }
.badge.ok { background: #e3f6ec; color: var(--green); }
.badge.warn { background: #fdf3e1; color: var(--amber); }
.cards + .cards { margin-top: 18px; }
.cards + .notice, .cards + .info { margin-top: 16px; }
.notice { border: 1px solid #f0d9a8; background: #fffaf0; color: #7a5410; border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; }
.info { border: 1px solid #cfe0fb; background: var(--blue-l); border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; }

/* ---------- receipt (comprobante) ---------- */
.comprobante { border: 1px solid var(--line); border-radius: 8px; padding: 22px; max-width: 860px; background: #fff; }
.comp-head { text-align: center; border-bottom: 2px solid var(--navy); padding-bottom: 10px; margin-bottom: 14px; }
.comp-head .empresa { font-size: 17px; font-weight: 600; }
.comp-head .titulo { font-size: 15px; font-weight: 600; margin-top: 6px; letter-spacing: .02em; }
.comp-datos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 24px; margin-bottom: 14px; }
.comp-datos div { display: flex; gap: 8px; }
.comp-datos b { font-weight: 600; min-width: 120px; color: var(--muted); }
.comp-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.comp-section { font-weight: 600; background: var(--bg-soft); border: 1px solid var(--line-l); padding: 6px 10px; margin: 12px 0 0; border-radius: 4px 4px 0 0; }
table.lines { width: 100%; border-collapse: collapse; }
table.lines td { padding: 5px 10px; border-bottom: 1px solid var(--line-l); }
table.lines td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.lines td.det { color: var(--muted); font-size: 12.5px; }
table.lines tr.total td { font-weight: 600; border-top: 1px solid var(--line); background: var(--bg-soft); }
table.lines tr.zero td { color: #a3a7ba; }
.neto { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: 16px; padding: 12px 14px; background: var(--navy); color: #fff; border-radius: 6px; font-size: 16px; font-weight: 600; }
.neto small { font-weight: 400; color: #c9cce0; font-size: 13px; }
.firmas { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 56px; text-align: center; }
.firmas div { border-top: 1px solid var(--text); padding-top: 6px; }
.section-title { font-size: 16px; margin: 26px 0 10px; }
.comp-note { margin-top: 14px; font-size: 12px; color: var(--muted); }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%); z-index: 50; background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); max-width: calc(100vw - 32px); }
.toast.error { background: var(--red); }

/* ---------- phone ---------- */
@media (max-width: 767px) {
  input, select, textarea { font-size: 16px; } /* no zoom on iOS */
  .menu-btn { display: inline-flex; }
  .top-empresa { display: none; }
  .brand span { display: none; }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; width: 260px; box-shadow: none; }
  body.drawer .sidebar { transform: none; box-shadow: 6px 0 24px rgba(0, 0, 0, .2); }
  body.drawer .scrim { display: block; position: fixed; inset: var(--top-h) 0 0 0; background: rgba(15, 18, 35, .35); z-index: 15; }
  .content { margin-left: 0; }
  .page-head { padding: 12px 16px; flex-wrap: wrap; }
  .page-head h1 { font-size: 18px; }
  .page-body { padding: 16px 16px 110px; }
  .band { padding: 14px 16px; }
  .field { grid-template-columns: 1fr; gap: 6px; margin-bottom: 14px; }
  .field > label { padding-top: 0; }
  .field .hint { grid-column: 1; margin-top: 0; }
  .inline-fields > div { max-width: none; flex: 1 1 100%; }
  .actions { left: 0; padding: 10px 16px; flex-wrap: wrap; }
  .actions .btn { flex: 1 1 auto; }
  .actions .grow { display: none; }
  /* Tables become one card per row */
  table.grid.stack thead { display: none; }
  table.grid.stack, table.grid.stack tbody, table.grid.stack tr, table.grid.stack td, table.grid.stack tfoot { display: block; width: 100%; }
  table.grid.stack tr { border-bottom: 1px solid var(--line-l); padding: 8px 4px; }
  table.grid.stack td { border: 0; padding: 3px 10px; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.grid.stack td::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; text-align: left; }
  table.grid.stack td.num { white-space: normal; }
  table.grid.stack td:first-child { font-weight: 600; }
  .comprobante { padding: 14px; }
  .comp-datos, .comp-cols { grid-template-columns: 1fr; }
  .comp-datos b { min-width: 104px; }
  .firmas { gap: 20px; }
}

/* ---------- print: only the receipt ---------- */
@media print {
  @page { margin: 14mm; }
  body { font-size: 12px; }
  .topbar, .sidebar, .scrim, .actions, .band, .page-head, .no-print, .toast, .tabs { display: none !important; }
  .content { margin: 0; padding: 0; }
  .page-body { padding: 0; max-width: none; }
  .comprobante { border: 0; padding: 0; max-width: none; }
  .comprobante + .comprobante { break-before: page; }
  .neto { background: #fff; color: #000; border: 2px solid #000; }
  .neto small { color: #333; }
  .table-wrap { border: 0; }
  table.grid th, table.grid td { padding: 4px 6px; }
  a { color: inherit; }
}
