/* App layer over the Muttdata tokens (web/ds). Light interface surfaces, flat cards, blue hairlines. */
:root {
  --gutter: clamp(16px, 2.4vw, 40px);
  --nav-h: 72px;
  --row-hl: rgba(0, 69, 251, .12);
}

body { background: var(--surface-mist); min-height: 100vh; }
button { font: inherit; }

/* --- Nav: floating white pill --- */
.nav {
  position: sticky; top: 16px; z-index: 10;
  margin: 16px var(--gutter) 0; height: var(--nav-h); padding: 0 12px 0 28px;
  display: flex; align-items: center; gap: var(--space-5);
  background: var(--mutt-white); border-radius: var(--radius-pill); box-shadow: var(--shadow-nav);
}
.nav__logo { width: 180px; height: auto; flex: none; }
.nav__divider { width: 1px; height: 28px; background: var(--border-hairline); }
.nav__title { color: var(--text-heading); font-weight: var(--weight-medium); font-size: var(--text-body-s); white-space: nowrap; }
.nav .tabs { margin-left: auto; }
.nav__logout { flex: none; }

.engine-picker {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 5px 5px 14px;
  background: var(--mutt-blue-tint); border-radius: var(--radius-pill);
}
.engine-picker__label {
  font-family: var(--font-mono); font-size: var(--text-kicker); text-transform: uppercase;
  letter-spacing: var(--tracking-label); color: var(--mutt-blue); white-space: nowrap;
}
.engine-picker select {
  border: none; cursor: pointer; padding: 8px 14px; border-radius: var(--radius-pill);
  background: var(--mutt-white); color: var(--mutt-navy); font: inherit;
  font-weight: var(--weight-medium); font-size: var(--text-caption);
}
.engine-picker select:focus-visible { outline: 2px solid var(--mutt-blue); outline-offset: 3px; }

.tabs, .segmented {
  display: inline-flex; gap: 4px; padding: 5px;
  background: var(--mutt-blue-tint); border-radius: var(--radius-pill);
}
.tabs__tab, .segmented__btn {
  border: none; cursor: pointer; padding: 10px 20px; border-radius: var(--radius-pill);
  background: transparent; color: var(--mutt-blue); font-weight: var(--weight-medium); font-size: var(--text-body-s);
  transition: background var(--duration-base) var(--ease-brand), color var(--duration-base) var(--ease-brand);
}
.segmented__btn { padding: 6px 14px; font-size: var(--text-caption); }
.tabs__tab.is-active, .segmented__btn.is-active { background: var(--mutt-navy); color: var(--mutt-white); font-weight: var(--weight-semibold); }
.tabs__tab:focus-visible, .segmented__btn:focus-visible, .btn:focus-visible, .invoice-list button[data-name]:focus-visible {
  outline: 2px solid var(--mutt-blue); outline-offset: 3px;
}

/* --- Buttons: pill with leading dot --- */
.btn {
  display: inline-flex; align-items: center; gap: 10px; padding: 13px 24px;
  border-radius: var(--radius-pill); border: 1px solid transparent; cursor: pointer;
  font-weight: var(--weight-medium); font-size: var(--text-body-s); line-height: 1; letter-spacing: -0.01em;
  white-space: nowrap; text-decoration: none;
  transition: background var(--duration-fast) var(--ease-brand), box-shadow var(--duration-base) var(--ease-brand), transform var(--duration-fast) var(--ease-brand);
}
.btn__dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.btn--primary { background: var(--mutt-blue); color: var(--mutt-white); box-shadow: var(--halo-on-light); }
.btn--primary:hover { background: var(--mutt-deep-blue); }
.btn--ghost { background: transparent; color: var(--mutt-blue); border-color: var(--mutt-blue); }
.btn--ghost:hover { background: var(--mutt-blue-tint); color: var(--mutt-blue); }
.btn:active { transform: scale(.985); }
.btn[disabled] { opacity: .4; cursor: not-allowed; }
.btn--sm { padding: 9px 16px; font-size: var(--text-caption); }

