:root {
  --green: #1f6f5c;
  --green-dark: #17554a;

  --bg: #f2f5f4;
  --card: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f7faf9;
  --surface-hover: #e8f1ee;

  --text: #1c2523;
  --muted: #62706c;
  --border: #d5dedb;

  --success-bg: #e1efeb;
  --warning-bg: #fff8df;
  --banner-bg: #fff7df;
  --banner-border: #e6cf85;

  --code-bg: #eef2f1;

  --danger: #b3261e;
  --danger-bg: #ffffff;
  --danger-border: #d8aaa6;

  color-scheme: light;
}

html[data-theme="dark"] {
  --green: #277d69;
  --green-dark: #5fc0a4;

  --bg: #111816;
  --card: #18221f;
  --surface: #202c28;
  --surface-soft: #1d2925;
  --surface-hover: #263a34;

  --text: #edf5f2;
  --muted: #a9bbb5;
  --border: #354640;

  --success-bg: #203c34;
  --warning-bg: #3a341d;
  --banner-bg: #3b321a;
  --banner-border: #746331;

  --code-bg: #24312d;

  --danger: #ff938b;
  --danger-bg: #2d201f;
  --danger-border: #734943;

  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
}

[hidden] { display: none !important; }

h1, h2, h3 { margin: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--green);
  color: #fff;
}
.topbar h1 { font-size: 1.2rem; }

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 12px calc(88px + env(safe-area-inset-bottom));
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}

.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login .card { width: 100%; max-width: 380px; }
.login h1 { margin-bottom: 8px; }

label { display: block; margin: 10px 0 4px; font-size: 0.9rem; color: var(--muted); }

input, select, textarea, button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 10px 12px;
  background: var(--surface);
  color: var(--text);
}
input, select, textarea { width: 100%; }

button {
  cursor: pointer;
  min-height: 44px;
  font-weight: 600;
}
button.primary { background: var(--green); border-color: var(--green); color: #fff; }
button.primary:active { background: var(--green-dark); }
button.ghost { background: transparent; border-color: rgba(255, 255, 255, 0.6); color: #fff; min-height: 36px; }
button.danger { color: var(--danger); }
button:disabled { opacity: 0.55; cursor: default; }

.row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.row > input { flex: 1; min-width: 0; width: auto; }
.row > button { flex-shrink: 0; }
.row > button.grow { flex: 1; }
.count-assignment-prompt .row { flex-wrap: wrap; }
.count-assignment-prompt select { width: 100%; }

.muted { color: var(--muted); font-size: 0.9rem; margin: 8px 0 0; }
.error { color: var(--danger); margin: 8px 0 0; font-size: 0.9rem; }

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

.scanner {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  margin-bottom: 8px;
  aspect-ratio: 4 / 3;
}
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner-frame {
  position: absolute;
  inset: 25% 10%;
  border: 3px solid rgba(255, 255, 255, 0.85);
  border-radius: 10px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.product-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.product-head h3 { font-size: 1.05rem; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--success-bg);
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}
.total { font-size: 1.4rem; font-weight: 700; color: var(--green-dark); }

.stock-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}
.stock-row .name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { min-width: 44px; padding: 8px; }
.stepper .qty { min-width: 2.4em; text-align: center; font-weight: 700; }

.add-stock { display: grid; grid-template-columns: 90px 1fr; gap: 8px; margin-top: 10px; }
.add-stock select { grid-column: 1 / -1; }

.item { cursor: pointer; }
.item:active { background: #f0f6f4; }

.banner { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--banner-bg); border-color: var(--banner-border); }
code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; }
#import-file { margin-top: 10px; }
.catalog-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.catalog-item .info { min-width: 0; overflow-wrap: anywhere; }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 6;
}
.tabbar button {
  flex: 1;
  border: 0;
  border-radius: 0;
  min-height: 56px;
  background: transparent;
  color: var(--muted);
}
.tabbar button.active { color: var(--green); border-top: 3px solid var(--green); }

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(76px + env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  font-size: 1.8rem;
  line-height: 1;
  padding: 0;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
  z-index: 7;
}

