:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --primary: #2463eb;
  --primary-dark: #1e40af;
  --primary-soft: #dbeafe;
  --accent: #22c55e;
  --warning: #f59e0b;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --border: #e2e8f0;
  --sidebar: #0f172a;
  --sidebar-muted: #94a3b8;
  --chip: #e2e8f0;
  --radius: 16px;
  --shadow: 0 18px 44px rgba(15, 23, 42, 0.09);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.16);
  --focus-ring: 0 0 0 3px rgba(36, 99, 235, 0.35);
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --transition: 0.15s ease;
  font-family: "Manrope", "Plus Jakarta Sans", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 100% 0%, rgba(59, 130, 246, 0.08), transparent 40%),
    linear-gradient(120deg, #f4f7fc 0%, #edf2fb 60%, #f7f9ff 100%);
  color: var(--ink);
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
  color: #fff;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand .logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.brand .tagline {
  color: var(--sidebar-muted);
  font-size: 12px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  margin-top: 6px;
}

.side-nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  background: transparent;
  color: #fff;
  border: 1px solid transparent;
  padding: 12px 14px;
  border-radius: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  cursor: pointer;
  font-weight: 600;
}

.nav-item span:last-child {
  font-size: 14px;
}

.nav-item .nav-icon {
  font-size: 16px;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(148, 163, 184, 0.16);
}

.nav-item:hover,
.nav-item.active {
  background: rgba(59, 130, 246, 0.24);
  border-color: rgba(59, 130, 246, 0.35);
}

.nav-item:hover .nav-icon,
.nav-item.active .nav-icon {
  background: rgba(59, 130, 246, 0.35);
}

.sidebar-footer {
  margin-top: auto;
}

.main {
  padding: 32px 40px 60px;
  display: grid;
  gap: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 16px;
  border: 1px solid #dbe4f2;
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #f7faff);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.mobile-menu-btn {
  display: none;
}

.mobile-menu-backdrop {
  display: none;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
}

.page-sub {
  color: var(--muted);
  font-size: 13px;
}

.top-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Focus mode reduces visual noise but keeps primary actions and values visible. */
body.focus-mode .page-sub,
body.focus-mode .chips,
body.focus-mode .stat-meta,
body.focus-mode .meta {
  display: none !important;
}

body.focus-mode .main {
  gap: 14px;
}

body.focus-mode .topbar {
  padding: 10px 12px;
}

body.focus-mode .panel {
  padding: 14px 16px;
}

body.focus-mode .panel-header {
  margin-bottom: 8px;
  padding-bottom: 8px;
}

.panel {
  background: var(--panel);
  border: 1px solid #d9e3f2;
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #edf2fb;
}

.panel-header h2 {
  margin: 0;
  font-size: 18px;
}

.panel-body {
  display: grid;
  gap: 16px;
}

.panel-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-bar label {
  font-size: 12px;
  color: var(--muted);
}

.filter-select {
  border: 1px solid #d4deed;
  border-radius: 10px;
  padding: 7px 10px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: #edf2fb;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  border: 1px solid #d7e2f3;
}

.chip.active {
  background: rgba(59, 130, 246, 0.18);
  border-color: #a8c2f6;
  color: var(--primary);
}

.chip-archive {
  background: #f3f0fa;
  border-color: #c7b8e8;
  color: #6b48b5;
  opacity: 0.85;
}

.chip-archive.active {
  background: rgba(107, 72, 181, 0.15);
  border-color: #a98de0;
  color: #6b48b5;
}

.chip-button {
  cursor: pointer;
  font: inherit;
}

.invoice-view-modes {
  align-items: center;
}

.invoice-sort-toolbar {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-top: 10px;
  margin-bottom: 10px;
}

.invoice-sort-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border: 1px solid #d7e2f3;
  border-radius: 12px;
  background: #f8fbff;
}

.invoice-sort-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.invoice-queue-summary {
  align-items: center;
}

.compose-coverage-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.compose-coverage-metrics {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.coverage-row {
  grid-template-columns: minmax(220px, 1.3fr) minmax(260px, 2fr) minmax(180px, 1.1fr) minmax(220px, 1.2fr);
}

/* ---- Tenant Shortcut Cards ---- */
.tenant-shortcuts-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0;
}

/* ── Compose split layout ─────────────────────────────────── */
.compose-layout {
  display: block;
}

.compose-main {
  display: grid;
  gap: 16px;
}

/* Two invoice previews side by side above tenants */
.compose-invoices-row {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.compose-invoice-panel {
  flex: 1 1 0;
  min-width: 0;
}

.compose-invoice-panel--new {
  /* always visible */
}

.compose-prev-sidebar,
.compose-sidebar {
  /* kept for any stale references, no-op */
}

.compose-sidebar-inner {
  display: grid;
  gap: 8px;
}

.compose-preview-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 4px;
  margin-bottom: 4px;
}

