/* Contract C-10 — visual direction approved on the mockup canvas 2026-09-10.
   Every value here is copied from design/ledger-core/*.dc.html; nothing invented.
   Fonts are self-hosted (deviation D4): no request leaves the browser to Google. */

@font-face {
  font-family: 'Instrument Sans';
  src: url('/static/fonts/instrument-sans-latin.woff2') format('woff2');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/static/fonts/ibm-plex-mono-400-latin.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('/static/fonts/ibm-plex-mono-500-latin.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --page: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #edeef1;
  --row-alt: #fafafb;
  --border: #d8dae0;
  --border-strong: #c0c3cc;

  --text: #15171c;
  --text-secondary: #555a66;
  --text-muted: #8b90a0;
  --text-disabled: #c0c3cc;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-tint: #eef2ff;

  --ok: #16a34a;
  --ok-bg: #f0fdf4;
  --ok-border: #bbf7d0;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --error-border: #fecaca;
  --error-strong: #991b1b;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --warn-border: #fde68a;

  --radius: 6px;
  --radius-card: 8px;
  --radius-chip: 4px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: 'Instrument Sans', system-ui, sans-serif;
  font-size: 14px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.num {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

/* ---------- top bar ---------- */

.topbar {
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}
.topbar-left { display: flex; align-items: center; gap: 28px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; color: var(--text); }
.brand-mark {
  width: 24px; height: 24px; border-radius: 5px; background: var(--accent);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.brand-soft { color: var(--text-muted); font-weight: 500; }

.nav { display: flex; align-items: center; gap: 4px; font-size: 13px; }
.nav a, .nav span { padding: 6px 10px; border-radius: 5px; }
.nav a { color: var(--text-secondary); font-weight: 500; }
.nav a.active { background: var(--accent-tint); color: var(--accent-hover); font-weight: 600; }
.nav span.soon { color: var(--text-disabled); font-weight: 500; }

.topbar-right { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--text-secondary); }
.topbar-right a { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.logout-form { margin: 0; }
.logout-button {
  display: flex; align-items: center; gap: 6px; padding: 0; border: 0; background: none;
  color: var(--text-secondary); font: inherit; font-size: 13px; cursor: pointer;
}

/* ---------- page shell ---------- */

.page {
  padding: 28px 28px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
}
.page-title { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; }
.page-sub { font-size: 13px; color: var(--text-secondary); }
.head-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.head-left { display: flex; flex-direction: column; gap: 6px; }
.title-row { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}
.card-pad { padding: 20px; }

/* ---------- controls ---------- */

label { font-size: 12px; font-weight: 600; color: var(--text-secondary); letter-spacing: 0.02em; }
.field { display: flex; flex-direction: column; gap: 6px; }

input, select {
  height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0 12px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input::placeholder { color: var(--text-muted); }
input.amount { text-align: right; }
input.amount.is-empty { border-color: var(--border); background: var(--row-alt); }
input.bad { border: 2px solid var(--error); background: var(--error-bg); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: var(--radius);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: #ffffff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); color: #ffffff; }
.btn-primary:disabled { background: var(--text-disabled); border-color: var(--text-disabled); cursor: not-allowed; }
.btn-secondary { background: var(--surface); color: var(--text-secondary); border-color: var(--border-strong); }
.btn-sm { height: 40px; padding: 0 16px; font-size: 14px; }
.btn-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--accent-hover); background: none; border: 0; cursor: pointer; font-family: inherit; }

.btn-row { display: flex; gap: 10px; }
.actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- chips, pills, banners ---------- */

.chip {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 11px; padding: 2px 6px; border-radius: var(--radius-chip);
  background: var(--accent-tint); color: var(--accent-hover); font-weight: 500;
}
.chip-neutral { background: var(--surface-2); color: var(--text-secondary); }
.pill {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn); font-weight: 600;
}
.status {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-radius: var(--radius); font-size: 13px; font-weight: 600;
}
.status-ok { background: var(--ok-bg); border: 1px solid var(--ok-border); color: var(--ok); }
.status-error { background: var(--error-bg); border: 1px solid var(--error-border); color: var(--error); }

.banner {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; background: var(--error-bg);
  border: 1px solid var(--error-border); border-radius: var(--radius-card);
  color: var(--error); font-size: 14px;
}
.banner-title { font-weight: 600; }
.banner-detail { color: var(--error-strong); }
.banner svg { flex: none; margin-top: 1px; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.stat-value { font-size: 20px; font-weight: 500; }
.stat-ok { background: var(--ok-bg); border-color: var(--ok-border); }
.stat-ok .stat-label, .stat-ok .stat-value { color: var(--ok); }
.stat-bad { background: var(--error-bg); border-color: var(--error-border); }
.stat-bad .stat-label, .stat-bad .stat-value { color: var(--error); }

/* ---------- journal ---------- */

.journal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); overflow: hidden; }
.jrow { display: grid; grid-template-columns: 110px 96px 1fr 130px 130px 90px; gap: 12px; align-items: center; }
.jhead {
  padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-size: 11px; font-weight: 600; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.right { text-align: right; }
.entry { border-bottom: 1px solid var(--border); }
.entry:last-child { border-bottom: 0; }
.entry-head { padding: 12px 16px 6px; }
.entry-no { font-size: 13px; font-weight: 500; }
.entry-date { font-size: 13px; }
.entry-concept { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; flex-wrap: wrap; }
.entry-ref { font-size: 12px; color: var(--text-muted); font-weight: 400; }
.line { padding: 3px 16px; font-size: 13px; }
.line:last-of-type { padding-bottom: 8px; }
.line-account { display: flex; gap: 10px; min-width: 0; }
.line-code { color: var(--accent-hover); width: 44px; flex: none; }
.line-name { color: var(--text-secondary); }
.dash { color: var(--text-disabled); }
.entry-total { padding: 6px 16px 10px; font-size: 12px; color: var(--text-muted); }
.entry-total .total-label { text-align: right; padding-right: 4px; }
.entry-total .total-value { text-align: right; border-top: 1px solid var(--border); padding-top: 4px; color: var(--text); font-weight: 500; }

.entry.reversal { background: var(--row-alt); }
.entry.reversed .entry-no,
.entry.reversed .entry-date,
.entry.reversed .entry-concept,
.entry.reversed .line { color: var(--text-muted); }
.entry.reversed .line-code { color: var(--text-muted); }
.entry.reversed .line-name { color: inherit; }
.entry.reversed .struck { text-decoration: line-through; }

.extornar-form { margin: 0; display: flex; justify-content: flex-end; }
.extornar {
  font-size: 12px; font-weight: 600; padding: 4px 8px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-chip);
  color: var(--text-secondary); background: var(--surface); cursor: pointer; font-family: inherit;
}
.extornar:disabled { border-color: var(--border); color: var(--text-disabled); background: var(--page); cursor: not-allowed; }

.empty-state { padding: 40px 16px; text-align: center; color: var(--text-secondary); display: flex; flex-direction: column; gap: 14px; align-items: center; }
.footnote { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--text-muted); flex-wrap: wrap; }

/* ---------- entry form ---------- */

.form-head { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.col-2 { grid-column: span 2; }
.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }

.lines { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); overflow: hidden; }
.lrow { display: grid; grid-template-columns: 40px 1fr 160px 160px 44px; gap: 12px; align-items: center; }
.lhead {
  padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-size: 11px; font-weight: 600; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.lbody { padding: 8px 16px; border-bottom: 1px solid var(--surface-2); }
.lno { font-size: 13px; color: var(--text-muted); }
.line-remove {
  display: flex; align-items: center; justify-content: center;
  border: 0; background: none; color: var(--text-muted); cursor: pointer; padding: 4px;
}
.lfoot { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--row-alt); gap: 12px; flex-wrap: wrap; }
.sums { display: grid; grid-template-columns: 160px 160px 44px; gap: 12px; align-items: center; }
.sum { text-align: right; display: flex; flex-direction: column; gap: 2px; }
.sum-label { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.sum-value { font-size: 16px; font-weight: 500; }
.sum.bad .sum-label, .sum.bad .sum-value { color: var(--error); }

/* ---------- login ---------- */

.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-box { width: 380px; max-width: 100%; display: flex; flex-direction: column; gap: 20px; }
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 28px; display: flex; flex-direction: column; gap: 18px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.login-title { font-size: 20px; font-weight: 600; }
.login-brand { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; }
.login-brand .brand-mark { width: 28px; height: 28px; border-radius: 6px; }
.login-foot { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-size: 11px; color: var(--text-muted); text-align: center; }
.login-error {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: var(--error-bg); border: 1px solid var(--error-border);
  border-radius: var(--radius); font-size: 13px; color: var(--error);
}

/* ---------- narrow screens (Pablo checks the Diario on his phone) ---------- */

@media (max-width: 900px) {
  .topbar { height: auto; padding: 10px 16px; flex-wrap: wrap; gap: 10px; }
  .topbar-left { flex-direction: column; align-items: flex-start; gap: 10px; }
  .nav { flex-wrap: wrap; }
  .page { padding: 18px 16px 32px; }
  .stats { grid-template-columns: 1fr; }
  .jrow { grid-template-columns: 1fr 110px 110px; }
  .jhead, .entry-head .entry-date, .entry-total .total-label { display: none; }
  .entry-head { display: flex; flex-wrap: wrap; gap: 8px; }
  .entry-total { display: grid; grid-template-columns: 1fr 110px 110px; }
  .line { display: grid; grid-template-columns: 1fr 110px 110px; }
  .line-code { width: auto; }
  .form-head { grid-template-columns: 1fr; }
  .col-2, .col-3, .col-4 { grid-column: span 1; }
  .lrow { grid-template-columns: 24px 1fr 44px; row-gap: 6px; }
  .lbody .amount { grid-column: 2 / 3; }
  .sums { grid-template-columns: 1fr 1fr; }
}
