:root {
  --bg: #e8eaed;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --card: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #f3f4f6;
  --input-bg: #ffffff;
  --input-border: #d1d5db;
  --topbar-bg: #ffffff;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-soft: #eff6ff;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;
  --flash-ok-bg: #ecfdf5;
  --flash-ok-ink: #065f46;
  --flash-ok-border: #a7f3d0;
  --flash-err-ink: #7f1d1d;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 16px rgba(15, 23, 42, 0.04);
  --radius: 8px;
  --font: "DM Sans", "Segoe UI", system-ui, sans-serif;
  --btn-on-accent: #ffffff;
  --focus-ring: rgba(29, 78, 216, 0.12);
  --focus-border: #93c5fd;
  --popover-shadow: 0 8px 28px rgba(15, 23, 42, 0.12);
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0f1419;
  --ink: #e7ecf1;
  --muted: #9aa5b1;
  --line: #2a3441;
  --card: #1a222d;
  --surface-2: #151b24;
  --surface-3: #121820;
  --input-bg: #121820;
  --input-border: #3a4656;
  --topbar-bg: #1a222d;
  --accent: #5b8def;
  --accent-hover: #7aa2f7;
  --accent-soft: #1e2a3d;
  --danger: #f87171;
  --danger-soft: #3a1c1c;
  --danger-border: #7f1d1d;
  --flash-ok-bg: #0f2e24;
  --flash-ok-ink: #6ee7b7;
  --flash-ok-border: #14532d;
  --flash-err-ink: #fca5a5;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.28);
  --btn-on-accent: #0b1220;
  --focus-ring: rgba(91, 141, 239, 0.22);
  --focus-border: #5b8def;
  --popover-shadow: 0 10px 32px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
}

.impersonation-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  background: #fef3c7;
  color: #78350f;
  border-bottom: 1px solid #fcd34d;
  font-size: 0.9rem;
  font-weight: 500;
}

html[data-theme="dark"] .impersonation-bar {
  background: #78350f;
  color: #fef3c7;
  border-bottom-color: #b45309;
}

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

.topbar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0 1.5rem;
  height: 56px;
  border-bottom: 1px solid var(--line);
  background: var(--topbar-bg);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}

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

.topbar nav,
.topbar .app-nav {
  display: flex;
  gap: 0.15rem;
  flex: 1;
}

.topbar nav a,
.topbar .app-nav a {
  color: var(--muted);
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
}

.topbar nav a.is-active,
.topbar nav a:hover,
.topbar .app-nav a.is-active,
.topbar .app-nav a:hover {
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
}

.nav-group {
  position: relative;
  display: flex;
  flex-direction: column;
}

.nav-group-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  font: inherit;
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}

.nav-group-caret {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: 0.7;
}

.nav-group-out .nav-group-trigger {
  background: #ecfdf5;
  color: #047857;
}

.nav-group-out .nav-group-trigger:hover,
.nav-group-out.is-active .nav-group-trigger,
.nav-group-out.is-open .nav-group-trigger {
  background: #d1fae5;
  color: #065f46;
}

.nav-group-in .nav-group-trigger {
  background: #fef2f2;
  color: #b91c1c;
}

.nav-group-in .nav-group-trigger:hover,
.nav-group-in.is-active .nav-group-trigger,
.nav-group-in.is-open .nav-group-trigger {
  background: #fee2e2;
  color: #991b1b;
}

.nav-group-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 11.5rem;
  padding: 0.35rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1);
  z-index: 30;
  flex-direction: column;
  gap: 0.15rem;
}

.nav-group.is-open .nav-group-menu {
  display: flex;
}

.nav-group-menu a {
  display: block;
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
}

.nav-group-out .nav-group-menu a:hover,
.nav-group-out .nav-group-menu a.is-active {
  background: #ecfdf5;
  color: #047857;
}

.nav-group-in .nav-group-menu a:hover,
.nav-group-in .nav-group-menu a.is-active {
  background: #fef2f2;
  color: #b91c1c;
}

html[data-theme="dark"] .nav-group-out .nav-group-trigger {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
}

html[data-theme="dark"] .nav-group-out .nav-group-trigger:hover,
html[data-theme="dark"] .nav-group-out.is-active .nav-group-trigger,
html[data-theme="dark"] .nav-group-out.is-open .nav-group-trigger {
  background: rgba(16, 185, 129, 0.28);
  color: #a7f3d0;
}

html[data-theme="dark"] .nav-group-in .nav-group-trigger {
  background: rgba(248, 113, 113, 0.15);
  color: #fca5a5;
}

html[data-theme="dark"] .nav-group-in .nav-group-trigger:hover,
html[data-theme="dark"] .nav-group-in.is-active .nav-group-trigger,
html[data-theme="dark"] .nav-group-in.is-open .nav-group-trigger {
  background: rgba(248, 113, 113, 0.28);
  color: #fecaca;
}

