:root {
  color-scheme: light;
  --navy: #1B2A4A;
  --navy-deep: #101B33;
  --navy-light: #2E4270;
  --yellow: #F2B705;
  --yellow-deep: #D9A400;
  --paper: #F7F5F0;
  --surface: #FFFFFF;
  --concrete: #8B8680;
  --concrete-light: #D8D4CC;
  --hairline: rgba(27, 42, 74, 0.09);
  --red: #d03b3b;
  --green: #0ca30c;
  --amber: #fab219;
  --shadow-xs: 0 1px 2px rgba(16, 27, 51, 0.05);
  --shadow-sm: 0 2px 6px rgba(16, 27, 51, 0.06), 0 1px 2px rgba(16, 27, 51, 0.05);
  --shadow-md: 0 10px 28px rgba(16, 27, 51, 0.10), 0 2px 6px rgba(16, 27, 51, 0.06);
  --shadow-lg: 0 28px 70px rgba(9, 15, 30, 0.32);
  --radius-card: 14px;
  --radius-ctrl: 10px;

  /* Theme-aware roles. --navy/--navy-light/--yellow stay fixed brand colors
     in both themes (header, tab bar, primary buttons already pair them with
     explicit white text) — these roles are for text/borders drawn directly
     against --paper/--surface, which do flip in dark mode. */
  --ink: var(--navy);
  --link: var(--navy-light);
  --focus-ring-color: var(--navy-light);
  --focus-ring-shadow: rgba(46, 66, 112, 0.14);
  --project-bar-bg: #EFEBE2;
  --stat-total: var(--navy);
  --stat-discount: #4a3aa7;
  --login-error-bg: #FBEAE4;
  --login-error-text: #a52f2f;
  --login-error-border: #F0C7B8;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #12151C;
    --surface: #1B2130;
    --concrete: #9B978F;
    --concrete-light: #333B4A;
    --hairline: rgba(255, 255, 255, 0.10);
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 28px 70px rgba(0, 0, 0, 0.6);
    --ink: #E7EAF1;
    --link: #8FA6E0;
    --focus-ring-color: #8FA6E0;
    --focus-ring-shadow: rgba(143, 166, 224, 0.22);
    --project-bar-bg: #171C27;
    --stat-total: #8FB0FF;
    --stat-discount: #9085e9;
    --login-error-bg: rgba(208, 59, 59, 0.16);
    --login-error-text: #FF9B9B;
    --login-error-border: rgba(208, 59, 59, 0.35);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #12151C;
  --surface: #1B2130;
  --concrete: #9B978F;
  --concrete-light: #333B4A;
  --hairline: rgba(255, 255, 255, 0.10);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 28px 70px rgba(0, 0, 0, 0.6);
  --ink: #E7EAF1;
  --link: #8FA6E0;
  --focus-ring-color: #8FA6E0;
  --focus-ring-shadow: rgba(143, 166, 224, 0.22);
  --project-bar-bg: #171C27;
  --stat-total: #8FB0FF;
  --login-error-bg: rgba(208, 59, 59, 0.16);
  --login-error-text: #FF9B9B;
  --login-error-border: rgba(208, 59, 59, 0.35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { touch-action: manipulation; }

body {
  margin: 0;
  background: var(--paper);
  font-family: 'Inter', sans-serif;
  color: var(--ink);
  padding-bottom: calc(90px + env(safe-area-inset-bottom));
  touch-action: pan-x pan-y;
  overscroll-behavior-y: contain;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--yellow); color: var(--navy); }

* { scrollbar-width: thin; scrollbar-color: var(--concrete-light) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--concrete-light); border-radius: 999px; }
*::-webkit-scrollbar-track { background: transparent; }

.app-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-deep) 100%);
  padding: calc(16px + env(safe-area-inset-top)) 16px 16px;
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  box-shadow: 0 4px 16px rgba(9, 15, 30, 0.18);
}
.app-header::after {
  content: "";
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 6px;
  background: linear-gradient(180deg, var(--yellow) 0%, var(--yellow-deep) 100%);
}
.app-header h1 {
  font-family: 'Barlow Condensed', sans-serif;
  color: #fff;
  font-size: 26px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0;
}
.app-header p {
  color: var(--concrete-light);
  font-size: 12px;
  margin: 3px 0 0;
  letter-spacing: 0.01em;
}
.header-actions { display: flex; align-items: center; gap: 8px; margin-top: 1px; }
.btn-export {
  white-space: nowrap;
  background: var(--yellow);
  color: var(--navy);
  border: none;
  border-radius: var(--radius-ctrl);
  padding: 7px 13px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
}
.btn-logout {
  color: var(--concrete-light);
  text-decoration: none;
  font-size: 17px;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-ctrl);
  transition: background 0.15s, color 0.15s;
}
.btn-logout:active { background: rgba(255,255,255,0.14); }

.btn-icon-badge {
  position: relative;
  background: none; border: none; color: var(--concrete-light);
  font-size: 16px; width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-ctrl); cursor: pointer; transition: background 0.15s;
}
.btn-icon-badge:active { background: rgba(255,255,255,0.14); }
.btn-icon-badge .badge {
  position: absolute; top: -3px; right: -3px;
  background: var(--red); color: #fff; font-family: 'Inter';
  font-size: 10px; font-weight: 700; line-height: 1;
  min-width: 16px; height: 16px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 3px;
  box-shadow: 0 0 0 2px var(--navy);
}

@media (hover: hover) {
  .btn-export:hover { background: var(--yellow-deep); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
  .btn-logout:hover, .btn-icon-badge:hover { background: rgba(255,255,255,0.10); color: #fff; }
}

.project-bar {
  background: var(--project-bar-bg);
  border-bottom: 1px solid var(--hairline);
  padding: 10px 16px;
}
.project-switcher {
  width: 100%; max-width: 720px; margin: 0 auto;
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface); border: 1px solid var(--yellow); border-radius: var(--radius-ctrl);
  padding: 9px 13px; font-family: 'Inter'; color: var(--ink);
  cursor: pointer; text-align: left;
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.15s, transform 0.08s;
}
.project-switcher:active { transform: scale(0.99); }
@media (hover: hover) {
  .project-switcher:hover { box-shadow: var(--shadow-sm); }
}
.project-switcher-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.project-switcher-tag {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--concrete);
}
.project-switcher-name {
  font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.project-switcher-action {
  font-size: 12px; font-weight: 700; color: var(--link); flex-shrink: 0; margin-left: 10px;
}
.project-switcher .chevron { color: var(--concrete); }

.tab-bar {
  background: var(--navy-light);
  display: flex;
  padding: 0 8px;
  box-shadow: 0 2px 10px rgba(16, 27, 51, 0.12);
  position: relative;
  z-index: 1;
}
.tab-btn {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: #B9C2D9;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 14px;
  padding: 11px 0;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.tab-btn.active { color: var(--yellow); border-bottom-color: var(--yellow); background: rgba(255,255,255,0.04); }
@media (hover: hover) {
  .tab-btn:not(.active):hover { color: #fff; background: rgba(255,255,255,0.05); }
}

main { max-width: 720px; margin: 0 auto; padding: 18px 16px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  padding: 15px 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent, var(--ink));
}
.stat-label {
  display: block;
  font-size: 12px;
  color: var(--concrete);
  margin-bottom: 6px;
  font-weight: 500;
}
.stat-value {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 21px;
  font-weight: 600;
  color: var(--accent, var(--ink));
  letter-spacing: -0.01em;
}
.stat-card-clickable {
  width: 100%; text-align: left; font-family: inherit; cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.1s ease;
}
.stat-card-clickable:active { transform: scale(0.99); }
@media (hover: hover) {
  .stat-card-clickable:hover { box-shadow: var(--shadow-md); }
}

.discount-filter-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius-ctrl);
  padding: 10px 13px; margin-bottom: 10px; font-size: 13px; font-weight: 600; color: var(--ink);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.panel h3 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 12px;
  color: var(--ink);
  display: flex; align-items: center; gap: 8px;
}
.panel h3::before {
  content: ""; width: 4px; height: 14px; background: var(--yellow); border-radius: 2px; flex-shrink: 0;
}
/* ---- ranked list (Spend by category / supplier) ---- */
/* Each row:  Name [27%]            265,000
              ████████████░░░░░░░░░░░░░░░░░
   A 2-column grid — name + share on the left (wraps if long), amount on the
   right (never wraps), bar spanning both columns underneath. */
