:root {
  --max-width: 1220px;
  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 10px;

  --bg: #f5f2e9;
  --bg-soft: #fbf8f2;
  --paper: rgba(255, 255, 255, 0.9);
  --paper-strong: #ffffff;
  --paper-muted: #f3efe6;

  --text: #1f2937;
  --text-strong: #101828;
  --text-secondary: #6b7280;
  --text-muted: #94a3b8;

  --primary: #167c5a;
  --primary-strong: #0f5f45;
  --primary-soft: rgba(22, 124, 90, 0.11);
  --secondary: #167c5a;
  --accent: #d89f32;
  --danger: #c2410c;
  --danger-soft: rgba(194, 65, 12, 0.1);

  --border: rgba(15, 23, 42, 0.1);
  --border-strong: rgba(15, 23, 42, 0.16);
  --shadow: 0 18px 48px rgba(53, 41, 24, 0.08);
  --shadow-soft: 0 10px 24px rgba(53, 41, 24, 0.06);

  --focus: 0 0 0 4px rgba(22, 124, 90, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  line-height: 1.55;
  background:
    radial-gradient(circle at top left, rgba(216, 159, 50, 0.14), transparent 24rem),
    radial-gradient(circle at top right, rgba(22, 124, 90, 0.12), transparent 22rem),
    linear-gradient(180deg, #fbf8f2 0%, #f4efe6 100%);
  color: var(--text);
}

body.theme-dark {
  color-scheme: dark;
  --bg: #0f141b;
  --bg-soft: #151c25;
  --paper: rgba(20, 27, 36, 0.9);
  --paper-strong: #16202b;
  --paper-muted: #1a2330;
  --text: #dde7f3;
  --text-strong: #f4f7fb;
  --text-secondary: #a9b8cb;
  --text-muted: #7d91aa;
  --primary: #34c48b;
  --primary-strong: #1ea06d;
  --primary-soft: rgba(52, 196, 139, 0.16);
  --secondary: #56d4a2;
  --accent: #f0b44a;
  --danger: #ff8a6b;
  --danger-soft: rgba(255, 138, 107, 0.16);
  --border: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.28);
  --shadow: 0 24px 56px rgba(0, 0, 0, 0.42);
  --shadow-soft: 0 14px 32px rgba(0, 0, 0, 0.32);
  --focus: 0 0 0 4px rgba(52, 196, 139, 0.22);

  background:
    radial-gradient(circle at top left, rgba(240, 180, 74, 0.08), transparent 24rem),
    radial-gradient(circle at top right, rgba(52, 196, 139, 0.14), transparent 22rem),
    linear-gradient(180deg, #10161d 0%, #0c1117 100%);
}

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

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

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.92em;
  background: rgba(15, 23, 42, 0.05);
  color: var(--text-strong);
  padding: 0.12rem 0.42rem;
  border-radius: 999px;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.2rem;
}

.main-shell {
  padding-top: 2rem;
  padding-bottom: 3rem;
}

.app-footer {
  padding: 0 0 1.8rem;
}

.app-footer-shell {
  display: flex;
  justify-content: center;
}

.app-footer p {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.9rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.54);
  color: var(--text-secondary);
  box-shadow: 0 10px 24px rgba(53, 41, 24, 0.05);
  text-align: center;
}

.app-footer strong {
  color: var(--text-strong);
}

.muted {
  color: var(--text-secondary);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Manrope", "IBM Plex Sans", sans-serif;
  color: var(--text-strong);
  letter-spacing: -0.03em;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.15rem);
  font-weight: 800;
  line-height: 1.02;
}

h2 {
  font-size: 1.35rem;
  font-weight: 800;
}

h3 {
  font-size: 1.05rem;
  font-weight: 800;
}

p {
  margin: 0;
}

.stack-sm,
.stack-md,
.stack-lg {
  display: grid;
}

.stack-sm {
  gap: 0.65rem;
}

.stack-md {
  gap: 1rem;
}

.stack-lg {
  gap: 1.5rem;
}

.page-kicker,
.dashboard-eyebrow,
.invoice-action-bar-label,
.invoice-action-section-label,
.settings-summary-item span,
.invoice-items-th {
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.page-header,
.dashboard-hero,
.settings-hero,
.invoice-editor-page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.page-header-copy,
.dashboard-lead,
.settings-hero-copy,
.invoice-editor-subtitle {
  max-width: 52rem;
  color: var(--text-secondary);
}

.page-header-copy {
  display: grid;
  gap: 0.55rem;
}

.page-header-actions,
.dashboard-actions,
.settings-hero-actions,
.settings-action-row,
.toolbar,
.form-actions,
.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: center;
}

.backlink,
.invoice-editor-backlink {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.backlink:hover,
.invoice-editor-backlink:hover {
  color: var(--text-strong);
}

.card,
.surface,
.invoice-action-bar,
.invoice-editor-surface,
.invoice-editor-empty-state {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.86));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.card,
.surface {
  padding: 1.2rem 1.25rem;
}

.surface-muted,
.settings-summary-item,
.vat-threshold,
.dashboard-link-tile {
  background: var(--paper-muted);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 16px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 1rem 0 0;
}

.topbar-shell {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.8rem 1.2rem;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  color: var(--text-strong);
}

.brand-mark {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, var(--primary), var(--primary-strong));
  color: #fff;
  font-family: "Manrope", sans-serif;
  font-weight: 800;
  font-size: 1.1rem;
  box-shadow: 0 12px 24px rgba(22, 124, 90, 0.22);
}

.brand-copy {
  display: grid;
  gap: 0.08rem;
}

.brand-copy strong {
  font-family: "Manrope", sans-serif;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.brand-copy small {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.nav-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  justify-self: end;
  width: 100%;
  max-width: none;
  gap: 0.8rem;
}

.nav-toggle {
  display: none;
}

.nav-toggle-btn {
  display: none;
  user-select: none;
  cursor: pointer;
  width: 2.8rem;
  height: 2.8rem;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--text-strong);
  font-size: 1.15rem;
  line-height: 1;
}

.nav {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.2rem;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
}

.nav a {
  padding: 0.52rem 0.72rem;
  border-radius: 999px;
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
  font-size: 0.98rem;
}

.nav a:hover {
  background: rgba(15, 23, 42, 0.05);
  color: var(--text-strong);
}

.nav a.active {
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.user-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.45rem;
  align-items: center;
  justify-content: flex-end;
  justify-self: end;
  min-width: 0;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.05);
  color: var(--text-strong);
  font-weight: 600;
}

.subject-switcher {
  position: relative;
}

.subject-switcher summary {
  list-style: none;
}

.subject-switcher summary::-webkit-details-marker {
  display: none;
}

.subject-switcher-summary {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.9rem;
  max-width: 13.5rem;
  padding: 0.46rem 0.72rem 0.46rem 0.82rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--text-strong);
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

.subject-switcher[open] .subject-switcher-summary {
  border-color: rgba(22, 124, 90, 0.24);
  box-shadow: 0 20px 44px rgba(15, 23, 42, 0.14);
}

.subject-switcher-copy {
  display: grid;
  gap: 0.02rem;
  min-width: 0;
  text-align: left;
}