html[data-theme="dark"] .nav-group-out .nav-group-menu a:hover,
html[data-theme="dark"] .nav-group-out .nav-group-menu a.is-active {
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
}

html[data-theme="dark"] .nav-group-in .nav-group-menu a:hover,
html[data-theme="dark"] .nav-group-in .nav-group-menu a.is-active {
  background: rgba(248, 113, 113, 0.18);
  color: #fca5a5;
}

.nav-toggle {
  display: none !important;
  align-items: center;
  gap: 0.45rem;
  margin-left: auto;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 6px;
  padding: 0.4rem 0.65rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--ink);
  cursor: pointer;
}

.nav-toggle-bars {
  width: 16px;
  height: 12px;
  display: inline-block;
  background:
    linear-gradient(currentColor, currentColor) 0 0 / 100% 2px no-repeat,
    linear-gradient(currentColor, currentColor) 0 5px / 100% 2px no-repeat,
    linear-gradient(currentColor, currentColor) 0 10px / 100% 2px no-repeat;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  flex-shrink: 0;
}

.user-menu .who {
  text-align: right;
  min-width: 0;
}

.user-menu .who strong {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}

.user-menu .who span {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}

.user-menu-logout {
  flex-shrink: 0;
  margin: 0;
}

.user-menu-logout .btn {
  white-space: nowrap;
  flex-shrink: 0;
  padding: 0.4rem 0.65rem;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #334155;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid var(--line);
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.wrap {
  width: min(960px, calc(100% - 2rem));
  margin: 1.5rem auto 3rem;
}

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

.page-head h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-head p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.list-sort {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  font-size: 0.86rem;
  color: var(--muted);
}

.list-sort select {
  min-width: 10.5rem;
  font-size: 0.86rem;
  padding: 0.35rem 0.55rem;
}

.invoice-list-filters {
  margin: 0 0 0.65rem;
}

.invoice-list-filters-row {
  display: grid;
  grid-template-columns: minmax(10rem, 1.6fr) repeat(5, minmax(7.5rem, 1fr)) auto;
  gap: 0.65rem 0.75rem;
  align-items: end;
}

.invoice-list-filters .field {
  margin: 0;
  min-width: 0;
}

.invoice-list-filters .field label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.invoice-list-filters input,
.invoice-list-filters select {
  width: 100%;
  font-size: 0.86rem;
  padding: 0.4rem 0.55rem;
}

.invoice-list-filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  padding-bottom: 0.05rem;
}

.invoice-list-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem;
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.invoice-list-pager {
  margin-top: 0.85rem;
}

@media (max-width: 1100px) {
  .invoice-list-filters-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .invoice-list-search,
  .invoice-list-filter-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .invoice-list-filters-row {
    grid-template-columns: 1fr;
  }
}

.contact-form-page {
  max-width: 46rem;
}

.contact-form-page .card {
  margin-bottom: 0;
}

@media (max-width: 1100px) {
  .contact-list-filters-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .contact-list-filters-row {
    grid-template-columns: 1fr;
  }
}

.th-sort {
  color: inherit;
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}

.th-sort:hover {
  color: var(--accent);
  text-decoration: none;
}

.th-sort.is-active {
  color: var(--accent);
}

.page-head-statement {
  align-items: center;
  gap: 1rem 1.25rem;
}

.page-head-statement .page-head-copy {
  flex: 1 1 14rem;
  min-width: 0;
}

.page-head-statement .stmt-actions-pdf {
  flex: 0 1 auto;
  margin: 0;
}

.page-head-statement .stmt-actions-sync {
  flex: 0 0 auto;
}

.stmt-actions-sync {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.55rem 0.7rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2, #f8fafc);
}

.stmt-actions-sync-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.2;
}

.stmt-actions-sync .btn-row {
  gap: 0.45rem;
  margin: 0;
}

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

.dash-wallets {
  grid-column: 1 / -1;
}

.dash-wallet-group + .dash-wallet-group {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}

.dash-wallet-group-title {
  margin: 0 0 0.55rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.dash-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.dash-panel-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.dash-panel-actions .btn {
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
}

.dash-link {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent, #1d4ed8);
  text-decoration: none;
}

.dash-link:hover {
  text-decoration: underline;
}

.dash-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.dash-list-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
}

.dash-list-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.dash-item-title {
  font-weight: 700;
  color: inherit;
  text-decoration: none;
}

a.dash-item-title:hover {
  color: var(--accent, #1d4ed8);
}

.dash-item-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  text-align: right;
  flex: 0 0 auto;
}