dialog {
  width: min(92vw, 460px);
  max-height: 90vh;
  border: 0;
  border-radius: 14px;
  padding: 16px;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
dialog h2 { margin-bottom: 4px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(80px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #222;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  max-width: 90vw;
  z-index: 20;
}
#toast.error-toast { background: var(--danger); }

/* Monthly inventory and reporting screens */
#app-view main { max-width: 1180px; }
.tabbar { overflow-x: auto; }
.tabbar button { min-width: 84px; }
.metric-grid { display:grid; grid-template-columns:repeat(4,minmax(130px,1fr)); gap:10px; }
.metric { margin-bottom:12px; }
.metric span { color:var(--muted); font-size:.82rem; }
.metric strong { display:block; margin-top:7px; color:var(--green-dark); font-size:1.45rem; }
.section-row { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.report-table { overflow:auto; }
.report-table table { width:100%; border-collapse:collapse; white-space:nowrap; }
.report-table th,.report-table td { text-align:left; border-bottom:1px solid var(--border); padding:10px; font-size:.84rem; }
.report-table th { color:var(--muted); font-size:.74rem; text-transform:uppercase; background:var(--surface-soft); position:sticky; top:0; z-index:1; }
.report-filters { grid-template-columns:repeat(4,minmax(130px,1fr)); align-items:end; }
.report-filters button { align-self:end; }
.count-table { max-height:65vh; }
.count-table input { width:84px; padding:7px; }
.count-table .notes-input { width:180px; }
.count-table tr.dirty { background:var(--warning-bg); }
.status { display:inline-block; border-radius:999px; padding:3px 8px; font-size:.72rem; font-weight:700; text-transform:uppercase; }
.status.open,.status.ok { background:var(--success-bg); color:var(--green-dark); }
.status.closed { background:#e7ecea; color:var(--muted); }
.status.review { background:#fce4d6; color:#8a4300; }
.report-list { display:grid; gap:12px; margin-top:14px; }
.report-bar { display:grid; grid-template-columns:100px 1fr 95px; gap:8px; align-items:center; font-size:.82rem; }
.report-bar i { height:11px; background:#e1e9e6; border-radius:99px; overflow:hidden; }
.report-bar b { display:block; height:100%; background:var(--green); border-radius:99px; }
.inline-check { display:flex; align-items:center; gap:8px; margin:0; }
.inline-check input { width:auto; }
.trend-bars { min-height:230px; display:flex; align-items:flex-end; gap:12px; overflow-x:auto; padding:20px 4px 0; }
.trend-column { min-width:88px; height:210px; display:flex; flex-direction:column; align-items:center; justify-content:flex-end; gap:7px; font-size:.76rem; }
.trend-column i { width:48px; background:linear-gradient(var(--green),var(--green-dark)); border-radius:6px 6px 0 0; }
.trend-column span { white-space:nowrap; }
@media(max-width:760px){.metric-grid{grid-template-columns:1fr 1fr}.report-filters{grid-template-columns:1fr 1fr}.count-table{max-height:none}.report-bar{grid-template-columns:82px 1fr 82px}.tabbar button{min-width:76px;font-size:.76rem}}
.scan-count-controls{margin-top:12px;padding-top:10px;border-top:1px solid var(--border)}
.scan-count-options{display:grid;grid-template-columns:1fr 1fr 110px;gap:8px;margin-top:8px;align-items:end}
.scan-count-options label{margin:0}.scan-count-options input{width:100%}.scan-count-success{border-left:4px solid var(--green)}
@media(max-width:600px){.scan-count-options{grid-template-columns:1fr 1fr}.scan-count-options label{grid-column:1/-1}}
.scan-count-prompt label{font-weight:700;margin-top:14px}.scan-count-prompt>input{font-size:1.35rem;text-align:center}.finalize-count{width:100%;margin-top:10px;background:var(--surface);border:2px solid var(--green);color:var(--green-dark)}.scan-next-actions{flex-wrap:wrap}.count-finalized{border-left:4px solid var(--green)}
.count-actions{display:flex;gap:6px}.count-actions button{min-height:34px;padding:6px 9px}.count-table tr.editing{outline:2px solid rgba(31,111,92,.25);outline-offset:-2px}.count-table input:disabled{background:#f4f7f6;color:var(--text);opacity:1}.count-actions .danger{background:var(--surface);border-color:#d8aaa6}

/* Start Count dialog: mobile-first, no horizontal scrolling */
#count-workflow-dialog {
  width: min(94vw, 520px);
  max-width: 94vw;
  max-height: min(88vh, 760px);
  margin: auto;
  padding: 0;
  overflow: hidden;
}
#count-workflow-dialog .count-workflow-card {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  max-height: min(88vh, 760px);
  padding: 16px;
  overflow-x: hidden;
  overflow-y: auto;
}
.count-workflow-head { min-width: 0; }
.count-workflow-head > div { min-width: 0; flex: 1; }
.count-workflow-head h2,
.count-workflow-head p,
.count-location-choice span,
.count-location-choice strong { overflow-wrap: anywhere; word-break: normal; }
.count-workflow-locations { width: 100%; min-width: 0; }
.count-location-choice {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}
.count-location-choice strong { text-align: right; white-space: normal; }
.count-workflow-actions { width: 100%; flex-wrap: wrap; }
.count-workflow-actions button { max-width: 100%; }

@media (max-width: 600px) {
  #count-workflow-dialog {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    max-height: calc(100dvh - 24px);
  }
  #count-workflow-dialog .count-workflow-card {
    max-height: calc(100dvh - 24px);
    padding: 14px;
  }
  .count-workflow-locations { gap: 7px; margin: 14px 0; }
  .count-location-choice {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 11px 12px;
  }
  .count-location-choice strong { text-align: left; }
  .count-workflow-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
  .count-workflow-actions button { width: 100%; }
}

/* Compact top-left dropdown navigation */
#app-view { overflow-x: hidden; }
.topbar { position: relative; justify-content: flex-start; gap: 10px; }
.topbar h1 { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.top-left-controls { position: relative; flex: 0 0 auto; }
.menu-trigger { min-height: 40px; padding: 8px 12px; background: var(--green); color: #fff; border-color: var(--green); }
.main-menu-panel { position: absolute; top: calc(100% + 7px); left: 0; z-index: 50; width: min(260px, calc(100vw - 24px)); max-height: calc(100dvh - 90px); overflow-y: auto; overflow-x: hidden; padding: 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); box-shadow: 0 14px 34px rgba(0,0,0,.16); }
.main-menu-panel button { display: block; width: 100%; min-height: 42px; padding: 9px 11px; text-align: left; background: transparent; color: var(--text); border: 0; border-radius: 8px; }
.main-menu-panel button:hover,.main-menu-panel button.active { background: var(--surface-hover); color: var(--green-dark); }
.menu-divider { height: 1px; margin: 6px 4px; background: var(--border); }
.tabbar { display: none !important; }
#app-view main { width: 100%; max-width: 1180px; min-width: 0; padding-bottom: 24px; }
.card,.filters,.row,.report-table,.count-table { min-width: 0; max-width: 100%; }
.report-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
button,input,select,textarea { max-width: 100%; }
@media(max-width:600px){.topbar{padding-left:10px;padding-right:10px}.main-menu-panel{position:fixed;top:64px;left:10px;width:calc(100vw - 20px);max-height:calc(100dvh - 76px)}#app-view main{padding-left:10px;padding-right:10px}.topbar h1{font-size:1.05rem}}
.location-manage-row{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:12px;align-items:center}.location-manage-row strong{overflow-wrap:anywhere}.location-actions{display:flex;gap:7px}.location-actions button{min-height:38px;padding:7px 11px}.location-actions .danger{background:var(--surface);color:#a42b22;border-color:#d8aaa6}@media(max-width:520px){.location-manage-row{grid-template-columns:1fr}.location-actions{display:grid;grid-template-columns:1fr 1fr}.location-actions button{width:100%}}

/* Product-to-location assignment */
.assignment-dialog-card {
  width: min(92vw, 520px);
  max-height: 85dvh;
  overflow-y: auto;
}

.location-assignment-list {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.location-assignment-choice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
}

.location-assignment-choice input {
  width: auto;
  margin: 0;
}

.location-assignment-choice.assigned {
  background: var(--surface-hover);
  border-color: var(--green);
}

.location-assignment-choice small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.location-module {
  display: grid;
  gap: 10px;
}

.location-module-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.location-products {
  display: grid;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.location-product-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.location-product-row:last-child {
  border-bottom: 0;
}

.location-product-info {
  min-width: 0;
}

.location-product-info strong,
.location-product-info small {
  display: block;
  overflow-wrap: anywhere;
}

.location-product-info small {
  margin-top: 3px;
  color: var(--muted);
}

.location-remove-button {
  min-height: 38px;
  padding: 7px 10px;
  background: var(--surface);
  color: var(--danger);
  border-color: #d8aaa6;
}

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

  .location-remove-button {
    width: 100%;
  }
}

/* Local wine-label OCR */
.wine-recognition-status {
  text-align: center;
}

.wine-ocr-card,
.wine-match-section {
  display: grid;
  gap: 10px;
}

.wine-ocr-lines {
  display: grid;
  gap: 4px;
  padding: 12px;
  background: #f5f7f6;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-weight: 600;
}

.wine-match-card {
  display: grid;
  gap: 8px;
}

.wine-match-card .primary {
  justify-self: start;
}

@media (max-width: 560px) {
  .wine-match-card .primary {
    width: 100%;
  }
}

/* Pull / Return operator administration */

.operator-admin-header,
.operator-card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.operator-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.operator-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
}

.operator-card h3 {
  margin: 0;
}

.operator-status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.85rem;
  font-weight: 700;
}

.operator-status.active {
  color: #165c38;
  background: #dff5e8;
}

.operator-status.disabled {
  color: #733a18;
  background: #f7e8dc;
}

.choice-line {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 8px 0;
}

.choice-line input {
  width: auto;
  margin: 0;
}

#operator-dialog fieldset {
  margin: 16px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}

.operator-code-result {
  min-width: min(440px, 85vw);
}

.operator-code-display {
  padding: 18px;
  margin: 16px 0;
  overflow-wrap: anywhere;
  text-align: center;
  border: 2px dashed var(--border);
  border-radius: 10px;
  background: #f5f7f6;
}

.operator-code-display code {
  font-size: 1.25rem;
  font-weight: 700;
  user-select: all;
}

@media (max-width: 560px) {
  .operator-admin-header,
  .operator-card-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .operator-admin-header .primary {
    width: 100%;
  }

  .operator-card .row {
    display: grid;
  }
}

/* Light / Dark theme controls */

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

.theme-toggle {
  min-width: 70px;
}

.page-heading {
  min-width: 0;
}

html[data-theme="dark"] .badge {
  background: var(--success-bg);
  color: var(--green-dark);
}

html[data-theme="dark"] .total,
html[data-theme="dark"] .metric strong {
  color: var(--green-dark);
}

html[data-theme="dark"] .item:active {
  background: var(--surface-hover);
}

html[data-theme="dark"] .main-menu-panel button:hover,
html[data-theme="dark"] .main-menu-panel button.active {
  background: var(--surface-hover);
  color: var(--green-dark);
}

html[data-theme="dark"] dialog {
  background: var(--card);
  color: var(--text);
  border-color: var(--border);
}

html[data-theme="dark"] .report-table th {
  background: var(--surface-soft);
}

html[data-theme="dark"] .count-table tr.dirty {
  background: var(--warning-bg);
}

html[data-theme="dark"] .count-table input:disabled {
  background: var(--surface-soft);
  color: var(--text);
}

html[data-theme="dark"] .finalize-count {
  background: var(--surface);
  color: var(--green-dark);
}

html[data-theme="dark"] .count-actions .danger,
html[data-theme="dark"] .location-actions .danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-border);
}

html[data-theme="dark"] .operator-code-display {
  background: var(--surface-soft);
}

html[data-theme="dark"] .operator-status.active {
  color: #92dec5;
  background: #203c34;
}

html[data-theme="dark"] .operator-status.disabled {
  color: #edb48d;
  background: #3a291f;
}

@media (max-width: 520px) {
  .topbar-actions {
    gap: 5px;
  }

  .theme-toggle {
    min-width: 62px;
    padding-left: 8px;
    padding-right: 8px;
  }
}

/* Requisition administration settings */

.requisition-settings-form {
  margin-top: 16px;
}

.requisition-settings-form .choice-line {
  margin-top: 16px;
}

.requisition-settings-form .row {
  justify-content: flex-end;
}

.requisition-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-divider {
  height: 1px;
  margin: 22px 0 18px;
  background: var(--border);
}

/* Bulk storage-location assignment */

.bulk-location-dialog {
  width: min(950px, 96vw);
  max-height: 92vh;
  padding: 0;
}

.bulk-location-dialog-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  min-height: 60vh;
}