.subject-switcher-user {
  font-weight: 700;
  line-height: 1.1;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subject-switcher-org {
  display: block;
  color: var(--text-secondary);
  font-size: 0.72rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subject-switcher-caret {
  color: var(--text-secondary);
  font-size: 0.74rem;
  flex: 0 0 auto;
  transition: transform 0.18s ease;
}

.subject-switcher[open] .subject-switcher-caret {
  transform: rotate(180deg);
}

.subject-switcher-menu {
  position: absolute;
  top: calc(100% + 0.55rem);
  right: 0;
  width: min(22rem, calc(100vw - 2rem));
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 22px 54px rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(16px);
}

.subject-switcher-menu-head {
  display: grid;
  gap: 0.15rem;
  margin-bottom: 0.55rem;
}

.subject-switcher-menu-head strong {
  font-size: 0.9rem;
}

.subject-switcher-menu-head span,
.subject-switcher-empty {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.subject-switcher-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  width: 100%;
  padding: 0.7rem 0.75rem;
  border-radius: 16px;
  color: var(--text-strong);
}

.subject-switcher-item:hover {
  background: rgba(15, 23, 42, 0.04);
}

.subject-switcher-item + .subject-switcher-item,
.subject-switcher-item + .subject-switcher-empty,
.subject-switcher-empty + .subject-switcher-manage {
  margin-top: 0.2rem;
}

.subject-switcher-item-copy {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.subject-switcher-item-copy strong {
  font-size: 0.92rem;
  line-height: 1.2;
}

.subject-switcher-item-copy small {
  color: var(--text-secondary);
  font-size: 0.78rem;
  line-height: 1.25;
}

.subject-switcher-item.is-current {
  background: rgba(22, 124, 90, 0.08);
  border: 1px solid rgba(22, 124, 90, 0.12);
}

.subject-switcher-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.3rem 0.56rem;
  border-radius: 999px;
  background: rgba(22, 124, 90, 0.14);
  color: var(--primary-strong);
  font-size: 0.74rem;
  font-weight: 700;
}

.subject-switcher-manage {
  display: inline-flex;
  margin-top: 0.55rem;
  color: var(--primary-strong);
  font-size: 0.84rem;
  font-weight: 600;
}

.user-actions .btn.small.subtle {
  min-height: 2.9rem;
  padding-inline: 0.8rem;
  border-radius: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  -webkit-appearance: none;
  appearance: none;
  min-height: 2.75rem;
  padding: 0.65rem 0.92rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  text-decoration: none;
  color: var(--text-strong);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset;
  font-weight: 700;
  font: inherit;
  font-size: 0.98rem;
  line-height: 1.2;
  letter-spacing: 0;
  white-space: nowrap;
  opacity: 1;
  background-clip: padding-box;
  cursor: pointer;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  transition:
    background-color 120ms ease,
    border-color 120ms ease,
    color 120ms ease,
    box-shadow 120ms ease,
    filter 120ms ease;
}

.btn:hover {
  background: #fff;
  border-color: var(--border-strong);
  color: var(--text-strong);
}

.btn.primary {
  background: linear-gradient(145deg, var(--primary), var(--primary-strong));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 14px 26px rgba(22, 124, 90, 0.22);
}

.btn.primary:hover {
  filter: brightness(1.03);
}

summary.btn,
button.btn,
input.btn,
input[type="submit"].btn,
input[type="button"].btn {
  -webkit-appearance: none;
  appearance: none;
}

.btn.subtle {
  background: transparent;
  box-shadow: none;
}

.btn.small {
  min-height: 2.2rem;
  padding: 0.45rem 0.75rem;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.2;
}

.btn[disabled],
button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn:focus,
input:focus,
select:focus,
textarea:focus {
  outline: none;
  box-shadow: var(--focus);
}

.dashboard-grid,
.settings-shell,
.settings-grid {
  display: grid;
  gap: 1.15rem;
}

.dashboard-hero {
  padding: 1.45rem 1.5rem;
}

.dashboard-actions {
  justify-content: flex-end;
}

.dashboard-link-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.95rem;
}

.dashboard-link-tile {
  display: grid;
  gap: 0.35rem;
  padding: 1rem 1.05rem;
  color: inherit;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.dashboard-link-tile strong {
  font-family: "Manrope", sans-serif;
  font-size: 1rem;
  color: var(--text-strong);
}

.dashboard-link-tile span {
  color: var(--text-secondary);
}

.dashboard-link-tile:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.dashboard-health {
  display: grid;
  gap: 0.6rem;
}

.dashboard-health-compact {
  padding: 1rem 1.15rem;
}

.dashboard-health-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 1.4rem;
  align-items: center;
}

.dashboard-recent {
  display: grid;
  gap: 0.8rem;
}

.dashboard-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.dashboard-invoice-list {
  display: grid;
  gap: 0.55rem;
}

.dashboard-invoice-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.72rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--paper-muted);
  color: inherit;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.dashboard-invoice-row:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
  border-color: var(--border-strong);
}

.dashboard-invoice-main,
.dashboard-invoice-meta {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
}

.dashboard-invoice-main strong,
.dashboard-invoice-meta strong {
  color: var(--text-strong);
}

.dashboard-invoice-main span,
.dashboard-invoice-meta span {
  color: var(--text-secondary);
}

.dashboard-invoice-meta {
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  align-items: center;
  justify-items: end;
  text-align: right;
  gap: 0.7rem;
}

.vat-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.vat-card-head h2 {
  font-size: 2rem;
}

.vat-badge,
.badge,
.invoice-action-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.36rem 0.72rem;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(15, 23, 42, 0.04);
  color: var(--text-secondary);
  font-weight: 700;
  white-space: nowrap;
}

.vat-badge-ok {
  background: rgba(22, 124, 90, 0.12);
  color: var(--primary-strong);
}

.vat-badge-warning {
  background: rgba(216, 159, 50, 0.14);
  color: #9d6400;
}

.vat-badge-critical,
.badge.overdue {
  background: var(--danger-soft);
  color: var(--danger);
}

.vat-badge-payer {
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
}

.vat-threshold-list,
.settings-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.vat-threshold {
  padding: 0.95rem 1rem;
}

.vat-threshold span,
.vat-threshold p {
  color: var(--text-secondary);
}

.vat-threshold strong {
  color: var(--text-strong);
}

.vat-threshold.is-reached {
  background: rgba(216, 159, 50, 0.16);
  border-color: rgba(216, 159, 50, 0.28);
}

.vat-threshold-labels {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  justify-content: space-between;
}

.vat-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 1rem;
  margin: 0.2rem 0 0.85rem;
  color: var(--text-secondary);
}

.settings-hero {
  padding: 1.35rem 1.45rem;
}

.settings-grid-top,
.settings-grid-meta,
.settings-grid-bank,
.settings-grid-subjects {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.settings-grid-subjects > :first-child {
  grid-column: 1 / -1;
}

.settings-card,
.settings-section-card {
  margin-bottom: 0;
}

.admin-hero {
  display: grid;
  gap: 1.2rem;
}

.admin-kicker {
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.admin-hero-grid {
  align-items: stretch;
}

.admin-notice {
  margin: 1rem 0;
}

.admin-overview-grid,
.admin-tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.admin-overview-grid {
  margin-bottom: 1rem;
}

.admin-section-card,
.admin-subject-section,
.admin-tech-card {
  display: grid;
  gap: 1rem;
}

.admin-subject-grid,
.admin-note-list,
.admin-manageable-list,
.admin-user-list {
  display: grid;
  gap: 0.95rem;
}

.admin-subject-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-subject-tile,
.admin-note-card,
.admin-user-card,
.admin-tool-card {
  display: grid;
  gap: 0.8rem;
  padding: 1rem;
}

.admin-subject-tile-head,
.admin-user-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
}

.admin-subject-tile h3,
.admin-note-card strong,
.admin-user-card strong {
  margin: 0;
  color: var(--text-strong);
}

.admin-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.admin-note-list {
  align-content: start;
}

.admin-note-card p,
.admin-user-hint {
  margin: 0;
}

.admin-form-grid {
  margin-bottom: 0.2rem;
}

.admin-inline-details,
.admin-tool-card {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.32);
}