.dash-balance {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (max-width: 860px) {
  .dash-grid {
    grid-template-columns: 1fr;
  }

  .dash-wallets {
    grid-column: auto;
  }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.35rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 1120px) {
  .grid-2 { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: start; }

  .nav-toggle { display: inline-flex !important; }

  .topbar {
    flex-wrap: wrap;
    height: auto;
    min-height: 56px;
    padding: 0.65rem 1rem;
    gap: 0.65rem;
  }

  .topbar .app-nav,
  .topbar nav {
    display: none;
    flex: 1 1 100%;
    flex-direction: column;
    gap: 0.2rem;
    order: 3;
  }

  .topbar.is-nav-open .app-nav,
  .topbar.is-nav-open nav {
    display: flex;
  }

  .nav-group {
    width: 100%;
  }

  .nav-group-trigger {
    width: 100%;
    justify-content: space-between;
  }

  .nav-group-menu {
    position: static;
    box-shadow: none;
    border: 0;
    background: transparent;
    padding: 0.15rem 0 0.35rem 0.65rem;
    min-width: 0;
  }

  .topbar .user-menu {
    display: none;
    flex: 1 1 100%;
    order: 4;
    justify-content: space-between;
    padding-top: 0.55rem;
    border-top: 1px solid var(--line);
  }

  .topbar.is-nav-open .user-menu {
    display: flex;
  }

  .user-menu .who strong,
  .user-menu .who span { max-width: 55vw; }

  .wrap {
    width: calc(100% - 1.25rem);
    margin: 1rem auto 2rem;
  }

  .card {
    padding: 1rem;
  }

  .table-scroll,
  .card:has(> .table) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table th,
  .table td {
    padding: 0.6rem 0.45rem;
    font-size: 0.88rem;
    white-space: nowrap;
  }

  .items-editor {
    display: block;
  }

  .items-editor thead {
    display: none;
  }

  .items-editor tbody,
  .items-editor tr,
  .items-editor td {
    display: block;
    width: 100%;
  }

  .items-editor tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.55rem;
    margin-bottom: 0.65rem;
    background: var(--surface-2);
  }

  .items-editor td {
    padding: 0.25rem 0;
  }

  .items-editor td:nth-child(1)::before { content: "Description"; }
  .items-editor td:nth-child(2)::before { content: "Qty"; }
  .items-editor td:nth-child(3)::before { content: "Rate"; }
  .items-editor td:nth-child(4)::before { content: "Amount"; }
  .items-editor td:nth-child(5)::before { content: ""; }

  .items-editor td::before {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin-bottom: 0.2rem;
  }

  .items-editor td:last-child {
    text-align: right;
  }

  .page-head .btn-row {
    width: 100%;
  }

  .page-head .btn-row .btn {
    flex: 1;
  }

  .page-head-statement {
    align-items: stretch;
  }

  .page-head-statement .stmt-actions-pdf,
  .page-head-statement .stmt-actions-sync {
    width: 100%;
  }

  .auth-body {
    align-items: center;
    justify-content: flex-start;
    padding: 3.25rem 0 1.25rem;
  }

  .auth-wrap,
  .auth-wrap-wide {
    width: calc(100% - 1.25rem);
    margin: 0 auto;
  }

  .auth-card.card {
    padding: 1.1rem;
  }

  .auth-theme-wrap {
    top: 0.75rem;
    right: 0.75rem;
  }
}

@media (min-width: 1121px) {
  .nav-toggle {
    display: none !important;
  }

  .topbar .app-nav,
  .topbar nav {
    display: flex !important;
  }

  .topbar .user-menu {
    display: flex !important;
  }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.55rem 0.9rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--accent);
  color: var(--btn-on-accent);
}
.btn-primary:hover { background: var(--accent-hover); color: var(--btn-on-accent); }

.btn-income {
  background: #059669;
  color: #ffffff;
}
.btn-income:hover { background: #047857; color: #ffffff; }

.btn-expense {
  background: #dc2626;
  color: #ffffff;
}
.btn-expense:hover { background: #b91c1c; color: #ffffff; }

html[data-theme="dark"] .btn-income {
  background: #10b981;
  color: #052e1c;
}
html[data-theme="dark"] .btn-income:hover { background: #34d399; color: #052e1c; }

html[data-theme="dark"] .btn-expense {
  background: #f87171;
  color: #450a0a;
}
html[data-theme="dark"] .btn-expense:hover { background: #fca5a5; color: #450a0a; }

.btn-secondary {
  background: var(--card);
  border-color: var(--line);
  color: var(--ink);
}
.btn-secondary:hover { background: var(--surface-2); color: var(--ink); }

.btn-danger {
  background: var(--card);
  border-color: var(--danger-border);
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger-soft); }

.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.flash {
  margin-bottom: 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 6px;
  font-weight: 500;
  border: 1px solid transparent;
}
.flash-success { background: var(--flash-ok-bg); color: var(--flash-ok-ink); border-color: var(--flash-ok-border); }
.flash-error { background: var(--danger-soft); color: var(--flash-err-ink); border-color: var(--danger-border); }
.flash-warn {
  background: #fff7ed;
  color: #9a3412;
  border-color: #fed7aa;
}

.email-verify-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  font-weight: 500;
}

.email-verify-banner strong {
  display: block;
  margin-bottom: 0.15rem;
}

.email-verify-banner span {
  font-weight: 500;
  opacity: 0.92;
}

html[data-theme="dark"] .flash-warn {
  background: rgba(251, 146, 60, 0.12);
  color: #fdba74;
  border-color: rgba(251, 146, 60, 0.35);
}

label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.3rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="email"],
input[type="password"],
input[type="file"],
textarea,
select {
  width: 100%;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  border-radius: 6px;
  padding: 0.55rem 0.7rem;
  font: inherit;
  color: var(--ink);
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
}

input[type="password"] {
  font-family: var(--font);
  letter-spacing: 0.08em;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--focus-border);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink);
  box-shadow: 0 0 0 1000px var(--input-bg) inset;
  transition: background-color 99999s ease-out;
  caret-color: var(--ink);
}

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