.prev-gap-warning {
  background: #fff8e1;
  border: 1px solid #f59e0b;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 11px;
  color: #92400e;
  margin-bottom: 8px;
}
.prev-invoice-payments-list {
  background: #f8f9fa;
  border: 1px solid #e2e6ea;
  border-radius: 6px;
  padding: 10px 12px;
  display: grid;
  gap: 6px;
  margin-top: 8px;
}
.prev-invoice-payments-list:empty { display: none; }
.prev-calc-breakdown {
  margin-top: 8px;
  background: #f0f4f8;
  border: 1px solid #d0dce8;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 11px;
}
.prev-calc-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
  margin-bottom: 5px;
}
.prev-calc-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
  color: #444;
}
.prev-calc-row + .prev-calc-row {
  border-top: 1px dotted #d0dce8;
}
.prev-calc-op {
  width: 14px;
  text-align: center;
  font-weight: 700;
  color: #6b7280;
  flex-shrink: 0;
}
.prev-calc-label {
  flex: 1;
}
.prev-calc-amt {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.prev-calc-result {
  border-top: 1px solid #a0b4c8 !important;
  margin-top: 2px;
  padding-top: 3px;
  color: #1e3a5f;
}

.prev-payment-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #333;
  padding: 6px 0;
  border-bottom: 1px solid #eee;
}
.prev-payment-row:last-child { border-bottom: none; }
.prev-payment-method { font-size: 14px; flex-shrink: 0; }
.prev-payment-info { flex: 1; line-height: 1.4; }
.prev-payment-type-badge { font-size: 10px !important; padding: 1px 6px !important; }
.prev-payment-date { color: #666; font-size: 11px; margin-top: 1px; }
.prev-payment-amount { font-weight: 600; color: #2d7a2d; white-space: nowrap; }

/* Transaction row highlight when navigating from payments panel */
@keyframes highlight-fade {
  0%   { background: #fff3cd; box-shadow: 0 0 0 3px #f0ad4e; }
  70%  { background: #fff3cd; box-shadow: 0 0 0 3px #f0ad4e; }
  100% { background: transparent; box-shadow: none; }
}
.highlight-pulse {
  animation: highlight-fade 2.5s ease forwards;
  border-radius: 4px;
}
.prev-payments-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 4px;
}
.prev-payments-none {
  font-size: 12px;
  color: #999;
  font-style: italic;
}

@media (max-width: 900px) {
  .compose-invoices-row { flex-direction: column; }
}
.tenant-shortcut-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.tenant-shortcut-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  cursor: pointer;
  min-width: 150px;
  max-width: 220px;
  background: #fff;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
  user-select: none;
  text-align: left;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}
.tenant-shortcut-card:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(36, 99, 235, 0.10);
}
.tenant-shortcut-card.is-ready {
  border-color: #bfdbfe;
}
.tenant-shortcut-card.is-ready:hover {
  border-color: var(--primary);
}
.tenant-shortcut-card.is-created {
  opacity: 0.88;
}
.tenant-shortcut-card.is-sent {
  opacity: 0.65;
}
.tenant-shortcut-card.is-blocked {
  border-color: #fed7aa;
}
.shortcut-edit-btn {
  font-size: 11px;
  padding: 2px 8px;
  opacity: 0.55;
  align-self: flex-start;
  width: 100%;
}
.shortcut-edit-btn:hover {
  opacity: 1;
}
.shortcut-tenant {
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.shortcut-prop {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.shortcut-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11px;
}
/* ---- end Tenant Shortcut Cards ---- */


.coverage-row-ready {
  border-color: #bfdbfe;
  background: #f8fbff;
}

.coverage-row-blocked {
  border-color: #fed7aa;
  background: #fffaf5;
}

.coverage-status-column {
  display: grid;
  gap: 6px;
}

.coverage-status-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.coverage-blocking {
  color: #b45309 !important;
}

.coverage-warning {
  color: #64748b !important;
}

.invoice-queue-badge {
  cursor: pointer;
  border: 1px solid transparent;
  font: inherit;
}

.invoice-queue-badge.active {
  border-color: currentColor;
  box-shadow: inset 0 0 0 1px currentColor;
}

.invoice-queue-badge:disabled {
  cursor: default;
  opacity: 0.55;
}

.form-card,
.upload-card {
  border: 1px solid #dce5f2;
  border-radius: 12px;
  padding: 16px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.form-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 12px;
}

.form-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 12px;
}

.form-block {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}

.block-title {
  font-weight: 600;
  margin-bottom: 10px;
}

.form-stack {
  display: grid;
  gap: 10px;
}

.auto-grow {
  resize: none;
  overflow: hidden;
  min-height: 80px;
}

.cards-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.property-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: grid;
  gap: 10px;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.05);
}