.admin-inline-details {
  padding: 0.85rem 0.95rem;
}

.admin-tool-card {
  padding: 0;
}

.admin-inline-details summary,
.admin-tool-card summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-weight: 700;
  color: var(--text-strong);
}

.admin-inline-details summary::-webkit-details-marker,
.admin-tool-card summary::-webkit-details-marker {
  display: none;
}

.admin-inline-details summary::after,
.admin-tool-card summary::after {
  content: "+";
  color: var(--text-secondary);
  font-size: 1.15rem;
  line-height: 1;
}

.admin-inline-details[open] summary::after,
.admin-tool-card[open] summary::after {
  content: "−";
}

.admin-inline-details[open] summary {
  margin-bottom: 0.85rem;
}

.admin-tool-card summary {
  padding: 1rem 1rem 0;
}

.admin-tool-card[open] summary {
  margin-bottom: 0.35rem;
}

.admin-tool-card > p,
.admin-tool-card > form {
  padding: 0 1rem 1rem;
}

.admin-delete-form {
  margin-top: 0.7rem;
}

.admin-access-form-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0 1rem;
}

.admin-access-checks {
  display: grid;
  gap: 0.35rem;
  align-content: start;
}

.settings-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.settings-source {
  max-width: 20rem;
  text-align: right;
}

.settings-section-copy,
.settings-form-note {
  color: var(--text-secondary);
}

.settings-summary-item {
  padding: 0.95rem 1rem;
}

.settings-account-list {
  display: grid;
  gap: 0.95rem;
}

.settings-account-card {
  display: grid;
  gap: 0.95rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--paper-muted);
  box-shadow: var(--shadow-soft);
}

.settings-account-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.settings-account-title {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  margin-bottom: 0.18rem;
}

.settings-account-subtitle {
  word-break: break-word;
}

.settings-account-meta {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.settings-account-edit {
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  padding-top: 0.85rem;
}

.settings-account-edit summary {
  font-weight: 700;
}

.settings-account-edit-form {
  margin-top: 0.95rem;
}

.settings-sync-box {
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.55);
}

.settings-api-docs,
.settings-api-token-list {
  display: grid;
  gap: 0.9rem;
}

.settings-link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.settings-token-created {
  display: grid;
  gap: 0.55rem;
  padding: 1rem;
  border: 1px solid rgba(22, 124, 90, 0.2);
  border-radius: 18px;
  background: rgba(22, 124, 90, 0.08);
}

.settings-token-created code {
  display: block;
  padding: 0.85rem 0.95rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
  overflow-wrap: anywhere;
}

.settings-api-token-card {
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--paper-muted);
}

.settings-api-token-head,
.settings-inline-form {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
}

.settings-inline-form {
  justify-content: flex-start;
}

.settings-sync-box-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.settings-form-grid-span-2 {
  grid-column: span 2;
}

.settings-account-card code {
  white-space: normal;
  overflow-wrap: anywhere;
}

.theme-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.theme-option-card {
  display: block;
  position: relative;
  cursor: pointer;
}

.theme-option-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-option-card-ui {
  display: grid;
  gap: 0.8rem;
  min-height: 100%;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--paper-muted);
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease, background 120ms ease;
}

.theme-option-card:hover .theme-option-card-ui {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.theme-option-card input:checked + .theme-option-card-ui {
  border-color: rgba(22, 124, 90, 0.32);
  box-shadow: var(--focus);
  background: linear-gradient(180deg, rgba(22, 124, 90, 0.08), rgba(255, 255, 255, 0.88));
}

.theme-option-preview {
  display: grid;
  gap: 0.55rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 14px;
}

.theme-option-preview-bar {
  display: block;
  height: 0.48rem;
  width: 56%;
  border-radius: 999px;
}

.theme-option-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

.theme-option-preview-grid span {
  display: block;
  min-height: 2.35rem;
  border-radius: 12px;
}

.theme-option-preview-light {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(243, 239, 230, 0.9));
}

.theme-option-preview-light .theme-option-preview-bar {
  background: linear-gradient(145deg, #167c5a, #0f5f45);
}

.theme-option-preview-light .theme-option-preview-grid span:nth-child(1) {
  background: #ffffff;
}

.theme-option-preview-light .theme-option-preview-grid span:nth-child(2) {
  background: #f3efe6;
}

.theme-option-preview-light .theme-option-preview-grid span:nth-child(3) {
  background: rgba(22, 124, 90, 0.12);
}

.theme-option-preview-dark {
  background: linear-gradient(180deg, rgba(28, 37, 49, 0.94), rgba(18, 24, 34, 0.98));
}

.theme-option-preview-dark .theme-option-preview-bar {
  background: linear-gradient(145deg, #34c48b, #1ea06d);
}

.theme-option-preview-dark .theme-option-preview-grid span:nth-child(1) {
  background: #202b38;
}

.theme-option-preview-dark .theme-option-preview-grid span:nth-child(2) {
  background: #17212c;
}

.theme-option-preview-dark .theme-option-preview-grid span:nth-child(3) {
  background: rgba(52, 196, 139, 0.18);
}

.theme-option-copy {
  display: grid;
  gap: 0.22rem;
}

.theme-option-copy strong {
  color: var(--text-strong);
  font-family: "Manrope", sans-serif;
  font-size: 1rem;
}

.theme-option-copy small {
  color: var(--text-secondary);
  font-size: 0.92rem;
}

.settings-summary-item strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--text-strong);
  font-weight: 700;
}

.settings-summary-item-wide {
  grid-column: 1 / -1;
}

.settings-form-wide,
.settings-card .form {
  max-width: none;
}

.settings-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 1rem;
}

.form {
  max-width: 560px;
}

.form-row {
  margin-bottom: 1rem;
}

.form-row-checkbox {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.2rem 0;
}

.form-row-checkbox label {
  margin-bottom: 0;
}

.form-row-checkbox input {
  flex: 0 0 auto;
}

label {
  display: block;
  margin-bottom: 0.42rem;
  color: var(--text-secondary);
  font-size: 0.94rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.78rem 0.88rem;
  color: var(--text-strong);
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 14px;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.8);
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  padding: 0;
  background: transparent;
  border: none;
}

input::placeholder,
textarea::placeholder {
  color: rgba(107, 114, 128, 0.7);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.checkbox-inline {
  display: inline-flex;
  gap: 0.55rem;
  align-items: center;
  color: var(--text-strong);
  font-weight: 600;
}

.checkbox-inline input {
  accent-color: var(--primary);
}

.recipient-shortcuts,
.settings-table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.settings-table-actions form,
.invoice-action-section-buttons form {
  display: inline-flex;
}

.filters {
  display: grid;
  gap: 0.95rem;
}

.filters-row {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 0.9rem;
  align-items: end;
}

.filters-row .field {
  grid-column: span 3;
  min-width: 0;
}

.filters-row .field.checkbox {
  grid-column: span 2;
}

.filters-row .field.actions {
  grid-column: span 4;
}

.filters-summary {
  color: var(--text-secondary);
}

.bulk-toolbar-card {
  padding: 1rem 1.1rem;
}

.recurring-empty-state {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
}

.recurring-plan-row {
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  padding-bottom: 0.85rem;
}

.recurring-plan-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.bulk-toolbar-form {
  display: block;
}

.bulk-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem 1rem;
  flex-wrap: wrap;
}

.bulk-toolbar-copy {
  display: grid;
  gap: 0.15rem;
}

.bulk-toolbar-copy strong {
  font-size: 1rem;
}