/* --- Labels --- */
.kicker {
  font-family: var(--font-mono); font-size: var(--text-kicker); text-transform: uppercase;
  letter-spacing: var(--tracking-label); line-height: 1; color: var(--mutt-blue);
  padding: 7px 10px 6px; border: 1px solid var(--mutt-blue); background: var(--mutt-blue-tint); border-radius: 8px;
}
.kicker--bare { padding: 0; border: none; background: none; }
.label {
  font-family: var(--font-mono); font-size: 11px; text-transform: uppercase;
  letter-spacing: var(--tracking-label); color: var(--text-body);
}
.tag {
  display: inline-block; padding: 5px 10px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: var(--weight-medium); line-height: 1; white-space: nowrap;
  background: var(--mutt-blue-tint); color: var(--mutt-blue);
}
.tag--green { background: rgba(96, 208, 69, .16); color: #2E7A1F; }
.tag--amber { background: rgba(242, 176, 62, .18); color: #8A5B00; }
.tag--orange { background: rgba(255, 115, 0, .14); color: #B34F00; }
.tag--violet { background: var(--mutt-violet-tint); color: var(--mutt-violet); }

/* --- Report job strip --- */
.job {
  margin: 12px var(--gutter) 0; padding: 12px 20px; display: flex; align-items: center; gap: var(--space-4);
  background: var(--mutt-white); border: 1px solid var(--border-hairline); border-radius: var(--radius-pill);
}
.job[hidden] { display: none; }
.job .kicker { white-space: nowrap; flex: none; }
.job__log { color: var(--text-body); font-size: var(--text-caption); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job__spinner {
  width: 14px; height: 14px; border-radius: 50%; flex: none;
  border: 2px solid var(--mutt-blue-tint-strong); border-top-color: var(--mutt-blue);
  animation: spin 900ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Invoices view: list | 2x2 workspace (OC · factura / NC · texto) --- */
main { padding: var(--space-5) var(--gutter) var(--gutter); }
.view { display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: var(--space-4); height: calc(100vh - var(--nav-h) - 72px); min-height: 640px; }
.workspace {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-4); min-height: 0;
}
.workspace.has-expanded .panel { display: none; }
.workspace.has-expanded .panel.is-expanded { display: flex; grid-column: 1 / -1; grid-row: 1 / -1; }
.view[hidden] { display: none; }
#view-report { display: block; height: auto; }
#view-report[hidden] { display: none; }

.invoice-list { display: flex; flex-direction: column; gap: 6px; overflow: auto; padding: 2px; }
.invoice-list #upload-open { align-self: flex-start; flex: none; margin-bottom: var(--space-2); }
/* Ghost buttons are transparent; on the mist list it keeps the white it had in the nav. */
.invoice-list #upload-open:not(:hover) { background: var(--mutt-white); }
.invoice-list button[data-name] {
  text-align: left; border: 1px solid transparent; background: transparent; cursor: pointer;
  padding: 10px 14px; border-radius: 14px; color: var(--text-heading); font-size: var(--text-body-s);
  transition: background var(--duration-fast) var(--ease-brand), border-color var(--duration-fast) var(--ease-brand);
}
.invoice-list button[data-name]:hover { background: var(--mutt-white); border-color: var(--border-hairline); }
.invoice-list button[data-name].is-active { background: var(--mutt-white); border-color: var(--mutt-blue); color: var(--mutt-blue); font-weight: var(--weight-medium); }
.invoice-list small { display: block; font-family: var(--font-mono); font-size: 11px; color: var(--text-body); letter-spacing: .02em; margin-top: 2px; }

.panel {
  background: var(--surface-card); border: 1px solid var(--border-hairline); border-radius: var(--radius-panel);
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.panel__head {
  display: flex; align-items: center; gap: var(--space-3); padding: 14px 20px;
  border-bottom: 1px solid var(--border-hairline); flex: none;
}
.panel__head .segmented { margin-left: auto; }
.panel__head { min-height: 58px; padding: 10px 14px 10px 20px; flex-wrap: wrap; row-gap: 8px; }
.panel__expand {
  flex: none; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border-hairline);
  background: var(--mutt-white); cursor: pointer; position: relative; color: var(--mutt-blue);
}
.panel__name { margin-right: auto; }
.panel__expand::before, .panel__expand::after {
  content: ""; position: absolute; width: 7px; height: 7px; border: 1.5px solid currentColor;
}
.panel__expand::before { top: 7px; right: 7px; border-left: 0; border-bottom: 0; }
.panel__expand::after { bottom: 7px; left: 7px; border-right: 0; border-top: 0; }
.panel.is-expanded .panel__expand::before { top: 6px; right: 6px; border: 1.5px solid currentColor; border-right: 0; border-top: 0; }
.panel.is-expanded .panel__expand::after { bottom: 6px; left: 6px; border: 1.5px solid currentColor; border-left: 0; border-bottom: 0; }
.panel__expand:hover { background: var(--mutt-blue-tint); }
.panel__expand:focus-visible { outline: 2px solid var(--mutt-blue); outline-offset: 2px; }
#note-tags { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* --- PDF documents (OC, system NC) --- */
.doc-frame { flex: 1; min-height: 0; display: flex; background: var(--mutt-blue-tint); }
.doc-frame > .empty { flex: 1; }
.pdf { flex: 1; width: 100%; height: 100%; border: 0; background: var(--mutt-blue-tint); }
#credit-note:has(> .pdf) { padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.note-summary { flex: none; padding: 12px 20px; border-bottom: 1px solid var(--border-hairline); max-height: 40%; overflow: auto; }
.note-summary:empty { display: none; }
.summary-line { display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: var(--text-caption); color: var(--text-body); margin-bottom: 8px; }
.summary-line strong { font-family: var(--font-mono); font-weight: var(--weight-medium); color: var(--text-heading); }
.summary-line .is-warn strong { color: #B37800; }
.issues.issues--tight { margin: 0 0 var(--space-5); }
.issues--tight li { padding: 6px 10px; }
.panel__name { font-family: var(--font-mono); font-size: var(--text-caption); color: var(--text-body); }
.panel__body { overflow: auto; padding: 20px; flex: 1; }

.image-frame { overflow: auto; flex: 1; padding: 20px; background: var(--mutt-blue-tint); }
.image-stack { position: relative; max-width: 900px; margin: 0 auto; box-shadow: var(--shadow-panel); background: #fff; }
.image-stack img { display: block; width: 100%; height: auto; }
.overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.overlay rect { fill: transparent; stroke: transparent; stroke-width: 2; transition: fill var(--duration-fast) var(--ease-brand); }
.overlay rect.is-flagged { stroke: var(--mutt-amber); stroke-dasharray: 4 3; }
.overlay rect.is-edited { stroke: var(--mutt-violet); stroke-dasharray: none; }
.overlay rect.is-active { fill: var(--row-hl); stroke: var(--mutt-blue); stroke-dasharray: none; }

/* --- Extraction --- */
.notice {
  padding: 12px 16px; border-radius: 14px; margin-bottom: var(--space-4); font-size: var(--text-body-s);
  background: rgba(242, 176, 62, .14); color: #6B4700; border: 1px solid rgba(242, 176, 62, .5);
}
.notice--info { background: var(--mutt-blue-tint); color: var(--text-heading); border-color: var(--border-hairline); }
.notice strong { color: inherit; }

.meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-bottom: var(--space-5); color: var(--text-body); font-size: var(--text-caption); }
.meta .btn { margin-left: auto; }

.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-6); }
.field { border: 1px solid var(--border-hairline); border-radius: 14px; padding: 12px 14px; }
.field.is-flagged { border-color: var(--mutt-amber); background: rgba(242, 176, 62, .08); }
.field__value { color: var(--text-heading); font-size: var(--text-body-s); font-weight: var(--weight-medium); margin-top: 6px; overflow-wrap: anywhere; }
.field__conf { font-family: var(--font-mono); font-size: 11px; color: var(--text-body); margin-top: 4px; }

.section-title { display: flex; align-items: baseline; gap: var(--space-3); margin: 0 0 var(--space-3); font-size: var(--text-heading-s); font-weight: var(--weight-regular); }
.section-title .label { margin-left: auto; }

.lines { width: 100%; border-collapse: collapse; font-size: var(--text-caption); }
.lines th {
  position: sticky; top: -20px; background: var(--mutt-white); z-index: 1; text-align: left;
  font-family: var(--font-mono); font-weight: var(--weight-regular); font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-body); padding: 8px 6px; border-bottom: 1px solid var(--mutt-blue);
}
.lines td { padding: 7px 6px; border-bottom: 1px solid var(--mutt-mist); color: var(--text-heading); vertical-align: top; }
.lines .num { text-align: right; font-family: var(--font-mono); font-size: 12px; white-space: nowrap; }
.lines tr { cursor: default; }
.lines tbody tr:hover td, .lines tbody tr.is-active td { background: var(--row-hl); }
.lines td.is-flagged { background: rgba(242, 176, 62, .16); box-shadow: inset 0 -2px 0 var(--mutt-amber); }

.issues { margin: var(--space-6) 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.issues li { font-size: var(--text-caption); padding: 8px 12px; border-radius: 10px; background: var(--mutt-mist); color: var(--text-heading); }
.issues code { font-size: 12px; color: var(--mutt-blue); }

.raw-text--edit {
  display: block; width: 100%; min-height: 420px; height: calc(100% - 120px); resize: vertical; padding: 14px;
  border: 1px solid var(--border-hairline); border-radius: 14px; background: var(--mutt-white);
}
.raw-text--edit:focus { outline: 2px solid var(--mutt-blue); outline-offset: 1px; }
.raw-text { margin: 0; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6; color: var(--text-heading); white-space: pre-wrap; }

/* --- Editing --- */
.hint { font-size: 12px; color: var(--text-body); margin: 0 0 var(--space-4); }
.lines .hint { margin: 2px 0 0; font-size: 11px; }
.editable { cursor: text; border-radius: 6px; transition: box-shadow var(--duration-fast) var(--ease-brand); }
.field__value.editable { margin-left: -4px; margin-right: -4px; padding: 2px 4px; min-height: 1.5em; }
.editable:hover { box-shadow: inset 0 0 0 1px var(--border-hairline); }
.editable:focus { outline: none; box-shadow: inset 0 0 0 2px var(--mutt-blue); background: var(--mutt-white); }
.lines td.is-edited, .field.is-edited { background: var(--mutt-violet-tint); box-shadow: inset 0 -2px 0 var(--mutt-violet); }
.lines td.is-edited.is-flagged, .field.is-edited.is-flagged { box-shadow: inset 0 -2px 0 var(--mutt-amber); }
.field.is-edited { border-color: var(--mutt-violet); box-shadow: none; }
.tag--edited { background: var(--mutt-violet); color: var(--mutt-white); }
.save-state { font-family: var(--font-mono); font-size: 11px; color: var(--text-body); }
.save-state.is-warn { color: #B34F00; }
.row-actions { width: 28px; padding: 4px 0 !important; text-align: center; }
.icon-btn {
  width: 22px; height: 22px; border-radius: 50%; border: none; background: transparent; cursor: pointer;
  color: var(--text-body); font-size: 15px; line-height: 1; opacity: 0;
}
.lines tr:hover .icon-btn, .icon-btn:focus-visible { opacity: 1; }
.icon-btn:hover { background: rgba(255, 115, 0, .14); color: #B34F00; }
.add-line { margin-top: var(--space-4); }

/* --- Credit note: generated draft and OC vs invoice contrast --- */
.doc { border: 1px solid var(--border-hairline); border-radius: 16px; padding: 20px; background: var(--mutt-white); }
.doc__head { display: flex; align-items: flex-start; gap: var(--space-4); margin-bottom: var(--space-4); }
.doc__head .btn { margin-left: auto; }
.doc__title { font-size: var(--text-heading-s); color: var(--text-heading); display: flex; align-items: baseline; gap: 10px; }
.doc__sub { font-size: var(--text-caption); color: var(--text-body); margin-top: 4px; }
.doc__refs { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--space-3); margin: 0 0 var(--space-5); }
.doc__refs dd { margin: 4px 0 0; font-size: var(--text-body-s); color: var(--text-heading); font-weight: var(--weight-medium); }
.doc__section { display: flex; align-items: baseline; gap: 10px; margin: var(--space-6) 0 var(--space-3); font-size: var(--text-body-s); font-weight: var(--weight-medium); color: var(--text-heading); }
.totals { margin: var(--space-4) 0 0 auto; max-width: 280px; display: grid; gap: 2px; font-size: var(--text-caption); }
.totals div { display: flex; justify-content: space-between; padding: 6px 4px; border-bottom: 1px solid var(--mutt-mist); }
.totals dt { color: var(--text-body); }
.totals dd { margin: 0; font-family: var(--font-mono); color: var(--text-heading); }
.totals__grand { border-bottom: 1px solid var(--mutt-blue) !important; }
.totals__grand dt, .totals__grand dd { font-weight: var(--weight-semibold); color: var(--text-heading); }
.lines--contrast tr.group th { border-bottom: none; padding-bottom: 0; color: var(--mutt-blue); position: static; }
.lines--contrast tr.is-quiet td { color: var(--text-body); }
.lines .muted { color: var(--text-body); opacity: .6; }

.empty { display: grid; place-items: center; gap: var(--space-4); text-align: center; padding: var(--space-8) var(--space-5); color: var(--text-body); }
.empty h3 { font-size: var(--text-heading-s); }

/* --- Report view --- */
.report { max-width: 1240px; margin: 0 auto; }
.report__card { background: var(--mutt-white); border: 1px solid var(--border-hairline); border-radius: var(--radius-card); padding: clamp(24px, 4vw, 56px); }
.report__head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-4); margin-bottom: var(--space-6); }
.report__head .btn { margin-left: auto; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-7); }
.stat { border-top: 1px solid var(--mutt-blue); padding-top: var(--space-3); }
.stat__value { font-family: var(--font-mono); font-size: 40px; line-height: 1; letter-spacing: -0.02em; color: var(--mutt-blue); }
.stat__value--amber { color: #B37800; }
.stat__label { margin-top: 10px; }

.md h1 { font-size: var(--text-display-m); margin-bottom: var(--space-5); }
.md h2 { font-size: var(--text-heading-l); margin: var(--space-8) 0 var(--space-4); padding-top: var(--space-5); border-top: 1px solid var(--border-hairline); }
.md h3 { font-size: var(--text-heading-s); font-weight: var(--weight-medium); margin: var(--space-6) 0 var(--space-3); }
.md p, .md li { font-size: var(--text-body-s); max-width: 80ch; }
.md ul { padding-left: 20px; }
.md code { font-size: .9em; color: var(--mutt-navy); background: var(--mutt-blue-tint); padding: 1px 5px; border-radius: 4px; }
.md .table-wrap { max-height: 520px; overflow: auto; border: 1px solid var(--border-hairline); border-radius: 14px; margin: var(--space-4) 0; }
.md table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.md th {
  position: sticky; top: 0; background: var(--mutt-white); text-align: left; white-space: nowrap;
  font-family: var(--font-mono); font-weight: var(--weight-regular); font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-body); padding: 10px; border-bottom: 1px solid var(--mutt-blue);
}
.md td { padding: 7px 10px; border-bottom: 1px solid var(--mutt-mist); color: var(--text-heading); }
.md td code { background: none; padding: 0; }
.md tbody tr:hover td { background: var(--mutt-blue-tint); }
.md .table-count { font-family: var(--font-mono); font-size: 11px; color: var(--text-body); margin-top: -8px; }

/* --- Data upload dialog: one column per document kind, pairing preview below --- */
.upload {
  width: min(1100px, calc(100vw - 2 * var(--gutter))); max-height: calc(100vh - 48px);
  padding: 0; border: none; border-radius: var(--radius-card); background: var(--mutt-white);
  box-shadow: var(--shadow-panel); color: var(--text-body);
}
.upload::backdrop { background: rgba(0, 18, 55, .45); }
.upload__card { display: flex; flex-direction: column; gap: var(--space-5); padding: var(--space-6); }
.upload__head h2 { font-size: var(--text-heading-s); color: var(--text-heading); margin-bottom: var(--space-2); }
.upload__hint { font-size: var(--text-body-s); max-width: 80ch; }
.upload__hint code { font-size: .9em; color: var(--mutt-navy); background: var(--mutt-blue-tint); padding: 1px 5px; border-radius: 4px; }
.upload__columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }
.upload__col {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3); min-width: 0;
  padding: var(--space-4); border: 1px solid var(--border-hairline); border-radius: var(--radius-panel);
  transition: background var(--duration-fast) var(--ease-brand), border-color var(--duration-fast) var(--ease-brand);
}
.upload__col.is-dragging { background: var(--mutt-blue-tint); border-color: var(--mutt-blue); }
.upload__drop {
  align-self: stretch; display: grid; gap: 4px; place-items: center; text-align: center; cursor: pointer;
  padding: var(--space-5) var(--space-3); border: 1px dashed var(--mutt-blue); border-radius: 14px;
  color: var(--mutt-blue); font-size: var(--text-body-s);
}
.upload__drop:hover { background: var(--mutt-blue-tint); }
.upload__drop:focus-within { outline: 2px solid var(--mutt-blue); outline-offset: 3px; }
.upload__drop input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload__drop small { color: var(--text-body); font-size: var(--text-caption); }
.upload.is-busy .upload__drop { opacity: .4; pointer-events: none; }
.upload__files { list-style: none; padding: 0; margin: 0; align-self: stretch; display: grid; gap: 6px; max-height: 220px; overflow: auto; }
.upload__files li {
  display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; border-radius: 10px;
  background: var(--mutt-mist); color: var(--text-heading); font-size: var(--text-caption);
}
.upload__files li.is-invalid { background: rgba(255, 115, 0, .10); flex-wrap: wrap; }
.upload__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload__error { flex-basis: 100%; order: 3; color: #B34F00; }
.upload__remove {
  flex: none; width: 22px; height: 22px; border-radius: 50%; border: none; background: transparent;
  cursor: pointer; color: var(--text-body); font-size: 16px; line-height: 1;
}
.upload__remove:hover:not([disabled]) { background: var(--mutt-white); color: var(--mutt-blue); }
.upload__pairs:empty { display: none; }
.upload__pairs { max-height: 260px; overflow: auto; border: 1px solid var(--border-hairline); border-radius: 14px; }
.upload__pairs table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.upload__pairs th {
  position: sticky; top: 0; background: var(--mutt-white); text-align: left; white-space: nowrap;
  font-family: var(--font-mono); font-weight: var(--weight-regular); font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-body); padding: 10px; border-bottom: 1px solid var(--mutt-blue);
}
.upload__pairs td { padding: 7px 10px; border-bottom: 1px solid var(--mutt-mist); color: var(--text-heading); overflow-wrap: anywhere; }
.upload__existing { font-style: italic; color: var(--text-body); }
.upload__missing { color: var(--text-body); }
.upload__legend { font-size: var(--text-caption); padding: 8px 10px; }
.upload__foot { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-3); flex-wrap: wrap; }
.upload__status { margin-right: auto; font-size: var(--text-caption); color: var(--text-body); }