.field { margin-bottom: 0.85rem; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
}
.form-grid .full { grid-column: 1 / -1; }

.table {
  width: 100%;
  border-collapse: collapse;
}
.table th,
.table td {
  text-align: left;
  padding: 0.7rem 0.55rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--surface-2);
}
.table td.num, .table th.num { text-align: right; }
.table tbody tr:hover td { background: var(--surface-2); }

button.linkish {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
button.linkish:hover { text-decoration: underline; }

button.linkish-danger {
  color: var(--danger);
}
button.linkish-danger:hover {
  color: var(--danger);
  filter: brightness(0.85);
}

.empty {
  padding: 2.25rem 1rem;
  text-align: center;
  color: var(--muted);
}

.hint {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 1rem;
}

.muted-sm {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.15rem;
}

.table .nowrap,
.nowrap {
  white-space: nowrap;
}

.logo-preview {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: 6px;
  background: var(--surface-3);
  border: 1px solid var(--line);
}

.items-editor {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.35rem;
}
.items-editor th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-align: left;
  padding: 0.35rem 0.3rem;
}
.items-editor td { padding: 0.3rem; }
.items-editor input { padding: 0.5rem 0.55rem; }

.section-title {
  margin: 1.1rem 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 700;
}

.invoice-form-block {
  margin-top: 1.25rem;
  padding: 1rem 1.05rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2, #f8fafc);
}

.invoice-form-block-from {
  border-left: 3px solid #64748b;
}

.invoice-form-block-client {
  border-left: 3px solid #0f766e;
}

html[data-theme="dark"] .invoice-form-block {
  background: rgba(255, 255, 255, 0.03);
}

.invoice-form-block .section-title {
  margin-top: 0;
}

.invoice-form-block .client-picker {
  margin-bottom: 0.75rem;
}

.auth-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 3.5rem 0 2rem;
}

.auth-card.maintenance-card h1 {
  margin-bottom: 0.5rem;
}

.auth-card.maintenance-card .hint {
  margin-bottom: 0;
}

.auth-wrap {
  width: min(400px, calc(100% - 2rem));
  margin: 0 auto;
}

.auth-wrap-wide {
  width: min(440px, calc(100% - 2rem));
}

.captcha-field .captcha-input {
  display: flex;
  align-items: stretch;
  max-width: 10rem;
}

.captcha-field .captcha-prefix {
  display: inline-flex;
  align-items: center;
  padding: 0 0.7rem;
  border: 1px solid var(--input-border);
  border-right: 0;
  border-radius: 8px 0 0 8px;
  background: var(--surface-3);
  color: var(--muted);
  font-weight: 600;
}

.captcha-field .captcha-input input {
  max-width: none;
  width: 100%;
  border-radius: 0 8px 8px 0;
}

.captcha-hint {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
}

.auth-foot {
  margin: 1.1rem 0 0;
  text-align: center;
  font-size: 0.88rem;
  color: var(--muted);
}

.auth-foot a {
  color: var(--ink);
  font-weight: 600;
}

.optional {
  font-weight: 400;
  color: var(--muted);
}

.auth-card h1 {
  margin: 0.35rem 0 0.25rem;
  font-size: 1.35rem;
}

.auth-brand {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.auth-remember {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.15rem 0 0.85rem;
  font-size: 0.9rem;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}

.auth-remember input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.client-picker {
  margin-bottom: 1.1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.client-picker select {
  font-weight: 500;
}

.account-strip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.88rem;
}

.account-strip strong { font-weight: 600; }
.account-strip span { color: var(--muted); }

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

.choice {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  margin: 0;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--ink);
}

.choice:has(input:checked) {
  border-color: var(--focus-border);
  background: var(--accent-soft);
}

.choice input {
  margin-top: 0.2rem;
  width: auto;
}

