:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --ink: #202124;
  --muted: #5f6368;
  --faint: #80868b;
  --line: #dadce0;
  --hairline: #e8eaed;
  --blue: #1a73e8;
  --blue-deep: #0b57d0;
  --blue-ink: #174ea6;
  --blue-soft: #d3e3fd;
  --blue-hover: #e8f0fe;
  --compose: #c2e7ff;
  --compose-ink: #001d35;
  --search: #e9eef6;
  --ok: #137333;
  --ok-soft: #e6f4ea;
  --warn: #b06000;
  --warn-soft: #fef7e0;
  --danger: #d93025;
  --danger-soft: #fce8e6;
  --draft: #5f6368;
  --draft-soft: #f1f3f4;
  --shadow:
    0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
  --shadow-lg:
    0 1px 3px 0 rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15);
  --sans: "Roboto", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --radius-pill: 16px;
  --radius-card: 16px;
  --sidebar: 256px;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
}
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
a {
  color: var(--blue);
}
h1,
h2,
h3 {
  font-weight: 400;
  margin: 0;
  letter-spacing: 0;
}
h1 {
  font-size: 22px;
  line-height: 1.27;
}
h2 {
  font-size: 16px;
  font-weight: 500;
  margin: 0 0 8px;
}
p {
  margin: 0;
}

.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  background: white;
  padding: 8px 12px;
  z-index: 40;
  border-radius: 8px;
}
.skip:focus {
  top: 12px;
}

.app {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  grid-template-rows: 64px minmax(0, 1fr);
  height: 100vh;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 8px 8px;
  background: var(--bg);
  border-bottom: 1px solid transparent;
  z-index: 5;
}
.brand {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 220px;
  flex: 0 0 auto;
  color: inherit;
  text-decoration: none;
  padding: 0 4px 0 8px;
  border-radius: 8px;
}
.brand:hover {
  background: transparent;
}
.brand img,
.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex: 0 0 auto;
  object-fit: contain;
  background: transparent;
}
.wordmark {
  font-size: 22px;
  color: var(--muted);
  font-weight: 400;
  margin-left: 4px;
}
.top-search {
  flex: 1;
  max-width: 720px;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  margin: 0 8px;
  padding: 0 16px 0 14px;
  background: var(--search);
  border-radius: 24px;
  transition:
    background 120ms ease,
    box-shadow 120ms ease;
}
.top-search svg {
  width: 24px;
  height: 24px;
  fill: var(--muted);
  flex: 0 0 auto;
}
.top-search input {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  height: 46px;
  font-size: 16px;
}
.top-search input::placeholder {
  color: var(--muted);
}
.top-search input:focus {
  outline: none;
}
.top-search:focus-within {
  background: var(--surface);
  box-shadow: var(--shadow);
}
.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}
a.guest-create {
  display: none;
  margin-left: auto;
}
.app.is-auth.is-login .guest-create {
  display: inline-flex;
}
.company-chip {
  max-width: min(220px, 28vw);
  margin-right: 4px;
  padding: 6px 10px;
  border-radius: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.company-chip:hover {
  background: rgba(32, 33, 36, 0.06);
  color: var(--ink);
}
.company-chip[hidden] {
  display: none !important;
}
.icon-round {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  text-decoration: none;
  flex: 0 0 auto;
}
.icon-round svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}
.icon-round:hover {
  background: rgba(32, 33, 36, 0.08);
}
.avatar-menu {
  position: relative;
}
.avatar {
  width: 32px;
  height: 32px;
  margin: 0 4px 0 8px;
  border: 0;
  padding: 0;
  border-radius: 50%;
  background: var(--blue-deep);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 500;
  font-size: 14px;
  flex: 0 0 auto;
  user-select: none;
  text-decoration: none;
  cursor: pointer;
}
.avatar:hover,
.avatar[aria-expanded="true"] {
  box-shadow: 0 0 0 4px var(--blue-soft);
}

