/* RanchPay 30 — caderno contábil: papel morno, verde-mata, números em mono. */

/* Tema padrão: escuro premium (vidro + brilho esmeralda). Claro opcional. */
:root {
  --bg: #070A09;
  --surface: rgba(20, 26, 23, 0.62);
  --surface-2: rgba(28, 36, 32, 0.55);
  --surface-solid: #111614;
  --sunken: rgba(255, 255, 255, 0.035);
  --border: rgba(214, 255, 232, 0.07);
  --border-strong: rgba(214, 255, 232, 0.13);
  --text: #EEF2EF;
  --text-2: #A4AFA8;
  --text-3: #6D7A73;

  --accent: #3EE39A;
  --accent-hover: #6BEDB3;
  --accent-ink: #03140B;
  --accent-soft: rgba(62, 227, 154, 0.12);
  --accent-text: #5BE8A9;
  --glow: 0 0 0 1px rgba(62, 227, 154, 0.35), 0 8px 28px -6px rgba(62, 227, 154, 0.45);

  --warning: #F5B94A;
  --warning-soft: rgba(245, 185, 74, 0.12);
  --danger: #FF7B6E;
  --danger-soft: rgba(255, 123, 110, 0.12);
  --info: #7CC0FF;
  --info-soft: rgba(124, 192, 255, 0.12);

  --font: 'Instrument Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Instrument Serif', Georgia, serif;
  --mono: 'IBM Plex Mono', ui-monospace, Consolas, monospace;

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --blur: blur(20px) saturate(150%);
  --shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-pop: 0 30px 80px -20px rgba(0, 0, 0, 0.8), 0 0 0 1px var(--border-strong);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --rail-w: 248px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #F2F1EC;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-2: rgba(250, 249, 245, 0.8);
  --surface-solid: #FFFFFF;
  --sunken: rgba(27, 29, 25, 0.045);
  --border: rgba(27, 29, 25, 0.09);
  --border-strong: rgba(27, 29, 25, 0.16);
  --text: #1B1D19;
  --text-2: #5A5D55;
  --text-3: #8B8D85;
  --accent: #17804F;
  --accent-hover: #11683F;
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(23, 128, 79, 0.1);
  --accent-text: #147046;
  --glow: 0 8px 20px -8px rgba(23, 128, 79, 0.5);
  --warning: #9A6700;
  --warning-soft: #FAF0D6;
  --danger: #B42318;
  --danger-soft: #FBE8E5;
  --info: #2B5C8A;
  --info-soft: #E5EDF6;
  --shadow: 0 1px 2px rgba(27, 29, 25, 0.05);
  --shadow-pop: 0 24px 48px -16px rgba(27, 29, 25, 0.25), 0 0 0 1px var(--border);
  color-scheme: light;
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-soft); }
[hidden] { display: none !important; }