.bulk-location-filters {
  display: grid;
  grid-template-columns:
    minmax(220px, 1fr)
    minmax(150px, 200px)
    minmax(150px, 200px);
  gap: 10px;
}

.bulk-location-select-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.bulk-location-product-list {
  display: grid;
  max-height: 52vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.bulk-location-product {
  display: grid;
  grid-template-columns:
    auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  margin: 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.bulk-location-product:last-child {
  border-bottom: 0;
}

.bulk-location-product input {
  width: 20px;
  height: 20px;
}

.bulk-location-product-info {
  min-width: 0;
}

.bulk-location-product-info strong,
.bulk-location-product-info small {
  display: block;
}

.bulk-location-product-info small {
  margin-top: 3px;
}

.bulk-location-message {
  padding: 10px 12px;
  border-radius: 8px;
}

.bulk-location-message.error {
  border: 1px solid #b42318;
}

.bulk-location-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-top: 12px;
  background: var(--card);
  border-top: 1px solid var(--border);
}

@media (max-width: 700px) {
  .bulk-location-filters {
    grid-template-columns: 1fr;
  }

  .bulk-location-product {
    grid-template-columns:
      auto minmax(0, 1fr);
  }

  .bulk-location-product .status {
    grid-column: 2;
  }

  .bulk-location-footer {
    align-items: stretch;
    flex-direction: column;
  }
}

/* Organization-specific club logo */

.club-logo {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  object-fit: contain;
  border-radius: 10px;
  padding: 3px;
  background: rgba(255, 255, 255, 0.94);
}

.club-logo-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.club-logo-settings {
  display: grid;
  grid-template-columns: minmax(100px, 160px) 1fr;
  gap: 18px;
  align-items: center;
  margin-top: 18px;
}

.club-logo-preview {
  display: block;
  width: 100%;
  max-width: 160px;
  max-height: 160px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: #fff;
}

.club-logo-settings form {
  min-width: 0;
}

.club-logo-settings input[type="file"] {
  width: 100%;
}

@media (max-width: 560px) {
  .club-logo {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .club-logo-settings {
    grid-template-columns: 1fr;
  }

  .club-logo-preview {
    margin: 0 auto;
  }

  .club-logo-settings .row {
    align-items: stretch;
  }

  .club-logo-settings .row button {
    width: 100%;
  }
}


/* ---------- Inventory catalog Mass Edit ---------- */

.catalog-view-header {
  align-items: center;
}

.catalog-view-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.catalog-view-switcher button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.mass-edit-filters {
  display: grid;
  grid-template-columns:
    minmax(240px, 2fr)
    minmax(160px, 1fr)
    minmax(160px, 1fr);
  gap: 12px;
  align-items: end;
}

.mass-edit-filters > div {
  min-width: 0;
}

.mass-edit-filters input,
.mass-edit-filters select {
  width: 100%;
}

.mass-edit-table-wrap {
  max-height: 68vh;
  padding: 0;
  overflow: auto;
}

.mass-edit-table {
  min-width: 1540px;
}

.mass-edit-table th,
.mass-edit-table td {
  vertical-align: top;
}

.mass-edit-table th {
  z-index: 3;
}

.mass-edit-table input,
.mass-edit-table select {
  width: 138px;
  min-width: 138px;
  padding: 7px;
}

.mass-edit-table
  [data-field="name"] {
  width: 250px;
  min-width: 250px;
  font-weight: 650;
}

.mass-edit-table
  [data-field="category"] {
  width: 130px;
  min-width: 130px;
}

.mass-edit-table
  [data-field="containerType"] {
  width: 130px;
  min-width: 130px;
}

.mass-edit-table
  [data-field="packSize"] {
  width: 90px;
  min-width: 90px;
}

.mass-edit-table
  [data-field="unitCost"],
.mass-edit-table
  [data-field="eventSellPrice"] {
  width: 110px;
  min-width: 110px;
}

.mass-edit-table
  [data-field="barcode"] {
  width: 170px;
  min-width: 170px;
}

.mass-edit-sticky-column {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 270px;
  background: var(--surface);
  box-shadow:
    1px 0 0 var(--border);
}

.mass-edit-table thead
  .mass-edit-sticky-column {
  z-index: 5;
  background: var(--surface-soft);
}

.mass-edit-table tr.dirty td {
  background: var(--warning-bg);
}

.mass-edit-table tr.dirty
  .mass-edit-sticky-column {
  background: var(--warning-bg);
}

.mass-edit-table tr.save-error td {
  background: rgba(180, 45, 45, 0.08);
}

.mass-edit-table tr.save-error
  .mass-edit-sticky-column {
  background: rgba(180, 45, 45, 0.08);
}

.mass-edit-table input.dirty,
.mass-edit-table select.dirty {
  border-color: #b98200;
  box-shadow:
    0 0 0 2px rgba(185, 130, 0, 0.16);
}

.mass-edit-location-cell {
  min-width: 180px;
  max-width: 240px;
}

.mass-edit-location-button {
  width: 100%;
  min-height: 36px;
  padding: 7px 9px;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}

.mass-edit-actions {
  position: sticky;
  bottom: 10px;
  z-index: 8;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow:
    0 8px 28px rgba(0, 0, 0, 0.18);
}

.mass-edit-actions p {
  margin: 3px 0 0;
}

html[data-theme="dark"]
  .mass-edit-table tr.save-error td,
html[data-theme="dark"]
  .mass-edit-table tr.save-error
  .mass-edit-sticky-column {
  background: rgba(255, 105, 105, 0.11);
}

@media (max-width: 760px) {
  .catalog-view-header {
    align-items: stretch;
  }

  .catalog-view-switcher {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

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

  .mass-edit-table-wrap {
    max-height: none;
  }

  .mass-edit-actions {
    align-items: stretch;
    flex-direction: column;
    bottom: 6px;
  }

  .mass-edit-actions .row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .mass-edit-actions button {
    width: 100%;
  }
}

/* ---------- Mass Edit multi-select and bulk changes ---------- */

.mass-edit-selection-bar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.mass-edit-selection-bar p {
  margin: 3px 0 0;
}

.mass-edit-bulk-panel {
  display: grid;
  grid-template-columns:
    minmax(180px, 1fr)
    minmax(220px, 2fr)
    auto;
  gap: 12px;
  align-items: end;
}

.mass-edit-bulk-panel > div {
  min-width: 0;
}

.mass-edit-bulk-panel input,
.mass-edit-bulk-panel select {
  width: 100%;
}

.mass-edit-bulk-apply {
  display: flex;
  align-items: end;
}

.mass-edit-bulk-apply button {
  min-height: 42px;
}

.mass-edit-bulk-panel > p {
  grid-column: 1 / -1;
  margin: 0;
}

.mass-edit-select-column {
  position: sticky;
  left: 0;
  z-index: 4;
  width: 50px;
  min-width: 50px;
  max-width: 50px;
  text-align: center;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--border);
}

.mass-edit-table thead
  .mass-edit-select-column {
  z-index: 7;
  background: var(--surface-soft);
}

.mass-edit-select-column input {
  width: 20px;
  min-width: 20px;
  height: 20px;
  margin: 5px auto;
}

.mass-edit-sticky-column {
  left: 50px;
}

.mass-edit-table tr.selected td {
  box-shadow:
    inset 0 1px 0 rgba(31, 111, 92, 0.3),
    inset 0 -1px 0 rgba(31, 111, 92, 0.3);
}

.mass-edit-table tr.selected
  .mass-edit-select-column {
  box-shadow:
    inset 4px 0 0 var(--primary),
    1px 0 0 var(--border);
}

.mass-edit-table tr.dirty
  .mass-edit-select-column {
  background: var(--warning-bg);
}

.mass-edit-table tr.save-error
  .mass-edit-select-column {
  background: rgba(180, 45, 45, 0.08);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 760px) {
  .mass-edit-selection-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .mass-edit-selection-bar .row {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .mass-edit-selection-bar button {
    width: 100%;
  }

  .mass-edit-bulk-panel {
    grid-template-columns: 1fr;
  }

  .mass-edit-bulk-panel > p {
    grid-column: auto;
  }

  .mass-edit-bulk-apply button {
    width: 100%;
  }
}

/* ---------- Purchase invoice / receipt upload ---------- */

.purchase-document-upload-row {
  display: grid;
  grid-template-columns:
    minmax(150px, 220px)
    minmax(280px, 1fr)
    auto;
  gap: 12px;
  align-items: center;
  width: 100%;
}

.purchase-document-upload-row
  #purchase-document-type {
  width: 100%;
  min-width: 0;
}

.purchase-document-upload-row
  #purchase-document-file {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text);
}

.purchase-document-upload-row
  #purchase-document-file::file-selector-button {
  min-height: 38px;
  margin-right: 12px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.purchase-document-upload-row
  #purchase-document-file::file-selector-button:hover {
  border-color: var(--primary);
}