.settings-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 100%;
}
.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 20px 12px 24px 16px;
  border-right: 1px solid var(--hairline);
  background: #fafafa;
}
.settings-nav-title {
  margin: 0 8px 10px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
}
.settings-nav a {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}
.settings-nav a:hover {
  background: rgba(32, 33, 36, 0.06);
}
.settings-nav a.active {
  background: var(--blue-soft);
  color: var(--blue-ink);
  font-weight: 700;
}
.settings-main {
  min-width: 0;
}
.settings-page {
  padding-top: 16px;
}

.app.is-auth aside,
.app.is-auth .top-search,
.app.is-auth .top-actions,
.app.is-auth .compose {
  display: none !important;
}
.app.is-auth {
  grid-template-columns: 1fr;
}
.app.is-auth #contenido {
  margin: 16px;
}

/* Consulting account: hide mutating controls; keep PDF/export/print visible */
.app.is-readonly .compose,
.app.is-readonly .owner-only,
.app.is-readonly a[href*="/nueva"],
.app.is-readonly a[href*="/editar"],
.app.is-readonly [data-new],
.app.is-readonly [data-new-client],
.app.is-readonly [data-save],
.app.is-readonly [data-save-profile],
.app.is-readonly [data-save-password],
.app.is-readonly [data-save-consultant],
.app.is-readonly [data-clear-consultant],
.app.is-readonly [data-emit],
.app.is-readonly [data-delete],
.app.is-readonly [data-del],
.app.is-readonly [data-del-pay],
.app.is-readonly [data-annul],
.app.is-readonly [data-add-pay],
.app.is-readonly [data-edit],
.app.is-readonly [data-logo-delete],
.app.is-readonly [data-logo-pick],
.app.is-readonly [data-logo-file],
.app.is-readonly .logo-card .people-actions,
.app.is-readonly .logo-actions,
.app.is-readonly label.file-pick {
  display: none !important;
}
.app.is-readonly .settings-page input,
.app.is-readonly .settings-page select,
.app.is-readonly .settings-page textarea {
  pointer-events: none;
  opacity: 0.92;
}
.app.is-readonly .avatar {
  background: #e8f0fe;
  color: #174ea6;
}
.auth-screen {
  min-height: calc(100vh - 96px);
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(420px, 100%);
  padding: 28px 28px 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.auth-card img,
.auth-logo {
  display: block;
  width: 56px;
  height: 56px;
  margin-bottom: 14px;
  border-radius: 14px;
  object-fit: contain;
  background: transparent;
}
.auth-card h1 {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 500;
}
.auth-card .lede {
  margin-bottom: 18px;
}
.auth-note {
  margin-top: 16px;
  color: var(--faint);
  font-size: 12px;
  line-height: 1.45;
}
.auth-submit {
  width: 100%;
  margin-top: 8px;
}
.auth-switch {
  margin-top: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.auth-card .eyebrow {
  margin-bottom: 4px;
}
.auth-card-wide {
  width: min(480px, 100%);
}
.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.auth-actions .btn {
  width: 100%;
}
.auth-mail {
  font-weight: 500;
  color: var(--ink);
  word-break: break-word;
}
button.linkish {
  border: 0;
  background: none;
  padding: 0;
  color: var(--blue);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
button.linkish:hover {
  text-decoration: underline;
}

aside {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0 12px 16px 0;
  overflow: auto;
  background: var(--bg);
  border-right: 1px solid transparent;
}
.compose {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  align-self: flex-start;
  margin: 8px 0 16px 8px;
  padding: 0 24px 0 16px;
  height: 56px;
  background: var(--compose);
  color: var(--compose-ink);
  text-decoration: none;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow);
  transition:
    box-shadow 150ms ease,
    background 150ms ease;
}
.compose svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}
.compose:hover {
  background: #a8daf7;
  box-shadow: var(--shadow-lg);
}
.nav {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 32px;
  margin-right: 12px;
  padding: 0 12px 0 26px;
  border-radius: 0 16px 16px 0;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 100ms ease;
}
.nav a svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  flex: 0 0 auto;
}
.nav a:hover {
  background: rgba(32, 33, 36, 0.06);
}
.nav a.active {
  background: var(--blue-soft);
  color: var(--blue-ink);
  font-weight: 700;
}
.nav a.active svg {
  fill: var(--blue-ink);
}
.nav-menu-pop {
  position: fixed;
  z-index: 30;
  min-width: 180px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow-lg);
}
.nav-menu-pop[hidden] {
  display: none;
}
.nav-menu-pop a,
.nav-menu-pop button {
  display: flex;
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 8px 12px;
  color: inherit;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.nav-menu-pop a:hover,
.nav-menu-pop button:hover {
  background: rgba(32, 33, 36, 0.06);
}
.nav-menu-pop [data-menu="logout"] {
  color: var(--danger);
}
.nav-menu-pop [data-menu="logout"]:hover {
  background: var(--danger-soft);
}
.legal-mini {
  margin-top: auto;
  padding: 20px 16px 4px 26px;
  color: var(--faint);
  font-size: 12px;
  line-height: 1.5;
}

#contenido {
  margin: 0 16px 16px 0;
  background: var(--surface);
  border-radius: var(--radius-card);
  border: 1px solid var(--hairline);
  overflow: auto;
  padding: 0;
  min-height: 0;
  box-shadow: none;
}
.page {
  padding: 20px 24px 40px;
}
.page-flush {
  padding: 0;
}
.page-head,
.split {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}
.page-head {
  padding: 4px 0 4px;
}
.lede {
  color: var(--muted);
  margin-top: 6px;
  max-width: 68ch;
  font-size: 14px;
}
.eyebrow {
  color: var(--blue-ink);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.card {
  background: transparent;
  padding: 4px 0 8px;
}
.card.report-card,
.settings-page > .card,
.settings-page form.card,
.settings-page .logo-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 20px 22px 18px;
  box-shadow: none;
}
.card.report-card {
  padding: 16px 18px 8px;
}
.settings-page > .card + .card,
.settings-page form.card + form.card,
.settings-page form.card + .card,
.settings-page .card + form.card {
  margin-top: 12px;
}
.danger-zone {
  border-color: #f6aea9 !important;
  background: linear-gradient(180deg, #fff 0%, #fffafa 100%) !important;
}
.danger-zone h2 {
  color: var(--danger);
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  background: #f0f4f9;
  border: 1px solid transparent;
  border-radius: 16px;
  padding: 16px 18px 14px;
}
.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.note {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 12px;
}
.banner {
  background: var(--warn-soft);
  color: var(--warn);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 0 24px 16px;
  font-size: 14px;
}
.page > .banner {
  margin: 0 0 16px;
}
.list-shell > .banner {
  margin: 12px 16px 0;
}
.mail-reading > .banner {
  margin: 12px 24px 0;
}
.banner a {
  color: inherit;
  font-weight: 700;
}
.banner-ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.banner-warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.toolbar,
.filters,
.modal-actions,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.filters {
  margin: 0 0 4px;
  padding: 0 0 12px;
  gap: 8px;
}
.toolbar label,
.filters label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.btn,
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  padding: 0 24px;
  height: 36px;
  border: 1px solid transparent;
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  background: transparent;
  line-height: 20px;
  white-space: nowrap;
  transition:
    background 100ms ease,
    box-shadow 100ms ease;
}
.btn-primary {
  background: var(--blue);
  color: #fff;
  border-color: transparent;
}
.btn-primary:hover {
  background: #1765cc;
  box-shadow: var(--shadow);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: default;
  box-shadow: none;
}
.btn-ghost {
  color: var(--blue-ink);
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--blue-hover);
}
.btn-danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: transparent;
}
.btn-danger:hover {
  background: #f9d4d1;
}
.btn-danger.btn-solid,
.danger-zone .btn-danger {
  background: var(--danger);
  color: #fff;
}
.danger-zone .btn-danger:hover {
  background: #c5221f;
  box-shadow: var(--shadow);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}