.bulk-toolbar-copy span {
  color: var(--text-secondary);
  font-size: 0.86rem;
}

.bulk-toolbar-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.bulk-toolbar-controls select {
  min-width: 14rem;
}

.bulk-toolbar-select-all {
  white-space: nowrap;
}

.table-wrap {
  overflow-x: auto;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
}

.table th,
.table td {
  padding: 0.88rem 1rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  text-align: left;
  vertical-align: top;
}

.selection-cell {
  width: 3rem;
  padding-right: 0.5rem;
  padding-left: 0.85rem;
}

.selection-cell input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
}

.table th {
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(243, 239, 230, 0.78);
}

.table tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover td {
  background: rgba(22, 124, 90, 0.03);
}

.table tbody tr.bulk-row-selected td {
  background: rgba(22, 124, 90, 0.08);
}

.row-overdue td {
  background: rgba(194, 65, 12, 0.05);
}

.notice {
  padding: 0.95rem 1rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--border-strong);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
}

.notice.success,
.settings-notice-success {
  border-left-color: var(--primary);
}

.notice.error,
.settings-notice-error {
  border-left-color: var(--danger);
}

.empty-state {
  padding: 1.4rem 1.5rem;
  border: 1px dashed rgba(15, 23, 42, 0.16);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.45);
  color: var(--text-secondary);
}

.pagination {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: wrap;
}

.pagination .btn[aria-current="page"],
.pagination .btn.primary[aria-current="page"] {
  pointer-events: none;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}

.invoice-detail-overview {
  display: grid;
  gap: 1rem;
}

.invoice-detail-sheet {
  display: grid;
  gap: 1rem;
  padding: 1.2rem 1.35rem;
}

.invoice-detail-hero {
  display: grid;
  gap: 0.9rem;
  padding: 1.15rem 1.35rem;
}

.invoice-detail-hero-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.invoice-detail-hero-copy {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

.invoice-detail-hero-title {
  font-size: clamp(2rem, 3.4vw, 2.8rem);
  line-height: 0.98;
}

.invoice-detail-hero-subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
}

.invoice-detail-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.invoice-detail-hero-actions form {
  margin: 0;
}

.invoice-detail-more {
  position: relative;
}

.invoice-detail-more summary {
  list-style: none;
}

.invoice-detail-more summary::-webkit-details-marker {
  display: none;
}

.invoice-detail-more[open] .btn {
  box-shadow: var(--focus);
}

.invoice-detail-more-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.55rem);
  z-index: 20;
  min-width: 240px;
  display: grid;
  gap: 0.55rem;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--paper-strong);
  box-shadow: var(--shadow);
}

.invoice-detail-more-menu form {
  margin: 0;
}

.invoice-detail-more-menu .btn,
.invoice-detail-more-menu .btn.small {
  justify-content: flex-start;
  width: 100%;
}

.app-dialog {
  width: min(760px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  border: none;
  background: transparent;
}

.app-dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(2px);
}

.app-dialog-card {
  display: grid;
  gap: 1rem;
  padding: 1.15rem 1.2rem 1.2rem;
  max-height: calc(100vh - 2rem);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--paper-strong);
  box-shadow: var(--shadow);
}

.app-dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.app-dialog-body {
  display: grid;
  gap: 1rem;
  max-height: calc(100vh - 10rem);
  overflow-y: auto;
  padding-right: 0.15rem;
}

.app-dialog .form {
  max-width: none;
}

.app-dialog .form-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  justify-content: flex-end;
  margin-top: 0.5rem;
  padding-top: 0.95rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), var(--paper-strong) 32%);
}

.invoice-detail-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.invoice-detail-sheet-title {
  display: grid;
  gap: 0.35rem;
}

.invoice-detail-sheet-title h2 {
  font-size: clamp(1.75rem, 3vw, 2.35rem);
  line-height: 1.02;
}

.invoice-detail-sheet-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(280px, 0.9fr);
  gap: 0.85rem;
  align-items: start;
}

.invoice-detail-sheet-block {
  display: grid;
  gap: 0.8rem;
  padding: 0.95rem 1rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.42);
}

.invoice-detail-sheet-block-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.invoice-detail-sheet-block-accent {
  background: linear-gradient(180deg, rgba(22, 124, 90, 0.06), rgba(255, 255, 255, 0.6));
}

.invoice-detail-party {
  display: grid;
  gap: 0.18rem;
}

.invoice-detail-party strong {
  font-size: 1.08rem;
}

.invoice-detail-party span {
  color: var(--text-secondary);
}

.invoice-detail-facts-grid {
  gap: 0.8rem 1rem;
}

.invoice-detail-sheet-payment {
  display: grid;
  gap: 0.8rem;
}

.invoice-detail-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}

.invoice-detail-overview-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.invoice-detail-total {
  min-width: 220px;
  display: grid;
  gap: 0.25rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--paper-muted);
}

.invoice-detail-total span,
.invoice-detail-note span {
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.invoice-detail-total strong {
  color: var(--text-strong);
  font-family: "Manrope", sans-serif;
  font-size: 1.65rem;
  line-height: 1.1;
}

.invoice-detail-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.info-pair-wide {
  grid-column: span 2;
}

.invoice-detail-inline-copy {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.invoice-detail-note {
  display: grid;
  gap: 0.35rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--border);
}

.invoice-detail-note-sheet {
  padding-top: 0.8rem;
}

.invoice-detail-section-heading {
  margin-top: -0.15rem;
}

.invoice-detail-items-table {
  margin-top: -0.1rem;
}

.invoice-detail-note p {
  margin: 0;
}

.stats-shell,
.stats-panel {
  display: grid;
  gap: 1rem;
}

.stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.stats-summary-grid-rolling .stats-summary-card strong {
  font-size: 1.2rem;
}

.stats-summary-card-period strong {
  font-size: 1.05rem;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.stats-summary-card {
  display: grid;
  gap: 0.3rem;
  padding: 1rem 1.1rem;
}

.stats-summary-card span {
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stats-summary-card strong {
  color: var(--text-strong);
  font-family: "Manrope", sans-serif;
  font-size: 1.5rem;
}

.stats-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.stats-year-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.stats-bars {
  display: grid;
  gap: 0.7rem;
}

.stats-bars-compact {
  gap: 0.55rem;
}

.stats-bar-row {
  display: grid;
  grid-template-columns: minmax(88px, 110px) minmax(0, 1fr) minmax(140px, auto);
  gap: 0.9rem;
  align-items: center;
  padding: 0.8rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--paper-muted);
  color: inherit;
}

.stats-bar-row.is-selected {
  border-color: rgba(22, 124, 90, 0.28);
  box-shadow: inset 0 0 0 1px rgba(22, 124, 90, 0.08);
}

.stats-bar-meta {
  display: grid;
  gap: 0.18rem;
}

.stats-bar-meta strong,
.stats-bar-value {
  color: var(--text-strong);
  font-weight: 800;
}

.stats-bar-meta span {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.stats-bar-track {
  position: relative;
  height: 0.8rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  overflow: hidden;
}

.stats-bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(145deg, var(--primary), var(--primary-strong));
}

.stats-month-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.8rem;
  align-items: end;
}

.stats-month-card {
  display: grid;
  gap: 0.55rem;
  justify-items: center;
  padding: 0.9rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--paper-muted);
  text-align: center;
}

.stats-month-card strong {
  color: var(--text-strong);
  font-size: 0.86rem;
}

.stats-month-value {
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.35;
}

.stats-month-track {
  display: flex;
  align-items: end;
  justify-content: center;
  width: 100%;
  min-height: 122px;
  padding: 0 0.35rem;
}

