:root {
  --blue: #1e3a8a;
  --blue-light: #2563eb;
  --blue-soft: #dbeafe;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --surface: #f1f5f9;
  --white: #fff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --sidebar: #0f172a;
  --sidebar-text: #94a3b8;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  color: var(--text);
  background: var(--surface);
  line-height: 1.5;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
}

.login-card {
  background: var(--white);
  border-radius: 16px;
  padding: 2rem;
  width: min(100%, 420px);
  box-shadow: 0 25px 60px rgba(0,0,0,0.25);
}

.login-logo { display: block; height: 64px; width: auto; margin: 0 0 0.35rem; }
.login-card .sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.5rem; }

.tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.25rem;
  background: var(--surface);
  padding: 0.25rem;
  border-radius: 10px;
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.5rem 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
}

.tab.active { background: var(--white); color: var(--blue); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 0.35rem; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}
.field input:focus, .field select:focus { outline: 2px solid var(--blue-soft); border-color: var(--blue-light); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: -0.01em;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.btn:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-primary {
  background: var(--blue-light);
  color: #fff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.28), 0 6px 16px rgba(37, 99, 235, 0.18);
}
.btn-primary:hover { background: #1d4ed8; }
.btn-primary:active { background: #1e3a8a; box-shadow: none; }
.btn-secondary {
  background: var(--white);
  color: #334155;
  border-color: var(--border);
}
.btn-secondary:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: var(--text);
}
.btn-quiet {
  background: transparent;
  color: #475569;
  border-color: transparent;
}
.btn-quiet:hover {
  background: #f1f5f9;
  color: var(--text);
}
.btn-whatsapp {
  color: #128C7E;
}
.btn-whatsapp:hover:not([aria-disabled="true"]):not(:disabled) {
  background: #ecfdf5;
  color: #075E54;
}
.btn-whatsapp[aria-disabled="true"],
.btn-whatsapp.is-disabled {
  opacity: 0.38;
  cursor: not-allowed;
  color: #94a3b8;
}
.btn-delete-sale:hover {
  background: #fef2f2;
  color: #dc2626;
}
.btn-danger { background: var(--red); color: #fff; }
.btn-danger-outline { background: #fff; color: var(--red); border-color: #fecaca; }
.btn-danger-outline:hover { background: #fef2f2; }
.btn-sm { padding: 0.38rem 0.7rem; font-size: 0.78rem; }
.btn-block { width: 100%; }
.row-actions { display: flex; gap: 0.3rem; flex-wrap: wrap; white-space: nowrap; }

.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}
.alert-error { background: #fef2f2; color: var(--red); border: 1px solid #fecaca; }
.alert-info { background: var(--blue-soft); color: var(--blue); }

.demo-hint {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--muted);
}
.demo-hint code { background: var(--surface); padding: 0.1rem 0.3rem; border-radius: 4px; font-size: 0.75rem; }

/* App shell */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 1.25rem 0;
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 0 1.25rem 1.25rem;
  font-weight: 700;
  color: #fff;
  font-size: 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
}
.platform-logo {
  height: 50px;
  width: auto;
  max-width: 100%;
  background: #fff;
  border-radius: 10px;
  padding: 4px 8px;
  box-sizing: content-box;
}
.sidebar-brand .platform-fav {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: cover;
  background: #fff;
  flex: 0 0 auto;
}

.sidebar-brand small { display: block; font-weight: 400; font-size: 0.7rem; color: var(--sidebar-text); margin-top: 0.2rem; }

.nav-item {
  display: block;
  padding: 0.65rem 1.25rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  border-left: 3px solid transparent;
  cursor: pointer;
  background: none;
  border-right: none;
  border-top: none;
  border-bottom: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,0.06); color: #fff; border-left-color: var(--blue-light); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.topbar h2 { margin: 0; font-size: 1.15rem; }

.content { padding: 1.5rem; flex: 1; }

/* Cards & tables */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
}
.stat-card strong { display: block; font-size: 1.75rem; color: var(--blue); }
.stat-card span { font-size: 0.8rem; color: var(--muted); }

.panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.panel-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.panel-header h3 { margin: 0; font-size: 1rem; }

table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th, td { padding: 0.75rem 1.25rem; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--surface); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: capitalize;
}
.badge-active, .badge-trial { background: #dcfce7; color: var(--green); }
.badge-inactive, .badge-suspended { background: #fef2f2; color: var(--red); }
.badge-plan { background: var(--blue-soft); color: var(--blue); }

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
}

.module-chip {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.78rem;
  cursor: pointer;
  user-select: none;
}
.module-chip.on { background: var(--blue-soft); border-color: #93c5fd; color: var(--blue); }
.module-chip input { display: none; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.modal {
  background: var(--white);
  border-radius: 14px;
  width: min(100%, 560px);
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
}

.modal.erp-modal-wide { width: min(100%, 720px); }
.modal.erp-modal-statement { width: min(100%, 640px); }
.modal.erp-modal-import { width: min(100%, 920px); max-height: 90vh; overflow: auto; }

.vyapar-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.5rem; margin: 0.75rem 0; }
.vyapar-stat { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem 0.4rem; text-align: center; }
.vyapar-stat strong { display: block; font-size: 1.2rem; }
.vyapar-stat span { font-size: 0.72rem; color: var(--muted); }
.vyapar-import .preview-table-wrap { max-height: 240px; overflow: auto; margin: 0.5rem 0 1rem; }

.modal h3 { margin: 0 0 1rem; }

.erp-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem 1rem;
  margin: 0 0 1rem;
}

.erp-section legend {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--blue);
  padding: 0 0.35rem;
}

.erp-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.app-accent-row { display: flex; gap: 0.5rem; align-items: center; }
.app-accent-row input[type="color"] { width: 44px; height: 36px; padding: 2px; flex: 0 0 auto; cursor: pointer; }
.app-tab-move { display: inline-flex; gap: 0.2rem; }
.app-tab-check { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.82rem; margin: 0; }
.erp-form .app-tab-check input { width: auto; }
.erp-form .field { margin-bottom: 0.65rem; }
.erp-form label { display: block; font-size: 0.78rem; font-weight: 500; margin-bottom: 0.25rem; color: var(--muted); }
.erp-form input, .erp-form select, .erp-form textarea {
  width: 100%; padding: 0.45rem 0.6rem; border: 1px solid var(--border);
  border-radius: 8px; font: inherit; font-size: 0.875rem;
}
.erp-form input[type="checkbox"],
.erp-form input[type="radio"] {
  width: auto;
  height: 1rem;
  padding: 0;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--blue);
}