.chip {
  border-color: #747775;
  color: var(--muted);
  padding: 0 16px;
  height: 32px;
  background: #fff;
  font-weight: 500;
}
.chip:hover {
  background: #f2f2f2;
}
.chip.active {
  background: var(--blue-soft);
  border-color: transparent;
  color: var(--blue-ink);
}

select.year,
.search {
  background: #fff;
  border: 1px solid #747775;
  border-radius: 4px;
  padding: 8px 12px;
  height: 36px;
  width: auto;
}
.search {
  min-width: 220px;
}
.search:focus,
select.year:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
}

/* Gmail-style mail list */
.list-shell {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px 12px;
  padding: 8px 12px 8px 16px;
  border-bottom: 1px solid var(--hairline);
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  z-index: 2;
}
.list-toolbar h1 {
  font-size: 16px;
  font-weight: 500;
  margin-right: 8px;
}
.list-toolbar .lede-inline {
  color: var(--muted);
  font-size: 13px;
  margin-right: auto;
}
.list-toolbar > div:first-child {
  min-width: 0;
  flex: 1 1 auto;
}
.list-toolbar > div:first-child .lede-inline {
  display: block;
  margin: 2px 0 0;
}
.list-toolbar > .btn,
.list-toolbar-split > .btn {
  margin-left: auto;
  flex: 0 0 auto;
  align-self: flex-start;
}
.list-toolbar-split {
  align-items: flex-start;
  justify-content: space-between;
}
.list-toolbar-end {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  max-width: 100%;
}
.list-toolbar-end label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}
.list-toolbar-end .year,
.list-toolbar-end select {
  min-width: 96px;
}
.mail-list {
  display: flex;
  flex-direction: column;
}
.mail-row {
  display: grid;
  grid-template-columns: 28px minmax(140px, 200px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px 0 12px;
  border-bottom: 1px solid var(--hairline);
  color: inherit;
  text-decoration: none;
  background: #fff;
  transition:
    box-shadow 80ms ease,
    background 80ms ease;
}
.mail-row:hover {
  z-index: 1;
  box-shadow:
    inset 1px 0 0 #dadce0,
    inset -1px 0 0 #dadce0,
    0 1px 2px 0 rgba(60, 64, 67, 0.3),
    0 1px 3px 1px rgba(60, 64, 67, 0.15);
  background: #f2f6fc;
}
.mail-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: transparent;
  justify-self: center;
}
.mail-row.is-unread .mail-dot {
  background: var(--blue);
}
.mail-row.is-unread .mail-from,
.mail-row.is-unread .mail-subject {
  font-weight: 700;
  color: var(--ink);
}
.mail-from {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  color: var(--ink);
}
.mail-snippet {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  color: var(--muted);
}
.mail-subject {
  color: var(--ink);
  font-weight: 500;
  flex: 0 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mail-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
}
.mail-preview::before {
  content: "— ";
  color: var(--faint);
}
.mail-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  flex: 0 0 auto;
  white-space: nowrap;
}
.mail-amount {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--ink);
  min-width: 5.5rem;
  text-align: right;
}
.mail-date {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  min-width: 3.6rem;
  text-align: right;
}
.mail-row.is-void {
  opacity: 0.72;
}
.mail-row.is-void .mail-amount {
  text-decoration: line-through;
  color: var(--faint);
}