.stats-month-fill {
  display: block;
  width: 100%;
  min-height: 10px;
  border-radius: 14px 14px 8px 8px;
  background: linear-gradient(180deg, var(--primary), var(--primary-strong));
}

.stats-rolling-rows {
  display: grid;
  gap: 0.75rem;
}

.stats-rolling-row {
  display: grid;
  grid-template-columns: minmax(120px, 140px) minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.9rem;
  align-items: start;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--paper-muted);
}

.stats-rolling-month,
.stats-rolling-metric {
  display: grid;
  gap: 0.28rem;
}

.stats-rolling-month strong,
.stats-rolling-metric strong {
  color: var(--text-strong);
}

.stats-rolling-month span,
.stats-rolling-metric span {
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.stats-rolling-track {
  position: relative;
  height: 0.78rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  overflow: hidden;
}

.stats-rolling-metric-card {
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.55);
}

.stats-rolling-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.stats-rolling-fill-invoiced {
  background: linear-gradient(145deg, var(--primary), var(--primary-strong));
}

.stats-rolling-fill-paid {
  background: linear-gradient(145deg, rgba(20, 83, 45, 0.88), rgba(34, 197, 94, 0.95));
}

.section-heading {
  display: grid;
  gap: 0.35rem;
}

.inline-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.scroll-card {
  scroll-margin-top: 6rem;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.info-pair {
  display: grid;
  gap: 0.3rem;
}

.info-pair span {
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.info-pair strong,
.info-pair div {
  color: var(--text-strong);
}

.invoice-action-bar {
  --invoice-action-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(250, 247, 241, 0.88));
  --invoice-action-border: var(--border);
  --invoice-action-shadow: var(--shadow-soft);
  --invoice-action-muted: var(--text-secondary);
  --invoice-action-title: var(--text-strong);
  --invoice-action-chip-bg: var(--primary-soft);
  --invoice-action-chip-border: rgba(22, 124, 90, 0.16);
  --invoice-action-chip-text: var(--primary-strong);

  display: grid;
  gap: 1rem;
  padding: 1.2rem 1.25rem;
  background: var(--invoice-action-bg);
  border: 1px solid var(--invoice-action-border);
  box-shadow: var(--invoice-action-shadow);
}

.invoice-action-bar-head,
.invoice-action-bar-sections {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.invoice-action-bar-meta {
  min-width: 0;
}

.invoice-action-bar-title {
  margin-top: 0.32rem;
  color: var(--invoice-action-title);
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.08;
}

.invoice-action-bar-subtitle {
  margin-top: 0.35rem;
  color: var(--invoice-action-muted);
}

.invoice-action-bar-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.invoice-action-section {
  display: grid;
  gap: 0.45rem;
  min-width: 0;
}

.invoice-detail-action-bar .invoice-action-bar-head {
  padding-bottom: 0.35rem;
}

.invoice-detail-action-bar .invoice-action-bar-sections {
  row-gap: 0.8rem;
}

.invoice-detail-action-bar .invoice-action-chip {
  background: rgba(255, 255, 255, 0.6);
}

.invoice-action-section-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.invoice-detail-action-bar,
.invoice-editor-notice {
  margin-bottom: 1rem;
}

body.theme-dark code {
  background: rgba(148, 163, 184, 0.14);
  color: var(--text-strong);
}

body.theme-dark .app-footer p {
  background: rgba(17, 24, 34, 0.72);
  border-color: rgba(148, 163, 184, 0.16);
  box-shadow: 0 16px 32px rgba(2, 6, 23, 0.3);
}

body.theme-dark .card,
body.theme-dark .surface,
body.theme-dark .invoice-action-bar,
body.theme-dark .invoice-editor-surface,
body.theme-dark .invoice-editor-empty-state,
body.theme-dark .section-disclosure {
  background: linear-gradient(180deg, rgba(24, 33, 44, 0.96), rgba(17, 24, 34, 0.92));
  border-color: var(--border);
  box-shadow: var(--shadow-soft);
}

body.theme-dark .surface-muted,
body.theme-dark .settings-summary-item,
body.theme-dark .vat-threshold,
body.theme-dark .dashboard-link-tile,
body.theme-dark .dashboard-invoice-row {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--border);
}

body.theme-dark .settings-account-card {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--border);
}

body.theme-dark .settings-sync-box {
  background: rgba(255, 255, 255, 0.025);
  border-color: var(--border);
}

body.theme-dark .admin-inline-details,
body.theme-dark .admin-tool-card {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(148, 163, 184, 0.14);
}

body.theme-dark .topbar-shell {
  background: rgba(15, 20, 27, 0.8);
  border-color: rgba(148, 163, 184, 0.14);
}

body.theme-dark .brand-copy small,
body.theme-dark .muted,
body.theme-dark .filters-summary,
body.theme-dark .settings-section-copy,
body.theme-dark .settings-form-note,
body.theme-dark .invoice-action-bar-subtitle,
body.theme-dark .invoice-editor-subtitle,
body.theme-dark .invoice-contact-preview,
body.theme-dark .invoice-editor-hint,
body.theme-dark .invoice-editor-summary-note,
body.theme-dark .invoice-editor-static-hint {
  color: var(--text-secondary);
}

body.theme-dark label,
body.theme-dark .page-header-copy p,
body.theme-dark .page-header-copy,
body.theme-dark .dashboard-lead,
body.theme-dark .checkbox-inline,
body.theme-dark .info-pair span,
body.theme-dark .settings-summary-item span,
body.theme-dark .invoice-items-th {
  color: #b7c5d7;
}

body.theme-dark .settings-account-edit {
  border-top-color: rgba(148, 163, 184, 0.12);
}

body.theme-dark .nav-toggle-btn,
body.theme-dark .btn,
body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
  background: rgba(17, 24, 34, 0.88);
  border-color: rgba(148, 163, 184, 0.2);
  color: var(--text-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

body.theme-dark .btn:hover,
body.theme-dark .nav-toggle-btn:hover {
  background: rgba(24, 33, 44, 0.96);
}

body.theme-dark .btn.subtle {
  background: transparent;
  box-shadow: none;
}

body.theme-dark .btn.primary {
  background: linear-gradient(145deg, var(--primary), var(--primary-strong));
  border-color: transparent;
  color: #08120d;
  box-shadow: 0 16px 28px rgba(30, 160, 109, 0.22);
}

body.theme-dark .btn.primary:hover {
  background: linear-gradient(145deg, #49cf98, #24ab74);
  border-color: transparent;
  color: #08120d;
}

body.theme-dark .user-chip {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-strong);
}

body.theme-dark .row-actions-panel {
  background: rgba(17, 24, 34, 0.98);
  border-color: rgba(148, 163, 184, 0.22);
  box-shadow: 0 24px 40px rgba(2, 6, 23, 0.48);
}

body.theme-dark .subject-switcher-summary {
  background: rgba(17, 24, 34, 0.9);
  border-color: rgba(148, 163, 184, 0.2);
}

body.theme-dark .subject-switcher-menu {
  background: rgba(11, 18, 28, 0.96);
  border-color: rgba(148, 163, 184, 0.18);
}

body.theme-dark .subject-switcher-item:hover {
  background: rgba(148, 163, 184, 0.08);
}

body.theme-dark .subject-switcher-item.is-current {
  background: rgba(52, 196, 139, 0.12);
  border-color: rgba(52, 196, 139, 0.2);
}

body.theme-dark .subject-switcher-badge {
  background: rgba(52, 196, 139, 0.16);
  color: #8ff0c8;
}

body.theme-dark .recurring-plan-row {
  border-bottom-color: rgba(148, 163, 184, 0.14);
}

body.theme-dark .nav a {
  color: var(--text-secondary);
}

body.theme-dark .nav a:hover {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-strong);
}