@media (max-width: 760px) {
  .upload__columns { grid-template-columns: 1fr; }
  .upload__card { padding: var(--space-5) 16px; }
}

/* --- Narrow screens: stack the panels --- */
@media (max-width: 1100px) {
  .nav { height: auto; flex-wrap: wrap; padding: 14px 16px; border-radius: 28px; row-gap: 12px; }
  .nav__divider, .nav__title { display: none; }
  .nav__logo { width: 180px; }
  .view { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .workspace { grid-template-columns: 1fr; grid-template-rows: none; }
  .workspace.has-expanded .panel.is-expanded { grid-row: auto; }
  .doc-frame, #credit-note:has(> .pdf) { min-height: 70vh; }
  .invoice-list { flex-direction: row; overflow-x: auto; }
  .invoice-list button { flex: none; }
  .invoice-list #upload-open { align-self: center; margin-bottom: 0; }
  .panel { max-height: 80vh; }
}
@media (max-width: 560px) {
  .nav .tabs { margin-left: 0; }
  .nav { justify-content: space-between; }
}

/* --- Login --- */
.login {
  min-height: 100vh; background: var(--surface-brand); color: var(--text-on-brand);
  display: flex; align-items: center; justify-content: center; padding: var(--space-7) var(--gutter);
}
.login__wrap { width: 100%; max-width: 440px; display: flex; flex-direction: column; align-items: center; gap: var(--space-7); }
.login__logo { height: 40px; width: auto; }
.login__card {
  width: 100%; background: var(--mutt-white); color: var(--text-body);
  border-radius: var(--radius-card); padding: var(--space-7) var(--space-6);
}
.login__card h1 { font-size: var(--text-display-m); margin-bottom: var(--space-6); }
.login__field { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-5); }
.login__field label {
  font-family: var(--font-mono); font-size: var(--text-kicker); text-transform: uppercase;
  letter-spacing: var(--tracking-label); color: var(--mutt-blue);
}
.login__field input {
  font: inherit; color: var(--text-heading); background: var(--mutt-white);
  border: 1px solid var(--border-hairline); border-radius: var(--radius-tile);
  padding: 12px 16px; transition: border-color var(--duration-fast) var(--ease-brand);
}
.login__field input:hover { border-color: var(--mutt-blue); }
.login__field input:focus-visible { outline: 2px solid var(--mutt-blue); outline-offset: 3px; border-color: var(--mutt-blue); }
.login__card .btn { width: 100%; justify-content: center; margin-top: var(--space-3); }
.login__error {
  font-size: var(--text-body-s); color: var(--mutt-navy); background: var(--mutt-violet-tint);
  border: 1px solid var(--mutt-violet); border-radius: var(--radius-tile);
  padding: var(--space-3) var(--space-4); margin-bottom: var(--space-5);
}
.login__error[hidden] { display: none; }
@media (max-width: 600px) { .login__card { padding: var(--space-6) var(--space-5); } }