.people-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--hairline);
}
.people-row:hover {
  background: #f8f9fa;
}
.people-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue-ink);
  display: grid;
  place-items: center;
  font-weight: 500;
  font-size: 16px;
}
.people-main strong {
  display: block;
  font-weight: 500;
}
.people-main span {
  color: var(--muted);
  font-size: 13px;
}
.people-actions {
  display: flex;
  gap: 4px;
}

table {
  width: 100%;
  border-collapse: collapse;
}
th {
  text-align: left;
  font-size: 12px;
  color: var(--faint);
  font-weight: 500;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
td {
  padding: 12px;
  border-bottom: 1px solid var(--hairline);
  vertical-align: middle;
}
td small {
  color: var(--faint);
}
.num,
.money {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
tbody tr:hover td {
  background: #f2f6fc;
}
td a {
  color: var(--ink);
  font-weight: 500;
  text-decoration: none;
}
td a:hover {
  color: var(--blue);
  text-decoration: underline;
}
.table-wrap {
  overflow-x: auto;
}

.estado {
  display: inline-flex;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
}
.estado-borrador {
  background: var(--draft-soft);
  color: var(--draft);
}
.estado-emitida {
  background: var(--warn-soft);
  color: var(--warn);
}
.estado-parcialmente_pagada {
  background: var(--blue-soft);
  color: var(--blue-ink);
}
.estado-pagada {
  background: var(--ok-soft);
  color: var(--ok);
}
.estado-pendiente {
  background: var(--warn-soft);
  color: var(--warn);
}
.estado-anulada {
  background: var(--danger-soft);
  color: var(--danger);
}
.profit-pos {
  color: var(--ok);
}
.profit-neg {
  color: var(--danger);
}
.estado-ingreso {
  background: var(--ok-soft);
  color: var(--ok);
}
.estado-gasto {
  background: var(--danger-soft);
  color: var(--danger);
}
.estado-login-ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.estado-login-fail {
  background: var(--danger-soft);
  color: var(--danger);
}

.handle-preview {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f8f9fa;
  border: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.handle-preview-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.handle-preview strong {
  font-size: 14px;
  font-weight: 500;
  color: var(--blue-ink);
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}

.logs-card {
  max-width: 960px;
}
.logs-table {
  width: 100%;
  border-collapse: collapse;
}
.logs-table th,
.logs-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--hairline);
  vertical-align: middle;
}
.logs-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  background: #f8f9fa;
}
.logs-table tbody tr:hover {
  background: #f6f8fc;
}
.logs-table .mono {
  font-variant-numeric: tabular-nums;
  font-family: "Roboto Mono", "SFMono-Regular", ui-monospace, Menlo, monospace;
  font-size: 13px;
}
.logs-table .muted {
  color: var(--muted);
}
.logs-table .empty-cell {
  color: var(--muted);
  text-align: center;
  padding: 28px 14px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.txn-card .chip {
  cursor: pointer;
}
.bank-book-table tr.is-pending {
  background: #fffaf5;
}
.bank-stats {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.bank-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  align-items: end;
}
.bank-filters label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--faint);
  font-weight: 500;
}
.bank-filters label.grow {
  flex: 1 1 220px;
}
.bank-filters select,
.bank-filters input {
  min-width: 180px;
}
.bank-stats {
  margin-bottom: 16px;
}
.bank-book-table td strong {
  font-weight: 500;
}
.txn-meta {
  margin-top: 2px;
  color: var(--faint);
  font-size: 12px;
}
.txn-in {
  color: var(--ok);
}
.txn-out {
  color: var(--danger);
}
.muted-cell {
  color: var(--faint);
  font-size: 12px;
}