body.theme-dark .nav a.active {
  background: rgba(52, 196, 139, 0.16);
  color: #8ff0c8;
}

body.theme-dark input::placeholder,
body.theme-dark textarea::placeholder {
  color: rgba(148, 163, 184, 0.68);
}

body.theme-dark input[type="date"],
body.theme-dark input[type="time"],
body.theme-dark input[type="datetime-local"] {
  color-scheme: dark;
}

body.theme-dark .table-wrap,
body.theme-dark .notice,
body.theme-dark .empty-state {
  background: rgba(17, 24, 34, 0.78);
  border-color: var(--border);
}

body.theme-dark .bulk-toolbar-copy span {
  color: #aebbcf;
}

body.theme-dark .recurring-empty-state {
  background: rgba(15, 23, 42, 0.45);
}

@media (max-width: 1320px) {
  .nav-wrap {
    gap: 0.65rem;
  }

  .nav a {
    padding: 0.48rem 0.58rem;
    font-size: 0.94rem;
  }

  .subject-switcher-summary {
    max-width: 12.5rem;
    padding-inline: 0.7rem;
  }
}

body.theme-dark .dashboard-invoice-main strong,
body.theme-dark .dashboard-invoice-meta strong,
body.theme-dark .vat-threshold strong,
body.theme-dark .vat-card h2,
body.theme-dark .dashboard-health h2,
body.theme-dark .stats-summary-card strong,
body.theme-dark .stats-bar-meta strong,
body.theme-dark .stats-bar-value,
body.theme-dark .stats-month-card strong,
body.theme-dark .stats-rolling-month strong,
body.theme-dark .stats-rolling-metric strong,
body.theme-dark .invoice-detail-total strong {
  color: var(--text-strong);
}

body.theme-dark .dashboard-invoice-main span,
body.theme-dark .dashboard-invoice-meta span,
body.theme-dark .vat-threshold span,
body.theme-dark .vat-threshold p,
body.theme-dark .vat-meta,
body.theme-dark .dashboard-health p,
body.theme-dark .vat-card .muted,
body.theme-dark .stats-summary-card span,
body.theme-dark .stats-bar-meta span,
body.theme-dark .stats-month-value,
body.theme-dark .stats-rolling-month span,
body.theme-dark .stats-rolling-metric span,
body.theme-dark .invoice-detail-total span,
body.theme-dark .invoice-detail-note span {
  color: #aebbcf;
}

body.theme-dark .stats-bar-row,
body.theme-dark .stats-month-card,
body.theme-dark .stats-rolling-row,
body.theme-dark .invoice-detail-total {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--border);
}

body.theme-dark .stats-rolling-metric-card {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border);
}

body.theme-dark .invoice-detail-sheet-block {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--border);
}

body.theme-dark .invoice-detail-more-menu {
  background: #16202b;
  border-color: var(--border);
}

body.theme-dark .app-dialog-card {
  background: #16202b;
  border-color: var(--border);
}

body.theme-dark .app-dialog .form-actions {
  background: linear-gradient(180deg, rgba(22, 32, 43, 0), #16202b 32%);
}

body.theme-dark .invoice-detail-sheet-block-accent {
  background: linear-gradient(180deg, rgba(52, 196, 139, 0.1), rgba(255, 255, 255, 0.03));
}

body.theme-dark .stats-bar-track,
body.theme-dark .stats-rolling-track {
  background: rgba(148, 163, 184, 0.12);
}

body.theme-dark .vat-threshold {
  background: rgba(255, 255, 255, 0.04);
}

body.theme-dark .vat-threshold.is-reached {
  background: rgba(240, 180, 74, 0.12);
  border-color: rgba(240, 180, 74, 0.28);
}

body.theme-dark .vat-badge {
  border-color: rgba(148, 163, 184, 0.18);
}

body.theme-dark .dashboard-health p strong,
body.theme-dark .vat-meta strong {
  color: var(--text-strong);
}

body.theme-dark .table th {
  background: rgba(10, 16, 23, 0.9);
}

body.theme-dark .table th,
body.theme-dark .table td {
  color: #dde7f3;
  border-bottom-color: rgba(148, 163, 184, 0.12);
}

body.theme-dark .table td a,
body.theme-dark .info-pair a {
  color: #55ddb0;
}

body.theme-dark .table td a:hover,
body.theme-dark .info-pair a:hover {
  color: #8ff0c8;
}

body.theme-dark .table td .muted,
body.theme-dark .table td .badge + .muted,
body.theme-dark .filters .muted,
body.theme-dark .empty-state,
body.theme-dark .notice,
body.theme-dark .info-pair .muted {
  color: #afbdd0;
}

body.theme-dark .table tbody tr:hover td {
  background: rgba(52, 196, 139, 0.06);
}

body.theme-dark .table tbody tr.bulk-row-selected td {
  background: rgba(52, 196, 139, 0.12);
}

body.theme-dark .row-overdue td {
  background: rgba(255, 138, 107, 0.08);
}

body.theme-dark .invoice-editor-empty-state,
body.theme-dark .invoice-editor-summary-card,
body.theme-dark .invoice-editor-catalog-card,
body.theme-dark .invoice-editor-more-options,
body.theme-dark .invoice-editor-static-field,
body.theme-dark .invoice-catalog-item,
body.theme-dark .invoice-catalog-empty {
  background: rgba(255, 255, 255, 0.03);
}

body.theme-dark .theme-option-card input:checked + .theme-option-card-ui {
  border-color: rgba(52, 196, 139, 0.4);
  background: linear-gradient(180deg, rgba(52, 196, 139, 0.1), rgba(24, 33, 44, 0.94));
}

@media print {
  body {
    background: #fff !important;
    color: #111 !important;
  }

  .topbar,
  .btn {
    display: none !important;
  }

  a {
    color: #111 !important;
    text-decoration: none !important;
  }

  .card,
  .surface,
  .table-wrap,
  .invoice-action-bar {
    background: #fff !important;
    border-color: rgba(0, 0, 0, 0.15) !important;
    box-shadow: none !important;
  }

  .table th,
  .table td {
    border-bottom-color: rgba(0, 0, 0, 0.12) !important;
    color: #111 !important;
  }

  .table th {
    background: #f6f6f6 !important;
  }
}

@media (max-width: 980px) {
  .admin-overview-grid,
  .admin-tool-grid,
  .admin-subject-grid,
  .settings-grid-top,
  .settings-grid-meta,
  .settings-grid-bank,
  .settings-grid-subjects,
  .stats-summary-grid,
  .stats-layout,
  .theme-picker,
  .dashboard-link-list,
  .vat-threshold-list,
  .settings-summary-grid,
  .settings-form-grid,
  .info-grid {
    grid-template-columns: 1fr;
  }

  .stats-month-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .invoice-detail-overview-head,
  .invoice-detail-hero-head,
  .invoice-detail-sheet-header,
  .invoice-detail-meta-grid,
  .invoice-detail-sheet-grid,
  .stats-rolling-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .invoice-detail-total {
    min-width: 0;
  }

  .invoice-detail-more-menu {
    position: static;
    min-width: 0;
  }

  .info-pair-wide {
    grid-column: auto;
  }

  .settings-account-meta {
    grid-template-columns: 1fr;
  }

  .settings-form-grid-span-2 {
    grid-column: auto;
  }

  .filters-row .field,
  .filters-row .field.checkbox,
  .filters-row .field.actions {
    grid-column: span 6;
  }
}

@media (max-width: 760px) {
  .topbar {
    padding-top: 0.7rem;
  }

  .topbar-shell {
    display: flex;
    grid-template-columns: none;
    padding: 0.85rem;
    border-radius: 18px;
  }

  .nav-toggle-btn {
    display: inline-flex;
  }

  .nav-wrap {
    display: none;
    width: 100%;
    grid-template-columns: none;
    flex-direction: column;
    align-items: stretch;
    justify-self: stretch;
    gap: 0.8rem;
    padding-top: 0.2rem;
  }

  .nav-toggle:checked ~ .nav-wrap {
    display: flex;
  }

  .nav,
  .user-actions,
  .dashboard-actions,
  .dashboard-section-head,
  .page-header-actions,
  .settings-hero-actions,
  .settings-action-row,
  .invoice-action-bar-head,
  .invoice-action-bar-sections,
  .invoice-action-section-buttons,
  .invoice-editor-page-head,
  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .nav a {
    border-radius: 14px;
  }

  .subject-switcher-summary {
    max-width: none;
  }

  .recurring-empty-state {
    flex-direction: column;
    align-items: stretch;
  }

  .filters-row {
    grid-template-columns: 1fr;
  }

  .filters-row .field,
  .filters-row .field.checkbox,
  .filters-row .field.actions {
    grid-column: auto;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-invoice-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .stats-bar-row {
    grid-template-columns: 1fr;
  }

  .dashboard-invoice-meta {
    width: 100%;
    grid-auto-flow: row;
    justify-items: start;
    text-align: left;
    gap: 0.25rem;
  }

  .stats-month-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats-rolling-row {
    grid-template-columns: 1fr;
  }

  .dashboard-health-inline {
    flex-direction: column;
    align-items: stretch;
  }

  .inline-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .vat-threshold-labels,
  .admin-subject-tile-head,
  .admin-user-card-head,
  .settings-card-head,
  .settings-account-head,
  .settings-hero,
  .page-header,
  .dashboard-hero {
    flex-direction: column;
    align-items: stretch;
  }

  .settings-source {
    max-width: none;
    text-align: left;
  }

  .settings-table-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .settings-table-actions form {
    display: flex;
  }

  .app-dialog {
    width: calc(100vw - 0.75rem);
    max-height: calc(100dvh - 0.75rem);
  }

  .app-dialog-card {
    gap: 0.85rem;
    padding: 0.95rem;
    max-height: calc(100dvh - 0.75rem);
    border-radius: 18px;
  }

  .app-dialog-head {
    position: sticky;
    top: 0;
    z-index: 3;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    background: inherit;
  }

  .app-dialog-body {
    max-height: calc(100dvh - 8.5rem);
    padding-bottom: max(0.25rem, env(safe-area-inset-bottom));
  }

  .app-dialog .form-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .recipient-shortcuts {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-inline-details,
  .admin-tool-card > p,
  .admin-tool-card > form,
  .admin-tool-card summary {
    padding-left: 0.9rem;
    padding-right: 0.9rem;
  }
}

/* --------------------------------------------------------------------- */
/* Invoice editor (phase-32) */

.invoice-editor-page {
  color: var(--text);
}

.invoice-editor-page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.invoice-editor-backlink {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-secondary);
  margin-bottom: 0.45rem;
}

.invoice-editor-backlink:hover {
  color: var(--text);
}

.invoice-editor-title {
  color: var(--text);
  margin-bottom: 0.35rem;
}

.invoice-editor-subtitle {
  color: var(--text-secondary);
  max-width: 62rem;
}

.invoice-editor-page-actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.invoice-editor-page-actions .btn,
.invoice-editor-secondary-actions .btn {
  color: var(--text);
}

.invoice-editor-notice {
  margin-bottom: 1rem;
}

.invoice-editor-empty-state {
  padding: 1.25rem 1.35rem;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.invoice-editor-empty-state h2,
.invoice-items-toolbar h2 {
  color: var(--text);
}

.invoice-editor-form {
  max-width: none;
}

.invoice-editor-surface {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0.01)), var(--paper);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.invoice-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 1.5rem;
  padding: 1.5rem;
}

.invoice-editor-main {
  min-width: 0;
}

.invoice-editor-fields {
  display: grid;
  gap: 1rem;
}

.invoice-editor-field-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 1rem;
  align-items: flex-start;
}