/* Email inbox list row */
.inbox-row {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 5px;
  transition: background 0.15s;
}
.inbox-row:hover { background: var(--light); }
.inbox-row--linked {
  border-left: 3px solid var(--success, #22c55e);
  background: #f0fdf4;
}
.inbox-row--linked:hover { background: #dcfce7; }

.inbox-thumb {
  width: 52px;
  height: 44px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}
.inbox-thumb-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: #f1f5f9;
}

.inbox-row-body {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.inbox-row-title {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.inbox-subject {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.inbox-row-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.inbox-row-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.btn-primary-soft {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}
.btn-primary-soft:hover {
  background: #dbeafe;
}


.property-thumb {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 10px;
  background: #eef2ff;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  z-index: 50;
}

.modal.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.modal-content {
  background: #fff;
  border-radius: 16px;
  width: min(1100px, 95vw);
  max-height: 90vh;
  overflow: auto;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.2);
  display: grid;
  gap: 18px;
}

.modal-content.modal-compact {
  width: min(760px, 95vw);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
}

.modal-gallery {
  display: grid;
  gap: 12px;
}

.gallery-slider {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  gap: 10px;
  align-items: center;
  position: relative;
}

.gallery-slider img {
  width: 100%;
  height: auto;
  max-height: 420px;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #eef2ff;
}

.gallery-slider #gallery-delete {
  position: absolute;
  top: 10px;
  right: 10px;
}

.gallery-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.gallery-item {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.gallery-item img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}

.gallery-item button {
  position: absolute;
  top: 8px;
  right: 8px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.summary-block {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #f8fafc;
  display: grid;
  gap: 8px;
}

.summary-list {
  display: grid;
  gap: 8px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.summary-label {
  color: var(--muted);
}

.summary-value {
  font-weight: 600;
  text-align: right;
}

.value-positive {
  color: #15803d;
}

.value-negative {
  color: #b91c1c;
}

.value-neutral {
  color: inherit;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.kpi-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  display: grid;
  gap: 6px;
}

.kpi-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-value {
  font-size: 20px;
  font-weight: 700;
}

.kpi-hint {
  font-size: 12px;
  color: var(--muted);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.base-row {
  display: grid;
  grid-template-columns: 2fr 0.8fr 0.8fr 1fr 0.6fr;
  gap: 10px;
  align-items: center;
}

.base-row.header {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.base-row.item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
}

.drop-zone.dragover {
  border-color: var(--primary);
  background: #eef2ff;
  color: var(--text);
}

.drop-zone input {
  display: none;
}

.base-form {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.property-card .meta {
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.badge.green { background: rgba(34, 197, 94, 0.16); color: #15803d; }
.badge.blue { background: rgba(59, 130, 246, 0.16); color: #1d4ed8; }
.badge.orange { background: rgba(245, 158, 11, 0.16); color: #b45309; }
.badge.red { background: rgba(220, 38, 38, 0.14); color: #b91c1c; }

.table {
  display: grid;
  gap: 8px;
}

.lease-group {
  border: 1px solid #dbe5f3;
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}

.lease-group-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: #f8fbff;
  border-bottom: 1px solid #e3ebf8;
}

.lease-group-header-main {
  display: grid;
  gap: 6px;
}

.lease-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lease-group-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.lease-group-header-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.lease-tenant-list {
  display: grid;
}

.lease-tenant-row {
  display: grid;
  grid-template-columns: 1.1fr 1.3fr 0.8fr 1.2fr;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid #eef3fb;
  font-size: 13px;
}

.lease-tenant-row:first-child {
  border-top: none;
}

.lease-tenant-row .table-actions {
  justify-content: flex-start;
}

.month-group {
  display: grid;
  gap: 8px;
}

.month-group + .month-group {
  margin-top: 6px;
}

.month-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 6px;
}

.month-title {
  font-weight: 700;
  text-transform: capitalize;
}

.month-meta {
  font-size: 12px;
  color: var(--muted);
}

.table-row {
  display: grid;
  grid-template-columns: 1.2fr 2fr 1fr 1fr;
  gap: 12px;
  padding: 12px;
  border: 1px solid #dbe5f3;
  border-radius: 12px;
  background: #fff;
  font-size: 13px;
  align-items: start;
  transition: transform 0.1s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.table-row:hover {
  border-color: #bfd3f3;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.08);
  transform: translateY(-1px);
}

.table-row strong {
  font-weight: 700;
}

.table-row .muted {
  color: var(--muted);
  font-size: 12px;
}

.table-row .muted.date-overdue {
  color: #dc2626;
  font-weight: 700;
}

.table-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
  align-items: center;
}

.invoice-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.invoice-bank-tools {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border: 1px solid #d7e2f3;
  border-radius: 12px;
  background: linear-gradient(180deg, #f8fbff 0%, #eef5ff 100%);
}

.invoice-bank-tools-passive {
  justify-content: flex-start;
  background: #f8fafc;
}

.invoice-bank-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #d7e2f3;
  background: #fff;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.invoice-bank-check.selected {
  border-color: #93c5fd;
  background: #dbeafe;
  color: #1d4ed8;
}

.invoice-bank-check input {
  margin: 0;
}

.invoice-bank-primary {
  min-width: 122px;
  justify-content: center;
}

.invoice-bank-secondary {
  background: #fff;
}

.invoice-actions > span {
  width: 100%;
}

.inline-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.inline-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.txn-link-suggestions {
  display: grid;
  gap: 8px;
  margin-top: 6px;
}

.txn-link-card {
  border: 1px solid #dbe5f3;
  border-radius: 12px;
  background: #fff;
  padding: 10px 12px;
  display: grid;
  gap: 6px;
}

.txn-link-card.active {
  border-color: #93c5fd;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.12);
  background: #f8fbff;
}

.txn-link-card-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}

.txn-link-card-title {
  font-weight: 700;
}

.txn-link-card-meta {
  font-size: 12px;
  color: var(--muted);
}

.txn-link-chiplist {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.txn-link-chip {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  background: #eef4ff;
  color: #1d4ed8;
  border: 1px solid #cdddff;
}

.txn-link-chip.warn {
  background: #fff6e8;
  color: #b45309;
  border-color: #f6d29e;
}

.info-box {
  background: #f6f8ff;
  border: 1px solid #dbe2ff;
  color: #1f2a5a;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 13px;
  line-height: 1.4;
}

.info-box strong {
  font-weight: 700;
}

.info-list {
  margin-top: 6px;
  white-space: pre-line;
}

.ai-batch-excluded-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.ai-batch-excluded-item {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid #dbe2ff;
  border-radius: 10px;
  padding: 8px 10px;
}

.ai-batch-excluded-title {
  font-weight: 700;
  color: #1f2a5a;
}

.ai-batch-excluded-meta {
  margin-top: 2px;
  color: #5b678f;
  font-size: 12px;
}

.ai-batch-excluded-reason {
  margin-top: 4px;
  color: #92400e;
}

.xml-preview-box {
  margin-top: 8px;
  padding: 10px;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid #dbe2ff;
  border-radius: 8px;
  background: #f8faff;
  color: #1f2a5a;
  font-size: 12px;
  line-height: 1.45;
}

.xml-human-box {
  padding: 10px;
}

.xml-human-head {
  display: grid;
  gap: 2px;
  margin-bottom: 8px;
  color: #1f2a5a;
}

.xml-human-list {
  display: grid;
  gap: 8px;
}

.xml-human-row {
  border: 1px solid #dbe2ff;
  border-radius: 8px;
  padding: 8px;
  background: #ffffff;
}

.xml-human-row-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.xml-human-amount {
  font-weight: 700;
  color: #1f2a5a;
  white-space: nowrap;
}

.xml-human-reason {
  margin-top: 4px;
  color: #374151;
}

.xml-human-meta {
  margin-top: 4px;
  font-size: 12px;
  color: #5b678f;
}

.job-progress-track {
  width: 100%;
  height: 10px;
  background: #dbe5ff;
  border-radius: 999px;
  overflow: hidden;
}

.job-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #60a5fa);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.job-progress-fill.indeterminate {
  width: 35%;
  animation: job-progress-indeterminate 1.2s ease-in-out infinite;
}

@keyframes job-progress-indeterminate {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(320%);
  }
}

.line-header,
.line-row {
  display: grid;
  grid-template-columns: 2fr 0.6fr 0.6fr 0.8fr 0.8fr 40px;
  gap: 8px;
  align-items: center;
}

.line-header {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.line-body {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.line-actions {
  display: flex;
  justify-content: flex-start;
  margin-top: 10px;
  gap: 10px;
  flex-wrap: wrap;
}

.line-actions select {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
  min-width: 200px;
}

.base-charge-picker {
  margin-top: 10px;
}

.base-charge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.base-charge-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  background: #f8fafc;
  font-size: 12px;
}

.line-total {
  font-weight: 700;
  font-size: 12px;
}

.invoice-preview {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  font-family: Arial, "Segoe UI", sans-serif;
  font-size: 11px;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

.invoice-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
}

.invoice-left {
  width: 50%;
  font-size: 12px;
  line-height: 1.4;
}

.invoice-right {
  width: 45%;
  font-size: 12px;
  line-height: 1.4;
  text-align: right;
}

.invoice-logo {
  max-width: 140px;
  max-height: 80px;
  margin-bottom: 8px;
}

.invoice-logo-text {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.invoice-label {
  font-weight: 700;
  margin-top: 8px;
}

.invoice-number-box {
  background: #cfe8ff;
  border: 1px solid #7fb6e6;
  color: #1e3a8a;
  padding: 6px 12px;
  border-radius: 3px;
  font-weight: 700;
  display: inline-block;
}

.invoice-meta {
  margin-top: 6px;
}

.invoice-meta .meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.invoice-company {
  margin-top: 10px;
}

.invoice-company .company-name {
  font-weight: 700;
}

.invoice-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  font-size: 12px;
}

.invoice-table th {
  text-align: left;
  background: #cfe8ff;
  border: 1px solid #7fb6e6;
  padding: 6px;
}

.invoice-table td {
  padding: 6px;
  border: 1px solid #7fb6e6;
}

.invoice-table th:nth-child(1),
.invoice-table td:nth-child(1) { width: 50%; }
.invoice-table th:nth-child(2),
.invoice-table td:nth-child(2) { width: 10%; }
.invoice-table th:nth-child(3),
.invoice-table td:nth-child(3) { width: 10%; }
.invoice-table th:nth-child(4),
.invoice-table td:nth-child(4) { width: 15%; }
.invoice-table th:nth-child(5),
.invoice-table td:nth-child(5) { width: 15%; }

.invoice-table td.num {
  text-align: right;
}

.invoice-vat {
  text-align: center;
  font-size: 11px;
  margin-top: 6px;
}

.invoice-summary {
  margin-top: 10px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.invoice-summary .summary-row {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.invoice-summary .summary-row span {
  min-width: 320px;
  text-align: right;
}

.invoice-summary .summary-row strong {
  min-width: 110px;
  text-align: right;
}

.invoice-summary .invoice-total {
  font-weight: 700;
  font-size: 13px;
}

.invoice-footer {
  margin-top: 16px;
  font-size: 11px;
  color: #1f2937;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.invoice-footer .footer-block {
  text-align: right;
}

.logo-preview {
  display: block;
  max-width: 160px;
  max-height: 90px;
  margin-top: 8px;
}

.status-select {
  background: #fff;
  border: 1px solid #c6d4ed;
  color: #1e3a8a;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #eff4ff;
  color: #1e3a8a;
  border: 1px solid #c7d2fe;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.action-menu {
  position: relative;
  min-width: 150px;
}

.action-menu > summary {
  list-style: none;
  justify-content: center;
}

.action-menu > summary::-webkit-details-marker {
  display: none;
}

.action-menu-list {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  width: min(260px, 92vw);
  max-height: 52vh;
  overflow: auto;
  background: #fff;
  border: 1px solid #dbe5f3;
  border-radius: 12px;
  box-shadow: 0 16px 26px rgba(15, 23, 42, 0.12);
  padding: 8px;
  z-index: 20;
}

.action-menu[open] .action-menu-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.action-menu-list .btn-icon {
  width: 100%;
  justify-content: flex-start;
}

#inv-lhv-batch-bar {
  position: sticky;
  top: 10px;
  z-index: 3;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.08);
}

.invoice-action-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  width: 100%;
}

.invoice-action-row .action-menu {
  flex: 1 1 140px;
  max-width: 190px;
}

.invoice-action-row .action-menu > summary {
  width: 100%;
}

.btn-danger {
  background: var(--danger-soft);
  color: #991b1b;
  border: 1px solid #fecaca;
}

.upload-box {
  border: 2px dashed #cbd5f5;
  border-radius: 14px;
  padding: 20px;
  text-align: center;
  margin-bottom: 12px;
  background: #f1f5ff;
}

.upload-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.upload-sub {
  color: var(--muted);
  font-size: 12px;
}

.upload-card input[type="file"] {
  margin: 8px 0 12px;
}

.stats-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

#portfolio-summary {
  margin: 16px 0 24px;
}

.stat-card {
  padding: 16px;
  border-radius: 14px;
  border: 1px solid #dbe5f3;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.06);
  transition: transform 0.12s ease, box-shadow 0.16s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 24px rgba(37, 99, 235, 0.1);
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  margin: 8px 0;
}

.stat-meta {
  color: var(--muted);
  font-size: 12px;
}

.stat-inline-toggle {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.stat-inline-toggle input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
}

label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  background: #fff;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #7ba4ff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}

.searchable-select {
  position: relative;
}

.searchable-select > select {
  display: none;
}

.searchable-select-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  background: #fff;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.searchable-select-input::placeholder {
  color: var(--muted);
}

.searchable-select-input:focus {
  outline: none;
  border-color: #7ba4ff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  background: linear-gradient(180deg, #2f6ef0 0%, #2157cf 100%);
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 6px 14px rgba(30, 64, 175, 0.22);
  transition: transform 0.08s ease, filter 0.16s ease, opacity 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(30, 64, 175, 0.24);
}

button:active,
button.btn-clicked {
  transform: translateY(1px) scale(0.99);
  filter: brightness(0.96);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.78;
}

button.btn-busy {
  pointer-events: none;
}

button.btn-busy::after {
  content: "";
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-left: 8px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  vertical-align: -1px;
  animation: btn-spin 0.8s linear infinite;
}

button.ghost.btn-busy::after {
  border-color: rgba(30, 64, 175, 0.25);
  border-top-color: var(--primary);
}

.primary {
  background: linear-gradient(180deg, #2f6ef0 0%, #2157cf 100%);
  border-color: #1f49a8;
}
.ghost {
  background: #ffffff;
  color: #334155;
  border: 1px solid #d3dceb;
  box-shadow: none;
}

.ghost:hover:not(:disabled) {
  border-color: #aac2ef;
  background: #f7faff;
  box-shadow: 0 6px 14px rgba(30, 64, 175, 0.08);
}

.form-title {
  margin: 0 0 12px;
  font-size: 17px;
  letter-spacing: 0.01em;
}

.code-block {
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px;
  border-radius: 12px;
  overflow: auto;
}

.ai-preview {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px;
  margin-top: 12px;
  font-size: 13px;
  color: #0f172a;
  white-space: normal;
}

.ai-preview .ai-suggest-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.ai-preview .ai-preview-lines {
  white-space: pre-wrap;
}

.problem-folders {
  margin-top: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
  padding: 12px;
}

.problem-folders-summary {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.problem-folders-summary strong {
  display: block;
  margin-bottom: 4px;
}

.problem-folders-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.problem-folder-search {
  min-width: 240px;
  max-width: 320px;
}

.problem-folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.problem-folder-card {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  padding: 0;
  min-height: 0;
  overflow: hidden;
  transition: box-shadow 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

.problem-folder-card.open {
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.problem-folder-card.pending {
  border-color: #fdba74;
  background: #fff7ed;
}

.problem-folder-card.manual {
  border-color: #fecaca;
  background: #fef2f2;
}

.problem-folder-card.resolved {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.problem-folder-card.ignored {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.problem-folder-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 12px;
  background: transparent;
  border: 0;
  text-align: left;
  cursor: pointer;
}

.problem-folder-head:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.45);
  outline-offset: -2px;
}

.problem-folder-head-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.problem-folder-title {
  font-weight: 700;
  color: #0f172a;
}

.problem-folder-count {
  font-size: 12px;
  border-radius: 999px;
  padding: 4px 10px;
  background: #e2e8f0;
  color: #0f172a;
  font-weight: 700;
}

.problem-folder-chevron {
  font-size: 14px;
  color: #475569;
  line-height: 1;
}

.problem-folder-card.pending .problem-folder-count {
  background: #fed7aa;
  color: #9a3412;
}

.problem-folder-card.manual .problem-folder-count {
  background: #fecaca;
  color: #991b1b;
}

.problem-folder-card.resolved .problem-folder-count {
  background: #bbf7d0;
  color: #166534;
}

.problem-folder-card.ignored .problem-folder-count {
  background: #e2e8f0;
  color: #475569;
}

.problem-folder-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 12px 12px;
}

.problem-folder-list[hidden] {
  display: none;
}

.problem-folder-item {
  border: 1px solid #dbe2ea;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  padding: 10px;
}

.problem-folder-item-title {
  font-weight: 700;
  font-size: 13px;
  color: #0f172a;
  word-break: break-word;
}

.problem-folder-item-meta {
  margin-top: 4px;
  font-size: 12px;
  color: #475569;
}

.problem-folder-item-reason {
  margin-top: 6px;
  font-size: 12px;
  color: #9a3412;
  white-space: pre-wrap;
  word-break: break-word;
}

.problem-folder-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.problem-folder-empty {
  font-size: 12px;
  color: #64748b;
}

.ghost.active {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1d4ed8;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px;
  background: #ffffff;
  min-height: 180px;
  max-height: 320px;
  overflow-y: auto;
}

.chat-bubble {
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
  max-width: 80%;
  white-space: pre-wrap;
}

.chat-bubble.user {
  align-self: flex-end;
  background: #dbeafe;
  color: #1e3a8a;
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: #f1f5f9;
  color: #0f172a;
}

.chat-input {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  align-items: flex-end;
}

@keyframes btn-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Searchable select (custom combobox) ─────────────────────────── */
.ss-wrap {
  position: relative;
  display: inline-block;
  width: 100%;
}
.ss-input {
  width: 100%;
  padding: 7px 30px 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: inherit;
  font-family: inherit;
  background: var(--surface, #fff) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 9px center;
  cursor: pointer;
  box-sizing: border-box;
  outline: none;
  transition: border-color .15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ss-input:focus {
  border-color: var(--primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%232463eb' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
}
.ss-dropdown {
  position: fixed;
  z-index: 99999;
  min-width: 120px;
  max-width: 420px;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  display: none;
}
.ss-dropdown.open { display: block; }
.ss-option {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
}
.ss-option:hover, .ss-option.focused {
  background: var(--primary-soft, #dbeafe);
  color: var(--primary);
}
.ss-option.selected {
  font-weight: 600;
}
.ss-option.hidden { display: none; }
.ss-empty {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
}

.chat-input textarea {
  flex: 1;
  resize: vertical;
  min-height: 60px;
}

.orig-list {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding: 6px 0 2px;
}

.orig-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 10px;
  background: #f1f5f9;
  font-size: 12px;
}

.link-like {
  border: none;
  background: none;
  color: var(--primary);
  padding: 0;
  cursor: pointer;
  font-weight: 600;
  text-align: left;
}

.link-like.txn-linked-open {
  color: #0f172a;
  font-weight: 700;
}

.link-like.txn-linked-open:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.orig-preview {
  margin-top: 16px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px;
  background: #ffffff;
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.orig-preview iframe {
  width: 100%;
  height: 520px;
  border: none;
}

.orig-preview img {
  max-width: 100%;
  max-height: 520px;
  object-fit: contain;
}

.lhv-pay-shell {
  max-height: 92vh;
}

.lhv-pay-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1.05fr) minmax(420px, 0.95fr);
  min-height: min(760px, 82vh);
}

.lhv-pay-preview-pane {
  border-right: 1px solid #e2e8f0;
  background: #f8fbff;
  padding: 14px 16px 16px;
  min-width: 0;
}

.lhv-pay-preview-head {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
}

.lhv-pay-preview-box {
  margin-top: 10px;
  min-height: 620px;
  padding: 8px;
  background: #fff;
}

.lhv-pay-preview-box iframe {
  height: min(70vh, 780px);
}

.lhv-pay-preview-box img {
  max-height: min(70vh, 780px);
}

/* ── Collapsible sections (details/summary) ── */
.collapsible-section {
  border: 1px solid #dce5f2;
  border-radius: 12px;
  padding: 16px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}
.collapsible-section > summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.collapsible-section > summary::before {
  content: '▸';
  font-size: 12px;
  transition: transform var(--transition);
}
.collapsible-section[open] > summary::before {
  transform: rotate(90deg);
}
.collapsible-section > summary::-webkit-details-marker { display: none; }

/* ── Inline details dropdown (advanced actions) ── */
.inline-details {
  position: relative;
}
.inline-details > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.inline-details > summary::-webkit-details-marker { display: none; }
.btn-toggle-advanced {
  font-size: 13px;
  padding: 6px 12px;
}
.advanced-actions-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 50;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 220px;
  margin-top: 4px;
}
.advanced-actions-dropdown .ghost {
  text-align: left;
  justify-content: flex-start;
  width: 100%;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
}
.advanced-actions-dropdown .ghost:hover {
  background: var(--primary-soft);
}

.lhv-pay-form-pane {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.invoice-row.drag-over {
  outline: 2px dashed #3b82f6;
  background: #eff6ff;
}

.invoice-row.priority-focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2), 0 12px 22px rgba(37, 99, 235, 0.14);
  animation: invoicePriorityPulse 1.2s ease;
}

@keyframes invoicePriorityPulse {
  0% {
    transform: translateY(-1px) scale(1);
  }
  40% {
    transform: translateY(-2px) scale(1.003);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .side-nav {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
  }
  .main { padding: 20px; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .lhv-pay-layout { grid-template-columns: 1fr; }
  .lhv-pay-preview-pane { border-right: none; border-bottom: 1px solid #e2e8f0; }
  .lhv-pay-preview-box { min-height: 280px; }
  .lhv-pay-preview-box iframe { height: 320px; }
  .lhv-pay-preview-box img { max-height: 320px; }
  .table-row { grid-template-columns: 1fr; }
  .invoice-actions { align-items: stretch; }
  .invoice-bank-tools { justify-content: flex-start; }
  .invoice-action-row { justify-content: flex-start; }
  .action-menu-list {
    left: 0;
    right: auto;
    width: min(320px, 96vw);
  }
  .lease-group-header { flex-direction: column; align-items: flex-start; }
  .lease-group-header-actions { justify-content: flex-start; }
  .lease-tenant-row { grid-template-columns: 1fr; }
  .lease-tenant-row .table-actions { justify-content: flex-start; }
  .coverage-row { grid-template-columns: 1fr; }
  .coverage-status-column { justify-items: start; }
  .compose-coverage-toolbar { align-items: flex-start; }
}

.highlight-new {
  animation: highlightFade 3s ease-out;
}
@keyframes highlightFade {
  0%   { background: #fef9c3; box-shadow: 0 0 0 2px #eab308; }
  100% { background: transparent; box-shadow: none; }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 15mm;
  }

  body {
    background: #fff;
  }

  body * {
    visibility: hidden;
  }

  #invoice-preview,
  #invoice-preview * {
    visibility: visible;
  }

  #invoice-preview {
    position: absolute;
    left: 0;
    top: 0;
    width: 190mm;
    max-width: 190mm;
    box-shadow: none;
    border: none;
    padding: 0;
  }
}

/* ?? Dashboard alert boxes ???????????????????????????????????????????? */
.alert-box {
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  margin-bottom: 10px;
  font-size: 14px;
}
.alert-box ul {
  margin: 6px 0 0 0;
  padding-left: 1.2em;
}
.alert-box li {
  margin-bottom: 3px;
}
.alert-box.alert-danger {
  background: #fff2f2;
  border-color: #fca5a5;
  color: #991b1b;
}
.alert-box.alert-warning {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #92400e;
}
.alert-box.alert-info {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1e40af;
}
.alert-box.alert-success {
  background: #f0fdf4;
  border-color: #86efac;
  color: #166534;
}

/* ---- Monthly overview ---- */
.badge-paid    { display:inline-flex;align-items:center;padding:2px 8px;border-radius:999px;font-size:11px;font-weight:700;background:rgba(34,197,94,.16);color:#15803d; }
.badge-partial { display:inline-flex;align-items:center;padding:2px 8px;border-radius:999px;font-size:11px;font-weight:700;background:rgba(245,158,11,.16);color:#b45309; }
.badge-unpaid  { display:inline-flex;align-items:center;padding:2px 8px;border-radius:999px;font-size:11px;font-weight:700;background:rgba(220,38,38,.14);color:#b91c1c; }

.text-danger  { color:#b91c1c; }
.text-warning { color:#b45309; }

.monthly-block {
  border: 1px solid #dbe5f3;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 10px;
}

.monthly-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: #f0f5fb;
  cursor: pointer;
  user-select: none;
}
.monthly-header:hover { background: #e4edf8; }

.monthly-title {
  font-weight: 700;
  font-size: 14px;
  color: #1e3a5f;
  white-space: nowrap;
}

.monthly-summary-inline {
  font-size: 12px;
  color: #4a6080;
  flex-shrink: 0;
}

.monthly-body { padding: 10px 14px; }
.monthly-body.collapsed { display: none; }

.monthly-section-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 8px 0 4px;
  border-bottom: 1px solid #e5edf8;
  margin-bottom: 6px;
}
.income-section-label  { color: #15803d; }
.expense-section-label { color: #b45309; }

.monthly-row {
  padding: 5px 0;
  border-bottom: 1px solid #f0f5fb;
}
.monthly-row:last-child { border-bottom: none; }

.monthly-row-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.monthly-category {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
}
.income-label  { background:rgba(34,197,94,.10);  color:#15803d; }
.expense-label { background:rgba(245,158,11,.10); color:#92400e; }

.monthly-counterparty {
  flex: 1;
  font-size: 13px;
  color: #2d4a6e;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.monthly-amount {
  font-size: 13px;
  font-weight: 700;
  color: #1e3a5f;
  white-space: nowrap;
}

.monthly-link-btn {
  font-size: 13px;
  padding: 2px 6px;
  min-width: 0;
}

.monthly-row-sub {
  font-size: 11px;
  color: #4a6080;
  padding-left: 2px;
  margin-top: 2px;
}

.monthly-totals {
  font-size: 12px;
  color: #4a6080;
  padding: 8px 0 4px;
  border-top: 1px solid #e5edf8;
  margin-top: 6px;
}

/* ─── Focus & Accessibility ──────────────────────────────────────────────── */

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 4px;
}

button:active:not(:disabled) {
  transform: scale(0.97);
  transition: transform 0.08s ease;
}

/* ─── Responsive: Tablet ─────────────────────────────────────────────────── */

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 200px 1fr;
  }
  .sidebar {
    padding: 20px 12px;
  }
  .brand .logo {
    font-size: 15px;
  }
  .nav-item {
    font-size: 12px;
    padding: 8px 10px;
  }
  .stats-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

/* ─── Responsive: Mobile ─────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: 8px;
  }
  .mobile-menu-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 90;
  }
  .mobile-menu-backdrop.open {
    display: block;
  }
  .main {
    padding: 12px;
  }
  .topbar {
    padding: 10px 12px;
    gap: 8px;
    align-items: center;
  }
  .page-title {
    font-size: 17px;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .stat-card {
    padding: 10px;
  }
  .stat-value {
    font-size: 20px;
  }
  .modal-content {
    width: 95vw;
    max-width: none;
    margin: 10px;
    max-height: 90vh;
  }
  .table-row {
    font-size: 12px;
  }
}