.mail-reading .payment-box {
  margin: 16px 24px 0;
  max-width: 860px;
  padding: 20px 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.08);
}
.payment-box {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.payment-box h2 {
  margin-bottom: 12px;
}
.payment-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.payment-meta .stat {
  background: #f8f9fa;
}
.bank-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}
.bank-card strong {
  display: block;
}
.bank-card .iban {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.02em;
}
.default-tag {
  display: inline-flex;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--blue-soft);
  color: var(--blue-ink);
  font-size: 12px;
  font-weight: 500;
}
.logo-card .help {
  margin-top: 4px;
  margin-bottom: 0;
}
.logo-frame {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 88px;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #fafafa;
}
.logo-preview {
  max-height: 72px;
  max-width: min(280px, 100%);
  object-fit: contain;
}
.logo-placeholder {
  color: var(--faint);
  font-size: 13px;
}
.logo-card label.btn {
  cursor: pointer;
}

.editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
}
.editor .card,
#emisor-form.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px 20px;
  background: #fff;
}
.summary {
  position: sticky;
  top: 12px;
  background: #f0f4f9;
  border: 0;
}
.summary h2 {
  font-size: 28px;
  font-weight: 400;
  color: var(--blue-ink);
}
.totals {
  max-width: 320px;
  margin-left: auto;
  margin-top: 16px;
}
.totals div,
.summary-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  font-variant-numeric: tabular-nums;
}
.grand {
  border-top: 1px solid var(--ink);
  margin-top: 6px;
  padding-top: 10px;
  font-size: 18px;
  font-weight: 500;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field > span {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}
.req {
  color: var(--danger);
}
#contenido input,
#contenido select,
#contenido textarea,
.modal input,
.modal select,
.modal textarea {
  width: 100%;
  background: #fff;
  border: 1px solid #747775;
  border-radius: 4px;
  padding: 10px 12px;
}
#contenido textarea,
.modal textarea {
  min-height: 72px;
  resize: vertical;
}
#contenido input:focus,
#contenido select:focus,
#contenido textarea:focus,
.modal input:focus,
.modal select:focus,
.modal textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
}
#contenido .search,
#contenido select.year {
  width: auto;
}
.field-error {
  color: var(--danger);
  font-size: 12px;
}
.help {
  color: var(--muted);
  font-size: 12px;
  margin-top: -4px;
  margin-bottom: 12px;
}
.lines-head,
.line {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 90px 120px 110px 36px;
  gap: 8px;
  align-items: start;
}
.lines-head {
  color: var(--faint);
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 6px;
}
.line {
  margin-bottom: 8px;
}
.line-total {
  padding-top: 10px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.code-field {
  position: relative;
}
.code-menu {
  position: absolute;
  z-index: 6;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  min-width: 240px;
  max-height: 240px;
  overflow: auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow-lg);
}
.code-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 8px 10px;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.code-option small {
  color: var(--muted);
  font-size: 12px;
}
.code-option.is-active,
.code-option:hover {
  background: var(--blue-hover);
}
.catalog-card {
  padding: 8px 8px 16px;
}
.catalog-head,
.catalog-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) 140px auto;
  gap: 8px;
  align-items: start;
}
.catalog-head {
  padding: 8px 8px 4px;
  color: var(--faint);
  font-size: 12px;
  font-weight: 500;
}
.catalog-row {
  padding: 8px;
  border-top: 1px solid var(--hairline);
}
.catalog-actions {
  display: flex;
  gap: 8px;
  padding-top: 2px;
}
@media (max-width: 720px) {
  .catalog-head {
    display: none;
  }
  .catalog-row,
  .catalog-actions {
    grid-template-columns: 1fr;
  }
  .catalog-row {
    display: grid;
  }
}
.icon-btn {
  width: 36px;
  height: 42px;
  border: 0;
  background: transparent;
  color: var(--danger);
  font-size: 20px;
  border-radius: 50%;
}
.icon-btn:hover {
  background: var(--danger-soft);
}