svg { width: 16px; height: 16px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.muted { color: var(--text-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.eyebrow { font-size: 11.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: var(--shadow);
  transition: background 120ms, border-color 120ms, color 120ms;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--sunken); border-color: transparent; color: var(--text); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { height: 28px; padding: 0 9px; font-size: 12.5px; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  color: var(--text-3);
  transition: background 120ms, color 120ms;
}
.icon-btn:hover { background: var(--sunken); color: var(--text); }

/* -------------------------------------------------------------- layout */
.app { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh; }

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 18px 12px 14px;
  border-right: 1px solid var(--border);
  background: var(--surface-2);
  min-width: 0;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px; }
.brand-logo { width: 36px; height: 36px; object-fit: contain; }
:root[data-theme="light"] .brand-logo { filter: brightness(0.12); }
.brand-text { display: grid; min-width: 0; }
.brand-text strong { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.brand-text strong em { font-family: var(--serif); font-size: 18px; font-weight: 400; color: var(--accent-text); }
.brand-text span { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { display: grid; gap: 1px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-weight: 500;
  transition: background 120ms, color 120ms;
}
.nav-item svg { color: var(--text-3); }
.nav-item > span:not(.nav-ico) { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover { background: var(--sunken); color: var(--text); }
.nav-item.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow), inset 0 0 0 1px var(--border); }
.nav-item.active svg { color: var(--accent-text); }
.nav-count { font-family: var(--mono); font-size: 11.5px; font-weight: 400; color: var(--text-3); }
.nav-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
}

.rail-foot { margin-top: auto; display: grid; gap: 8px; }
.rail-actions { display: flex; gap: 2px; }
.ai-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12.5px;
  color: var(--text-2);
  text-align: left;
}
.ai-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex-shrink: 0; }
.ai-pill.on i { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ai-pill.off i { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }
.ai-pill span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { min-width: 0; padding: 36px 44px 80px; }
.main:focus { outline: none; }
#view { max-width: 1180px; margin: 0 auto; animation: fade 220ms var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------------- page header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-head h1 { font-size: 26px; letter-spacing: -0.02em; }
.page-head p { margin-top: 4px; color: var(--text-2); max-width: 620px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.greeting .eyebrow { margin-bottom: 10px; }
.greeting h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 44px;
  line-height: 1.05;
  letter-spacing: -0.015em;
}
.greeting h1 em { color: var(--accent-text); }
.greeting p { margin-top: 12px; font-size: 16px; color: var(--text-2); max-width: 640px; line-height: 1.55; }
.greeting p strong { color: var(--text); font-weight: 600; }

/* ---------------------------------------------------------------- card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 12px; }
.card-head h2 { font-size: 14.5px; }
.card-head .hint { font-size: 12.5px; color: var(--text-3); }
.card-body { padding: 0 18px 18px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; }

/* -------------------------------------------------------------- figures */
.figures {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, 1fr);
  margin: 28px 0 16px;
  border-top: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border);
}
.figure { padding: 16px 20px 18px 0; min-width: 0; }
.figure + .figure { padding-left: 20px; border-left: 1px solid var(--border); }
.figure-label { font-size: 12.5px; color: var(--text-2); }
.figure-value { margin-top: 6px; font-family: var(--mono); font-size: 22px; font-weight: 500; letter-spacing: -0.03em; white-space: nowrap; }
.figure.lead .figure-value { font-size: 30px; }
.figure-sub { margin-top: 2px; font-size: 12.5px; color: var(--text-3); }
.figure.danger .figure-value { color: var(--danger); }
.figure.warning .figure-value { color: var(--warning); }

/* -------------------------------------------------------- cash timeline */
.timeline { padding: 4px 18px 18px; }
.timeline-bars { display: grid; grid-template-columns: repeat(var(--days), minmax(0, 1fr)); gap: 4px; align-items: end; height: 132px; }
.tl-day { position: relative; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.tl-bar {
  display: block;
  width: 100%;
  min-height: 3px;
  border-radius: 3px 3px 1px 1px;
  background: var(--sunken);
  transition: background 120ms;
}
.tl-day.has .tl-bar { background: var(--accent); opacity: 0.85; }
.tl-day.has.late .tl-bar { background: var(--danger); }
.tl-day.has:hover .tl-bar { opacity: 1; }
.tl-day.weekend:not(.has) .tl-bar { background: color-mix(in srgb, var(--sunken) 60%, transparent); }
.tl-day.has { cursor: pointer; }
.tl-amount {
  position: absolute;
  bottom: calc(var(--h) + 6px);
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-2);
  white-space: nowrap;
}
.timeline-axis { display: grid; grid-template-columns: repeat(var(--days), minmax(0, 1fr)); gap: 4px; margin-top: 8px; border-top: 1px solid var(--border); padding-top: 6px; }
.timeline-axis span { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); text-align: center; }
.timeline-axis span.today { color: var(--accent-text); font-weight: 600; }
.timeline-axis span.month { color: var(--text-2); }