.role-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.role-chip {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.25rem 0.5rem; border: 1px solid var(--border); border-radius: 6px;
  font-size: 0.78rem; cursor: pointer;
}
.role-chip input { width: auto; }

.erp-form .field-hint { font-size: 0.72rem; color: var(--muted); margin: 0.3rem 0 0; line-height: 1.35; }
.erp-form label.same-as-display {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  font-weight: 500;
  color: inherit;
  cursor: pointer;
}
.erp-form .same-as-display input {
  width: auto;
  margin: 0;
}
.brand-asset-row .image-picker img {
  width: 88px;
  height: 88px;
  object-fit: contain;
  background: #f8fafc;
}
.brand-favicon-picker img {
  width: 48px;
  height: 48px;
}

.party-photo-picker, .product-image-picker, .image-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.party-photo-picker img, .product-image-picker img, .image-picker img {
  width: 72px; height: 72px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--border); background: #f3f4f6;
}
.party-photo-picker img.is-empty, .product-image-picker img.is-empty, .image-picker img.is-empty {
  background: repeating-linear-gradient(45deg,#f3f4f6,#f3f4f6 8px,#e5e7eb 8px,#e5e7eb 16px);
}
.party-photo-actions, .image-picker-actions { display: flex; gap: 0.4rem; align-items: center; }
.party-photo-browse, .image-picker-browse { margin: 0; cursor: pointer; }
.party-photo-picker .section-hint, .product-image-picker .section-hint, .image-picker .section-hint { flex-basis: 100%; margin: 0; }

.lots-thumb {
  width: 56px;
  height: 56px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: block;
}
.lots-facts {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin: 0 0 1rem;
  font-size: 0.85rem;
}
.lots-facts dl { display: grid; grid-template-columns: 10rem 1fr; gap: 0.25rem 0.75rem; margin: 0.5rem 0 0; }
.lots-facts dt { color: var(--muted); font-weight: 500; }
.lots-facts dd { margin: 0; }
.lots-draft-form .stock-section { display: none; }
#lots-slabs { margin: 0.35rem 0 0.5rem; }
#b2b-slab-copy { max-width: 100%; }
.badge-unpublished { background: #e0e7ff; color: #3730a3; }
.badge-lots-review { background: #ffedd5; color: #9a3412; }
tr.editable-row.is-lots-review td:first-child strong { box-shadow: inset 3px 0 0 #f97316; padding-left: 0.4rem; }
.lots-pm-flag {
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  margin: 0 0 1rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.lots-pm-review-panel { max-width: 760px; }
.badge-unchanged { background: #e5e7eb; color: #374151; }
.badge-not-seen { background: #fee2e2; color: #991b1b; }
.lots-book-tabs { display: flex; gap: 0.5rem; margin: 0 0 0.75rem; }
tr.lots-product-row.is-not-seen { opacity: 0.72; }
.lots-history-overlay {
  position: fixed;
  inset: 0;
  z-index: 420;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.lots-history-overlay.is-open {
  display: flex;
}
.lots-history-panel {
  background: #fff;
  border-radius: 12px;
  max-width: 640px;
  width: 100%;
  max-height: 80vh;
  overflow: auto;
  padding: 1.25rem 1.4rem;
  box-shadow: 0 16px 48px rgba(0,0,0,0.28);
}
.lots-history-panel h4 { margin: 0 0 0.5rem; }
.lots-history-list { margin: 0.75rem 0 1rem; padding-left: 1.2rem; }
.lots-history-list li { margin-bottom: 0.85rem; }
.lots-diff-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.4rem 0 0.75rem;
  font-size: 0.85rem;
}
.lots-diff-table th,
.lots-diff-table td {
  text-align: left;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.lots-diff-table th { color: var(--muted); font-weight: 600; }
.lots-image-review {
  display: grid;
  grid-template-columns: minmax(240px, 340px) 1fr;
  gap: 1rem;
  align-items: start;
}
.lots-image-zoom {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  width: 100%;
}
.lots-image-zoom:disabled { cursor: default; }
.lots-draft-form .lots-image-review img#lots-image-preview {
  width: 100%;
  height: auto;
  min-height: 240px;
  max-height: 380px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.lots-draft-form .lots-image-review img#lots-image-preview.is-empty {
  min-height: 240px;
}
.lots-image-review-actions { display: flex; flex-direction: column; gap: 0.65rem; }
.lots-lightbox {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(15, 23, 42, 0.78);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.25rem;
}
.lots-lightbox[hidden] { display: none; }
.lots-lightbox img {
  max-width: min(94vw, 960px);
  max-height: 82vh;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
}

.sale-lines { margin: 0 0 0.5rem; padding-left: 1.2rem; font-size: 0.85rem; color: var(--muted); }
.sale-lines li { margin-bottom: 0.25rem; }

.unit-hierarchy-section .section-hint { font-size: 0.75rem; color: var(--muted); margin: 0 0 0.75rem; }
.unit-card { border: 1px solid var(--border); border-radius: 10px; padding: 0.75rem; margin-bottom: 0.75rem; background: var(--surface); }
.unit-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.btn-remove-lower { background: none; border: none; color: #dc2626; cursor: pointer; font-size: 1rem; padding: 0.15rem 0.4rem; }
.relation-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.65rem; }
.relation-label { font-size: 0.85rem; white-space: nowrap; color: var(--muted); }
.relation-row input { flex: 1; max-width: 120px; }
.relation-unit { font-size: 0.85rem; font-weight: 600; }
.hierarchy-preview { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px; padding: 0.65rem 0.85rem; margin: 0.75rem 0; font-size: 0.82rem; }
.hierarchy-preview pre { margin: 0.35rem 0 0; white-space: pre-wrap; font-family: inherit; }
.hierarchy-preview .total-line { margin-top: 0.5rem; font-weight: 600; color: var(--blue); }
.margin-hint { font-size: 0.78rem; color: #059669; margin-bottom: 0.5rem; }
.readonly-field { background: #f1f5f9; color: var(--muted); }
.barcode-cell { font-size: 0.8rem; background: #f1f5f9; padding: 0.15rem 0.4rem; border-radius: 4px; }
.item-field.is-hidden { display: none !important; }
.item-settings-list { display: flex; flex-direction: column; gap: 0.55rem; max-height: 52vh; overflow: auto; padding-right: 0.25rem; }
.item-setting-row {
  display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; justify-content: space-between;
  border: 1px solid var(--border); border-radius: 10px; padding: 0.55rem 0.7rem; background: var(--surface);
}
.item-setting-title { font-size: 0.88rem; font-weight: 600; }
.seg { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button {
  border: 0; background: #fff; padding: 0.28rem 0.65rem; font-size: 0.78rem; cursor: pointer; color: var(--text);
}
.seg button + button { border-left: 1px solid var(--border); }
.seg button.is-on { background: #1e3a8a; color: #fff; font-weight: 600; }
.item-settings-labels { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; }

.modal-backdrop:has(.erp-modal-pos) {
  align-items: flex-start;
  overflow-y: auto;
}
.modal.erp-modal-pos {
  width: min(100%, 860px);
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal.erp-modal-pos .pos-form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  margin: 0;
}
.modal.erp-modal-pos .pos-fieldset {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  border: none;
  margin: 0;
  padding: 0 0.15rem 0.5rem 0;
}
.modal.erp-modal-pos .form-actions {
  flex-shrink: 0;
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  background: var(--white);
}
.pos-scan-box {
  background: #0f172a; color: #fff; border-radius: 12px; padding: 1rem 1.1rem; margin: 0.5rem 0 1rem;
}
.pos-scan-box label { display: block; font-size: 0.8rem; color: #94a3b8; margin-bottom: 0.35rem; }
.pos-scan-box input {
  width: 100%; font-size: 1.35rem; font-weight: 700; letter-spacing: 0.04em;
  padding: 0.75rem 0.9rem; border: 2px solid #334155; border-radius: 10px;
  background: #1e293b; color: #fff;
}
.pos-scan-box input.pos-product-search { font-size: 1.05rem; letter-spacing: 0; font-weight: 600; }
.pos-scan-box input:focus { outline: none; border-color: #3b82f6; }
.pos-suggest-wrap { position: relative; }
.pos-suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 140;
  max-height: 240px; overflow-y: auto;
  background: #fff; color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
}
.pos-suggest-item {
  display: flex; justify-content: space-between; gap: 0.75rem; align-items: baseline;
  width: 100%; border: none; background: #fff; text-align: left; font: inherit;
  padding: 0.55rem 0.8rem; cursor: pointer; border-bottom: 1px solid var(--border);
}
.pos-suggest-item:last-child { border-bottom: none; }
.pos-suggest-item:hover, .pos-suggest-item.is-active { background: var(--blue-soft); }
.pos-suggest-item strong { font-size: 0.88rem; }
.pos-suggest-item span { font-size: 0.75rem; color: var(--muted); }
.pos-feedback { margin-top: 0.5rem; font-size: 0.85rem; color: #94a3b8; min-height: 1.2em; }
.pos-feedback.ok { color: #4ade80; }
.pos-feedback.err { color: #f87171; }
.pos-cart-wrap { max-height: 280px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; }
.pos-empty { padding: 0.75rem 1rem; margin: 0; }
.pos-qty { display: flex; align-items: center; gap: 0.35rem; }
.pos-rate, .pur-rate {
  width: 6rem; padding: 0.35rem 0.45rem; border: 1px solid var(--border);
  border-radius: 6px; font: inherit; font-weight: 600;
}
.pos-unit, .pur-unit {
  min-width: 5.75rem; max-width: 8rem; padding: 0.35rem 0.4rem;
  border: 1px solid var(--border); border-radius: 6px; font: inherit;
}
.qty-btn {
  width: 28px; height: 28px; border: 1px solid var(--border); border-radius: 6px;
  background: #fff; cursor: pointer; font-size: 1rem; line-height: 1;
}
.pos-totals {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem;
  margin: 1rem 0; padding: 0.85rem; background: var(--surface); border-radius: 10px;
}
.pos-totals div { display: flex; flex-direction: column; gap: 0.15rem; }
.pos-totals span { font-size: 0.72rem; color: var(--muted); }
.pos-totals strong { font-size: 1rem; }
.pos-grand strong { color: var(--blue); font-size: 1.2rem; }

.pos-paid-hint {
  margin: 0.4rem 0 0;
  font-size: 0.8rem;
  color: #b45309;
  font-weight: 600;
}
.pos-party-tail {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px dashed var(--border);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.25rem; }

@media (max-width: 768px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; }
  .form-row { grid-template-columns: 1fr; }
  .desktop-shell { flex-direction: column; }
  .desktop-sidebar { width: 100%; }
}

/* Staff Desktop ERP shell */
.desktop-shell { display: flex; min-height: 100vh; background: var(--surface); }
.desktop-sidebar { width: 240px; background: #0f172a; color: #94a3b8; display: flex; flex-direction: column; flex-shrink: 0; }
.desktop-brand { padding: 1.15rem 1rem; border-bottom: 1px solid rgba(255,255,255,0.08); color: #fff; }
.desktop-brand strong { display: block; font-size: 1rem; }
.desktop-brand small { font-size: 0.72rem; color: #64748b; }
.desktop-nav { flex: 1; padding: 0.5rem 0; overflow-y: auto; }
.desktop-nav-item { display: flex; align-items: center; gap: 0.5rem; width: 100%; padding: 0.6rem 1rem; border: none; background: none; color: #94a3b8; font: inherit; font-size: 0.85rem; text-align: left; cursor: pointer; border-left: 3px solid transparent; }
.desktop-nav-item:hover, .desktop-nav-item.active { background: rgba(255,255,255,0.06); color: #fff; border-left-color: #2563eb; }
.desktop-nav-parent.open { color: #e2e8f0; }
.nav-chevron { width: 14px; height: 14px; margin-left: auto; opacity: 0.65; flex-shrink: 0; transition: transform 0.18s ease; }
.desktop-nav-parent.open .nav-chevron { transform: rotate(90deg); opacity: 0.9; }
.desktop-nav-children { display: none; padding: 0.1rem 0 0.45rem; }
.desktop-nav-children.is-open { display: block; }
.desktop-nav-sub { padding: 0.42rem 1rem 0.42rem 2.15rem; font-size: 0.8rem; border-left-color: transparent; }
.desktop-nav-sub.active { border-left-color: #38bdf8; }
.nav-icon { font-size: 1rem; }
.desktop-sidebar-foot { padding: 1rem; border-top: 1px solid rgba(255,255,255,0.08); }
.desktop-link { color: #94a3b8; font-size: 0.8rem; text-decoration: none; }
.desktop-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.desktop-topbar { background: #fff; border-bottom: 1px solid var(--border); padding: 0.7rem 1.25rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.desktop-topbar-lead { min-width: 0; }
.desktop-topbar h2 { margin: 0; font-size: 1.15rem; }
.desktop-subtitle { font-size: 0.78rem; color: var(--muted); text-transform: capitalize; }
.crumb-trail {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 0.2rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
.crumb {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: #64748b;
  padding: 0.32rem 0.7rem;
  border-radius: 999px;
  line-height: 1.2;
  white-space: nowrap;
}
.crumb-link { cursor: pointer; }
.crumb-link:hover { background: #fff; color: #0f172a; }
.crumb-link:focus-visible { outline: 2px solid #93c5fd; outline-offset: 1px; }
.crumb-current {
  color: #0f172a;
  font-weight: 650;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}
.crumb-sep {
  width: 12px;
  height: 12px;
  color: #cbd5e1;
  flex-shrink: 0;
}
.crumb-home { width: 14px; height: 14px; flex-shrink: 0; }
.desktop-user { display: flex; align-items: center; gap: 0.75rem; font-size: 0.875rem; }
.desktop-content { padding: 1.25rem; flex: 1; overflow-y: auto; }
.desktop-module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.75rem; }
.desktop-module-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 1rem; text-align: left; cursor: pointer; font: inherit; }
.desktop-module-card:hover { border-color: #93c5fd; box-shadow: 0 8px 24px rgba(30,58,138,0.08); }
.desktop-module-card .module-icon { font-size: 1.5rem; display: block; margin-bottom: 0.35rem; }
.desktop-module-card strong { display: block; font-size: 0.9rem; }
.desktop-module-card small { color: var(--muted); font-size: 0.75rem; }
.workspace-header { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.workspace-header h3 { margin: 0 0 0.35rem; }
.party-txn-head { align-items: flex-start; margin-bottom: 0.75rem; }
.party-os { text-align: right; min-width: 9.5rem; }
.party-os-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.party-os strong { display: block; font-size: 1.45rem; line-height: 1.2; margin: 0.1rem 0; }
.party-os small { display: block; font-size: 0.82rem; font-weight: 700; }
.party-os-receive strong, .party-os-receive small { color: #15803d; }
.party-os-pay strong, .party-os-pay small { color: #dc2626; }
.party-os-clear strong, .party-os-clear small { color: #64748b; }
.workspace-actions, .header-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.erp-cta-group {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}
.erp-cta-group .btn {
  padding: 0.55rem 1.05rem;
  font-size: 0.8125rem;
  border-radius: 10px;
}
.erp-cta-group .btn-secondary {
  background: transparent;
  border-color: transparent;
  color: #334155;
  box-shadow: none;
}
.erp-cta-group .btn-secondary:hover {
  background: #fff;
  border-color: #e2e8f0;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}
.erp-cta-group .btn-primary {
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.3), 0 4px 12px rgba(37, 99, 235, 0.2);
}
.workspace-preview { background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.preview-toolbar { display: flex; gap: 0.5rem; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.party-list-toolbar { flex-wrap: wrap; align-items: center; }
.party-list-filter {
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: #fff;
  min-width: 10rem;
}
.party-os-cell { text-align: right; white-space: nowrap; }
.party-os-cell strong { display: block; }
.party-os-cell small { font-weight: 700; }
.preview-search { flex: 1; padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; }
.preview-table { width: 100%; font-size: 0.85rem; }
.pos-fieldset { border: none; margin: 0; padding: 0; min-inline-size: 0; }
.pos-form.is-view .pos-fieldset { opacity: 0.96; }
.preview-note { padding: 0.75rem 1rem; margin: 0; font-size: 0.78rem; color: var(--muted); background: var(--surface); border-top: 1px solid var(--border); }
.muted { color: var(--muted); }
.section-title { margin: 1rem 0 0.75rem; font-size: 1rem; }
.geo-map-list { list-style: none; margin: 0 0 1rem; padding: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.geo-map-list li { display: flex; align-items: center; gap: 0.75rem; padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--border); }
.geo-map-list li:last-child { border-bottom: none; }
.geo-map-list li.is-selected { background: var(--blue-soft); }
.geo-map-list .link-btn { border: none; background: none; font: inherit; font-weight: 600; color: var(--blue); cursor: pointer; text-align: left; }
.geo-map-list .link-btn:hover { text-decoration: underline; }
.geo-map-list .muted { margin-right: auto; }

.stmt-party {
  margin: -0.35rem 0 0.65rem;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
}
.stmt-form .section-hint { margin: 0 0 0.85rem; color: var(--muted); font-size: 0.82rem; line-height: 1.4; }
.stmt-fields {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 0.85rem 1rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.stmt-field-group h4 {
  margin: 0 0 0.45rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.stmt-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.erp-form label.stmt-check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  padding: 0.38rem 0.7rem 0.38rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.stmt-check span { line-height: 1.2; }
.erp-form label.stmt-check:has(input:checked) {
  background: var(--blue-soft);
  border-color: #93c5fd;
  color: var(--blue);
}
.stmt-preview {
  margin-top: 1.1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.stmt-preview-open,
.stmt-preview-totals {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: baseline;
  margin: 0 0 0.65rem;
  font-size: 0.88rem;
}
.stmt-preview-open { justify-content: space-between; }
.stmt-preview-table { max-height: min(42vh, 360px); overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.stmt-sheet .stmt-preview-table { max-height: min(58vh, 680px); border: none; border-radius: 0; }
.stmt-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}
.stmt-dates {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.1rem;
  margin-left: auto;
}
.stmt-dates label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
  white-space: nowrap;
}
.stmt-dates input[type="date"] {
  display: inline-block;
  margin: 0;
  padding: 0.42rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}
.stmt-sheet {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.stmt-sheet-head { padding: 1.1rem 1.25rem 0.95rem; border-bottom: 1px solid var(--border); }
.stmt-sheet-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
}
.stmt-sheet-top { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.stmt-sheet-head h3 { margin: 0 0 0.25rem; font-size: 1.25rem; }
.stmt-sheet-head p { margin: 0; font-size: 0.85rem; color: #475569; line-height: 1.4; }
.stmt-sheet-period { margin-top: 0.45rem !important; font-weight: 700; color: #0f172a !important; }
.stmt-sheet-body { padding: 0; }
.stmt-table { font-size: 0.84rem; }
.stmt-table th, .stmt-table td { padding: 0.55rem 0.85rem; vertical-align: middle; }
.stmt-table th.num, .stmt-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stmt-table tbody tr.stmt-open { background: #f8fafc; font-weight: 700; }
.stmt-table tfoot tr { background: #f1f5f9; font-weight: 700; }
.stmt-table tfoot tr.stmt-close { background: #eff6ff; }
.stmt-table tfoot td { border-top: 1px solid var(--border); }
.stmt-preview-note { margin: 0.5rem 0 0; font-size: 0.75rem; }

.party-map-wrap { position: relative; }
.party-map-filters { display: flex; gap: 0.5rem; padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.party-map-filters select { flex: 1; min-width: 140px; padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; }
.party-map-canvas { height: min(62vh, 560px); min-height: 360px; z-index: 0; background: #e5e7eb; }
.party-map-empty { padding: 1.25rem 1rem; text-align: center; color: var(--muted); }
.party-map-carousel {
  display: flex; gap: 12px; overflow-x: auto; padding: 12px 16px 16px;
  border-top: 1px solid var(--border); scroll-snap-type: x mandatory;
}
.party-map-card {
  flex: 0 0 300px; scroll-snap-align: start;
  border: 1px solid var(--border); border-radius: 12px; padding: 0.85rem 0.95rem;
  background: #fff; cursor: pointer; box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}
.party-map-card.is-focused { border-color: #1d4ed8; border-width: 2px; box-shadow: 0 8px 20px rgba(29, 78, 216, 0.15); }
.party-map-card-title { font-weight: 800; font-size: 0.92rem; margin-bottom: 0.35rem; }
.party-map-card-meta { font-size: 0.78rem; color: var(--muted); line-height: 1.35; }
.party-map-card-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.7rem; }
.party-map-pin { background: none; border: none; }
.party-map-pin-dot {
  display: block; width: 16px; height: 16px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.35);
}

.thermal-picker-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); z-index: 80;
  display: flex; align-items: flex-end; justify-content: center;
}
.thermal-picker {
  background: #fff; width: min(480px, 100%); max-height: 80vh; overflow: auto;
  border-radius: 16px 16px 0 0; padding: 1rem 1.1rem 1.25rem;
  box-shadow: 0 -8px 30px rgba(15, 23, 42, 0.18);
}
.thermal-picker h3 { margin: 0 0 0.25rem; font-size: 1.05rem; }
.thermal-picker-item {
  display: flex; align-items: center; gap: 0.65rem; width: 100%;
  border: 1px solid var(--border); border-radius: 10px; padding: 0.7rem 0.8rem;
  background: #fff; margin: 0.4rem 0; cursor: pointer; text-align: left; font: inherit;
}
.thermal-picker-item:hover { border-color: var(--blue); background: var(--blue-soft); }
.thermal-picker-item strong { display: block; }
.thermal-picker-item span { font-size: 0.78rem; color: var(--muted); }
.thermal-badge {
  margin-left: auto; font-size: 0.72rem; font-weight: 700; color: #1d4ed8;
  background: var(--blue-soft); padding: 0.15rem 0.45rem; border-radius: 999px;
}

.biz-dash { max-width: 1100px; }
.dash-asof { margin: 0 0 1rem; }
.dash-profit {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  border-radius: 12px; padding: 1.1rem 1.25rem; margin-bottom: 1rem;
  border: 1px solid var(--border);
}
.dash-profit.is-yes { background: #ecfdf5; border-color: #6ee7b7; }
.dash-profit.is-no { background: #fef2f2; border-color: #fecaca; }
.dash-profit-kicker { display: block; font-size: 0.75rem; color: var(--muted); margin-bottom: 0.2rem; }
.dash-profit strong { font-size: 1.35rem; }
.dash-profit p { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.88rem; max-width: 46rem; }
.dash-profit-today { font-size: 0.85rem; color: var(--muted); align-self: center; }
.dash-panel { margin-bottom: 1rem; }
.dash-water { margin: 0; }
.dash-water .dash-total td { font-weight: 700; }
.dash-settings { padding: 1rem 1.25rem 1.15rem; }
.dash-advice { margin: 0; padding: 0.85rem 1.25rem 1.1rem 1.6rem; }
.dash-advice li { margin: 0.4rem 0; }
.dash-advice .sev-warn { color: #991b1b; }
.dash-advice .sev-good { color: #166534; }
.dash-split { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.dash-tabs { display: flex; gap: 0.35rem; }
.dash-tab {
  border: 1px solid var(--border); background: #fff; border-radius: 999px;
  padding: 0.25rem 0.7rem; font: inherit; font-size: 0.78rem; cursor: pointer;
}
.dash-tab.active { background: var(--blue-soft); border-color: #93c5fd; color: var(--blue); font-weight: 600; }
.dash-rank { margin: 0; }
.dash-empty { padding: 1rem 1.25rem; }
.dash-chart-wrap { padding: 0.5rem 0.75rem 0.85rem; overflow-x: auto; }
.dash-chart { width: 100%; height: 200px; display: block; }
.dash-bar { fill: #2563eb; }
.dash-bar-label { font-size: 10px; fill: #64748b; }
.dash-axis { font-size: 11px; fill: #64748b; }
.dash-axis-line { stroke: #e5e7eb; }
.dash-mini { list-style: none; margin: 0; padding: 0.5rem 0; }
.dash-mini li { display: flex; justify-content: space-between; gap: 0.75rem; padding: 0.45rem 1.25rem; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.dash-mini li:last-child { border-bottom: none; }
.dash-mini span { color: var(--muted); font-size: 0.78rem; text-align: right; }
@media (max-width: 900px) {
  .dash-split { grid-template-columns: 1fr; }
}
.slab-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.5rem;
  background: #fff;
}
.slab-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.45rem; }
.slab-range { font-size: 0.78rem; color: var(--blue); margin-left: auto; }
.slab-fields { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.slab-fields label { font-size: 0.75rem; color: var(--muted); display: flex; flex-direction: column; gap: 0.2rem; min-width: 6.5rem; }
.slab-fields input { width: 7rem; }
.unit-matrix { font-size: 0.82rem; margin: 0; }
.offer-banner-thumb { width: 96px; height: 40px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); vertical-align: middle; }
.banner-picker img { width: 100%; height: 180px; object-fit: cover; border-radius: 10px; background: #0f172a; }
.banner-picker-stage {
  overflow: hidden;
  border-radius: 10px;
  background: #0f172a;
  margin-bottom: 0.75rem;
}
.banner-picker-stage[data-place="fill"] img { object-fit: cover; }
.banner-picker-stage[data-place="fit"] img { object-fit: contain; }
.banner-picker-stage[data-place="stretch"] img { object-fit: fill; }
.banner-picker-stage[data-place="center"] {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
}
.banner-picker-stage[data-place="center"] img {
  width: auto;
  height: auto;
  max-width: none;
  object-fit: none;
}
.banner-picker-stage[data-place="tile"] {
  background-repeat: repeat;
  background-position: top left;
  background-size: auto;
}
.banner-picker-stage[data-place="tile"] img { opacity: 0; height: 180px; }
.banner-place-radios {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 0.35rem 0 0.25rem;
}
.banner-place-opt {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-size: 0.78rem;
}
.banner-place-opt input { margin: 0 0 4px; }
.banner-place-opt.is-on { border-color: var(--blue, #2563eb); box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18); }
.banner-place-name { font-weight: 700; }
.banner-place-opt small { color: var(--muted); line-height: 1.25; }
@media (max-width: 720px) {
  .banner-place-radios { grid-template-columns: 1fr 1fr; }
}
.offer-picker {
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  background: #fff;
}
.offer-pick-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  padding: 0.35rem 0.15rem;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border);
}
.offer-pick-row:last-child { border-bottom: none; }

.home-layout-list { list-style: none; margin: 0 0 1rem; padding: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.home-layout-list li { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); }
.home-layout-list li:last-child { border-bottom: none; }
.home-layout-idx {
  flex: 0 0 1.6rem; height: 1.6rem; border-radius: 999px;
  background: var(--blue-soft, #e0e7ff); color: var(--blue, #1d4ed8);
  display: grid; place-items: center; font-size: 0.75rem; font-weight: 700;
}
.home-layout-list strong { flex: 1; font-size: 0.9rem; }
.home-layout-actions { display: flex; gap: 0.35rem; }

.cat-studio {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  height: calc(100vh - 128px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.cat-rail {
  background: #f8fafc;
  border-right: 1px solid var(--border);
  padding: 0.85rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-height: 0;
  color: var(--text);
}
.cat-rail-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex: 0 0 auto; }
.cat-rail h3 { margin: 0; font-size: 0.95rem; color: var(--text); }
.cat-rail .field-hint { color: var(--muted); font-size: 0.72rem; margin: 0; line-height: 1.35; flex: 0 0 auto; }
.cat-rail .preview-search {
  flex: 0 0 auto;
  width: 100%;
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}
.cat-tree { overflow: auto; flex: 1 1 auto; min-height: 0; padding-right: 0.1rem; }
.cat-branch { margin-bottom: 0.15rem; }
.cat-node {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
}
.cat-node:hover { background: #e2e8f0; }
.cat-node.on { background: #1e3a8a; color: #fff; }
.cat-node.on .cat-meta em { background: rgba(255,255,255,0.2); }
.cat-node.is-off .cat-name { opacity: 0.5; text-decoration: line-through; }
.cat-sub { padding-left: 1.1rem; font-size: 0.8rem; }
.cat-uncat { background: #fff7ed; border: 1px solid #fed7aa; margin-bottom: 0.4rem; }
.cat-uncat.on { background: #c2410c; border-color: #c2410c; color: #fff; }
.cat-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-meta { display: flex; gap: 0.22rem; align-items: center; font-size: 0.68rem; flex-shrink: 0; }
.cat-meta em { font-style: normal; background: #e2e8f0; color: #334155; padding: 0.08rem 0.35rem; border-radius: 999px; font-weight: 700; }
.cat-ch { font-size: 0.62rem; font-weight: 700; padding: 0.06rem 0.28rem; border-radius: 4px; }
.cat-ch.on { background: #dcfce7; color: #166534; }
.cat-ch.off { background: #e2e8f0; color: #94a3b8; }
.cat-node.on .cat-ch.on { background: rgba(255,255,255,0.22); color: #fff; }
.cat-node.on .cat-ch.off { background: rgba(255,255,255,0.12); color: #cbd5e1; }
.cat-stage { padding: 1rem 1.15rem 1.15rem; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.cat-stage-head { display: flex; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.65rem; flex: 0 0 auto; }
.cat-stage-head h3 { margin: 0.1rem 0 0.1rem; font-size: 1.25rem; }
.cat-kicker { margin: 0; font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.cat-stage-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.cat-switch, .cat-seq { font-size: 0.78rem; font-weight: 600; display: flex; align-items: center; gap: 0.3rem; color: var(--muted); }
.cat-seq input { width: 3.6rem; padding: 0.3rem 0.35rem; border: 1px solid var(--border); border-radius: 8px; }
.cat-node-main { display: flex; align-items: center; gap: 0.45rem; min-width: 0; flex: 1; }
.cat-thumb {
  width: 28px; height: 28px; border-radius: 50%; object-fit: cover;
  flex: 0 0 auto; background: #e2e8f0;
}
.cat-thumb.brand-letter {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700; color: #3730a3; background: #eef2ff;
  object-fit: unset;
}
.cat-image-block {
  margin: 0 0 0.85rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
}
.cat-image-block .cat-kicker { margin: 0 0 0.45rem; }
.cat-image-picker img {
  width: 88px; height: 88px; border-radius: 50%; object-fit: cover;
}
.cat-rename-row { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; margin-bottom: 0.65rem; flex: 0 0 auto; }
.cat-rename-row input { flex: 1; min-width: 160px; padding: 0.5rem 0.65rem; border: 1px solid var(--border); border-radius: 8px; }
.cat-reparent {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin-bottom: 0.65rem;
  padding: 0.55rem 0.65rem;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  flex: 0 0 auto;
}
.cat-reparent strong { font-size: 0.82rem; }
.cat-reparent select { flex: 1; min-width: 180px; padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.cat-reparent .field-hint { flex: 1 0 100%; margin: 0; }
.cat-reparent.is-ready { background: #ecfdf5; border-color: #86efac; }
.cat-movebar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin-bottom: 0.65rem;
  padding: 0.55rem 0.65rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  flex: 0 0 auto;
}
.cat-movebar select { flex: 1; min-width: 180px; padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.cat-movebar.is-ready { background: #ecfdf5; border-color: #86efac; }
.pay-form { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.1rem 1.15rem; }
.pay-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}
.pay-grid label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.82rem; font-weight: 600; }
.pay-grid input, .pay-grid select { font: inherit; font-weight: 500; padding: 0.5rem 0.65rem; border: 1px solid var(--border); border-radius: 8px; }
.pay-alloc-head { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin: 0.25rem 0 0.35rem; }
.pay-alloc-head h4 { margin: 0; font-size: 0.95rem; }
.pay-assign-cell { display: flex; gap: 0.35rem; align-items: center; }
.pay-assign { width: 7.5rem; padding: 0.4rem 0.5rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; }
.pay-totals { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 0.85rem; padding: 0.75rem 0.85rem; background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; }
.pay-total { display: flex; flex-direction: column; gap: 0.15rem; min-width: 8rem; }
.pay-total span { font-size: 0.75rem; color: var(--muted); }
.pay-total.is-adv strong { color: #1d4ed8; }
.pay-total.is-bad strong { color: #b91c1c; }
.pay-empty { padding: 0.75rem 0.25rem; }
@media (max-width: 900px) {
  .pay-grid { grid-template-columns: 1fr; }
}
.cat-table-wrap { flex: 1 1 auto; min-height: 0; max-height: none; overflow: auto; }
.cat-row-move { min-width: 140px; padding: 0.28rem 0.4rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.78rem; background: #fff; }
.ord-status { min-width: 160px; padding: 0.35rem 0.5rem; border: 1px solid var(--border); border-radius: 8px; background: #fff; font: inherit; }
@media (max-width: 960px) {
  .cat-studio { grid-template-columns: 1fr; height: auto; min-height: 70vh; }
  .cat-rail { max-height: 240px; }
}