.mail-reading {
  padding: 0 0 40px;
}
.mail-reading .actions {
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--hairline);
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  z-index: 2;
  gap: 8px;
}
.actions-right {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
  justify-content: flex-end;
}
.mail-reading .banner {
  margin: 12px 24px 0;
}
.sheet {
  position: relative;
  margin: 16px 24px 0;
  padding: 32px 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: 860px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.08);
}
.sheet-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}
.parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin: 20px 0;
}
.parties h3 {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--blue-ink);
  font-weight: 500;
}
.stamp {
  position: absolute;
  right: 48px;
  top: 168px;
  border: 2px solid var(--danger);
  color: var(--danger);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 6px 10px;
  transform: rotate(-12deg);
  border-radius: 4px;
  pointer-events: none;
}

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(32, 33, 36, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 30;
}
.modal {
  width: min(520px, 100%);
  padding: 24px;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 8px 28px rgba(32, 33, 36, 0.28);
}
.modal.modal-wide,
.modal-back .modal-wide {
  width: min(920px, 100%);
  max-height: min(86vh, 900px);
  overflow: auto;
}
.ledger-modal .split {
  align-items: flex-start;
  margin-bottom: 16px;
}
.ledger-table-wrap {
  margin-top: 4px;
}
.ledger-summary {
  margin: 0 0 14px;
}
.ledger-modal tr.is-opening td {
  background: #f8fafc;
  font-weight: 500;
}
.btn-compact {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 999px;
}
.modal h2 {
  font-size: 22px;
  font-weight: 400;
}
.modal p {
  margin: 12px 0 20px;
  color: var(--muted);
}
.modal-actions {
  justify-content: flex-end;
}
.toast {
  position: fixed;
  left: 24px;
  bottom: 24px;
  background: #323232;
  color: #fff;
  padding: 14px 16px;
  border-radius: 4px;
  z-index: 40;
  max-width: min(480px, calc(100% - 32px));
  box-shadow: var(--shadow-lg);
  font-size: 14px;
}
.empty,
.loading {
  padding: 48px 24px;
  color: var(--muted);
  text-align: center;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wide {
  grid-column: 1 / -1;
}
.section-pad {
  padding: 8px 24px 24px;
}

@media (max-width: 1100px) {
  .stats {
    grid-template-columns: 1fr 1fr;
  }
  .mail-row {
    grid-template-columns: 20px minmax(100px, 140px) minmax(0, 1fr) auto;
  }
}
@media (max-width: 980px) {
  .editor,
  .parties,
  .form-grid {
    grid-template-columns: 1fr;
  }
  .summary {
    position: static;
  }
}
@media (max-width: 800px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(0, 1fr);
    height: 100vh;
  }
  .brand {
    width: auto;
  }
  .wordmark {
    display: none;
  }
  .top-search {
    min-width: 0;
    height: 40px;
    margin: 0 4px;
  }
  .top-search input {
    font-size: 14px;
    height: 38px;
  }
  .top-actions .icon-round[href="#/ajustes"] {
    display: none;
  }
  .settings-layout {
    grid-template-columns: 1fr;
  }
  .settings-nav {
    border-right: 0;
    border-bottom: 1px solid var(--hairline);
    flex-direction: row;
    flex-wrap: wrap;
    padding: 12px 16px;
  }
  aside {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 0 8px 8px;
    overflow: auto;
  }
  .compose {
    margin: 0;
    height: 40px;
    padding: 0 14px 0 12px;
    white-space: nowrap;
  }
  .compose span {
    display: none;
  }
  .nav {
    flex-direction: row;
  }
  .nav a {
    border-radius: 16px;
    padding: 0 12px;
    margin: 0;
    height: 36px;
    white-space: nowrap;
  }
  .nav a span {
    display: none;
  }
  .legal-mini {
    display: none;
  }
  #contenido {
    margin: 0 8px 8px;
    border-radius: 12px;
  }
  .page {
    padding: 16px 14px 32px;
  }
  .sheet {
    margin: 12px 12px 0;
    padding: 20px 14px;
  }
  .mail-reading .banner {
    margin: 12px;
  }
  .mail-row {
    grid-template-columns: 12px minmax(0, 1fr) auto;
    gap: 6px;
    padding: 8px 12px;
    min-height: 52px;
  }
  .mail-from {
    display: none;
  }
  .mail-meta {
    grid-column: 3;
    grid-row: 1;
  }
  .mail-snippet {
    grid-column: 2;
  }
  .mail-amount {
    min-width: 0;
  }
  .list-toolbar {
    padding: 8px;
  }
  .lines-head {
    display: none;
  }
  .line {
    grid-template-columns: 1fr 1fr;
  }
  .line textarea,
  .line .code-field {
    grid-column: 1 / -1;
  }
  .stats {
    grid-template-columns: 1fr;
  }
  .section-pad {
    padding: 8px 14px 24px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Informes */
.report-list-toolbar {
  margin: 0 0 16px;
  padding: 4px 0 8px;
}
.report-list-toolbar .list-toolbar-end {
  flex-wrap: wrap;
}
.report-list-toolbar .report-range-select,
.report-list-toolbar select.year {
  min-width: 140px;
}
.report-page .report-head {
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 12px;
}
.report-head-copy {
  min-width: 0;
  flex: 1 1 auto;
}
.report-head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 10px;
  flex: 0 0 auto;
}
.report-year-field {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--faint);
  font-weight: 500;
}
.report-year-field select {
  min-width: 110px;
}
.report-toolbar {
  margin: 0 0 16px;
}
.report-filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: 12px;
}
.report-filters-bar label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--faint);
  font-weight: 500;
}
.report-filters-bar label.grow {
  flex: 1 1 240px;
}
.report-filters-bar input,
.report-filters-bar select {
  min-width: 140px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  background: #f8fafc;
}
.report-filters-bar input:focus,
.report-filters-bar select:focus {
  outline: none;
  border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 3px var(--blue-soft);
}
.report-filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}
.report-filters-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
}
.report-split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.report-table-card {
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 4px 8px 8px;
  margin-top: 4px;
}
.report-page .card.report-card {
  margin-top: 12px;
}
.report-tabs {
  display: flex;
  gap: 4px;
  margin: 0 0 18px;
  padding: 4px;
  width: fit-content;
  max-width: 100%;
  background: #f0f4f9;
  border-radius: 999px;
  border: 1px solid var(--hairline);
}
.report-tab {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 16px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
}
.report-tab:hover {
  background: rgba(32, 33, 36, 0.06);
  color: var(--ink);
}
.report-tab.active {
  background: var(--surface);
  color: var(--blue-ink);
  box-shadow: var(--shadow);
}
.report-filters {
  margin-bottom: 16px;
}
.report-table {
  width: 100%;
}
.report-table tfoot th {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  font-weight: 700;
}
.report-stats {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.report-stats .stat {
  background: #fff;
  border: 1px solid var(--hairline);
  border-radius: 12px;
}
@media (max-width: 980px) {
  .report-split-grid {
    grid-template-columns: 1fr;
  }
  .report-head-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

.health-kpis .stat {
  position: relative;
  min-height: 92px;
}
.health-kpi-meta {
  display: block;
  margin-top: 6px;
  font-style: normal;
  font-size: 12px;
  color: var(--faint);
  font-weight: 400;
}
.health-charts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.health-chart-card {
  padding: 18px 18px 12px;
}
.health-chart-card .help {
  margin: 0 0 12px;
}
.health-chart svg {
  display: block;
  width: 100%;
  height: auto;
}
.health-grid {
  stroke: var(--hairline);
  stroke-width: 1;
}
.health-axis {
  fill: var(--faint);
  font-size: 10px;
  font-family: var(--sans);
}
.health-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
}
.health-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.health-legend-item i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}
.health-chart-empty {
  padding: 36px 12px;
  text-align: center;
  color: var(--muted);
}
.health-partner-search {
  display: block;
  margin-bottom: 12px;
}
.health-partner-search input {
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  background: #f8fafc;
}
.health-partner-search input:focus {
  outline: none;
  border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 3px var(--blue-soft);
}
.health-partner-hits {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.health-partner-hit {
  text-align: left;
  border: 1px solid var(--hairline);
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.health-partner-hit:hover {
  border-color: var(--blue-soft);
  background: var(--blue-hover);
}
.health-partner-kind {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.health-partner-card {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--hairline);
}
.health-partner-stats {
  margin-top: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.health-partner-card h3 {
  margin: 8px 0 10px;
  font-size: 14px;
  font-weight: 500;
}

@media (max-width: 980px) {
  .health-charts {
    grid-template-columns: 1fr;
  }
  .health-partner-stats {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    background: white;
  }
  .skip,
  .topbar,
  aside,
  .no-print,
  .toast,
  #dialogo,
  .report-tabs {
    display: none !important;
  }
  .app {
    display: block;
    height: auto;
  }
  #contenido {
    margin: 0;
    border: 0;
    border-radius: 0;
    overflow: visible;
    box-shadow: none;
  }
  .page {
    padding: 0;
  }
  .card.report-card,
  .stat {
    break-inside: avoid;
  }
  a {
    color: inherit;
    text-decoration: none;
  }
}