.choice strong {
  display: block;
  font-size: 0.9rem;
}

.choice small {
  display: block;
  color: var(--muted);
  margin-top: 0.15rem;
  font-size: 0.8rem;
}

.kyc-policy-list {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.85rem;
}

.table-clients .client-row-open,
.table-counterparties .counterparty-row-open {
  cursor: pointer;
}

.table-clients .client-row-open:hover,
.table-counterparties .counterparty-row-open:hover {
  background: var(--surface-2, #f8fafc);
}

.client-row-actions,
.counterparty-row-actions {
  width: 1%;
  white-space: nowrap;
  vertical-align: middle;
}

.client-row-actions .row-actions,
.counterparty-row-actions .row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
}

.client-row-actions .row-actions form,
.counterparty-row-actions .row-actions form {
  display: inline-flex;
  margin: 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  position: relative;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.icon-btn-danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger-border);
}

.icon-btn[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 0.35rem);
  left: 50%;
  transform: translateX(-50%) translateY(0.15rem);
  padding: 0.28rem 0.5rem;
  border-radius: 6px;
  background: #1f2937;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.01em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease, transform 0.12s ease, visibility 0.12s ease;
  z-index: 30;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.18);
}

html[data-theme="dark"] .icon-btn[data-tip]::after {
  background: #e7ecf1;
  color: #0f1419;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.icon-btn[data-tip]:hover::after,
.icon-btn[data-tip]:focus-visible::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Crypto wallet editors */
.wallet-row {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.35rem;
}

.wallet-row:last-child {
  border-bottom: none;
}

.wallet-block {
  padding: 0.95rem 1rem 0.55rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2, #f8fafc);
  border-bottom: 1px solid var(--line);
}

.wallet-block:last-child {
  margin-bottom: 0;
}

.wallet-add-card .wallet-add-block {
  margin-bottom: 0;
  background: var(--card, #fff);
  border-style: dashed;
}

.wallet-aml-slot {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px dashed var(--line);
  background: var(--surface-2, #f9fafb);
  color: var(--ink);
  font-size: 0.88rem;
}

.wallet-aml-slot .hint {
  margin: 0;
}

.wallet-assoc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.wallet-assoc-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
}

.wallet-assoc-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.wallet-assoc-main {
  min-width: 0;
  flex: 1;
}

.wallet-assoc-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.wallet-assoc-sep {
  color: var(--muted);
  font-weight: 500;
}

.wallet-assoc-addr {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.82rem;
  word-break: break-all;
  color: var(--muted);
}

.wallet-assoc-note {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
}

.wallet-assoc-ex {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
}

.wallet-assoc-ex.is-shared,
.wallet-assoc-item.is-shared .wallet-assoc-ex {
  background: #fffbeb;
  color: #92400e;
  border-color: #fde68a;
}

html[data-theme="dark"] .wallet-assoc-ex {
  background: #3a2718;
  color: #fdba74;
  border-color: #9a3412;
}

.wallet-row-actions {
  margin-top: -0.25rem;
}

.wallet-row-exchange {
  background: var(--surface-2, #f8fafc);
  border-radius: 10px;
  padding: 0.85rem 0.85rem 0.35rem;
  border: 1px dashed var(--line);
  border-bottom: 1px dashed var(--line);
}

.wallet-exchange-disclaimer {
  margin: 0.75rem 0 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid #f59e0b;
  border-left-width: 4px;
  border-radius: 8px;
  background: #fffbeb;
  color: #78350f;
  font-size: 0.9rem;
  line-height: 1.5;
}

.wallet-exchange-disclaimer strong {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.wallet-exchange-disclaimer p {
  margin: 0;
}

html[data-theme="dark"] .wallet-exchange-disclaimer {
  background: rgba(245, 158, 11, 0.12);
  border-color: #d97706;
  color: #fcd34d;
}

.wallet-row-shared {
  background: #fff7ed;
  border-radius: 10px;
  padding: 0.85rem 0.85rem 0.35rem;
  border: 1px solid #fed7aa;
  border-bottom: 1px solid #fed7aa;
}

.wallet-shared-badge {
  margin: 0;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: 0.88rem;
  line-height: 1.35;
}

html[data-theme="dark"] .wallet-row-shared {
  background: #3a2718;
  border-color: #9a3412;
}

html[data-theme="dark"] .wallet-shared-badge {
  background: #2a1f12;
  border-color: #92400e;
  color: #fdba74;
}

.wallet-exchange-flag {
  margin: 0;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  font-size: 0.85rem;
  line-height: 1.35;
}

html[data-theme="dark"] .wallet-exchange-flag {
  background: #3a2718;
  border-color: #9a3412;
  color: #fdba74;
}

#wallets-editor .form-grid {
  gap: 0.65rem 0.85rem;
}

.wallet-type-toggle {
  display: inline-flex;
  width: 100%;
  max-width: 16rem;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2, #f8fafc);
  gap: 2px;
}

.wallet-type-opt {
  flex: 1 1 0;
  margin: 0;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

.wallet-type-opt input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.wallet-type-opt span {
  display: block;
  text-align: center;
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.2;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.wallet-type-opt:hover span {
  color: var(--ink);
}

.wallet-type-opt input:checked + span {
  background: var(--card, #fff);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.wallet-type-opt input:focus-visible + span {
  outline: 2px solid var(--focus-border, #2563eb);
  outline-offset: 1px;
}

html[data-theme="dark"] .wallet-type-toggle {
  background: rgba(255, 255, 255, 0.04);
}

html[data-theme="dark"] .wallet-type-opt input:checked + span {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: none;
}

.stmt-wallet-picker {
  display: grid;
  gap: 0.45rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2, #f8fafc);
}

.stmt-wallet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}

.stmt-wallet-check {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  font-size: 0.9rem;
  color: var(--ink);
}

.stmt-wallet-check input {
  margin-top: 0.2rem;
  width: auto;
}

.stmt-wallet-empty-hint {
  margin: 0.25rem 0 0;
}

.wallet-type-opt.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.stmt-account-toggle {
  max-width: 18rem;
}

.stmt-dir {
  display: inline-block;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.stmt-dir-in { color: #047857; }
.stmt-dir-out { color: #b91c1c; }
.table .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
}

.stmt-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin: 0 0 1rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2, #f8fafc);
  font-size: 0.85rem;
  color: var(--muted);
}

.stmt-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.stmt-mark {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 999px;
  flex: 0 0 auto;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.stmt-mark-matched {
  background: #16a34a;
}

.stmt-mark-unidentified {
  background: #eab308;
}

.stmt-mark-problematic {
  background: #dc2626;
}

.stmt-mark-refund {
  background: #7c3aed;
}

.stmt-mark-col {
  width: 1.25rem;
  padding-right: 0.25rem !important;
  vertical-align: middle;
}

.stmt-personal-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #5b4630;
  background: #efe4d0;
  border-radius: 4px;
  vertical-align: middle;
}

.stmt-row-matched {
  background: rgba(22, 163, 74, 0.04);
}

.stmt-row-unidentified {
  background: rgba(234, 179, 8, 0.06);
}

.stmt-row-problematic {
  background: rgba(220, 38, 38, 0.05);
}

.stmt-row-refund {
  background: rgba(124, 58, 237, 0.06);
}

.stmt-refund-note {
  color: #6d28d9;
  border-color: rgba(124, 58, 237, 0.28);
  background: rgba(124, 58, 237, 0.08);
}

.stmt-personal-xfer {
  color: #5b4630;
  border-color: rgba(120, 90, 40, 0.28);
  background: #efe4d0;
}

.stmt-inv-link {
  display: inline-block;
  margin-left: 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font);
}

.stmt-ex-note {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.06);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--font);
  letter-spacing: 0.01em;
  vertical-align: middle;
}

html[data-theme="dark"] .stmt-ex-note {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

html[data-theme="dark"] .stmt-legend {
  background: var(--surface-2);
}

html[data-theme="dark"] .stmt-row-matched {
  background: rgba(34, 197, 94, 0.08);
}

html[data-theme="dark"] .stmt-row-unidentified {
  background: rgba(234, 179, 8, 0.1);
}

html[data-theme="dark"] .stmt-row-problematic {
  background: rgba(248, 113, 113, 0.1);
}

html[data-theme="dark"] .stmt-row-refund {
  background: rgba(167, 139, 250, 0.12);
}

html[data-theme="dark"] .stmt-refund-note {
  color: #c4b5fd;
  border-color: rgba(167, 139, 250, 0.35);
  background: rgba(167, 139, 250, 0.12);
}

html[data-theme="dark"] .stmt-personal-xfer {
  color: #e7d3a8;
  border-color: rgba(231, 211, 168, 0.35);
  background: rgba(231, 211, 168, 0.12);
}

.stmt-filters-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem 1rem;
  margin-bottom: 0;
}

.stmt-filters-meta > .field {
  margin-bottom: 0;
}

.stmt-filters-toggles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 1.15rem;
  margin-bottom: 0;
  padding-top: 0.15rem;
}

.stmt-filter-check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
}

.stmt-filter-check input {
  width: auto;
  margin: 0;
}

@media (max-width: 640px) {
  .stmt-filters-meta {
    grid-template-columns: 1fr;
  }
}
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.stmt-table .nowrap { white-space: nowrap; }
.stmt-you {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  vertical-align: middle;
}
.stmt-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.stmt-pager-info {
  color: var(--muted);
  font-size: 0.9rem;
}

.stmt-comment-cell {
  min-width: 7.5rem;
  max-width: 12rem;
}

.stmt-memo-cell {
  min-width: 5.5rem;
  max-width: 11rem;
}

.stmt-memo-text {
  display: inline-block;
  max-width: 100%;
  font-size: 0.8rem;
  line-height: 1.3;
  color: var(--ink);
  word-break: break-word;
}

.stmt-comment-text {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  line-height: 1.3;
  color: var(--ink);
  word-break: break-word;
}

.stmt-comment-btn {
  padding: 0.25rem 0.55rem;
  font-size: 0.78rem;
}

#stmt-comment-modal .digital-modal-form input[type="text"] {
  width: 100%;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.theme-toggle-icon {
  width: 14px;
  height: 14px;
  display: inline-block;
  position: relative;
}

.theme-toggle-icon-moon {
  border-radius: 50%;
  box-shadow: inset -3px -1px 0 1px currentColor;
}

.theme-toggle-icon-sun {
  border-radius: 50%;
  border: 1.5px solid currentColor;
  box-sizing: border-box;
}

.theme-toggle-icon-sun::before,
.theme-toggle-icon-sun::after {
  content: "";
  position: absolute;
  inset: -3px;
  background:
    linear-gradient(currentColor, currentColor) center / 1.5px 100% no-repeat,
    linear-gradient(currentColor, currentColor) center / 100% 1.5px no-repeat;
  opacity: 0.85;
}

.theme-toggle-icon-sun::after {
  transform: rotate(45deg);
}

html[data-theme="dark"] .theme-toggle-icon-moon { display: none; }
html:not([data-theme="dark"]) .theme-toggle-icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle-icon-sun { display: inline-block; }
html:not([data-theme="dark"]) .theme-toggle-icon-moon { display: inline-block; }

.auth-theme-wrap {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  margin: 0;
  width: auto;
}

.auth-wrap-wide + .auth-theme-wrap,
.auth-theme-wrap.wide {
  width: auto;
}

.digital-share-banner {
  margin-bottom: 1rem;
}

.digital-share-copy-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.digital-share-copy-row input {
  flex: 1 1 220px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
}

.share-sheet {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.share-sheet[hidden] {
  display: none !important;
}

.share-sheet-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(15, 23, 42, 0.45);
  cursor: pointer;
}

.share-sheet-panel {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 16px 16px 0 0;
  padding: 1rem 1.1rem 1.25rem;
  box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.18);
  animation: share-sheet-in 0.2s ease;
}

@keyframes share-sheet-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.share-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.share-sheet-x {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.35rem;
}

.share-sheet-url {
  margin: 0 0 0.85rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  background: var(--surface-2, #f3f4f6);
  border: 1px solid var(--line);
  font-size: 0.78rem;
  word-break: break-all;
}

.share-sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.share-sheet-actions .btn {
  justify-content: center;
  text-align: center;
}

body.share-sheet-open {
  overflow: hidden;
}

@media (min-width: 720px) {
  .share-sheet {
    align-items: center;
    padding: 1rem;
  }

  .share-sheet-panel {
    border-radius: 14px;
  }
}

.permanent-links-card {
  margin-bottom: 1rem;
}

.permanent-link-list {
  display: grid;
  gap: 0.85rem;
}

.permanent-link-row {
  padding: 0.65rem 0;
  border-top: 1px solid var(--line);
}

.permanent-link-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.permanent-link-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.75rem;
  margin-bottom: 0.4rem;
}

.permanent-link-meta .muted-sm {
  margin: 0;
}

.actions-cell {
  white-space: nowrap;
  overflow: visible;
}

.actions-cell .row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.1rem;
  flex-wrap: wrap;
  overflow: visible;
}