.invoice-editor-field-row > label {
  display: flex;
  align-items: center;
  min-height: 44px;
  margin: 0;
  color: var(--text-secondary);
  font-weight: 700;
}

.invoice-editor-field-control {
  min-width: 0;
}

.invoice-editor-surface input,
.invoice-editor-surface select,
.invoice-editor-surface textarea {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-strong);
}

.invoice-editor-surface input::placeholder,
.invoice-editor-surface textarea::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

.invoice-editor-inline-row {
  display: flex;
  gap: 0.65rem;
  align-items: center;
}

.invoice-editor-inline-row > *:first-child {
  flex: 1 1 auto;
}

.invoice-contact-preview,
.invoice-editor-hint,
.invoice-editor-summary-note,
.invoice-editor-static-hint {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.invoice-contact-preview {
  margin-top: 0.55rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.invoice-contact-preview strong,
.invoice-editor-static-hint strong {
  color: var(--text);
}

.invoice-contact-sep {
  color: rgba(255, 255, 255, 0.35);
}

.invoice-editor-static-field {
  padding: 0.85rem 0.95rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.invoice-editor-static-main {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
}

.invoice-editor-static-hint {
  margin-top: 0.35rem;
}

.invoice-editor-due-grid {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(180px, 220px);
  gap: 0.75rem;
}

.invoice-editor-due-grid .invoice-editor-hint {
  grid-column: 1 / -1;
}

.invoice-editor-more-options {
  margin-top: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
}

.section-disclosure {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.86));
  box-shadow: var(--shadow-soft);
}

.invoice-editor-more-options summary {
  cursor: pointer;
  list-style: none;
  padding: 0.9rem 1rem;
  font-weight: 700;
  color: var(--text);
}

.section-disclosure summary {
  cursor: pointer;
  list-style: none;
  padding: 1rem 1.15rem;
  font-family: "Manrope", "IBM Plex Sans", sans-serif;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-strong);
}

.invoice-editor-more-options summary::-webkit-details-marker {
  display: none;
}

.section-disclosure summary::-webkit-details-marker {
  display: none;
}

.invoice-editor-more-options summary::after {
  content: "+";
  float: right;
  color: var(--text-secondary);
}

.section-disclosure summary::after {
  content: "+";
  float: right;
  color: var(--text-secondary);
}

.invoice-editor-more-options[open] summary::after {
  content: "−";
}

.section-disclosure[open] summary::after {
  content: "−";
}

.invoice-editor-more-options-body {
  padding: 0 1rem 1rem;
}

.section-disclosure-body {
  padding: 0 1.15rem 1.15rem;
}

.invoice-editor-sidebar {
  min-width: 0;
  display: grid;
  gap: 1rem;
}

.invoice-editor-summary-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.015));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.1rem 1rem;
  position: sticky;
  top: 84px;
}

.invoice-editor-catalog-card {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem;
  display: grid;
  gap: 0.85rem;
}

.invoice-editor-catalog-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}

.invoice-editor-catalog-head h3 {
  margin: 0;
  font-size: 1rem;
}

.invoice-editor-catalog-head strong {
  color: var(--secondary);
}

.invoice-editor-catalog-toolbar {
  display: grid;
  gap: 0.5rem;
}