.purchase-document-upload-row
  #purchase-upload-document {
  min-width: 170px;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .purchase-document-upload-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .purchase-document-upload-row
    #purchase-upload-document {
    width: 100%;
  }
}

/* ---------- Reusable context-sensitive How To dialog ---------- */

.page-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.page-title-group h1 {
  min-width: 0;
}

.how-to-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 7px 12px;
  white-space: nowrap;
}

.how-to-button span {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-weight: 800;
  line-height: 1;
}

.how-to-dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: min(86vh, 860px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow:
    0 22px 70px rgba(0, 0, 0, 0.34);
}

.how-to-dialog::backdrop {
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(2px);
}

.how-to-dialog-card {
  display: flex;
  flex-direction: column;
  max-height: min(86vh, 860px);
}

.how-to-dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}

.how-to-dialog-header h2 {
  margin: 2px 0 6px;
}

.how-to-dialog-header p {
  margin-top: 0;
  margin-bottom: 0;
}

.how-to-eyebrow {
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.how-to-close-icon {
  flex: 0 0 auto;
  min-width: 42px;
  min-height: 42px;
  padding: 4px 10px;
  font-size: 1.65rem;
  line-height: 1;
}

.how-to-content {
  overflow-y: auto;
  padding: 20px 24px 24px;
}

.how-to-section {
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
}

.how-to-section + .how-to-section {
  margin-top: 14px;
}

.how-to-section h3 {
  margin: 0 0 10px;
}

.how-to-section ol,
.how-to-section ul {
  margin: 0;
  padding-left: 24px;
}

.how-to-section li {
  padding-left: 4px;
  line-height: 1.5;
}

.how-to-section li + li {
  margin-top: 7px;
}

.how-to-dialog-footer {
  display: flex;
  justify-content: flex-end;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.how-to-dialog-footer button {
  min-width: 110px;
}

@media (max-width: 600px) {
  .page-title-group {
    width: 100%;
    justify-content: space-between;
  }

  .how-to-button {
    flex: 0 0 auto;
  }

  .how-to-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 13px;
  }

  .how-to-dialog-card {
    max-height: calc(100dvh - 16px);
  }

  .how-to-dialog-header {
    padding: 18px 16px 14px;
  }

  .how-to-content {
    padding: 14px 16px 18px;
  }

  .how-to-section {
    padding: 14px;
  }

  .how-to-dialog-footer {
    padding: 12px 16px;
  }

  .how-to-dialog-footer button {
    width: 100%;
  }
}

/* ---------- How To mobile topbar correction ---------- */

.page-title-group {
  flex: 1 1 auto;
  min-width: 0;
}

.page-title-group h1 {
  min-width: 0;
  overflow-wrap: normal;
  word-break: normal;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .topbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
  }

  .top-left-controls {
    grid-column: 1;
    min-width: 0;
  }

  .page-title-group {
    grid-column: 2;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    width: 100%;
    min-width: 0;
  }

  .page-title-group h1 {
    width: 100%;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    overflow-wrap: normal;
    word-break: normal;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .page-title-group .how-to-button {
    flex: none;
    min-height: 38px;
    padding: 7px 10px;
  }

  .topbar-actions {
    grid-column: 3;
    display: flex;
    gap: 7px;
    align-items: center;
  }
}

@media (max-width: 600px) {
  .topbar {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
  }

  .top-left-controls {
    grid-column: 1;
    grid-row: 1;
  }

  .page-title-group {
    grid-column: 2;
    grid-row: 1;
  }

  .topbar-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .topbar-actions button {
    width: 100%;
    min-width: 0;
  }

  .page-title-group h1 {
    font-size: 1.05rem;
  }

  .how-to-button {
    font-size: 0.9rem;
  }

  .how-to-button span {
    width: 20px;
    height: 20px;
  }
}

@media (max-width: 420px) {
  .page-title-group {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .how-to-button {
    padding: 7px 9px;
  }

  .how-to-button span {
    display: none;
  }
}

/* ---------- How To topbar responsive correction ---------- */

.page-title-group {
  flex: 1 1 auto;
  min-width: 0;
}

.page-title-group h1 {
  min-width: 0;
  margin: 0;
  overflow-wrap: normal;
  word-break: normal;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .topbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    align-items: center;
  }

  .top-left-controls {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }

  .page-title-group {
    grid-column: 2;
    grid-row: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    width: 100%;
    min-width: 0;
  }

  .page-title-group h1 {
    width: 100%;
    min-width: 0;
    overflow: hidden;
    overflow-wrap: normal;
    word-break: normal;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .page-title-group .how-to-button {
    width: auto;
    min-width: 0;
    min-height: 38px;
    padding: 7px 10px;
  }

  .topbar-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }

  .topbar-actions button {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 420px) {
  .page-title-group h1 {
    font-size: 1rem;
  }

  .how-to-button {
    padding: 7px 9px;
    font-size: 0.88rem;
  }

  .how-to-button span {
    display: none;
  }
}

/* ---------- Catalog Barcode Tasks mobile layout ---------- */

@media (max-width: 760px) {

  .catalog-management-card {
    padding: 16px;
  }

  .catalog-view-header {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    align-items: stretch;
  }

  .catalog-view-header > div:first-child {
    min-width: 0;
  }

  .catalog-view-header h3 {
    margin-bottom: 6px;
  }

  .catalog-view-header p {
    margin-bottom: 0;
  }

  .catalog-view-switcher {
    display: grid;
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  .catalog-view-switcher button {
    width: 100%;
    min-width: 0;
    min-height: 48px;
    padding: 9px 10px;
  }

  #catalog-barcode-panel {
    min-width: 0;
    overflow: hidden;
  }

  .catalog-item {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    align-items: stretch;
    width: 100%;
    min-width: 0;
  }

  .catalog-item .info {
    width: 100%;
    min-width: 0;
  }

  .catalog-item .info strong {
    display: block;
    overflow-wrap: anywhere;
    word-break: normal;
  }

  .catalog-item .info p {
    margin-bottom: 0;
  }

  .catalog-item > .row {
    display: grid;
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    min-width: 0;
  }

  .catalog-item > .row button {
    width: 100%;
    min-width: 0;
    min-height: 46px;
    margin: 0;
    padding: 9px 10px;
    white-space: normal;
    overflow-wrap: normal;
    word-break: normal;
  }
}

@media (max-width: 480px) {

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

  .catalog-item > .row button {
    width: 100%;
  }
}

/* ---------- Mass Edit mobile spreadsheet layout ---------- */

@media (max-width: 760px) {

  #catalog-mass-edit-panel {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
  }

  .mass-edit-table-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    max-height: 70vh;
    overflow-x: auto;
    overflow-y: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
  }

  .mass-edit-table {
    width: max-content;
    min-width: 1320px;
  }

  .mass-edit-select-column {
    left: 0;
    width: 42px;
    min-width: 42px;
    max-width: 42px;
    padding-left: 6px;
    padding-right: 6px;
  }

  .mass-edit-select-column input {
    width: 20px;
    min-width: 20px;
    height: 20px;
    margin-left: auto;
    margin-right: auto;
  }

  .mass-edit-sticky-column {
    left: 42px;
    width: 210px;
    min-width: 210px;
    max-width: 210px;
  }

  .mass-edit-table
    [data-field="name"] {
    width: 188px;
    min-width: 188px;
    max-width: 188px;
    box-sizing: border-box;
    text-overflow: ellipsis;
  }

  .mass-edit-table
    [data-field="category"] {
    width: 112px;
    min-width: 112px;
  }

  .mass-edit-table input,
  .mass-edit-table select {
    min-height: 42px;
  }

  .mass-edit-table th,
  .mass-edit-table td {
    padding: 8px;
  }

  .mass-edit-table thead
    .mass-edit-select-column,
  .mass-edit-table thead
    .mass-edit-sticky-column {
    position: sticky;
  }

  .mass-edit-table
    .mass-edit-select-column {
    z-index: 5;
  }

  .mass-edit-table
    .mass-edit-sticky-column {
    z-index: 4;
    box-shadow:
      1px 0 0 var(--border),
      8px 0 12px rgba(0, 0, 0, 0.08);
  }

  .mass-edit-table thead
    .mass-edit-sticky-column {
    z-index: 7;
  }

  .mass-edit-table thead
    .mass-edit-select-column {
    z-index: 8;
  }

  #mass-edit-summary::after {
    content: " · Swipe table left/right for more columns";
  }
}