/* --------------------------------------------------------------- lists */
.list { display: grid; }
.list-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  border-top: 1px solid var(--border);
  text-align: left;
  width: 100%;
  transition: background 120ms;
}
.list-row:hover { background: var(--surface-2); }
.list-row .t { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .d { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .v { text-align: right; }
.list-empty { padding: 22px 18px; border-top: 1px solid var(--border); color: var(--text-3); font-size: 13px; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.dot.danger { background: var(--danger); }
.dot.warning { background: var(--warning); }
.dot.info { background: var(--info); }
.dot.success { background: var(--accent); }

.date-chip {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--r);
  background: var(--sunken);
  line-height: 1;
}
.date-chip b { font-family: var(--mono); font-size: 16px; font-weight: 500; }
.date-chip small { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-3); margin-top: -8px; }

/* --------------------------------------------------------------- pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--sunken);
  color: var(--text-2);
}
.pill.success { background: var(--accent-soft); color: var(--accent-text); }
.pill.warning { background: var(--warning-soft); color: var(--warning); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill svg { width: 12px; height: 12px; stroke-width: 2.25; }

.tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 6px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-2);
  white-space: nowrap;
}
.tag.on { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }
.tag.off { border-style: dashed; color: var(--text-3); }
.tags { display: inline-flex; gap: 4px; }

/* ------------------------------------------------------------- toolbar */
.toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.tabs { display: inline-flex; gap: 2px; padding: 3px; border-radius: 8px; background: var(--sunken); }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow), inset 0 0 0 1px var(--border); }
.tab .num { font-size: 11px; color: var(--text-3); }