.actions-cell .row-actions form {
  display: inline-flex;
  margin: 0;
}

a.icon-btn {
  text-decoration: none;
  color: var(--muted);
}

a.icon-btn:hover {
  color: var(--ink);
}

body.digital-modal-open {
  overflow: hidden;
}

.digital-modal[hidden] {
  display: none !important;
}

.digital-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.digital-modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  margin: 0;
  background: rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(8px) saturate(1.05);
  -webkit-backdrop-filter: blur(8px) saturate(1.05);
  cursor: pointer;
}

html[data-theme="dark"] .digital-modal-backdrop {
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(10px) saturate(1.08);
  -webkit-backdrop-filter: blur(10px) saturate(1.08);
}

body.digital-modal-open .topbar {
  filter: blur(3px);
  transition: filter 0.18s ease;
}

body.digital-modal-open main.wrap > :not(.digital-modal) {
  filter: blur(3px);
  transition: filter 0.18s ease;
}

body.digital-modal-open .invoice-actions,
body.digital-modal-open .invoice-page,
body.digital-modal-open .digital-share-wrap {
  filter: blur(3px);
  transition: filter 0.18s ease;
}

.digital-modal-panel {
  position: relative;
  z-index: 1;
  width: min(26rem, 100%);
  max-height: min(90vh, 40rem);
  overflow: auto;
  padding: 1.15rem 1.25rem 1.25rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--popover-shadow);
}