@media (max-width: 430px) {

  .mass-edit-select-column {
    width: 40px;
    min-width: 40px;
    max-width: 40px;
  }

  .mass-edit-sticky-column {
    left: 40px;
    width: 190px;
    min-width: 190px;
    max-width: 190px;
  }

  .mass-edit-table
    [data-field="name"] {
    width: 168px;
    min-width: 168px;
    max-width: 168px;
  }
}


/* ========================================================
 * FINANCIAL CLOSEOUT REPORT PRINT LAYOUT
 * ======================================================== */

.financial-report-document {
  width: 100%;
  max-width: 1120px;
  margin: 18px auto 0;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
}

.financial-report-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 18px;
}

.financial-report-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 20px;
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 3px solid var(--green);
}

.financial-report-logo {
  display: block;
  width: auto;
  max-width: 150px;
  height: auto;
  max-height: 110px;
  object-fit: contain;
}

.financial-report-header-text {
  min-width: 0;
}

.financial-report-header h1 {
  margin: 2px 0 6px;
  font-size: clamp(1.55rem, 3vw, 2.25rem);
  line-height: 1.1;
  color: var(--green-dark);
}

.financial-report-organization {
  margin: 0;
  font-weight: 700;
  color: var(--muted);
}

.financial-report-event-name {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.financial-report-location {
  margin: 4px 0 0;
  color: var(--muted);
}

.financial-report-metadata,
.financial-report-summary-grid,
.financial-report-audit-grid {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(0, 1fr));
  gap: 8px 22px;
}