.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 10px; color: var(--text-3); pointer-events: none; }
.search input {
  width: 260px;
  height: 34px;
  padding: 0 12px 0 32px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 13px;
}
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* --------------------------------------------------------------- table */
.table { width: 100%; border-collapse: collapse; }
.table th {
  padding: 9px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table th.r, .table td.r { text-align: right; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { cursor: pointer; transition: background 120ms; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .t { font-weight: 500; }
.table .d { font-size: 12.5px; color: var(--text-3); max-width: 340px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table tr.paid .t, .table tr.paid .money { color: var(--text-3); }
.money { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 500; letter-spacing: -0.02em; white-space: nowrap; }

.empty { padding: 48px 20px; text-align: center; color: var(--text-3); }
.empty strong { display: block; color: var(--text); font-weight: 500; margin-bottom: 4px; }

/* ------------------------------------------------------------ dropzone */
.dropzone {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px 24px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  transition: border-color 150ms, background 150ms;
}
.dropzone.big { flex-direction: column; text-align: center; padding: 44px 24px; gap: 14px; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); color: var(--accent-text); flex-shrink: 0; }
.dropzone-icon svg { width: 20px; height: 20px; }
.dropzone h3 { font-size: 15px; }
.dropzone p { font-size: 13px; color: var(--text-2); }
.dropzone .formats { font-family: var(--mono); font-size: 11px; color: var(--text-3); letter-spacing: 0.04em; }
.dropzone .grow { flex: 1; min-width: 0; }

.banner {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  border-radius: var(--r);
  background: var(--warning-soft);
  color: var(--text);
  font-size: 13.5px;
}
.banner svg { color: var(--warning); margin-top: 2px; }
.banner code { font-family: var(--mono); font-size: 12.5px; padding: 1px 5px; border-radius: 4px; background: var(--surface); }
.banner strong { font-weight: 600; }

/* ---------------------------------------------------------- inbox item */
.inbox { display: grid; gap: 14px; margin-top: 20px; }
.inbox-file { overflow: hidden; }
.inbox-file-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.inbox-thumb { width: 36px; height: 46px; border-radius: 4px; object-fit: cover; border: 1px solid var(--border); background: var(--sunken); display: grid; place-items: center; color: var(--text-3); flex-shrink: 0; }
.inbox-file-head .name { flex: 1; min-width: 0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-file-head .meta { font-size: 12px; color: var(--text-3); }
.inbox-error { padding: 14px 16px; color: var(--danger); font-size: 13.5px; }

.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.reading { display: flex; align-items: center; gap: 10px; padding: 18px 16px; color: var(--text-2); font-size: 13.5px; }
.reading .skeleton { flex: 1; height: 10px; border-radius: 5px; background: linear-gradient(90deg, var(--sunken), var(--border), var(--sunken)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.extract { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); border-top: 1px solid var(--border); }
.extract:first-of-type { border-top: 0; }
.extract.done { opacity: 0.6; }
.extract-fields { padding: 16px; border-right: 1px solid var(--border); }
.extract-title { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.extract-title h3 { font-size: 15px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.fields .full { grid-column: 1 / -1; }

.field { display: grid; gap: 4px; min-width: 0; }
.field label { font-size: 12px; font-weight: 500; color: var(--text-2); }
.input, .select {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 13.5px;
  transition: border-color 120ms, box-shadow 120ms;
}
.input.mono { font-family: var(--mono); font-size: 12.5px; }
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.missing { border-color: var(--warning); background: var(--warning-soft); }
.select { appearance: none; padding-right: 28px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238B8D85' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; background-size: 14px; }
textarea.input { height: auto; min-height: 64px; padding: 8px 10px; resize: vertical; }

.extract-side { display: flex; flex-direction: column; gap: 14px; padding: 16px; background: var(--surface-2); }
.side-block h4 { font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); margin-bottom: 6px; }
.side-block .t { font-weight: 600; }
.side-block .d { font-size: 12.5px; color: var(--text-2); }
.new-flag { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 4px; font-size: 12px; font-weight: 600; color: var(--accent-text); }
.alerts { display: grid; gap: 6px; }
.alert { display: flex; gap: 8px; font-size: 12.5px; line-height: 1.45; color: var(--text-2); }
.alert .dot { margin-top: 5px; flex-shrink: 0; }
.extract-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 4px; }
.extract-actions .btn-primary { flex: 1; }
.confidence { font-family: var(--mono); font-size: 11px; color: var(--text-3); }

/* -------------------------------------------------------------- drawer */
.drawer-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(15, 18, 16, 0.32); animation: fade-in 180ms; }
@keyframes fade-in { from { opacity: 0; } }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  width: min(520px, 100vw);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 260ms var(--ease), visibility 260ms;
}
.drawer.open { transform: none; visibility: visible; }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 16px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { font-size: 18px; margin-top: 2px; }
.drawer-head .sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 22px; display: grid; gap: 22px; align-content: start; }
.drawer-foot { display: flex; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
.drawer-foot .spacer { flex: 1; }

.amount-hero { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.amount-hero .money { font-size: 32px; }

.section h3 { font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); margin-bottom: 8px; }
.kv { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 7px 12px; font-size: 13.5px; }
.kv dt { color: var(--text-3); }
.kv dd { min-width: 0; overflow-wrap: anywhere; }

.checks { display: grid; gap: 6px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; }
.check .mark { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; margin-top: 1px; background: var(--accent-soft); color: var(--accent-text); }
.check.bad .mark { background: var(--danger-soft); color: var(--danger); }
.check .mark svg { width: 11px; height: 11px; stroke-width: 3; }

.doc-card { border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.doc-card + .doc-card { margin-top: 10px; }
.doc-card-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.doc-card-head .t { flex: 1; font-weight: 500; font-size: 13.5px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-card-body { padding: 12px; display: grid; gap: 10px; }
.doc-card-body .kv { grid-template-columns: 110px minmax(0, 1fr); font-size: 13px; }
.missing-doc { padding: 12px; border: 1px dashed var(--border-strong); border-radius: var(--r); color: var(--text-3); font-size: 13px; }
.missing-doc + .doc-card, .doc-card + .missing-doc { margin-top: 10px; }

.copy-line { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--r-sm); background: var(--sunken); }
.copy-line code { flex: 1; min-width: 0; font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }

.items { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.items td { padding: 5px 0; border-top: 1px dashed var(--border); }
.items td:last-child { text-align: right; font-family: var(--mono); }

.confirm-box { display: grid; gap: 10px; width: 100%; padding: 12px; border-radius: var(--r); background: var(--accent-soft); }
.confirm-box p { font-size: 13.5px; }
.confirm-box .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form .full { grid-column: 1 / -1; }

/* ---------------------------------------------------------- companies */
.co-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.monogram {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  flex-shrink: 0;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-family: var(--serif);
  font-size: 17px;
  font-style: italic;
}
.co-cell > div { min-width: 0; }

/* ---------------------------------------------------------- documents */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; padding: 16px; }
.doc-tile { display: grid; gap: 10px; padding: 14px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); text-align: left; transition: border-color 120ms, box-shadow 120ms; }
.doc-tile:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.doc-tile .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.doc-tile .t { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-tile .d { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-tile .bottom { display: flex; justify-content: space-between; align-items: baseline; padding-top: 10px; border-top: 1px solid var(--border); }

/* --------------------------------------------------------- drop overlay */
.drop-overlay { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(3px); pointer-events: none; }
.drop-overlay-card { display: grid; justify-items: center; gap: 6px; padding: 36px 48px; border-radius: 18px; border: 2px dashed var(--accent); background: var(--surface); box-shadow: var(--shadow-pop); text-align: center; }
.drop-overlay-card svg { width: 28px; height: 28px; color: var(--accent-text); margin-bottom: 4px; }
.drop-overlay-card strong { font-size: 17px; }
.drop-overlay-card span { color: var(--text-2); font-size: 13px; }

/* --------------------------------------------------------------- toasts */
.toasts { position: fixed; left: 50%; bottom: 22px; z-index: 90; display: grid; gap: 8px; transform: translateX(-50%); pointer-events: none; }
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 13.5px;
  box-shadow: var(--shadow-pop);
  animation: toast-in 220ms var(--ease);
  pointer-events: auto;
  white-space: nowrap;
}
.toast svg { width: 15px; height: 15px; }
.toast.error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ------------------------------------------------------------ responsivo */
@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
  .figures { grid-template-columns: repeat(2, 1fr); }
  .figure:nth-child(3) { padding-left: 0; border-left: 0; }
  .figure:nth-child(n+3) { border-top: 1px solid var(--border); }
  .extract { grid-template-columns: 1fr; }
  .extract-fields { border-right: 0; border-bottom: 1px solid var(--border); }
}

@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail {
    position: sticky;
    top: 0;
    z-index: 30;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .brand-text, .rail-foot .ai-pill span, .nav-count { display: none; }
  .brand { padding: 0; }
  .nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
  .nav::-webkit-scrollbar { display: none; }
  .nav-item { flex-shrink: 0; }
  .nav-item:not(.active) > span:not(.nav-ico) { display: none; }
  .rail-foot { margin: 0; display: flex; align-items: center; gap: 2px; }
  .ai-pill { width: 32px; height: 32px; padding: 0; justify-content: center; border: 0; background: none; }
  .main { padding: 22px 16px 60px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .greeting h1 { font-size: 34px; }
  .search input { width: 100%; }
  .search { flex: 1; }
  .tabs { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .dropzone:not(.big) { flex-direction: column; align-items: flex-start; }

  .table thead { display: none; }
  .table, .table tbody { display: block; }
  .table tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .table td { display: block; padding: 0; border: 0; }
  .table td.hide-sm { display: none; }
  .table td.first { grid-column: 1 / -1; }
  .table .d { max-width: none; }
}

@media (max-width: 560px) {
  .figures { grid-template-columns: 1fr; }
  .figure, .figure + .figure { padding-left: 0; border-left: 0; }
  .figure + .figure { border-top: 1px solid var(--border); }
  .fields, .form { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .timeline-amounts { display: none; }
  .tl-amount { display: none; }
  .toast { white-space: normal; border-radius: 12px; }
}

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