.rank-list { display: flex; flex-direction: column; min-width: 0; }
.rank-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; row-gap: 7px;
  align-items: baseline; padding: 11px 4px; border-bottom: 1px solid var(--hairline);
  color: var(--ink); cursor: pointer; border-radius: 8px; -webkit-user-select: none; user-select: none;
  transition: background 0.12s;
}
.rank-row:last-of-type { border-bottom: none; }
.rank-row:active { background: var(--paper); }
.rank-row:focus-visible { outline: 2px solid var(--focus-ring-color); outline-offset: 1px; }
.rank-label { min-width: 0; font-size: 14px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.rank-name { margin-right: 6px; }
/* Share sits inline after the name, so it follows the name onto a second
   line when the name wraps instead of forcing the row wider. */
.rank-share {
  display: inline-block; vertical-align: 1px; white-space: nowrap;
  font-size: 11px; font-weight: 600; line-height: 1; color: var(--concrete);
  background: var(--paper); border: 1px solid var(--hairline); border-radius: 999px; padding: 3px 7px;
}
.rank-amount { font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 600; white-space: nowrap; text-align: right; }
.rank-track {
  grid-column: 1 / -1; height: 6px; border-radius: 999px; background: var(--hairline); overflow: hidden;
}
.rank-fill { height: 100%; border-radius: 999px; background: var(--stat-total); }
.rank-more {
  margin-top: 8px; padding: 10px 0; width: 100%; border: 1px solid var(--concrete-light); border-radius: var(--radius-ctrl);
  background: none; color: var(--link); font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
@media (hover: hover) {
  .rank-row:hover { background: var(--paper); }
  .rank-row:hover .rank-name { color: var(--link); }
  .rank-more:hover { border-color: var(--link); }
}

.panel-row { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 560px) { .panel-row { grid-template-columns: 1fr 1fr; } }

#owedList .owed-row, #paidWithList2 .owed-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0;
  border: none; border-bottom: 1px solid var(--hairline); font-size: 14px;
  width: 100%; background: none; color: var(--ink); font-family: inherit; text-align: left; cursor: pointer;
}
#owedList .owed-name, #paidWithList2 .owed-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#owedList .owed-right, #paidWithList2 .owed-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
#owedList .owed-chev, #paidWithList2 .owed-chev { color: var(--concrete); font-size: 16px; line-height: 1; }
#owedList .owed-row:active, #paidWithList2 .owed-row:active { background: var(--paper); }
#owedList .owed-total { cursor: default; font-weight: 700; }
#owedList .owed-total:active { background: none; }
@media (hover: hover) {
  #owedList .owed-row:not(.owed-total):hover .owed-name { color: var(--link); }
  #paidWithList2 .owed-row:hover .owed-name { color: var(--link); }
}
.owed-view-all {
  margin-left: auto; background: none; border: none; padding: 0; cursor: pointer;
  font-family: 'Inter', sans-serif; font-size: 12px; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--link);
}
#owedList .owed-row:last-child, #paidWithList2 .owed-row:last-child { border-bottom: none; }
#owedList .owed-amt { font-family: 'JetBrains Mono', monospace; color: var(--red); font-weight: 600; }

.empty-state { text-align: center; padding: 64px 24px; }
.empty-icon {
  font-size: 30px; margin: 0 auto 14px; width: 64px; height: 64px;
  display: flex; align-items: center; justify-content: center;
  background: var(--paper); border-radius: 999px;
}
.empty-title { font-family: 'Barlow Condensed', sans-serif; font-size: 18px; font-weight: 700; margin: 0; letter-spacing: 0.01em; }
.empty-sub { color: var(--concrete); font-size: 14px; margin: 6px auto 0; max-width: 280px; line-height: 1.5; }

