/* Tokens from fotomica.cl (see spec, UI and design), warmed into a paper/ink palette. */
:root {
  --paper: #f5f2ea; --paper-2: #ece7db; --surface: #fffdf9; --tint: #faf7f0;
  --ink: #1c1b18; --ink-2: #47433b; --ink-3: #6a655b;
  --rule: #e4ddcf; --rule-2: #cfc6b4;
  --accent: #2e6a4c; --accent-ink: #1d4a33; --accent-soft: #e6efe7;
  --red: #b0382b; --red-soft: #f8e9e5;
  --radius: 8px; --ring: 0 0 0 3px rgba(46, 106, 76, .22);
  /* Legacy names kept for inline styles and older rules. */
  --black: var(--ink); --white: var(--surface); --gray-dark: var(--ink-2); --gray-mid: var(--ink-3);
  --gray-light: var(--rule); --gray-bg: var(--tint); --green: var(--accent); --green-ink: var(--accent-ink); --line: var(--rule);
  --sans: 'Geist', system-ui, sans-serif; --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--ink); text-decoration-color: var(--rule-2); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); }

/* Layout: fixed sidebar on desktop; a growing nav soaked up all space past main's max-width on wide screens. */
/* Sidebar tone painted on .app too, so full-page captures past 100vh keep the column. */
.app { display: flex; min-height: 100vh; background: linear-gradient(to right, var(--paper-2) 231px, var(--rule) 231px 232px, transparent 232px); }
.nav { flex: 0 0 232px; position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 28px 16px 20px; background: var(--paper-2); border-right: 1px solid var(--rule); display: flex; flex-direction: column; gap: 2px; }
.nav a.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-height: 0; padding: 0 10px 24px; margin-bottom: 8px; border-bottom: 1px solid var(--rule-2); border-radius: 0; }
.nav a.brand:hover { background: none; }
.nav a.brand:last-child { border-bottom: 0; }
.nav a.brand img { display: block; width: 116px; height: auto; }
.nav a.brand .lbl { font-size: 10px !important; letter-spacing: .22em; }
.nav-links { display: flex; flex-direction: column; gap: 2px; padding-top: 8px; }
.nav a { position: relative; display: flex; align-items: center; min-height: 38px; padding: 0 12px; border-radius: 6px; text-decoration: none; color: var(--ink-2); font-size: 14px; }
.nav-links a:hover { background: rgba(255, 253, 249, .6); color: var(--ink); }
.nav-links a[aria-current] { background: var(--surface); color: var(--ink); font-weight: 500; box-shadow: 0 1px 0 var(--rule-2), inset 0 0 0 1px var(--rule); }
.nav-links a[aria-current]::before { content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav .who { margin-top: auto; padding: 16px 10px 0; border-top: 1px solid var(--rule-2); display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.nav .who .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: .1em; }
main { flex: 1 1 auto; min-width: 0; max-width: 1200px; padding: 36px 48px 64px; display: flex; flex-direction: column; gap: 28px; }
@media (max-width: 700px) {
  .app { flex-direction: column; background: none; }
  .nav { flex: none; position: static; height: auto; overflow: visible; flex-flow: row wrap; align-items: center; gap: 0; padding: 12px 16px 0; border-right: 0; border-bottom: 1px solid var(--rule); }
  .nav a.brand { flex: 1 1 auto; flex-direction: row; align-items: center; gap: 10px; padding: 2px 0 10px; margin: 0; border: 0; }
  .nav a.brand img { width: 92px; }
  .nav .who { order: 1; margin: 0 0 10px; padding: 0; border: 0; }
  /* Keep every destination visible without requiring a hidden horizontal swipe. */
  .nav-links { order: 2; flex: 1 0 100%; flex-direction: row; flex-wrap: wrap; gap: 4px; padding: 8px 0 10px; border-top: 1px solid var(--rule-2); }
  .nav-links a { flex: none; min-height: 36px; padding: 0 12px; white-space: nowrap; font-size: 13.5px; }
  .nav-links a[aria-current] { background: var(--ink); color: var(--surface); box-shadow: none; }
  .nav-links a[aria-current]::before { display: none; }
  main { padding: 20px 16px 48px; gap: 22px; }
  h1 { font-size: 32px; }
}

/* Type */
h1 { margin: 0; font-size: 38px; line-height: 1.1; font-weight: 500; letter-spacing: -.025em; }
h2 { margin: 0; }
h3 { margin: 0; font-weight: 500; }
b, strong { font-weight: 600; }
.lbl { font-family: var(--mono); font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); font-weight: 400; }
.mono, .num { font-family: var(--mono); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--red); }
.muted { color: var(--ink-3); font-size: 14px; }
.big { font-family: var(--mono); font-size: 26px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.grow { flex: 1 1 380px; min-width: 0; }

/* Surfaces */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 20px 22px; display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: inherit; box-shadow: 0 1px 2px rgba(60, 50, 30, .04); }
a.card:hover { border-color: var(--rule-2); box-shadow: 0 2px 8px rgba(60, 50, 30, .07); }
.card.alert { border-color: #e2b4ac; box-shadow: inset 3px 0 0 var(--red); }
.card.alert .lbl { color: var(--red); }
.card.ok { border-color: #b9d3c1; background: var(--accent-soft); }
.box { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 2px rgba(60, 50, 30, .04); }
.box > header { padding: 12px 18px; min-height: 48px; background: var(--tint); border-bottom: 1px solid var(--rule); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; align-items: center; }
.box > .body { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.box > .body > .btn, .box > .body > a.btn { align-self: flex-start; }
.box > .body.row { flex-direction: row; flex-wrap: wrap; align-items: center; }
.scroll { overflow-x: auto; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; vertical-align: bottom; padding: 10px 12px; background: var(--surface); border-bottom: 1px solid var(--rule-2); font-weight: 500; }
th.lbl { font-size: 10.5px; }
td { padding: 11px 12px; border-top: 1px solid var(--rule); vertical-align: top; }
thead + tbody tr:first-child td { border-top: 0; }
tbody tr:hover td { background: var(--tint); }
th:first-child, td:first-child { padding-left: 18px; }
th:last-child, td:last-child { padding-right: 18px; }
tr.voided td { color: var(--ink-3); text-decoration: line-through; }

/* Status pills */
.pill { display: inline-block; font-family: var(--mono); font-size: 10.5px; line-height: 1.5; letter-spacing: .08em; text-transform: uppercase; padding: 2px 9px; border-radius: 999px; background: var(--paper-2); color: var(--ink-2); border: 1px solid transparent; white-space: nowrap; }
.pill.ok { background: var(--accent-soft); color: var(--accent-ink); border-color: #c9ddcf; }
.pill.bad { background: var(--red-soft); color: var(--red); border-color: #efcdc6; }
/* Documents table: long block reasons wrap and account pickers stay narrow, so the row fits without sideways scroll. */
.docs .pill { white-space: normal; display: inline-block; max-width: 200px; }
.docs .num .lbl { white-space: normal; display: inline-block; max-width: 120px; } /* provenance labels wrap; amounts stay on one line */
.docs select { max-width: 200px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 20px; border-radius: 6px; border: 1px solid var(--ink); background: var(--ink); color: var(--surface); font: 500 14px var(--sans); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #000; border-color: #000; }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--rule-2); }
.btn.ghost:hover { background: var(--tint); border-color: var(--ink-3); }
.btn.link { background: transparent; border-color: transparent; color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--rule-2); padding: 0 8px; }
.btn.link:hover { color: var(--ink); text-decoration-color: currentColor; }
.btn.small { min-height: 34px; padding: 0 13px; font-size: 13.5px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* Forms */
form.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
input, select, textarea { min-height: 42px; border: 1px solid var(--rule-2); border-radius: 6px; padding: 0 12px; font: 14px var(--sans); color: var(--ink); background: var(--surface); max-width: 100%; }
textarea { padding: 10px 12px; min-height: 84px; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
input::placeholder, textarea::placeholder { color: #9a9387; }
input[type=file] { padding: 6px 8px 6px 6px; display: inline-flex; align-items: center; color: var(--ink-2); }
input[type=file]::file-selector-button { min-height: 30px; margin-right: 10px; padding: 0 12px; border: 1px solid var(--rule-2); border-radius: 4px; background: var(--tint); color: var(--ink); font: 500 13px var(--sans); cursor: pointer; }
input[type=checkbox], input[type=radio] { min-height: 0; width: 18px; height: 18px; accent-color: var(--accent); }
label.fld { display: flex; flex-direction: column; gap: 6px; }
main > .card { width: 100%; }
/* The user form is a label/field grid; scope it so other unclassed forms keep their layout. */
.box > form[action="/usuarios"] { padding: 16px 18px; display: grid; grid-template-columns: max-content minmax(0, 420px); gap: 10px 16px; align-items: center; }
.box > form[action="/usuarios"] > .btn { grid-column: 2; justify-self: start; }
@media (max-width: 700px) { .box > form[action="/usuarios"] { grid-template-columns: minmax(0, 1fr); gap: 6px; } .box > form[action="/usuarios"] > .btn { grid-column: 1; margin-top: 8px; } }
form[action="/login"] { display: flex; flex-direction: column; gap: 6px; }
form[action="/login"] .lbl { margin-top: 8px; }
form[action="/login"] .btn { margin-top: 16px; }

/* Messages */
.flash { padding: 12px 16px; border-radius: var(--radius); border: 1px solid #b9d3c1; background: var(--accent-soft); color: var(--accent-ink); box-shadow: inset 3px 0 0 var(--accent); }
.flash.err { border-color: #e2b4ac; background: var(--red-soft); color: var(--red); box-shadow: inset 3px 0 0 var(--red); }

/* Bank lines (bancos) */
.lines { max-height: 640px; overflow-y: auto; }
.line { width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--rule); border-left: 3px solid transparent; background: var(--surface); padding: 12px 16px 12px 14px; min-height: 54px; display: flex; gap: 12px; align-items: center; cursor: pointer; font: 14px var(--sans); color: var(--ink); }
.line:hover { background: var(--tint); }
.line.done { border-left-color: var(--accent); }
.line.sel { border-left-color: var(--ink); background: var(--paper); }
.line .d { font-family: var(--mono); font-size: 12px; color: var(--ink-3); width: 44px; flex: none; }
.line .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Journal grid */
.journal { display: grid; grid-template-columns: minmax(0, 1fr) 110px 110px; gap: 6px 12px; font-size: 14px; }
.journal .h { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; color: var(--ink-3); text-transform: uppercase; padding-bottom: 4px; border-bottom: 1px solid var(--rule); }
.journal .h.r { text-align: right; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 6px; }
.dot.bad { background: var(--red); }
details > summary { cursor: pointer; }
details > summary:hover { color: var(--ink); }
pre { margin: 0; font: 12px var(--mono); white-space: pre-wrap; word-break: break-all; color: var(--ink-2); }
img { max-width: 100%; }

@media (prefers-reduced-motion: no-preference) {
  .btn, .nav a, input, select, textarea, .card, .line { transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease, color .12s ease; }
}