.financial-report-metadata {
  margin: 18px 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
}

.financial-report-section {
  margin: 22px 0 0;
  padding: 0;
  break-inside: auto;
}

.financial-report-section-title {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-left: 5px solid var(--green);
  background: var(--surface);
  color: var(--text);
  font-size: 1.15rem;
  line-height: 1.2;
}

.financial-report-summary-section {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
}

.financial-report-metric {
  display: grid;
  grid-template-columns:
    minmax(0, 1fr) auto;
  gap: 12px;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px dotted var(--border);
}

.financial-report-metric-label {
  min-width: 0;
  overflow-wrap: anywhere;
}

.financial-report-metric-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.financial-report-metric-strong {
  margin-top: 4px;
  padding-top: 9px;
  border-top: 2px solid var(--text);
  border-bottom: 0;
  font-size: 1.05rem;
  font-weight: 800;
}

.financial-report-table {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.financial-report-table-row {
  display: grid;
  grid-template-columns:
    minmax(170px, 2.4fr)
    minmax(64px, .7fr)
    minmax(72px, .8fr)
    minmax(64px, .7fr)
    minmax(82px, .9fr)
    minmax(92px, 1fr)
    minmax(82px, .9fr)
    minmax(92px, 1fr);
  min-width: 900px;
}

.financial-report-table-cell {
  min-width: 0;
  padding: 8px 7px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  overflow-wrap: anywhere;
}

.financial-report-table-cell:last-child {
  border-right: 0;
}

.financial-report-table-header {
  background: var(--green);
  color: #fff;
  font-size: .82rem;
  font-weight: 800;
}

.financial-report-item-row {
  background: var(--card);
  font-size: .87rem;
}

.financial-report-item-row:nth-child(odd) {
  background: var(--surface);
}

.financial-report-item-name {
  text-align: left;
  font-weight: 650;
}

.financial-report-number,
.financial-report-money {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.financial-report-extended {
  font-weight: 800;
}

.financial-report-empty {
  padding: 14px;
  color: var(--muted);
  font-style: italic;
}

.financial-report-category-totals {
  width: min(100%, 500px);
  margin: 10px 0 0 auto;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  break-inside: avoid;
}

.financial-report-override-table {
  border: 1px solid var(--border);
  border-radius: 8px;
}

.financial-report-override-row {
  display: grid;
  grid-template-columns:
    minmax(180px, 1.6fr)
    repeat(3, minmax(120px, 1fr));
  gap: 10px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
  font-variant-numeric: tabular-nums;
}

.financial-report-override-row:last-child {
  border-bottom: 0;
}

.financial-report-footnote {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: .82rem;
}

.financial-report-notes {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.financial-report-audit {
  margin-bottom: 0;
}

@media (max-width: 760px) {
  .financial-report-document {
    padding: 14px;
  }

  .financial-report-header {
    grid-template-columns: 1fr;
  }

  .financial-report-logo {
    max-width: 120px;
    max-height: 90px;
  }

  .financial-report-metadata,
  .financial-report-summary-grid,
  .financial-report-audit-grid {
    grid-template-columns: 1fr;
  }

  .financial-report-override-row {
    grid-template-columns: 1fr;
  }
}

@page {
  size: letter portrait;
  margin: 0.45in;
}

@media print {
  html,
  body {
    width: 100%;
    min-width: 0;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    color: #000 !important;
  }

  body.printing-financial-close-report
    > *:not(#financial-close-report-document) {
    display: none !important;
  }

  body.printing-financial-close-report
    #financial-close-report-document,
  body.printing-financial-close-report
    #financial-close-report-document * {
    visibility: visible !important;
  }

  body.printing-financial-close-report
    #financial-close-report-document {
    position: absolute;
    inset: 0 auto auto 0;
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: #fff !important;
    color: #000 !important;
    box-shadow: none !important;
  }

  body.printing-financial-close-report
    .no-print,
  body.printing-financial-close-report
    button,
  body.printing-financial-close-report
    .topbar,
  body.printing-financial-close-report
    .tabbar,
  body.printing-financial-close-report
    .main-menu-panel {
    display: none !important;
  }

  .financial-report-header {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 16px;
    padding-bottom: 10px;
    border-color: #000 !important;
  }

  .financial-report-logo {
    max-width: 1.3in;
    max-height: .9in;
  }

  .financial-report-header h1,
  .financial-report-organization,
  .financial-report-event-name,
  .financial-report-location {
    color: #000 !important;
  }

  .financial-report-header h1 {
    font-size: 18pt;
  }

  .financial-report-event-name {
    font-size: 11pt;
  }

  .financial-report-metadata,
  .financial-report-summary-section,
  .financial-report-category-totals,
  .financial-report-notes,
  .financial-report-table,
  .financial-report-override-table {
    border-color: #555 !important;
    background: #fff !important;
    box-shadow: none !important;
  }

  .financial-report-metadata,
  .financial-report-summary-grid,
  .financial-report-audit-grid {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }

  .financial-report-section {
    margin-top: 14px;
  }

  .financial-report-section-title {
    margin-bottom: 6px;
    padding: 5px 7px;
    border-color: #000 !important;
    background: #eee !important;
    color: #000 !important;
    font-size: 11pt;
    break-after: avoid;
  }

  .financial-report-table {
    overflow: visible !important;
    border-radius: 0 !important;
  }

  .financial-report-table-row {
    grid-template-columns:
      minmax(135px, 2.4fr)
      minmax(42px, .7fr)
      minmax(48px, .8fr)
      minmax(42px, .7fr)
      minmax(56px, .9fr)
      minmax(64px, 1fr)
      minmax(56px, .9fr)
      minmax(64px, 1fr);
    min-width: 0 !important;
  }

  .financial-report-table-header {
    background: #ddd !important;
    color: #000 !important;
  }

  .financial-report-table-cell {
    padding: 4px;
    border-color: #777 !important;
    font-size: 7.5pt;
  }

  .financial-report-item-row {
    background: #fff !important;
    break-inside: avoid;
  }

  .financial-report-item-row:nth-child(odd) {
    background: #f6f6f6 !important;
  }

  .financial-report-category-totals {
    margin-top: 5px;
    padding: 5px 8px;
    border-radius: 0;
    background: #fff !important;
    break-inside: avoid;
  }

  .financial-report-metric {
    padding: 3px 0;
    border-color: #777 !important;
    font-size: 8.5pt;
  }

  .financial-report-metric-strong {
    border-color: #000 !important;
  }

  .financial-report-category {
    break-before: auto;
  }

  .financial-report-category
    .financial-report-section-title,
  .financial-report-category
    .financial-report-table-header {
    break-after: avoid;
  }

  .financial-report-override-row {
    grid-template-columns:
      minmax(130px, 1.6fr)
      repeat(3, minmax(90px, 1fr));
    padding: 5px 7px;
    border-color: #777 !important;
    font-size: 8pt;
    break-inside: avoid;
  }

  .financial-report-notes,
  .financial-report-footnote {
    font-size: 8.5pt;
  }

  .financial-report-audit {
    break-inside: avoid;
  }
}

/* ---------- Printable inventory count worksheets ---------- */

.count-worksheet-card {
  margin-top: 16px;
}

.count-worksheet-controls {
  display: grid;
  grid-template-columns:
    repeat(3, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}

.count-worksheet-controls > div {
  min-width: 0;
}

.count-worksheet-controls select {
  width: 100%;
}

.count-worksheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.count-worksheet-preview-panel {
  margin-top: 16px;
}

.count-worksheet-preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.count-worksheet-output {
  background: #ddd;
  padding: 20px;
  overflow-x: auto;
}

.count-worksheet-document {
  width: min(100%, 1000px);
  min-height: 600px;
  margin: 0 auto;
  padding: 28px;
  background: #fff;
  color: #000;
  box-sizing: border-box;
}

.count-worksheet-header {
  border-bottom: 2px solid #111;
  padding-bottom: 14px;
  margin-bottom: 18px;
}

.count-worksheet-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.count-worksheet-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.count-worksheet-brand h1 {
  margin: 0;
  font-size: 24px;
}

.count-worksheet-brand p {
  margin: 4px 0 0;
  color: #444;
}

.count-worksheet-meta {
  display: grid;
  grid-template-columns:
    repeat(2, minmax(220px, 1fr));
  gap: 20px;
  margin-top: 18px;
}

.count-line {
  display: inline-block;
  width: 180px;
  margin-left: 6px;
  border-bottom: 1px solid #000;
}

.count-worksheet-section {
  margin: 0 0 24px;
}

.count-worksheet-group-title {
  margin: 20px 0 7px;
  padding: 6px 8px;
  background: #eee;
  border: 1px solid #999;
  font-size: 17px;
}

.count-worksheet-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  color: #000;
}

.count-worksheet-table th,
.count-worksheet-table td {
  border: 1px solid #777;
  padding: 7px 6px;
  text-align: left;
  vertical-align: middle;
}

.count-worksheet-table th {
  background: #eee;
  font-size: 12px;
}

.count-worksheet-table th:nth-child(1) {
  width: 29%;
}

.count-worksheet-table th:nth-child(2) {
  width: 10%;
}

.count-worksheet-table th:nth-child(3) {
  width: 12%;
}

.count-worksheet-table th:nth-child(4) {
  width: 11%;
}

.count-worksheet-table th:nth-child(5) {
  width: 10%;
}

.count-worksheet-table th:nth-child(6) {
  width: 28%;
}

.count-worksheet-table td {
  height: 31px;
  font-size: 12px;
}

.count-item-name {
  font-weight: 600;
}

.count-write-cell {
  background: #fff;
}

.count-notes-cell {
  min-width: 140px;
}

.count-worksheet-empty {
  padding: 30px 0;
  text-align: center;
}

.count-worksheet-footer {
  margin-top: 18px;
  padding-top: 8px;
  border-top: 1px solid #aaa;
  text-align: center;
  color: #555;
  font-size: 10px;
}

@media (max-width: 720px) {
  .count-worksheet-controls {
    grid-template-columns: 1fr;
  }

  .count-worksheet-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .count-worksheet-actions button {
    width: 100%;
  }

  .count-worksheet-output {
    padding: 8px;
  }

  .count-worksheet-document {
    padding: 14px;
  }

  .count-worksheet-meta {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .count-worksheet-table {
    min-width: 760px;
  }
}

@media print {
  body * {
    visibility: hidden !important;
  }

  #count-worksheet-output,
  #count-worksheet-output * {
    visibility: visible !important;
  }

  #count-worksheet-output {
    position: absolute;
    inset: 0;
    width: 100%;
    padding: 0;
    overflow: visible;
    background: #fff;
  }

  .count-worksheet-document {
    width: 100%;
    max-width: none;
    min-height: 0;
    margin: 0;
    padding: 0;
  }

  .count-worksheet-section {
    break-inside: auto;
  }

  .count-worksheet-group-title {
    break-after: avoid;
    background: #eee !important;
    color: #000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .count-worksheet-table {
    min-width: 0;
  }

  .count-worksheet-table thead {
    display: table-header-group;
  }

  .count-worksheet-table tr {
    break-inside: avoid;
  }

  .count-worksheet-table th {
    background: #eee !important;
    color: #000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  @page {
    margin: 0.45in;
  }
}
/* Full-page assigned count workspace */
.count-workspace-header { display:flex; justify-content:space-between; align-items:flex-start; gap:1rem; position:sticky; top:0; z-index:5; }
.count-workspace-table { overflow:auto; max-height:calc(100vh - 320px); }
.count-workspace-table table { min-width:760px; }
.count-workspace-table input[data-qty] { width:130px; font-size:1.1rem; font-weight:700; }
.count-workspace-table input[data-notes] { min-width:240px; }
.count-only-user .tabbar button[hidden], .count-only-user [data-menu-tab][hidden] { display:none !important; }
@media (max-width:767px) {
  .count-workspace-header { position:static; display:block; }
  .count-workspace-header .row { display:grid; grid-template-columns:1fr; margin-top:1rem; }
  .count-workspace-table { max-height:none; }
}
/* Explicit Count Only navigation boundary */
body.count-only-user [data-menu-tab]:not([data-menu-tab="dashboard"]):not([data-menu-tab="scan"]):not([data-menu-tab="count-workspace"]),
body.count-only-user [data-tab]:not([data-tab="dashboard"]):not([data-tab="scan"]):not([data-tab="count-workspace"]) {
  display: none !important;
}
/* Final menu layering and Count Only visibility */
.topbar { z-index: 100; }
.top-left-controls { z-index: 110; }
.main-menu-panel {
  z-index: 1000;
  background: var(--card);
  opacity: 1;
  isolation: isolate;
}
body.main-menu-open::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.22);
  pointer-events: none;
}
body.main-menu-open .count-workspace-header {
  visibility: hidden;
}
body.count-only-user #main-menu-panel [data-menu-tab]:not([data-menu-tab="dashboard"]):not([data-menu-tab="scan"]):not([data-menu-tab="count-workspace"]),
body.count-only-user #requisition-module-button,
body.count-only-user #pull-module-button,
body.count-only-user #administration-menu-button,
body.count-only-user #module-menu-divider,
body.count-only-user .tabbar [data-tab]:not([data-tab="dashboard"]):not([data-tab="scan"]):not([data-tab="count-workspace"]) {
  display: none !important;
}