.filter-bar { display: flex; gap: 8px; margin-bottom: 10px; }
.filter-bar input {
  flex: 1; padding: 10px 13px; border-radius: var(--radius-ctrl); border: 1px solid var(--concrete-light); font-size: 14px;
  background: var(--surface); transition: border-color 0.15s, box-shadow 0.15s;
}
.btn-filter {
  background: var(--surface); border: 1px solid var(--concrete-light); border-radius: var(--radius-ctrl); padding: 0 14px; cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-filter.active { background: var(--yellow); border-color: var(--yellow-deep); }

.filter-panel {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 12px; padding: 14px; margin-bottom: 12px;
  box-shadow: var(--shadow-xs);
}
.filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
/* Grid items default to min-width:auto, so an input/select's intrinsic width
   (or a long <option> label) can push a 1fr column past the screen edge on
   narrow phones — min-width:0 + width:100% keeps both columns inside. */
.filter-row > * { min-width: 0; }
.filter-row select, .filter-row input {
  width: 100%; min-width: 0; max-width: 100%;
  border: 1px solid var(--concrete-light); border-radius: var(--radius-ctrl); padding: 8px 10px; font-size: 13px; font-family: inherit;
  background: var(--surface); color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.filter-row select { text-overflow: ellipsis; }
.filter-field { display: flex; flex-direction: column; gap: 4px; }
.filter-field span { font-size: 11px; font-weight: 600; color: var(--concrete); }
.filter-field input[type="date"] { min-height: 36px; -webkit-appearance: none; appearance: none; display: block; }
.filter-field input[type="date"]::-webkit-date-and-time-value { text-align: left; }
.btn-link { background: none; border: none; color: var(--red); font-size: 12px; font-weight: 600; cursor: pointer; padding: 0; }

.gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px;
}
.gallery-thumb {
  position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden;
  background: var(--concrete-light);
  box-shadow: var(--shadow-xs);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; display: block; transition: transform 0.25s ease; }
@media (hover: hover) {
  .gallery-thumb:hover { box-shadow: var(--shadow-sm); }
  .gallery-thumb:hover img { transform: scale(1.05); }
}
.gallery-delete {
  position: absolute; top: 6px; right: 6px; background: rgba(16,27,51,0.68); color: #fff;
  border: none; border-radius: 999px; width: 26px; height: 26px; cursor: pointer; font-size: 12px;
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.gallery-caption {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 7px 5px;
  display: flex; flex-direction: column; gap: 1px;
  background: linear-gradient(to top, rgba(0,0,0,0.72), transparent);
  color: #fff; font-size: 11px; pointer-events: none;
}
.gallery-caption-text { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gallery-date { font-size: 10px; opacity: 0.85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Caption + upload time in the full-size viewer, above the Download button. */
.viewer-info {
  position: absolute; left: 16px; right: 16px; bottom: 76px; z-index: 3;
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; pointer-events: none;
}
.viewer-caption {
  color: #fff; font-size: 14px; font-weight: 600; max-width: 100%;
  background: rgba(16,27,51,0.6); padding: 3px 10px; border-radius: 8px; overflow-wrap: anywhere;
}
.viewer-uploaded {
  pointer-events: auto; border: none; font-family: inherit; cursor: pointer;
  color: rgba(255,255,255,0.9); font-size: 12px; background: rgba(16,27,51,0.6); padding: 4px 11px; border-radius: 999px;
}
.viewer-uploaded:disabled { cursor: default; }
.gallery-thumb.selectable img { cursor: pointer; }
.gallery-checkbox {
  position: absolute; top: 6px; left: 6px; width: 24px; height: 24px; border-radius: 999px;
  background: rgba(16,27,51,0.55); border: 2px solid #fff; color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.gallery-thumb.selected .gallery-checkbox { background: var(--navy); border-color: var(--yellow); }
.gallery-thumb.selected { outline: 3px solid var(--yellow); outline-offset: 0; }

.gallery-selection-bar {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap;
}
.gallery-selection-bar #gallerySelectedCount { font-size: 13px; font-weight: 600; color: var(--ink); }
.gallery-selection-actions { display: flex; gap: 8px; margin-left: auto; }

.tx-list { display: flex; flex-direction: column; gap: 10px; }
.tx-card {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius-card); padding: 13px;
  display: flex; gap: 12px; align-items: flex-start;
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
}
.tx-thumb {
  width: 56px; height: 56px; border-radius: var(--radius-ctrl); background: var(--paper);
  flex-shrink: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; cursor: pointer; border: none; padding: 0;
}
.tx-thumb img { width: 100%; height: 100%; object-fit: cover; }
.tx-main { flex: 1; min-width: 0; cursor: pointer; }
.tx-top { display: flex; justify-content: space-between; gap: 8px; }
.tx-title { font-size: 14px; font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-amount { font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 14px; white-space: nowrap; }
.tx-sub { font-size: 12px; color: var(--concrete); margin: 3px 0 0; }
.tx-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 7px; }
.tx-date { font-size: 11px; color: var(--concrete); }
.tx-status { font-size: 11px; font-weight: 700; letter-spacing: 0.01em; }
.tx-delete { background: none; border: none; color: var(--concrete); cursor: pointer; align-self: flex-start; padding: 4px; border-radius: 6px; transition: color 0.15s, background 0.15s; }
@media (hover: hover) {
  .tx-delete:hover { color: var(--red); background: rgba(208,59,59,0.08); }
}

/* ---- supplier card ---- */
.supplier-card { flex-direction: column; gap: 8px; align-items: stretch; }
.supplier-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.supplier-name {
  margin: 0; font-size: 15px; font-weight: 700; line-height: 1.3; color: var(--ink);
  min-width: 0; overflow-wrap: anywhere;
}
.supplier-top .tx-amount { flex-shrink: 0; padding-top: 1px; }
.supplier-bottom { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.supplier-meta { margin: 0; min-width: 0; line-height: 1.4; }
.supplier-actions { display: flex; gap: 6px; flex-shrink: 0; }
.supplier-action {
  width: 34px; height: 34px; border-radius: var(--radius-ctrl); border: 1px solid var(--hairline);
  background: var(--paper); display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; text-decoration: none; cursor: pointer; padding: 0;
  transition: background 0.15s, border-color 0.15s;
}
.supplier-action-delete { background: none; color: var(--concrete); }
@media (hover: hover) {
  .supplier-action:hover { border-color: var(--link); }
  .supplier-action-delete:hover { background: rgba(208,59,59,0.08); border-color: var(--red); }
}

.fab {
  position: fixed; bottom: 24px; right: 24px;
  background: linear-gradient(135deg, var(--yellow) 0%, var(--yellow-deep) 100%);
  color: var(--navy); border: none; border-radius: 999px;
  padding: 15px 22px; font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 15px;
  letter-spacing: 0.02em; box-shadow: 0 8px 24px rgba(217,164,0,0.4), 0 2px 8px rgba(16,27,51,0.15); cursor: pointer;
}

.modal-overlay {
  position: fixed; inset: 0; background: rgba(12, 18, 34, 0.5); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface); width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto;
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow-lg);
}
@media (min-width: 560px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: 18px; }
}
.modal-header {
  position: sticky; top: 0; background: var(--surface); display: flex; justify-content: space-between; align-items: center;
  padding: 16px 18px; border-bottom: 1px solid var(--hairline); z-index: 2;
}
.modal-header h2 {
  font-family: 'Barlow Condensed', sans-serif; text-transform: uppercase; font-size: 18px; margin: 0; font-weight: 700;
  letter-spacing: 0.02em;
}
.btn-icon { background: none; border: none; font-size: 18px; color: var(--concrete); cursor: pointer; padding: 4px; border-radius: 6px; transition: background 0.15s, color 0.15s; }
@media (hover: hover) {
  .btn-icon:hover { background: var(--paper); color: var(--ink); }
}
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.modal-footer { position: sticky; bottom: 0; background: var(--surface); padding: 16px 18px; border-top: 1px solid var(--hairline); }

.field label { display: block; font-size: 12px; color: var(--concrete); font-weight: 600; margin-bottom: 6px; letter-spacing: 0.01em; }
.field input, .field select {
  width: 100%; border: 1px solid var(--concrete-light); border-radius: var(--radius-ctrl); padding: 10px 12px; font-size: 14px; font-family: inherit;
  background: var(--surface); transition: border-color 0.15s, box-shadow 0.15s;
}
.field textarea {
  width: 100%; border: 1px solid var(--concrete-light); border-radius: var(--radius-ctrl); padding: 10px 12px; font-size: 14px; font-family: inherit;
  background: var(--surface); color: var(--ink); resize: vertical; min-height: 64px; line-height: 1.4;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
/* Let both columns shrink to the screen — a date/time input's built-in
   minimum width otherwise pushes the second column past the edge. */
.field-row > * { min-width: 0; }
.field input[type="datetime-local"], .field input[type="date"] { min-width: 0; max-width: 100%; display: block; }
.view-note { white-space: pre-wrap; overflow-wrap: anywhere; font-weight: 500; }
.tx-note { font-size: 12px; color: var(--ink); opacity: 0.8; margin: 4px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

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

.toggle-chip {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--concrete-light);
  border-radius: 999px; padding: 6px 13px; font-size: 12px; font-weight: 600; background: var(--surface); cursor: pointer; margin-bottom: 8px;
  transition: background 0.15s, border-color 0.15s;
}
.toggle-chip.active { background: var(--yellow); border-color: var(--yellow-deep); }
.toggle-chip .checkbox {
  width: 14px; height: 14px; border-radius: 4px; border: 1.5px solid var(--ink); display: inline-block;
}
.toggle-chip.active .checkbox { background: var(--navy); }

.autocomplete-wrap { position: relative; }
.suggestions {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 12px; box-shadow: var(--shadow-md); z-index: 10; max-height: 190px; overflow-y: auto;
}
.suggestion-item {
  width: 100%; text-align: left; padding: 10px 13px; font-size: 14px; background: none; border: none; cursor: pointer;
  display: flex; justify-content: space-between; border-bottom: 1px solid var(--hairline);
  transition: background 0.1s;
}
.suggestion-item:hover { background: var(--paper); }
.suggestion-item .sup-cat { font-size: 11px; color: var(--concrete); }
.suggestion-add { color: var(--ink); font-weight: 700; border-top: 1px solid var(--hairline); }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--concrete-light); border-radius: 999px; padding: 6px 13px; font-size: 12px; font-weight: 600;
  background: var(--surface); color: var(--ink); cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip.add-new { color: var(--concrete); }
@media (hover: hover) {
  .chip:not(.active):hover { border-color: var(--link); }
}

.status-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.status-btn {
  border: 1.5px solid var(--c); border-radius: var(--radius-ctrl); padding: 10px 0; font-size: 12px; font-weight: 700; text-transform: capitalize;
  background: var(--surface); color: var(--ink); cursor: pointer;
}
.status-btn.active { background: var(--c); color: #fff; box-shadow: var(--shadow-xs); }
.status-btn:disabled, .field input:disabled { opacity: 0.55; cursor: not-allowed; }

.upload-btn {
  width: 100%; border: 2px dashed var(--concrete-light); border-radius: 12px; padding: 18px; background: var(--paper);
  color: var(--concrete); font-size: 14px; cursor: pointer; font-weight: 500;
  transition: border-color 0.15s, background 0.15s;
}
@media (hover: hover) {
  .upload-btn:hover { border-color: var(--link); background: var(--surface); }
}
.upload-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.upload-choice .upload-btn { padding: 16px 8px; min-width: 0; }
.preview-wrap { position: relative; width: 96px; height: 96px; margin-bottom: 8px; }
.preview-wrap img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; box-shadow: var(--shadow-xs); }
.preview-remove {
  position: absolute; top: -6px; right: -6px; background: var(--surface); border-radius: 999px; border: none;
  width: 22px; height: 22px; box-shadow: var(--shadow-sm); color: var(--red); cursor: pointer;
}

.gallery-stage-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 12px; margin-top: 10px;
}
.gallery-stage-item { display: flex; flex-direction: column; gap: 5px; }
.gallery-stage-thumb-wrap { position: relative; width: 100%; aspect-ratio: 1; }
.gallery-stage-thumb-wrap img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; box-shadow: var(--shadow-xs); display: block; }
.gallery-stage-remove {
  position: absolute; top: -6px; right: -6px; background: var(--surface); border-radius: 999px; border: none;
  width: 20px; height: 20px; box-shadow: var(--shadow-sm); color: var(--red); cursor: pointer; font-size: 10px; padding: 0;
}
.gallery-stage-caption {
  width: 100%; border: 1px solid var(--concrete-light); border-radius: var(--radius-ctrl); padding: 5px 7px;
  font-size: 11px; font-family: inherit; background: var(--surface); color: var(--ink);
}