.invoice-catalog-status {
  min-height: 1.2rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.invoice-catalog-status[hidden] {
  display: none;
}

.invoice-catalog-status[data-state="success"] {
  color: var(--secondary);
}

.invoice-catalog-status[data-state="error"] {
  color: #ff8a80;
}

.invoice-catalog-list {
  display: grid;
  gap: 0.6rem;
}

.invoice-catalog-empty {
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
  padding: 0.85rem 0.95rem;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.02);
}

.invoice-catalog-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.75rem 0.8rem;
  background: rgba(255, 255, 255, 0.03);
}

.invoice-catalog-item-main {
  min-width: 0;
  display: grid;
  gap: 0.25rem;
}

.invoice-catalog-item-title {
  font-weight: 700;
  color: var(--text);
}

.invoice-catalog-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.75rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.invoice-catalog-item-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.invoice-catalog-insert,
.invoice-catalog-remove {
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
}

.invoice-catalog-insert {
  min-width: 74px;
  height: 40px;
  padding: 0 0.8rem;
  font-weight: 700;
}

.invoice-catalog-remove {
  width: 40px;
  height: 40px;
  font-size: 1.35rem;
  line-height: 1;
}

.invoice-catalog-insert:hover,
.invoice-catalog-remove:hover {
  background: rgba(255, 255, 255, 0.08);
}

.invoice-editor-summary-kicker {
  color: var(--secondary);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.8rem;
  margin-bottom: 0.45rem;
}

.invoice-editor-summary-total,
.invoice-editor-actions-total strong {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text);
}

.invoice-editor-summary-meta {
  display: grid;
  gap: 0.6rem;
  margin-top: 1rem;
}

.invoice-editor-summary-meta > div,
.invoice-editor-summary-breakdown > div {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
}

.invoice-editor-summary-meta span,
.invoice-editor-summary-breakdown span,
.invoice-editor-actions-total span {
  color: var(--text-secondary);
}

.invoice-editor-summary-meta strong,
.invoice-editor-summary-breakdown strong {
  color: var(--text);
}

.invoice-editor-summary-breakdown {
  margin: 1rem 0;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 0.6rem;
}

.invoice-items-section {
  padding: 0 1.5rem 1.5rem;
}

.invoice-items-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.invoice-items-scroll {
  overflow-x: auto;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem;
}

.invoice-items-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 0.75rem;
  min-width: 860px;
}

.invoice-items-th {
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  padding: 0 0.3rem 0.2rem;
  text-align: left;
}

.invoice-items-th-total,
.invoice-item-cell-total {
  text-align: right;
}

.invoice-items-th-drag,
.invoice-item-cell-drag {
  width: 3.25rem;
}

.invoice-items-th-remove,
.invoice-item-cell-remove {
  width: 6rem;
}

.invoice-item-row td {
  vertical-align: middle;
  padding: 0;
}

.invoice-item-cell {
  padding: 0 0.3rem;
}

.invoice-item-cell-drag {
  padding-right: 0.15rem;
}

.invoice-item-cell-qty {
  width: 6.5rem;
}

.invoice-item-cell-unit {
  width: 6rem;
}

.invoice-item-cell-price,
.invoice-item-cell-vat {
  width: 10rem;
}

.invoice-item-cell-desc {
  min-width: 0;
}

.invoice-item-cell-total {
  width: 10.5rem;
}

.invoice-item-total {
  min-height: 44px;
  display: inline-flex;
  width: 100%;
  align-items: center;
  justify-content: flex-end;
  padding: 0.55rem 0.2rem;
  color: var(--text);
  font-weight: 700;
}

.invoice-row-drag {
  width: 42px;
  height: 42px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  cursor: grab;
}

.invoice-row-drag span {
  display: block;
  width: 14px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.invoice-row-drag:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.invoice-row-drag:active {
  cursor: grabbing;
}

.invoice-item-row.is-dragging {
  opacity: 0.52;
}

.invoice-item-desc-field {
  display: grid;
  gap: 0.45rem;
}

.invoice-item-suggestions {
  border: 1px solid rgba(76, 175, 80, 0.35);
  background: rgba(255, 255, 255, 0.035);
  border-radius: 14px;
  padding: 0.55rem;
}

.invoice-item-suggestions[hidden] {
  display: none;
}

.invoice-item-suggestions-head {
  color: var(--secondary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  margin-bottom: 0.45rem;
}

.invoice-item-suggestions-list {
  display: grid;
  gap: 0.35rem;
}

.invoice-suggestion-option {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  color: var(--text);
  padding: 0.55rem 0.7rem;
  display: grid;
  gap: 0.2rem;
  cursor: pointer;
}

.invoice-suggestion-option:hover,
.invoice-suggestion-option.is-active {
  border-color: rgba(76, 175, 80, 0.45);
  background: rgba(76, 175, 80, 0.08);
}

.invoice-row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  padding: 0.1rem 0;
}

.row-actions-menu {
  position: relative;
  display: inline-block;
}

.row-actions-menu summary {
  list-style: none;
}

.row-actions-trigger {
  min-width: 8.4rem;
  justify-content: space-between;
  cursor: pointer;
}

.row-actions-trigger::-webkit-details-marker {
  display: none;
}

.row-actions-trigger::after {
  content: "▾";
  font-size: 0.8rem;
  opacity: 0.7;
}

.row-actions-menu[open] .row-actions-trigger::after {
  content: "▴";
}

.row-actions-panel {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  z-index: 20;
  display: grid;
  gap: 0.45rem;
  min-width: 13.75rem;
  padding: 0.55rem;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow-soft);
}

.row-actions-panel form {
  margin: 0;
}

.row-actions-panel .btn {
  width: 100%;
  justify-content: flex-start;
}

.invoice-suggestion-title {
  font-weight: 700;
}

.invoice-suggestion-meta {
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.invoice-row-save-catalog,
.invoice-row-duplicate,
.invoice-row-remove {
  width: 42px;
  height: 42px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  line-height: 1;
  cursor: pointer;
}

.invoice-row-save-catalog {
  font-size: 1.25rem;
  color: #ffd54f;
}

.invoice-row-duplicate {
  font-size: 1.05rem;
  font-weight: 700;
}

.invoice-row-remove {
  font-size: 1.45rem;
}

.invoice-row-save-catalog:hover,
.invoice-row-duplicate:hover,
.invoice-row-remove:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.invoice-editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.invoice-editor-actions-total {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.invoice-editor-actions-total span {
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.82rem;
  font-weight: 700;
}

.invoice-editor-submit {
  min-width: 180px;
}

.invoice-editor-secondary-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.invoice-editor-secondary-actions form {
  display: inline-flex;
}

@media (max-width: 980px) {
  .invoice-editor-layout {
    grid-template-columns: 1fr;
  }

  .invoice-editor-summary-card {
    position: static;
  }

  .invoice-catalog-item {
    grid-template-columns: 1fr;
  }

  .invoice-catalog-item-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  .invoice-editor-page-head,
  .invoice-editor-actions,
  .invoice-items-toolbar,
  .invoice-editor-inline-row {
    flex-direction: column;
    align-items: stretch;
  }

  .invoice-editor-layout,
  .invoice-items-section,
  .invoice-editor-actions {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .invoice-editor-field-row {
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }

  .invoice-editor-field-row > label {
    min-height: 0;
  }

  .invoice-editor-due-grid {
    grid-template-columns: 1fr;
  }

  .invoice-item-cell-drag,
  .invoice-item-cell-qty,
  .invoice-item-cell-unit,
  .invoice-item-cell-price,
  .invoice-item-cell-vat,
  .invoice-item-cell-total {
    width: auto;
  }

  .invoice-items-table {
    min-width: 860px;
  }
}