.stmt-request-panel {
  width: min(34rem, 100%);
  max-height: min(92vh, 48rem);
}

.stmt-request-layout {
  margin-top: 0.35rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--line);
}

.stmt-req-wallet-picker {
  max-height: 11rem;
  overflow: auto;
}

.digital-modal-form .stmt-wallet-check input[type="checkbox"],
.digital-modal-form .stmt-filter-check input[type="checkbox"],
.digital-modal-form .stmt-req-account-radio,
.digital-modal-form input[type="checkbox"],
.digital-modal-form input[type="radio"] {
  width: auto;
  min-width: 1rem;
  max-width: 1.1rem;
  height: auto;
  margin: 0.15rem 0 0;
  flex: 0 0 auto;
  align-self: flex-start;
}

.digital-modal-form .stmt-wallet-check {
  align-items: flex-start;
}

.digital-modal-form .stmt-wallet-check span {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.35;
}

.pdf-preview-panel {
  width: min(56rem, 100%);
  max-height: min(94vh, 56rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 1rem;
}

.pdf-preview-frame-wrap {
  flex: 1 1 auto;
  min-height: min(70vh, 42rem);
  margin-top: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
}

.pdf-preview-frame {
  display: block;
  width: 100%;
  height: 100%;
  min-height: min(70vh, 42rem);
  border: 0;
  background: #fff;
}

.pdf-preview-actions {
  margin-top: 0.85rem;
  justify-content: flex-end;
}

html[data-theme="dark"] .pdf-preview-frame {
  background: #111;
}

.digital-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.digital-modal-x {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
}

.digital-modal-x:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.digital-modal-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.digital-modal-form label {
  margin: 0;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.85rem;
}

.digital-modal-form select {
  width: auto;
  min-width: 8rem;
}

.digital-modal-form .field select,
.digital-modal-form .field input {
  width: 100%;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}

.status-pill-btn {
  font: inherit;
  cursor: pointer;
}

.status-choice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.status-choice-btn {
  font: inherit;
  cursor: pointer;
  min-width: 5.5rem;
  justify-content: center;
}

.status-choice-btn.is-current {
  outline: 2px solid currentColor;
  outline-offset: 1px;
}

.status-pill-draft {
  background: #f1f5f9;
  color: #475569;
  border-color: #cbd5e1;
}

.status-pill-pending {
  background: #fff7ed;
  color: #c2410c;
  border-color: #fed7aa;
}

.status-pill-paid {
  background: var(--flash-ok-bg);
  color: var(--flash-ok-ink);
  border-color: var(--flash-ok-border);
}

.status-pill-overdue {
  background: var(--danger-soft);
  color: var(--flash-err-ink);
  border-color: var(--danger-border);
}

.status-pill-declined {
  background: #f1f5f9;
  color: #64748b;
  border-color: #cbd5e1;
  text-decoration: line-through;
}

html[data-theme="dark"] .status-pill-draft {
  background: #1e293b;
  color: #94a3b8;
  border-color: #334155;
}

html[data-theme="dark"] .status-pill-pending {
  background: #3a2718;
  color: #fdba74;
  border-color: #9a3412;
}

html[data-theme="dark"] .status-pill-declined {
  background: #1e293b;
  color: #94a3b8;
  border-color: #475569;
}

.invoice-row-declined td {
  color: var(--muted);
  text-decoration: line-through;
}

.invoice-row-declined .status-pill,
.invoice-row-declined .actions-cell,
.invoice-row-declined .actions-cell a,
.invoice-row-declined .actions-cell button {
  text-decoration: none;
}

.invoice-row-declined .actions-cell {
  color: inherit;
}

.status-tx {
  margin-top: 0.25rem;
  font-size: 0.72rem;
  color: var(--muted);
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.totp-status-on { color: #047857; }
html[data-theme="dark"] .totp-status-on { color: #6ee7b7; }

.totp-setup {
  display: grid;
  gap: 0.85rem;
  max-width: 28rem;
}

.totp-steps {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.totp-qr-wrap {
  display: inline-flex;
  padding: 0.65rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  width: fit-content;
}

.totp-qr {
  display: block;
  width: 200px;
  height: 200px;
}

.totp-secret {
  margin: 0;
  font-size: 0.85rem;
  word-break: break-all;
}

.totp-backup-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.totp-backup-list code {
  font-size: 0.92rem;
}

.totp-subhead {
  margin: 0 0 0.55rem;
  font-size: 0.95rem;
}

.totp-manage-grid {
  gap: 1.25rem;
}

@media (max-width: 640px) {
  .totp-backup-list {
    grid-template-columns: 1fr;
  }
}