.btn-primary {
  background: var(--navy); color: #fff; border: none; border-radius: var(--radius-ctrl); padding: 10px 16px; font-size: 14px;
  font-weight: 600; cursor: pointer; box-shadow: var(--shadow-xs);
}
.btn-primary.full { width: 100%; padding: 14px 0; font-family: 'Barlow Condensed', sans-serif; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.03em; font-size: 15px; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary {
  flex: 1; background: var(--surface); border: 1px solid var(--concrete-light); border-radius: var(--radius-ctrl); padding: 10px 0;
  font-size: 14px; font-weight: 600; cursor: pointer; color: var(--ink);
}
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-danger {
  flex: 1; background: var(--red); color: #fff; border: none; border-radius: var(--radius-ctrl); padding: 10px 0;
  font-size: 14px; font-weight: 600; cursor: pointer; box-shadow: var(--shadow-xs);
}
.btn-danger:disabled { opacity: 0.5; cursor: not-allowed; }
@media (hover: hover) {
  .btn-primary:not(:disabled):hover { background: var(--navy-light); box-shadow: var(--shadow-sm); }
  .btn-secondary:not(:disabled):hover { border-color: var(--link); color: var(--link); }
  .btn-danger:not(:disabled):hover { background: #b83232; box-shadow: var(--shadow-sm); }
}

.viewer-overlay {
  position: fixed; inset: 0; background: rgba(8, 12, 24, 0.9); z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  overflow: hidden; /* the stage slides off-screen while swiping between images */
  touch-action: none; /* swipes go to the viewer, not page scroll */
}
.viewer-stage { will-change: transform; }
.viewer-counter {
  position: absolute; top: 22px; left: 50%; transform: translateX(-50%);
  color: #fff; font-size: 13px; font-weight: 600; letter-spacing: 0.02em;
  background: rgba(16,27,51,0.6); padding: 4px 11px; border-radius: 999px; z-index: 2;
}
.viewer-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 44px; height: 44px; border-radius: 999px; border: none; cursor: pointer;
  background: rgba(16,27,51,0.55); color: #fff; font-size: 28px; line-height: 1;
  display: flex; align-items: center; justify-content: center; padding: 0 0 3px;
  transition: background 0.15s, opacity 0.15s;
}
.viewer-nav-prev { left: 12px; }
.viewer-nav-next { right: 12px; }
.viewer-nav:disabled { opacity: 0; pointer-events: none; }
@media (hover: hover) { .viewer-nav:hover { background: rgba(16,27,51,0.85); } }
/* On phones swiping is the way to move — keep the arrows out of the photo. */
@media (hover: none) { .viewer-nav { display: none !important; } }
.viewer-stage {
  position: relative; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.viewer-full {
  max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: var(--shadow-lg);
  animation: viewerFadeIn 0.2s ease;
}
/* The small thumbnail stretched to fit while the full image loads — blurred
   so the low resolution reads as "loading", not as a bad photo. */
.viewer-preview {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  filter: blur(8px); opacity: 0.85; transform: scale(1.02);
}
.viewer-spinner {
  position: absolute; top: 50%; left: 50%; width: 42px; height: 42px; margin: -21px 0 0 -21px;
  border: 3px solid rgba(255,255,255,0.25); border-top-color: var(--yellow); border-radius: 999px;
  animation: spin 0.8s linear infinite;
}
.viewer-error {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  flex-direction: column; align-items: center; gap: 12px;
  background: rgba(16,27,51,0.85); color: #fff; padding: 18px 22px; border-radius: 14px; text-align: center;
}
.viewer-error p { margin: 0; font-size: 14px; font-weight: 600; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes viewerFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Tiles: neutral placeholder (the tile's own background) until the
   thumbnail has loaded, then fade it in. */
.gallery-thumb img { opacity: 0; transition: opacity 0.25s ease, transform 0.25s ease; }
.gallery-thumb.thumb-loaded img { opacity: 1; }
.gallery-thumb:not(.thumb-loaded):not(.thumb-failed)::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,0.35) 50%, transparent 70%);
  background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }
.thumb-retry {
  position: absolute; inset: 0; width: 100%; height: 100%; border: none; cursor: pointer;
  background: var(--concrete-light); color: var(--ink); font-size: 26px; font-weight: 700; z-index: 1;
}
/* Keep delete / select controls usable above a failed tile's ↻ button. */
.gallery-delete, .gallery-checkbox { z-index: 2; }
.viewer-close { position: absolute; top: 16px; right: 16px; color: #fff; font-size: 24px; z-index: 3; }

.confirm-modal { padding: 20px; max-width: 320px; border-radius: 16px; }
.confirm-title { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 17px; margin: 0; letter-spacing: 0.01em; }
.confirm-msg { color: var(--concrete); font-size: 13px; margin: 6px 0 0; line-height: 1.5; }
.confirm-actions { display: flex; gap: 8px; margin-top: 18px; }

/* ---- view (read-only) modal ---- */
.view-row {
  display: flex; justify-content: space-between; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--hairline); font-size: 14px;
}
.view-row:last-child { border-bottom: none; }
.view-label { color: var(--concrete); font-size: 12px; font-weight: 500; padding-top: 2px; }
.view-value { font-weight: 600; text-align: right; }
.view-value.mono { font-family: 'JetBrains Mono', monospace; }
.view-footer { display: flex; gap: 10px; }
.view-footer .btn-secondary, .view-footer .btn-primary { flex: 1; }

.payment-row { font-size: 13px; padding: 7px 0; }
.payment-row .view-label { padding-top: 0; }

.viewer-download {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 3;
  background: var(--yellow); color: var(--navy); border: none; border-radius: 999px;
  padding: 10px 20px; font-family: 'Inter'; font-weight: 700; font-size: 13px; cursor: pointer;
  box-shadow: var(--shadow-md);
}

/* ---- login page ---- */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 30% 20%, var(--navy-light) 0%, var(--navy) 45%, var(--navy-deep) 100%);
  font-family: 'Inter', sans-serif; padding: 20px;
  padding-top: calc(20px + env(safe-area-inset-top));
}
.login-card {
  background: var(--surface); border-radius: 20px; padding: 34px 28px; width: 100%; max-width: 360px;
  box-shadow: var(--shadow-lg);
}
.login-title {
  font-family: 'Barlow Condensed', sans-serif; font-weight: 800; text-transform: uppercase;
  font-size: 28px; color: var(--ink); margin: 0; text-align: center; letter-spacing: 0.03em;
}
.login-sub { color: var(--concrete); font-size: 13px; text-align: center; margin: 6px 0 26px; }
.login-error {
  background: var(--login-error-bg); color: var(--login-error-text); border: 1px solid var(--login-error-border); border-radius: var(--radius-ctrl);
  padding: 10px 13px; font-size: 13px; margin-bottom: 16px;
}
.login-form { display: flex; flex-direction: column; gap: 6px; }
.login-form label { font-size: 12px; color: var(--concrete); font-weight: 600; margin-top: 8px; }
.login-form input {
  border: 1px solid var(--concrete-light); border-radius: var(--radius-ctrl); padding: 12px 13px; font-size: 15px; font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.login-form .btn-primary.full { margin-top: 20px; box-shadow: var(--shadow-sm); }
.captcha-row { display: flex; align-items: center; gap: 8px; }
.captcha-img {
  border: 1px solid var(--concrete-light); border-radius: var(--radius-ctrl);
  background: #fff; display: block; width: 150px; height: 50px;
}
.captcha-row .btn-icon {
  border: 1px solid var(--concrete-light); border-radius: var(--radius-ctrl);
  width: 40px; height: 40px; flex-shrink: 0; font-size: 16px;
}
.login-form button:disabled { opacity: 0.5; }

/* ---- misc polish ---- */
.tx-card, .stat-card, .panel { transition: box-shadow 0.15s ease, transform 0.1s ease; }
.tx-card:active { transform: scale(0.99); }
@media (hover: hover) {
  .tx-card:hover { box-shadow: var(--shadow-sm); border-color: transparent; }
}
.chip, .status-btn, .toggle-chip, .tab-btn, .btn-primary, .btn-secondary, .btn-danger, .fab, .btn-filter, .project-switcher {
  transition: background 0.15s ease, color 0.15s ease, transform 0.08s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.fab:active, .btn-primary:active, .btn-danger:active, .btn-secondary:active { transform: scale(0.97); }
@media (hover: hover) {
  .fab:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(217,164,0,0.45), 0 4px 10px rgba(16,27,51,0.18); }
}
.modal { animation: slideUp 0.2s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.chart-hint { margin: 10px 0 0; text-align: center; font-size: 11px; color: var(--concrete); }

/* ---- offline / sync strip (under the project bar) ---- */
.sync-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 16px; font-size: 12.5px; font-weight: 600;
  background: #FFF4D6; color: #6B4E00; border-bottom: 1px solid rgba(217,164,0,0.35);
}
.sync-bar.sync-bar-offline { background: #F1E9E9; color: #7A2E2E; border-bottom-color: rgba(208,59,59,0.25); }
.sync-now {
  flex-shrink: 0; border: 1px solid currentColor; background: none; color: inherit; border-radius: 999px;
  padding: 4px 11px; font-size: 12px; font-weight: 700; font-family: inherit; cursor: pointer;
}
.sync-now:disabled { opacity: 0.6; }
:root[data-theme="dark"] .sync-bar { background: #3A3016; color: #FFD979; }
:root[data-theme="dark"] .sync-bar.sync-bar-offline { background: #3A1E22; color: #FF9B9B; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sync-bar { background: #3A3016; color: #FFD979; }
  :root:not([data-theme="light"]) .sync-bar.sync-bar-offline { background: #3A1E22; color: #FF9B9B; }
}

/* ---- pull to refresh ---- */
.ptr-indicator {
  position: fixed; top: calc(env(safe-area-inset-top) + 10px); left: 50%; z-index: 45;
  width: 40px; height: 40px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow-md);
  display: flex; align-items: center; justify-content: center; pointer-events: none;
  transform: translate(-50%, -56px); opacity: 0; transition: transform 0.2s ease, opacity 0.2s ease;
}
.ptr-indicator.dragging { transition: none; }
.ptr-icon { font-size: 20px; font-weight: 700; color: var(--concrete); line-height: 1; }
.ptr-indicator.ready .ptr-icon { color: var(--link); }
.ptr-indicator.refreshing .ptr-icon { color: var(--link); animation: spin 0.8s linear infinite; }

/* ---- toast ---- */
.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 80;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 32px); width: max-content;
  background: #101B33; color: #fff; padding: 11px 14px 11px 16px; border-radius: 12px; box-shadow: var(--shadow-lg);
  font-size: 13px; font-weight: 500; transition: transform 0.2s ease, opacity 0.2s ease;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.toast-action {
  flex-shrink: 0; background: none; border: none; color: var(--yellow); font-family: inherit;
  font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; cursor: pointer; padding: 2px 4px;
}

/* ---- transactions: day headers + waiting-to-sync entries ---- */
.tx-day {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 8px 2px -2px; font-size: 12px; font-weight: 700; color: var(--concrete);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.tx-day:first-child { margin-top: 0; }
.tx-day-total { font-family: 'JetBrains Mono', monospace; text-transform: none; letter-spacing: 0; color: var(--ink); }
.tx-pending { border-style: dashed; border-color: var(--yellow-deep); }
.tx-status-pending { color: var(--yellow-deep); }
.tx-status-error { color: var(--red); white-space: normal; text-align: right; }

/* ---- dashboard period chips ---- */
.range-chips {
  display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px 14px; padding: 0 16px 2px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.range-chips::-webkit-scrollbar { display: none; }
.range-chips button {
  flex-shrink: 0; border: 1px solid var(--concrete-light); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 7px 13px; font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.range-chips button.active { background: var(--navy); border-color: var(--navy); color: #fff; }

/* ---- amount shortcuts ---- */
/* Buttons first, the "= 25,000" readout on its own line below — fits the
   half-width Amount column on a phone without squeezing either. */
.amount-helper { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.amount-preview { order: 2; flex-basis: 100%; font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 600; color: var(--link); }
.amount-preview:empty { display: none; }
.amount-helper button {
  flex-shrink: 0; border: 1px solid var(--concrete-light); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 4px 10px; font-family: inherit; font-size: 11.5px; font-weight: 700; cursor: pointer;
}
.amount-helper button:active { background: var(--paper); }

/* ---- supplier statement ---- */
.stmt-name { margin: 0; font-size: 18px; font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
.stmt-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stmt-tile { background: var(--paper); border: 1px solid var(--hairline); border-radius: var(--radius-ctrl); padding: 10px; min-width: 0; }
.stmt-tile .stat-label { margin-bottom: 4px; font-size: 11px; }
.stmt-value { display: block; font-family: 'JetBrains Mono', monospace; font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
.stmt-paid { color: var(--green); }
.stmt-owed { color: var(--red); }
.stmt-rows { display: flex; flex-direction: column; }
.stmt-row {
  display: flex; justify-content: space-between; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--hairline);
}
.stmt-row:last-child { border-bottom: none; }
.stmt-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stmt-date { font-size: 11px; color: var(--concrete); }
.stmt-text { font-size: 13.5px; font-weight: 600; overflow-wrap: anywhere; }
.stmt-detail { font-size: 12px; color: var(--concrete); overflow-wrap: anywhere; }
.stmt-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.stmt-amount { font-family: 'JetBrains Mono', monospace; font-size: 13.5px; font-weight: 700; white-space: nowrap; }
.stmt-payment .stmt-amount { color: var(--green); }
.stmt-bal { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--concrete); white-space: nowrap; }

/* Upload preview: the date each photo will be saved with. */
.gallery-stage-date { font-size: 10.5px; font-weight: 600; color: var(--link); line-height: 1.3; }
.gallery-stage-date.no-date { color: var(--concrete); font-weight: 500; }

/* "Small / general purchase" — a real tick in the box when selected. */
.toggle-chip .checkbox { position: relative; flex-shrink: 0; width: 16px; height: 16px; background: var(--surface); }
.toggle-chip.active .checkbox { background: var(--navy); border-color: var(--navy); }
.toggle-chip.active .checkbox::after {
  content: ''; position: absolute; left: 4.5px; top: 1px; width: 4px; height: 8.5px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
/* Supplier box while a general purchase is ticked: switched off, says so. */
.field input.is-general:disabled {
  background: var(--paper); border-style: dashed; cursor: not-allowed; opacity: 1; -webkit-text-fill-color: currentColor;
}
.field input.is-general:disabled::placeholder { color: var(--ink); opacity: 0.75; font-weight: 600; -webkit-text-fill-color: var(--ink); }

/* Category: one picker field instead of a long row of chips. */
.picker-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--concrete-light); border-radius: var(--radius-ctrl); padding: 10px 12px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; text-align: left; cursor: pointer;
}
.picker-btn > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-caret { color: var(--concrete); font-size: 12px; flex-shrink: 0; }
.picker-btn:focus-visible { outline: none; border-color: var(--focus-ring-color); box-shadow: 0 0 0 3px var(--focus-ring-shadow); }

.cat-modal { display: flex; flex-direction: column; max-height: 85vh; overflow: hidden; }
.cat-search { padding: 12px 18px 8px; }
.cat-search input {
  width: 100%; border: 1px solid var(--concrete-light); border-radius: var(--radius-ctrl); padding: 10px 12px;
  font-size: 16px; font-family: inherit; background: var(--surface); color: var(--ink); /* 16px: no iPhone zoom */
}
.cat-list { flex: 1; overflow-y: auto; padding: 0 10px 6px; -webkit-overflow-scrolling: touch; min-height: 120px; }
.cat-list.is-busy { opacity: 0.55; pointer-events: none; }
.cat-row { display: flex; align-items: center; gap: 2px; border-bottom: 1px solid var(--hairline); }
.cat-row.active .cat-name { font-weight: 700; }
.cat-name {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 13px 8px;
  background: none; border: none; color: var(--ink); font: inherit; font-size: 14.5px; text-align: left; cursor: pointer;
}
.cat-text { overflow-wrap: anywhere; }
.cat-tick { width: 16px; flex-shrink: 0; color: var(--green); font-weight: 800; }
.cat-icon {
  flex-shrink: 0; width: 40px; height: 40px; border: none; background: none; border-radius: 10px;
  color: var(--concrete); font-size: 15px; cursor: pointer;
}
.cat-add { width: 100%; padding: 13px 8px; background: none; border: none; border-bottom: 1px solid var(--hairline);
  color: var(--link); font: inherit; font-size: 14.5px; font-weight: 700; text-align: left; cursor: pointer; }
.cat-panel { flex-direction: column; align-items: stretch; gap: 8px; padding: 12px 8px; background: var(--paper); border-radius: 12px; border-bottom: none; margin: 4px 0; }
.cat-panel input, .cat-panel select {
  width: 100%; border: 1px solid var(--concrete-light); border-radius: var(--radius-ctrl); padding: 10px 12px;
  font-size: 16px; font-family: inherit; background: var(--surface); color: var(--ink);
}
.cat-panel-title { margin: 0; font-weight: 700; font-size: 14px; overflow-wrap: anywhere; }
.cat-note { margin: 0; font-size: 12.5px; color: var(--concrete); line-height: 1.45; overflow-wrap: anywhere; }
.cat-panel-actions { display: flex; gap: 8px; }
.cat-panel-actions > button { flex: 1; }
.cat-empty, .cat-foot { margin: 0; padding: 12px 18px; font-size: 12px; color: var(--concrete); text-align: center; }
.cat-foot { border-top: 1px solid var(--hairline); padding-bottom: max(12px, env(safe-area-inset-bottom)); }
@media (hover: hover) {
  .cat-name:hover, .cat-add:hover { background: var(--paper); }
  .cat-icon:hover { background: var(--paper); color: var(--ink); }
}

/* New project — step 2: choose its categories, grouped by kind of project. */
.pc-modal { display: flex; flex-direction: column; max-height: 92vh; overflow: hidden; }
.pc-body { flex: 1; overflow-y: auto; padding: 14px 18px 18px; -webkit-overflow-scrolling: touch; }
.pc-intro { margin: 0 0 6px; font-size: 13px; color: var(--concrete); line-height: 1.5; overflow-wrap: anywhere; }
.pc-intro strong { color: var(--ink); }
.pc-section { padding: 14px 0 4px; border-top: 1px solid var(--hairline); margin-top: 10px; }
.pc-section:first-child { border-top: none; margin-top: 0; }
.pc-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.pc-section-head h4 { margin: 0; font-family: 'Barlow Condensed', sans-serif; font-size: 16px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; color: var(--ink); }
.pc-all { background: none; border: none; padding: 4px 0; color: var(--link); font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer; flex-shrink: 0; }
.pc-chip { max-width: 100%; overflow-wrap: anywhere; text-align: left; }
.pc-custom-row { display: flex; gap: 8px; margin-bottom: 10px; }
.pc-custom-row input {
  flex: 1; min-width: 0; border: 1px solid var(--concrete-light); border-radius: var(--radius-ctrl); padding: 10px 12px;
  font-size: 16px; font-family: inherit; background: var(--surface); color: var(--ink);
}
.pc-custom-row .btn-secondary { flex: 0 0 auto; padding-left: 16px; padding-right: 16px; }
.pc-footer { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.pc-count { margin: 0 0 10px; font-size: 12.5px; color: var(--concrete); text-align: center; }
/* Dark mode: navy-on-dark ticked chips were hard to tell from unticked. */
:root[data-theme="dark"] .pc-chip.active { background: var(--yellow); border-color: var(--yellow-deep); color: #1B2A4A; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pc-chip.active { background: var(--yellow); border-color: var(--yellow-deep); color: #1B2A4A; }
}

/* Dashboard custom period popup */
.dash-custom-error { margin: 10px 0 0; font-size: 12.5px; color: var(--red); font-weight: 600; }
#dashCustomModal .field label { margin-bottom: 4px; }

/* ===== Multi-currency ===== */
.currency-select {
  width: 100%; border: 1px solid var(--concrete-light); border-radius: var(--radius-ctrl); padding: 10px 8px;
  font-size: 14px; font-family: inherit; background: var(--surface); color: var(--ink);
}
.field-hint { margin: 6px 0 0; font-size: 11.5px; color: var(--concrete); line-height: 1.4; }
.label-cur { color: var(--ink); font-weight: 700; }
.stat-cur { font-weight: 600; opacity: 0.75; }

/* Entry form: currency + amount side by side */
.amount-cur-row { display: flex; gap: 8px; align-items: flex-start; }
.amount-cur-row .currency-select { flex: 0 0 92px; width: 92px; font-weight: 700; text-overflow: ellipsis; }
.amount-input-wrap { flex: 1; min-width: 0; }

.fx-box { margin-top: 10px; padding: 12px; border-radius: 12px; background: var(--paper); border: 1px solid var(--hairline); display: flex; flex-direction: column; gap: 8px; }
.fx-box.fx-missing { border-color: var(--red); }
.fx-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.fx-label { font-size: 12px; font-weight: 600; color: var(--concrete); }
.fx-box.fx-missing .fx-label { color: var(--red); }
.fx-rate-row { display: flex; align-items: center; gap: 8px; }
.fx-rate-row input {
  flex: 1; min-width: 0; border: 1px solid var(--concrete-light); border-radius: var(--radius-ctrl); padding: 9px 10px;
  font-size: 16px; font-family: 'JetBrains Mono', monospace; background: var(--surface); color: var(--ink);
}
.fx-unit { font-size: 13px; font-weight: 700; color: var(--ink); white-space: nowrap; flex-shrink: 0; }
.fx-result { margin: 0; font-family: 'JetBrains Mono', monospace; font-size: 14px; font-weight: 700; color: var(--ink); }
.fx-result:empty { display: none; }
.fx-link { align-self: flex-start; background: none; border: none; padding: 2px 0; color: var(--link); font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer; text-align: left; }

/* Lists: an entry in another currency shows what it came to underneath */
.tx-amounts { display: flex; flex-direction: column; align-items: flex-end; flex-shrink: 0; }
.tx-amount-base { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--concrete); white-space: nowrap; margin-top: 1px; }

/* Dashboard: spent by currency */
.cur-breakdown { display: flex; flex-direction: column; }
.cur-row { display: grid; grid-template-columns: 48px 1fr auto; gap: 8px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--hairline); }
.cur-row:last-child { border-bottom: none; }
.cur-code { font-weight: 800; font-size: 13px; color: var(--ink); }
.cur-own { font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 14px; color: var(--ink); min-width: 0; }
.cur-count { display: block; font-family: inherit; font-size: 11px; font-weight: 500; color: var(--concrete); }
.cur-base { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--concrete); white-space: nowrap; text-align: right; }

/* Projects tab: base currency */
.proj-cur { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.proj-cur-select { width: auto; max-width: 220px; padding: 5px 8px; font-size: 12.5px; }

/* Settings */
.set-modal { display: flex; flex-direction: column; max-height: 92vh; overflow: hidden; }
.set-body { flex: 1; overflow-y: auto; padding: 14px 18px 18px; -webkit-overflow-scrolling: touch; }
.set-section h4 { margin: 0 0 6px; font-family: 'Barlow Condensed', sans-serif; font-size: 16px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; color: var(--ink); }
.set-meta { margin: 0 0 12px; font-size: 12.5px; color: var(--concrete); line-height: 1.5; }
.set-meta strong { color: var(--ink); }
.set-updated { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border-radius: 12px; background: var(--paper); border: 1px solid var(--hairline); }
.set-updated-label { margin: 0; font-size: 11px; font-weight: 600; color: var(--concrete); text-transform: uppercase; letter-spacing: 0.04em; }
.set-updated-value { margin: 2px 0 0; font-size: 14px; font-weight: 700; color: var(--ink); }
.set-updated-value.stale { color: var(--yellow-deep); }
.set-updated .btn-secondary { flex: 0 0 auto; padding-left: 14px; padding-right: 14px; white-space: nowrap; }
.set-search {
  width: 100%; margin: 12px 0 4px; border: 1px solid var(--concrete-light); border-radius: var(--radius-ctrl); padding: 10px 12px;
  font-size: 16px; font-family: inherit; background: var(--surface); color: var(--ink);
}
.set-rates { display: flex; flex-direction: column; }
.set-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 40px; gap: 6px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--hairline); }
.set-cur { display: flex; flex-direction: column; min-width: 0; }
.set-cur strong { font-size: 14px; color: var(--ink); }
.set-cur span { font-size: 11.5px; color: var(--concrete); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-rate { font-size: 12.5px; color: var(--concrete); text-align: right; display: flex; flex-direction: column; align-items: flex-end; }
.set-rate strong { font-family: 'JetBrains Mono', monospace; color: var(--ink); font-size: 13px; }
.set-badge { margin-top: 2px; font-size: 10px; font-weight: 700; color: var(--yellow-deep); text-transform: uppercase; letter-spacing: 0.04em; }
.set-none { font-style: italic; }
.set-edit { grid-template-columns: 1fr; gap: 8px; padding: 12px; background: var(--paper); border-radius: 12px; border-bottom: none; margin: 4px 0; }
.set-edit-actions { display: flex; gap: 8px; }
.set-edit-actions > button { flex: 1; }
.set-empty { padding: 16px 0; text-align: center; font-size: 13px; color: var(--concrete); margin: 0; }
.set-note { margin: 12px 0 0; font-size: 11.5px; color: var(--concrete); line-height: 1.5; }
.set-credit { margin: 8px 0 0; font-size: 11px; color: var(--concrete); }
.set-credit a { color: var(--link); }
.set-credit:empty { display: none; }

/* Header: the ⚙ button made the title wrap on phones — keep "SITE LEDGER"
   on one line and the icon buttons a little tighter on narrow screens. */
.app-header h1 { white-space: nowrap; }
.header-actions { flex-shrink: 0; }
@media (max-width: 420px) {
  .header-actions { gap: 2px; }
  .btn-icon-badge, .btn-logout { width: 30px; }
  .btn-export { padding: 7px 10px; margin: 0 2px; }
}

/* Entry form currency picker: shows just the code ("AED"); the list it
   opens still has the full names. */
.cur-pick { position: relative; flex: 0 0 88px; }
.cur-pick-label {
  display: flex; align-items: center; justify-content: space-between; gap: 4px; height: 100%; min-height: 42px;
  border: 1px solid var(--concrete-light); border-radius: var(--radius-ctrl); padding: 0 10px;
  background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 800; pointer-events: none;
}
.cur-pick-label::after { content: '▾'; font-size: 11px; color: var(--concrete); }
.cur-pick select { display: none; }
button.cur-pick-label { width: 100%; font-family: inherit; cursor: pointer; pointer-events: auto; }
button.cur-pick-label:focus-visible { outline: none; border-color: var(--focus-ring-color); box-shadow: 0 0 0 3px var(--focus-ring-shadow); }

/* Currency picker popup — fixed height so it doesn't jump while filtering */
.cur-modal { height: 85vh; }
.cur-group { margin: 12px 8px 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--concrete); }
.cur-row {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 8px; border: none; border-bottom: 1px solid var(--hairline);
  background: none; font: inherit; color: var(--ink); text-align: left; cursor: pointer;
}
.cur-row:hover, .cur-row:focus-visible { background: var(--paper); outline: none; }
.cur-row-code { flex: 0 0 44px; font-family: 'JetBrains Mono', monospace; font-weight: 800; font-size: 14px; }
.cur-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cur-row-name { font-size: 14px; overflow-wrap: anywhere; }
.cur-row-places { font-size: 11.5px; color: var(--concrete); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cur-row-tick { flex: 0 0 16px; color: var(--green); font-weight: 800; }
.cur-row.active .cur-row-name { font-weight: 700; }

/* Settings: rate on one line, "edited" under it */
.set-rate-line { white-space: nowrap; }
p.proj-cur { display: block; }
.proj-cur-locked { flex-wrap: wrap; }
.proj-cur-note { display: block; margin-top: 2px; font-size: 11.5px; color: var(--concrete); }
/* Projects tab: currency not confirmed yet — picker + Save */
.proj-cur-edit { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.proj-cur-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.proj-cur-save { padding: 6px 12px; font-size: 12.5px; width: auto; flex: 0 0 auto; }
.proj-cur-save:disabled { opacity: 0.45; cursor: default; }
.proj-cur-edit .proj-cur-note { flex-basis: 100%; margin-top: 0; }

/* ===== Paid with (payment methods) ===== */
.label-optional { font-weight: 500; color: var(--concrete); }
.pm-none { color: var(--concrete); font-weight: 500; }
.pm-tag { display: inline-block; vertical-align: 1px; margin-left: 4px; padding: 1px 7px; border-radius: 999px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.02em; }
.pm-tag-company { background: rgba(46, 66, 112, 0.12); color: var(--link); }
.pm-tag-personal { background: rgba(217, 164, 0, 0.16); color: var(--yellow-deep); }
.tx-pm { white-space: nowrap; }
.pm-panel .pm-name, .pm-panel .pm-kind {
  width: 100%; border: 1px solid var(--concrete-light); border-radius: var(--radius-ctrl); padding: 10px 12px;
  font-size: 16px; font-family: inherit; background: var(--surface); color: var(--ink);
}
.pm-owner { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pm-owner-btn { border: 1px solid var(--concrete-light); background: var(--surface); color: var(--ink); border-radius: var(--radius-ctrl); padding: 9px; font: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer; }
.pm-owner-btn.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.pm-foot { padding: 10px 18px max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--hairline); }
.pm-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 6px; }
.pm-sum { display: flex; flex-direction: column; gap: 3px; text-align: left; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--hairline); background: var(--paper); cursor: pointer; font: inherit; color: var(--ink); }
.pm-sum-label { font-size: 11px; font-weight: 600; color: var(--concrete); }
.pm-sum-value { font-family: 'JetBrains Mono', monospace; font-size: 15px; font-weight: 700; }
.pm-sum-personal .pm-sum-value { color: var(--yellow-deep); }
.pm-amt { color: var(--ink) !important; }
:root[data-theme="dark"] .pm-owner-btn.active { background: var(--yellow); border-color: var(--yellow-deep); color: #1B2A4A; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pm-owner-btn.active { background: var(--yellow); border-color: var(--yellow-deep); color: #1B2A4A; }
}
#paidWithList2 .owed-amt { font-family: 'JetBrains Mono', monospace; font-weight: 600; }

/* ===== Invoices & expense claims ===== */
.inv-bar {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; margin-bottom: 12px;
  padding: 12px 14px; border-radius: var(--radius-card); border: 1px solid var(--hairline); background: var(--surface);
  box-shadow: var(--shadow-sm); font: inherit; color: var(--ink); cursor: pointer;
}
.inv-bar-icon { font-size: 22px; flex-shrink: 0; }
.inv-bar-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.inv-bar-text strong { font-size: 14px; }
.inv-bar-text span { font-size: 12px; color: var(--concrete); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-bar-chev { font-size: 20px; color: var(--concrete); flex-shrink: 0; }

.inv-modal .set-body { padding-bottom: 24px; }
.inv-list { margin-top: 14px; display: flex; flex-direction: column; }
.inv-row { display: flex; align-items: center; gap: 2px; border-bottom: 1px solid var(--hairline); }
.inv-row-main {
  flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 4px; background: none; border: none; font: inherit; color: var(--ink); text-align: left; cursor: pointer;
}
.inv-row-main.busy { opacity: 0.5; pointer-events: none; }
.inv-row-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.inv-row-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.inv-row-top strong { font-family: 'JetBrains Mono', monospace; font-size: 13.5px; }
.inv-row-client { font-size: 13.5px; font-weight: 600; overflow-wrap: anywhere; }
.inv-row-meta { font-size: 11.5px; color: var(--concrete); }
.inv-row-total { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 13px; white-space: nowrap; }
.inv-row-pdf { font-family: inherit; font-size: 11px; font-weight: 700; color: var(--link); }
.inv-badge { padding: 1px 7px; border-radius: 999px; font-size: 10.5px; font-weight: 700; }
.inv-badge-invoice { background: rgba(46, 66, 112, 0.12); color: var(--link); }
.inv-badge-claim { background: rgba(217, 164, 0, 0.16); color: var(--yellow-deep); }
.inv-del { margin: 6px 0; }

.inv-section { padding: 14px 0 6px; border-top: 1px solid var(--hairline); }
.inv-section:first-child { border-top: none; padding-top: 2px; }
.inv-section h4 { margin: 0 0 10px; font-family: 'Barlow Condensed', sans-serif; font-size: 16px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; color: var(--ink); }
.inv-section .pc-section-head h4 { margin: 0; }
.inv-section .field { margin-bottom: 12px; }
.inv-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.inv-seg-btn { border: 1px solid var(--concrete-light); background: var(--surface); color: var(--ink); border-radius: var(--radius-ctrl); padding: 10px; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.inv-seg-btn.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.inv-range { margin-bottom: 10px; }
.inv-dates { margin-top: 2px; }
.inv-dates[hidden] { display: none; }
.inv-nowrap { white-space: nowrap; }

.inv-cats { display: flex; flex-direction: column; }
.inv-cat { position: relative; display: flex; align-items: center; gap: 10px; padding: 11px 4px; border-bottom: 1px solid var(--hairline); cursor: pointer; }
.inv-cat:last-child { border-bottom: none; }
.inv-cat input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.inv-check { position: relative; width: 20px; height: 20px; flex-shrink: 0; border: 2px solid var(--concrete-light); border-radius: 5px; background: var(--surface); }
.inv-cat.active .inv-check { background: var(--navy); border-color: var(--navy); }
.inv-cat.active .inv-check::after { content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.inv-cat input:focus-visible + .inv-check { box-shadow: 0 0 0 3px var(--focus-ring-shadow); }
.inv-cat-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.inv-cat-name { font-size: 14px; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.inv-cat.active .inv-cat-name { font-weight: 700; }
.inv-cat-meta { font-size: 11.5px; color: var(--concrete); }
.inv-cat-already { color: var(--yellow-deep); font-weight: 700; }
.inv-cat-amt { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.inv-warn { color: var(--red) !important; }

.inv-seller summary { list-style: none; cursor: pointer; }
.inv-seller summary::-webkit-details-marker { display: none; }
.inv-seller-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.inv-seller-title { flex-shrink: 0; font-family: 'Barlow Condensed', sans-serif; font-size: 16px; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; color: var(--ink); }
.inv-seller-title::after { content: " \25BE"; font-size: 12px; color: var(--concrete); }
.inv-seller[open] .inv-seller-title::after { content: " \25B4"; }
.inv-seller-sum { font-size: 12.5px; font-weight: 600; color: var(--concrete); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.inv-seller[open] .inv-seller-sum { display: none; }
.inv-seller > .set-meta { margin-top: 10px; }

.inv-summary { padding: 4px 12px; border-radius: 12px; background: var(--paper); border: 1px solid var(--hairline); }
.inv-summary .set-empty { padding: 10px 0; }
.inv-sum-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--hairline); font-size: 13.5px; color: var(--ink); }
.inv-sum-row > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.inv-sum-count { color: var(--concrete); font-size: 12px; }
.inv-sum-amt { font-family: 'JetBrains Mono', monospace; font-weight: 600; white-space: nowrap; }
.inv-sum-sub { color: var(--concrete); }
.inv-sum-total { border-bottom: none; font-weight: 800; font-size: 15px; }
.inv-sum-total .inv-sum-amt { font-weight: 800; }
.inv-sum-note { margin: 4px 0 8px; font-size: 12px; color: var(--yellow-deep); font-weight: 600; line-height: 1.45; }

.inv-footer { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.inv-footer .dash-custom-error { margin: 0 0 10px; }
.inv-footer-row { display: flex; gap: 8px; }
.inv-footer-row .btn-secondary { flex: 0 0 auto; padding-left: 18px; padding-right: 18px; }
.inv-footer-row .btn-primary { flex: 1; }
.inv-footer-row .btn-primary:disabled { opacity: 0.6; }

.inv-already { max-width: 380px; }
.inv-already-list { margin: 12px 0 4px; max-height: 40vh; overflow-y: auto; }
.inv-already-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--hairline); }
.inv-already-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 13px; color: var(--ink); }
.inv-already-text strong { overflow-wrap: anywhere; }
.inv-already-text span { font-size: 11.5px; color: var(--concrete); }
.inv-already-amt { font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.inv-already-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.inv-already-actions > button { width: 100%; padding-top: 11px; padding-bottom: 11px; }
.inv-cancel-link { background: none; border: none; color: var(--concrete); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; }

:root[data-theme="dark"] .inv-seg-btn.active,
:root[data-theme="dark"] .inv-cat.active .inv-check { background: var(--yellow); border-color: var(--yellow-deep); color: #1B2A4A; }
:root[data-theme="dark"] .inv-cat.active .inv-check::after { border-color: #1B2A4A; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .inv-seg-btn.active,
  :root:not([data-theme="light"]) .inv-cat.active .inv-check { background: var(--yellow); border-color: var(--yellow-deep); color: #1B2A4A; }
  :root:not([data-theme="light"]) .inv-cat.active .inv-check::after { border-color: #1B2A4A; }
}
