:root {
  color-scheme: light;
  --brand-red: #E60000;
  --brand-black: #111111;
  --brand-white: #FFFFFF;
  --brand-bg: #F7F8FA;
  --brand-border: #D9E1E6;
  --brand-text: #1A1A1A;
  --brand-muted: #6B7280;
  --bg: var(--brand-bg);
  --surface: var(--brand-white);
  --surface-soft: #F8FAFC;
  --ink: var(--brand-text);
  --muted: var(--brand-muted);
  --line: var(--brand-border);
  --accent: var(--brand-red);
  --accent-dark: #B80000;
  --accent-soft: #FFE5E5;
  --gold: #9A6700;
  --red: var(--brand-red);
  --green: #067647;
  --blue: #2563eb;
  --shadow: 0 18px 40px rgba(17, 17, 17, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  letter-spacing: 0;
  overflow-x: hidden;
}

body.locked {
  overflow: hidden;
}

body.modal-open {
  overflow: hidden;
}

label[id*="RateLabel"]:not(#saleRateLabel):not(#purchaseRateLabel):not(#expenseRateLabel),
label[id*="FundingRateLabel"],
label:has(select[name="fundingCurrency"]),
label:has(input[name="fundingRate"]),
label:has(input[name="usdPreview"]),
label:has(input[name="afnPreview"]),
label:has(input[name="baseAmount"]) {
  display: none !important;
}

body.locked .sidebar,
body.locked .mobile-menu-toggle,
body.locked .mobile-sidebar,
body.locked .mobile-sidebar-overlay,
body.locked .app-shell {
  display: none;
}

body:not(.locked) .login-screen {
  display: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #ffffff, var(--brand-bg));
}

.login-card {
  width: min(390px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card .brand-mark {
  margin-bottom: 2px;
}

.brand-logo {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  border-radius: 8px;
  object-fit: contain;
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.5);
}

.login-logo {
  width: 132px;
  height: 132px;
  justify-self: center;
  box-shadow: 0 0 0 1px var(--line), 0 10px 24px rgba(22, 32, 42, 0.12);
}

.login-card h1 {
  margin: 0;
  font-size: 24px;
}

.login-card p {
  margin: 0;
  color: var(--muted);
}

.login-error {
  min-height: 18px;
  color: var(--red);
  font-size: 13px;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 220px;
  min-width: 220px;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  overflow-y: auto;
  background: linear-gradient(180deg, var(--brand-black), #142428);
  color: #f8fafc;
}

.mobile-menu-toggle,
.mobile-sidebar,
.mobile-sidebar-overlay {
  display: none;
}

.mobile-menu-toggle {
  position: fixed;
  left: 14px;
  top: 14px;
  z-index: 950;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--brand-black);
  box-shadow: 0 10px 24px rgba(17, 17, 17, 0.12);
}

.mobile-sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 980;
  background: rgba(17, 17, 17, 0.48);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.mobile-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 990;
  width: min(292px, 86vw);
  height: 100vh;
  padding: 16px;
  overflow-y: auto;
  background: var(--brand-white);
  color: var(--brand-black);
  border-right: 1px solid var(--line);
  box-shadow: 18px 0 44px rgba(17, 17, 17, 0.18);
  transform: translateX(-104%);
  transition: transform 220ms ease;
}

.mobile-sidebar.open {
  transform: translateX(0);
}

.mobile-sidebar-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.mobile-sidebar-head,
.mobile-brand {
  display: flex;
  align-items: center;
}

.mobile-sidebar-head {
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.mobile-brand {
  gap: 10px;
}

.mobile-brand strong,
.mobile-brand span {
  display: block;
}

.mobile-brand strong {
  font-size: 14px;
}

.mobile-brand span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.mobile-menu-close {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--brand-black);
}

.mobile-menu-nav {
  display: grid;
  gap: 6px;
  padding: 14px 0 4px;
}

.mobile-menu-link {
  width: 100%;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 12px 12px;
  border: 1px solid transparent;
  border-left: 4px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--brand-black);
  font-weight: 700;
  text-align: left;
}

.mobile-menu-link svg,
.mobile-menu-close svg,
.mobile-menu-toggle svg {
  width: 20px;
  height: 20px;
}

.mobile-menu-link:hover,
.mobile-menu-link.active {
  border-color: var(--line);
  border-left-color: var(--brand-red);
  background: var(--accent-soft);
  color: var(--brand-red);
}

.mobile-logout-link {
  margin-top: 8px;
  color: var(--brand-red);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--brand-red);
  color: var(--brand-white);
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 2px;
  color: #cbd5dc;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.nav-button,
.icon-button,
.link-button,
.mini-button,
.secondary-button,
.primary-button,
.segment {
  border: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
}

.nav-button {
  justify-content: flex-start;
  width: 100%;
  min-height: 46px;
  padding: 12px 14px;
  border-left: 3px solid transparent;
  background: transparent;
  color: #d9e3e7;
}

.nav-button span {
  display: grid;
  gap: 2px;
  font-size: 14px;
  line-height: 1.2;
}

.dari-label,
.inline-dari,
th span,
.segment span {
  direction: rtl;
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

.dari-label {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
}

.inline-dari {
  color: var(--muted);
}

.nav-button small {
  color: #a9bbc3;
  font-size: 11px;
  line-height: 1.1;
}

.link-button > span,
.primary-button > span,
.secondary-button > span {
  display: grid;
  gap: 1px;
  line-height: 1.15;
}

.link-button .dari-label,
.primary-button .dari-label,
.secondary-button .dari-label {
  color: inherit;
  font-size: 11px;
  opacity: 0.86;
  margin-top: 0;
}

.nav-button:hover,
.nav-button.active {
  background: rgba(230, 0, 0, 0.14);
  border-left-color: var(--brand-red);
  color: #ffffff;
}

.nav-button svg,
.icon-button svg,
.link-button svg,
.mini-button svg,
.secondary-button svg,
.primary-button svg,
.status-pill svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.side-actions {
  margin-top: 4px;
  display: flex;
  gap: 8px;
}

.icon-button {
  width: 42px;
  background: #242424;
  color: #ffffff;
}

.icon-button:hover {
  background: var(--brand-red);
}

.app-shell {
  min-height: 100vh;
  margin-left: 220px;
  padding: 20px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 22px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(29px, 2.4vw, 34px);
  line-height: 1.1;
}

.topbar h1::after,
.report-toolbar h2::after,
.panel-head h2::after {
  content: "";
  display: block;
  width: 44px;
  height: 3px;
  margin-top: 8px;
  border-radius: 999px;
  background: var(--brand-red);
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 16px;
}

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

.status-pill,
.link-button {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 15px;
  text-decoration: none;
  white-space: nowrap;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

body[data-active-view="customer-sheet"] .topbar,
body[data-active-view="customer-detail"] .topbar,
body[data-active-view="people"] .topbar,
body[data-active-view="purchases"] .topbar,
body[data-active-view="sales"] .topbar,
body[data-active-view="supplier-detail"] .topbar {
  display: none;
}

body[data-active-view="customer-sheet"] .app-shell,
body[data-active-view="customer-detail"] .app-shell,
body[data-active-view="people"] .app-shell,
body[data-active-view="purchases"] .app-shell,
body[data-active-view="sales"] .app-shell,
body[data-active-view="supplier-detail"] .app-shell {
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  padding: 12px 16px;
}

body[data-active-view="customer-sheet"] #view-customer-sheet,
body[data-active-view="customer-detail"] #view-customer-detail,
body[data-active-view="people"] #view-people,
body[data-active-view="purchases"] #view-purchases,
body[data-active-view="sales"] #view-sales,
body[data-active-view="supplier-detail"] #view-supplier-detail {
  height: calc(100vh - 24px);
  overflow: hidden;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.compact-kpis {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
}

.business-value-panel {
  margin-top: 16px;
}

.business-admin-panel h3 {
  margin: 0;
  color: var(--brand-black);
  font-size: 1rem;
}

.business-admin-panel .split-grid > section {
  min-width: 0;
}

.kpi {
  min-height: 108px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
  min-width: 0;
}

.kpi svg {
  color: var(--brand-red);
}

.kpi span {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.15;
}

.kpi strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(20px, 1.25vw, 24px);
  line-height: 1.15;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  overflow-wrap: normal;
  word-break: normal;
  letter-spacing: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.dashboard-number,
.dashboard-number .tag,
.dashboard-number span {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  white-space: normal;
}

.dashboard-number .tag {
  min-height: 0;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
}

.kpi small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel + .panel {
  margin-top: 14px;
}

.panel-head {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: clamp(20px, 1.5vw, 24px);
}

.panel-head span {
  color: var(--muted);
  font-size: 13px;
  text-align: left;
}

.panel-actions,
.report-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.partner-account-actions {
  width: 100%;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
}

.investment-actions {
  justify-content: flex-end;
}

.app-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
}

.app-modal.hidden {
  display: none !important;
}

.app-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 17, 17, 0.58);
}

.app-modal-card {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  box-shadow: 0 24px 70px rgba(17, 17, 17, 0.32);
}

.confirm-modal-card {
  position: relative;
  z-index: 1;
  width: min(360px, calc(100vw - 28px));
  border-radius: 6px;
  box-shadow: 0 24px 70px rgba(17, 17, 17, 0.32);
}

.confirm-modal-card .panel-head {
  min-height: 44px;
  padding: 8px 10px;
}

.confirm-modal-card h2 {
  font-size: 14px;
}

.compact-confirm-form {
  gap: 8px;
  padding: 10px;
}

.compact-confirm-form input {
  min-height: 34px;
  padding: 6px 9px;
}

.filter-row {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
}

.filter-row label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.sale-mode-control {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 7px;
}

.sale-mode-control legend {
  color: var(--brand-black);
  font-size: 12px;
  font-weight: 900;
  padding: 0 6px;
}

.sale-mode-control label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--brand-black);
  font-weight: 800;
  min-height: 34px;
  padding: 5px 11px 5px 7px;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.sale-mode-control input {
  appearance: none;
  width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  border: 2px solid var(--brand-black);
  border-radius: 50%;
  background: #ffffff;
  accent-color: var(--brand-red);
  box-shadow: inset 0 0 0 4px #ffffff;
}

.sale-mode-control label:has(input:checked) {
  border-color: rgba(230, 0, 0, 0.72);
  background: var(--accent-soft);
  color: var(--brand-red);
  box-shadow: 0 5px 14px rgba(230, 0, 0, 0.1);
}

.sale-mode-control input:checked {
  border-color: var(--brand-red);
  background: var(--brand-red);
}

.multi-sale-fields {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 12px;
  overflow: hidden;
}

.compact-head {
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.compact-head h3 {
  margin: 0;
  font-size: 15px;
}

.multi-sale-rows {
  display: grid;
  gap: 10px;
}

.multi-sale-header,
.multi-sale-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.55fr) minmax(58px, 0.48fr) minmax(82px, 0.72fr) minmax(88px, 0.78fr) minmax(40px, 44px);
  gap: 8px;
  min-width: 0;
}

.multi-sale-header {
  align-items: center;
  margin-bottom: 8px;
  padding: 0 10px;
  color: var(--brand-black);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

.multi-sale-row {
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  min-width: 0;
}

.multi-sale-row label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  min-width: 0;
  overflow-wrap: anywhere;
}

.multi-sale-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 40px;
}

.row-add-button {
  border-color: rgba(230, 0, 0, 0.32);
  color: var(--brand-red);
}

.multi-sale-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--brand-black);
}

.multi-sale-total strong {
  color: var(--brand-red);
  font-size: 18px;
}

.mini-button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--brand-black);
}

.mini-button.text-mini {
  width: auto;
  min-width: 0;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.mini-button:hover {
  background: var(--accent-soft);
  color: var(--brand-red);
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.dashboard-position-grid,
.dashboard-filter-panel,
.dashboard-report-grid,
.pending-panel {
  margin-bottom: 14px;
}

.section-grid {
  display: grid;
  grid-template-columns: minmax(290px, 360px) minmax(0, 1fr);
  gap: 14px;
}

#view-sales .section-grid {
  grid-template-columns: minmax(470px, 0.95fr) minmax(0, 1.05fr);
}

.two-forms {
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  margin-bottom: 14px;
}

.three-forms {
  grid-template-columns: repeat(3, minmax(260px, 1fr));
}

.form-panel {
  align-self: start;
}

.wide-panel {
  min-width: 0;
}

.stacked-form {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.form-hint {
  margin: -4px 0 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--brand-black);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.expense-clear-options {
  display: grid;
  gap: 8px;
  padding-top: 4px;
}

.expense-clear-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--brand-black);
  font-weight: 700;
}

.expense-clear-toggle input {
  margin: 0;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

input,
select {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--ink);
}

input:focus,
select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.inline-search {
  width: min(320px, 100%);
  min-height: 44px;
  border-color: var(--brand-border);
  background: var(--brand-white);
  box-shadow: 0 8px 18px rgba(17, 17, 17, 0.05);
}

.form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.primary-button {
  min-height: 44px;
  padding: 9px 14px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  font-size: 15px;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button {
  min-height: 44px;
  padding: 9px 14px;
  border: 1px solid var(--brand-black);
  background: var(--brand-white);
  color: var(--brand-black);
  font-weight: 700;
  font-size: 15px;
}

.secondary-button:hover {
  background: #fff5f5;
  border-color: var(--brand-red);
  color: var(--brand-red);
}

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

.form-actions .primary-button,
.form-actions .secondary-button {
  flex: 1 1 130px;
}

.hidden {
  display: none !important;
}

input[readonly] {
  background: #F8FAFC;
  color: var(--brand-black);
  font-weight: 800;
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

.compact-table table {
  min-width: 360px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

#view-dashboard table {
  min-width: 520px;
}

th,
td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  font-size: 14px;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  border-top: 3px solid var(--brand-red);
  background: #F3F4F6;
  color: var(--brand-black);
  font-size: 12px;
  text-transform: uppercase;
}

th span {
  display: block;
  margin-top: 3px;
  color: var(--brand-muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.1;
  text-transform: none;
}

tbody tr:hover {
  background: #fff5f5;
}

.search-match-row td {
  background: #fff1f1;
  box-shadow: inset 4px 0 0 var(--brand-red);
}

.filter-match-row td {
  background: #fff1f1;
}

.search-match-row .link-cell {
  color: var(--brand-black);
}

#view-customer-sheet,
#view-customer-detail {
  display: none;
}

#view-customer-sheet.active,
#view-customer-detail.active {
  display: block;
}

.customer-sheet-panel,
.customer-ledger-panel,
.supplier-sheet-panel,
.supplier-ledger-panel {
  border-radius: 6px;
  box-shadow: 0 8px 20px rgba(17, 17, 17, 0.04);
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.customer-sheet-panel .panel-head,
.customer-ledger-panel .panel-head,
.supplier-sheet-panel .panel-head,
.supplier-ledger-panel .panel-head {
  min-height: 34px;
  padding: 4px 8px;
}

.customer-sheet-toolbar,
.customer-ledger-toolbar,
.supplier-sheet-toolbar,
.supplier-ledger-toolbar {
  border-top: 3px solid var(--brand-red);
}

.customer-sheet-toolbar h2,
.customer-ledger-toolbar h2,
.supplier-sheet-toolbar h2,
.supplier-ledger-toolbar h2 {
  min-width: max-content;
  font-size: 14px;
  color: var(--brand-black);
}

.customer-ledger-toolbar .mini-button,
.supplier-ledger-toolbar .mini-button {
  width: 28px;
  height: 28px;
}

.customer-ledger-toolbar .mini-button.text-mini,
.supplier-ledger-toolbar .mini-button.text-mini {
  min-height: 28px;
  padding: 0 7px;
}

.customer-sheet-toolbar .panel-actions,
.customer-ledger-toolbar .panel-actions,
.supplier-sheet-toolbar .panel-actions,
.supplier-ledger-toolbar .panel-actions {
  flex: 1 1 auto;
  justify-content: flex-end;
}

.customer-sheet-toolbar .inline-search,
.supplier-sheet-toolbar .inline-search {
  width: min(360px, 44vw);
  min-height: 30px;
  padding: 4px 8px;
  border-radius: 5px;
  box-shadow: none;
}

.customer-sheet-toolbar .primary-button,
.customer-sheet-toolbar .secondary-button,
.supplier-sheet-toolbar .primary-button,
.supplier-sheet-toolbar .secondary-button,
.ledger-entry-form .primary-button,
.ledger-entry-form .secondary-button,
.compact-filter-row .secondary-button {
  min-height: 30px;
  padding: 4px 9px;
  border-radius: 5px;
  font-size: 12px;
}

.compact-action {
  min-height: 30px;
}

.currency-modal-card {
  max-width: 380px;
}

.cash-currency-list {
  display: grid;
  gap: 5px;
  font-size: 13px;
  line-height: 1.35;
}

.dashboard-cash-line {
  display: grid;
  grid-template-columns: minmax(92px, 1fr) auto;
  align-items: center;
  gap: 6px;
}

.dashboard-cash-box-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
  gap: 12px;
  margin: 0 0 14px;
}

.stock-table-panel {
  min-height: calc(100vh - 150px);
  display: flex;
  flex-direction: column;
}

.stock-toolbar {
  border-top: 3px solid var(--brand-red);
  gap: 10px;
}

.stock-toolbar h2 {
  min-width: max-content;
  font-size: 16px;
}

.stock-toolbar .panel-actions {
  flex: 1 1 auto;
  justify-content: flex-end;
  gap: 8px;
}

.stock-toolbar .inline-search,
.stock-toolbar select,
.stock-toolbar label input {
  min-height: 34px;
  border-radius: 6px;
  box-shadow: none;
}

.stock-toolbar .inline-search {
  width: min(300px, 32vw);
}

.stock-toolbar select,
.stock-toolbar label {
  width: min(190px, 22vw);
}

.stock-toolbar label {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.stock-toolbar label input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 6px 10px;
}

.expense-sheet-panel,
.roz-namcha-panel {
  gap: 12px;
}

.expense-table-panel,
.roz-namcha-table-panel {
  box-shadow: none;
}

.roz-namcha-panel .kpi-grid {
  margin-top: 4px;
}

.stock-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}

.stock-table {
  min-width: 1060px;
}

.product-modal-card {
  width: min(520px, 100%);
}

.purchase-invoice-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(0, 1.5fr);
  gap: 16px;
}

.purchase-invoice-panel,
.purchase-transactions-panel {
  min-width: 0;
}

.purchase-transactions-panel {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 150px);
}

.purchase-transactions-panel .table-wrap {
  flex: 1 1 auto;
  min-height: 0;
}

.selector-field {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--brand-black);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  font-weight: 800;
}

.selector-field span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.purchase-invoice-summary {
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand-red);
  border-radius: 6px;
  background: #fff;
  padding: 10px;
}

.purchase-invoice-summary strong {
  display: block;
  margin-bottom: 8px;
}

.purchase-invoice-summary dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.purchase-invoice-summary div {
  min-width: 0;
}

.purchase-invoice-summary dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.purchase-invoice-summary dd {
  margin: 2px 0 0;
  font-size: 13px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.purchase-expense-inline-list {
  display: grid;
  gap: 6px;
}

.purchase-expense-chip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--brand-black);
  font-size: 12px;
  font-weight: 800;
}

.purchase-expense-chip small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-weight: 700;
}

.picker-modal-card {
  width: min(760px, 100%);
}

.picker-search {
  width: 100%;
  margin: 0 0 10px;
}

.select-with-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.picker-select-row {
  cursor: pointer;
}

.picker-select-row:hover {
  background: #fff4f4;
}

.text-row-action {
  width: auto;
  min-width: 68px;
  padding: 0 10px;
  border-radius: 5px;
}

.purchase-transactions-table {
  min-width: 1120px;
}

.purchase-sheet-panel {
  border-radius: 6px;
  box-shadow: 0 8px 20px rgba(17, 17, 17, 0.04);
  min-height: calc(100vh - 145px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.purchase-sheet-toolbar {
  border-top: 3px solid var(--brand-red);
  min-height: 34px;
  padding: 4px 8px;
}

.purchase-sheet-toolbar h2 {
  min-width: max-content;
  font-size: 14px;
  color: var(--brand-black);
}

.sheet-toolbar-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
}

.sheet-toolbar-actions .primary-button {
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 12px;
  white-space: nowrap;
}

.purchase-sheet-controls {
  display: grid;
  grid-template-columns: repeat(8, minmax(92px, 1fr));
  gap: 7px;
  align-items: end;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.purchase-page-controls {
  grid-template-columns: minmax(180px, 1.5fr) repeat(2, minmax(120px, .8fr)) repeat(4, minmax(92px, auto));
  align-items: end;
}

.entry-modal-card {
  width: min(980px, calc(100vw - 24px));
  max-height: calc(100vh - 28px);
  overflow: hidden;
}

.entry-modal-card .panel-head {
  min-height: 40px;
  padding: 8px 10px;
}

.entry-modal-card h2 {
  font-size: 15px;
}

.popup-entry-form {
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  max-height: calc(100vh - 92px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px;
}

.popup-entry-form .purchase-line-items {
  grid-column: 1 / -1;
  margin-top: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.popup-entry-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 2px;
}

.popup-entry-actions .primary-button,
.popup-entry-actions .secondary-button {
  min-height: 30px;
  border-radius: 5px;
  padding: 5px 10px;
  font-size: 12px;
}

.purchase-sheet-controls label {
  min-width: 0;
  gap: 4px;
  font-size: 11px;
  font-weight: 800;
}

.purchase-sheet-controls input,
.purchase-sheet-controls select,
.purchase-sheet-controls .selector-field {
  min-height: 30px;
  border-radius: 5px;
  font-size: 12px;
}

.purchase-sheet-controls input,
.purchase-sheet-controls select {
  padding: 4px 8px;
}

.purchase-sheet-controls .selector-field {
  padding: 4px 8px;
  font-weight: 800;
}

.purchase-sheet-controls .primary-button,
.purchase-sheet-controls .secondary-button,
.purchase-sheet-controls .mini-button {
  min-height: 30px;
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 12px;
  justify-content: center;
  white-space: nowrap;
}

.purchase-inline-total {
  min-height: 30px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand-red);
  border-radius: 5px;
  padding: 4px 8px;
  color: var(--brand-black);
  background: #fff;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.purchase-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}

.sales-sheet-panel {
  min-height: calc(100vh - 145px);
}

.sales-sheet-controls {
  grid-template-columns: repeat(8, minmax(92px, 1fr));
}

#saleForm.sales-sheet-controls.popup-entry-form {
  grid-template-columns: minmax(220px, 1.4fr) minmax(180px, 1fr) minmax(140px, 0.7fr);
  gap: 12px;
  align-items: end;
  width: 100%;
}

#saleForm.sales-sheet-controls.popup-entry-form label {
  min-width: 0;
}

#saleForm.sales-sheet-controls.popup-entry-form select,
#saleForm.sales-sheet-controls.popup-entry-form input,
#saleForm.sales-sheet-controls.popup-entry-form .selector-field {
  width: 100%;
  min-width: 0;
}

.purchase-line-items,
.multi-sale-fields {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.purchase-line-head,
.multi-sale-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.purchase-line-head-expense {
  display: grid;
  grid-template-columns: minmax(150px, 1.3fr) minmax(130px, 1fr) minmax(76px, .55fr) minmax(94px, .7fr) minmax(108px, .8fr) auto;
}

.purchase-line-head strong,
.multi-sale-head strong {
  color: var(--brand-black);
  font-size: 13px;
}

.purchase-line-rows,
.multi-sale-rows {
  display: grid;
  gap: 6px;
}

.multi-sale-row,
.purchase-line-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.3fr) minmax(130px, 1fr) minmax(76px, .55fr) minmax(94px, .7fr) minmax(108px, .8fr) auto;
  gap: 6px;
  align-items: end;
}

.purchase-line-row-expense {
  grid-template-columns: minmax(150px, 1.3fr) minmax(130px, 1fr) minmax(76px, .55fr) minmax(94px, .7fr) minmax(108px, .8fr) auto;
}

.multi-sale-row label,
.purchase-line-row label {
  min-width: 0;
  gap: 4px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 800;
}

.multi-sale-row input,
.multi-sale-row select,
.purchase-line-row input,
.purchase-line-row select {
  min-height: 28px;
  width: 100%;
  border-radius: 5px;
  padding: 4px 7px;
  font-size: 12px;
}

.multi-sale-actions {
  display: flex;
  gap: 5px;
  align-items: center;
  justify-content: flex-end;
  min-height: 28px;
}

.multi-sale-actions .mini-button {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 5px;
}

.purchase-line-total,
.multi-sale-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 7px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand-red);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}

.purchase-line-total strong,
.multi-sale-total strong {
  color: var(--brand-black);
  font-size: 14px;
  font-weight: 900;
}

.sales-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}

.sales-transactions-table {
  min-width: 1120px;
}

.purchase-expense-modal-card {
  width: min(460px, calc(100vw - 24px));
}

.compact-modal-form {
  gap: 10px;
}

.compact-modal-form input,
.compact-modal-form select {
  min-height: 34px;
  border-radius: 6px;
  font-size: 13px;
}

.kpi-currency-lines {
  display: block;
  font-size: 15px;
  line-height: 1.45;
  font-weight: 800;
}

.dashboard-cash-box {
  min-height: 108px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: grid;
  align-content: start;
  gap: 0;
  min-width: 0;
}

.dashboard-cash-box span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.15;
}

.dashboard-cash-box strong {
  color: var(--brand-black);
  display: block;
  margin-top: 8px;
  max-width: 100%;
  font-size: clamp(20px, 1.25vw, 24px);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  overflow-wrap: normal;
  word-break: normal;
  font-variant-numeric: tabular-nums;
}

.dashboard-profit-box small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
}

.dashboard-cash-total-usd {
  background: #e60000;
  border-color: #e60000;
  color: #ffffff;
  box-shadow: 0 12px 28px rgba(230, 0, 0, 0.2);
}

.dashboard-cash-total-usd span,
.dashboard-cash-total-usd strong {
  color: #ffffff;
}

.dashboard-cash-modal-card {
  max-width: 380px;
}

.sheet-subbar {
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 9px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
  color: var(--muted);
  font-size: 12px;
}

.sheet-subbar strong {
  color: var(--brand-black);
  font-size: 13px;
}

.sheet-table {
  min-width: 0;
  border-collapse: collapse;
}

.sheet-table th,
.sheet-table td {
  height: 34px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.25;
}

.sheet-table th {
  position: static;
  border-top: 0;
  background: #F3F4F6;
  color: var(--brand-black);
  font-size: 11px;
}

.sheet-table th span {
  display: none;
}

.sheet-table .row-action {
  width: 28px;
  height: 28px;
  border-radius: 5px;
}

.sheet-table .row-action svg {
  width: 14px;
  height: 14px;
}

.customer-main-table,
.customer-ledger-table,
.supplier-main-table,
.supplier-ledger-table {
  width: 100%;
}

.supplier-main-table th:nth-child(1) { width: 20%; }
.supplier-main-table th:nth-child(2) { width: 10%; }
.supplier-main-table th:nth-child(3) { width: 11%; }
.supplier-main-table th:nth-child(4),
.supplier-main-table th:nth-child(5),
.supplier-main-table th:nth-child(6),
.supplier-main-table th:nth-child(7) { width: 10%; }
.supplier-main-table th:nth-child(8) { width: 9%; }
.supplier-main-table th:nth-child(9) { width: 10%; }

.supplier-ledger-table th:nth-child(1) { width: 9%; }
.supplier-ledger-table th:nth-child(2) { width: 8%; }
.supplier-ledger-table th:nth-child(3) { width: 23%; }
.supplier-ledger-table th:nth-child(4),
.supplier-ledger-table th:nth-child(5),
.supplier-ledger-table th:nth-child(6),
.supplier-ledger-table th:nth-child(7),
.supplier-ledger-table th:nth-child(8) { width: 10%; }
.supplier-ledger-table th:nth-child(9) { width: 6%; }
.supplier-ledger-table th:nth-child(10) { width: 6%; }

.customer-main-table th:nth-child(1) { width: 28%; }
.customer-main-table th:nth-child(2) { width: 16%; }
.customer-main-table th:nth-child(3) { width: 28%; }
.customer-main-table th:nth-child(4) { width: 12%; }
.customer-main-table th:nth-child(5) { width: 16%; }

.customer-ledger-table th:nth-child(1) { width: 11%; }
.customer-ledger-table th:nth-child(2) { width: 10%; }
.customer-ledger-table th:nth-child(3) { width: 27%; }
.customer-ledger-table th:nth-child(4),
.customer-ledger-table th:nth-child(5),
.customer-ledger-table th:nth-child(6) { width: 12%; }
.customer-ledger-table th:nth-child(7) { width: 8%; }
.customer-ledger-table th:nth-child(8) { width: 8%; }

.customer-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  max-height: min(430px, calc(100vh - 315px));
  overflow-y: auto;
  overflow-x: auto;
  overscroll-behavior: contain;
}

.customer-ledger-table-wrap {
  max-height: min(420px, calc(100vh - 330px));
}

body[data-active-view="customer-sheet"] .customer-table-wrap,
body[data-active-view="customer-detail"] .customer-ledger-table-wrap,
body[data-active-view="people"] .supplier-table-wrap,
body[data-active-view="supplier-detail"] .supplier-ledger-table-wrap {
  max-height: none;
}

.customer-table-wrap .sheet-table th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: #F3F4F6;
}

.sheet-summary {
  width: min(420px, 100%);
  margin: 8px 10px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #ffffff;
  flex: 0 0 auto;
}

.ledger-summary {
  margin-top: 10px;
}

.sheet-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 9px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
  color: var(--muted);
  font-size: 12px;
}

.sheet-summary-head strong {
  color: var(--brand-black);
}

.sheet-summary .table-wrap {
  max-height: 150px;
  overflow: auto;
}

.sheet-summary-table {
  min-width: 0 !important;
}

.sheet-summary-table th,
.sheet-summary-table td {
  height: 24px;
  padding: 3px 8px;
  font-size: 11px;
}

.ledger-info-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 0;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.ledger-info-row .kpi {
  min-height: 0;
  padding: 8px 10px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
}

.ledger-info-row .kpi:last-child {
  border-right: 0;
}

.ledger-info-row .kpi span {
  font-size: 11px;
}

.ledger-info-row .kpi strong {
  margin-top: 4px;
  font-size: 14px;
}

.ledger-info-row .kpi small {
  margin-top: 2px;
  font-size: 11px;
}

.compact-filter-row {
  padding: 6px 9px;
  border-bottom: 1px solid var(--line);
  gap: 8px;
  align-items: end;
}

.compact-filter-row label {
  min-width: 150px;
  max-width: 190px;
  gap: 4px;
  font-size: 11px;
}

.compact-filter-row input {
  min-height: 30px;
  padding: 4px 8px;
  border-radius: 5px;
}

.ledger-entry-form {
  display: grid;
  grid-template-columns: minmax(150px, 1.2fr) minmax(120px, 0.8fr) minmax(92px, 0.55fr) minmax(130px, 0.75fr) minmax(110px, 0.65fr) minmax(180px, 1.4fr) auto;
  gap: 8px;
  align-items: end;
  padding: 6px 9px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.ledger-entry-form label {
  min-width: 0;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
}

.ledger-entry-form input,
.ledger-entry-form select {
  min-height: 30px;
  padding: 4px 8px;
  border-radius: 5px;
}

.ledger-actions {
  flex-wrap: nowrap;
  gap: 6px;
}

.ledger-actions .primary-button,
.ledger-actions .secondary-button {
  flex: 0 0 auto;
}

.total-row td {
  background: #fff0f0;
  color: var(--brand-black);
  font-weight: 800;
}

.action-buttons {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.link-cell {
  width: auto;
  height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--brand-red);
  font-weight: 800;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-cell:hover {
  color: var(--brand-black);
  background: transparent;
}

.attachment-link {
  color: var(--brand-red);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
  word-break: break-word;
}

.attachment-link:hover {
  color: var(--brand-black);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  padding: 16px;
}

.row-action {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  background: #ffffff;
  color: #41515e;
}

.row-action:hover {
  background: var(--accent-soft);
  color: var(--brand-red);
}

.row-action.print-action {
  color: var(--brand-black);
  border-color: var(--brand-border);
}

.row-action.print-action:hover {
  background: #fff5f5;
  border-color: var(--brand-red);
  color: var(--brand-red);
}

.row-action.danger {
  color: var(--red);
}

.row-action svg {
  width: 16px;
  height: 16px;
}

.amount {
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.text-danger {
  color: var(--brand-red) !important;
  font-weight: 800;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--brand-black);
  font-size: 12px;
  font-weight: 700;
}

.tag.good {
  background: #dcfae6;
  color: var(--green);
}

.tag.warn {
  background: #fef0c7;
  color: var(--brand-red);
}

.tag.bad {
  background: #fee4e2;
  color: var(--red);
}

.primary-button,
.icon-button:hover,
.row-action.danger,
.dashboard-cash-total-usd,
.tag.red,
.tag.danger,
.badge-red,
.bg-red,
.btn-red,
.active-red,
.red-card,
.red-header,
[class*="red-card"],
[class*="red-header"],
[style*="background: #e60000"],
[style*="background:#e60000"],
[style*="background: var(--brand-red)"],
[style*="background:var(--brand-red)"] {
  color: #ffffff !important;
}

.primary-button *,
.icon-button:hover *,
.row-action.danger *,
.dashboard-cash-total-usd *,
.tag.red *,
.tag.danger *,
.badge-red *,
.bg-red *,
.btn-red *,
.active-red *,
.red-card *,
.red-header *,
[class*="red-card"] *,
[class*="red-header"] *,
[style*="background: #e60000"] *,
[style*="background:#e60000"] *,
[style*="background: var(--brand-red)"] *,
[style*="background:var(--brand-red)"] * {
  color: #ffffff !important;
  stroke: #ffffff !important;
}

@media print {
  .sidebar,
  .navbar,
  .topbar,
  .actions,
  .btn,
  button,
  .row-action,
  .mini-button,
  .primary-button,
  .secondary-button,
  .button-row,
  .panel-actions,
  .mobile-menu-toggle,
  .mobile-sidebar,
  .mobile-sidebar-overlay,
  .no-print {
    display: none !important;
  }

  body {
    background: #ffffff !important;
    color: #111111 !important;
    font-family: "DejaVu Sans", "Noto Sans Arabic", Arial, sans-serif;
  }

  .print-container {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
  }

  table {
    width: 100%;
    border-collapse: collapse;
  }

  th,
  td {
    border: 1px solid #D9E1E6;
    padding: 7px;
    font-size: 11px;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: anywhere;
  }

  th {
    background: #E60000 !important;
    color: #ffffff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  @page {
    size: A4;
    margin: 12mm;
  }
}

.simple-summary {
  background: var(--brand-bg);
  border: 1px solid var(--brand-border);
  border-radius: 8px;
  color: var(--brand-text);
  line-height: 1.8;
  padding: 10px 12px;
}

.simple-summary strong {
  color: var(--brand-black);
}

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

.report-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.report-toolbar h2 {
  margin: 0;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.segment {
  min-width: 92px;
  padding: 9px 12px;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  flex-direction: column;
  gap: 1px;
  line-height: 1.1;
  font-weight: 700;
}

.segment span {
  font-size: 11px;
  opacity: 0.82;
}

.segment + .segment {
  border-left: 1px solid var(--line);
}

.segment.active {
  background: var(--accent);
  color: #ffffff;
}

.schema-grid,
.partner-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 16px;
}

.schema-item,
.partner-item {
  min-height: 58px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.schema-item strong,
.partner-item strong {
  display: block;
  font-size: 14px;
}

.schema-item span,
.partner-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.schema-item .dari {
  margin-top: 8px;
  color: var(--brand-red);
  direction: rtl;
  text-align: left;
  line-height: 1.6;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 44px));
  min-height: 42px;
  display: none;
  align-items: center;
  padding: 11px 14px;
  border-radius: 8px;
  background: var(--brand-black);
  color: #ffffff;
  box-shadow: var(--shadow);
  transform: translateY(10px);
  opacity: 0;
}

.toast.show {
  display: flex;
  animation: toastWorked 0.28s ease-out forwards;
}

.toast.success {
  border-left: 5px solid var(--brand-red);
}

button.is-loading {
  cursor: wait;
  opacity: 0.78;
}

button.is-loading svg {
  animation: spinOnce 0.8s linear infinite;
}

.panel.worked {
  animation: workedPulse 0.85s ease-out;
}

@keyframes spinOnce {
  to {
    transform: rotate(360deg);
  }
}

@keyframes toastWorked {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes workedPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(230, 0, 0, 0.34), var(--shadow);
    transform: translateY(0);
  }
  45% {
    box-shadow: 0 0 0 6px rgba(230, 0, 0, 0.11), 0 16px 38px rgba(17, 17, 17, 0.14);
    transform: translateY(-1px);
  }
  100% {
    box-shadow: var(--shadow);
    transform: translateY(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;
}

@media (min-width: 1181px) {
  .kpi-grid,
  .compact-kpis,
  .dashboard-cash-box-grid {
    grid-template-columns: repeat(6, minmax(160px, 1fr));
  }

  #view-dashboard #dashboardKpis {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  #view-dashboard #dashboardCashBoxes {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1350px) {
  .kpi-grid,
  .compact-kpis,
  .dashboard-cash-box-grid {
    grid-template-columns: repeat(5, minmax(170px, 1fr));
  }

  #view-dashboard #dashboardKpis {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  #view-dashboard #dashboardCashBoxes {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  .kpi-grid,
  .compact-kpis,
  .dashboard-cash-box-grid {
    grid-template-columns: repeat(4, minmax(180px, 1fr));
  }

  #view-dashboard #dashboardKpis,
  #view-dashboard #dashboardCashBoxes {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .kpi strong,
  .dashboard-cash-box strong {
    font-size: clamp(22px, 1.45vw, 25px);
  }

  .detail-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .split-grid,
  .section-grid,
  #view-sales .section-grid,
  .two-forms {
    grid-template-columns: 1fr;
  }

  .purchase-sheet-controls,
  .sales-sheet-controls {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .purchase-page-controls,
  .popup-entry-form {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .multi-sale-row,
  .purchase-line-row {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

  .multi-sale-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 1150px) {
  .kpi-grid,
  .compact-kpis,
  .dashboard-cash-box-grid {
    grid-template-columns: repeat(4, minmax(180px, 1fr));
  }

  #view-dashboard #dashboardKpis,
  #view-dashboard #dashboardCashBoxes {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .kpi strong,
  .dashboard-cash-box strong {
    font-size: clamp(22px, 2vw, 25px);
  }
}

@media (max-width: 767px) {
  body.mobile-menu-open {
    overflow: hidden;
  }

  body:not(.locked) .mobile-menu-toggle {
    display: inline-grid;
    place-items: center;
  }

  body:not(.locked) .mobile-sidebar,
  body:not(.locked) .mobile-sidebar-overlay {
    display: block;
  }

  .sidebar {
    display: none;
  }

  .app-shell {
    width: 100%;
    max-width: 100vw;
    margin-left: 0;
    padding: 72px 12px 16px;
  }

  body[data-active-view="customer-sheet"] .app-shell,
  body[data-active-view="customer-detail"] .app-shell,
  body[data-active-view="people"] .app-shell,
  body[data-active-view="purchases"] .app-shell,
  body[data-active-view="sales"] .app-shell,
  body[data-active-view="supplier-detail"] .app-shell {
    height: auto;
    min-height: 100vh;
    overflow: visible;
    padding: 72px 12px 16px;
  }

  body[data-active-view="customer-sheet"] #view-customer-sheet,
  body[data-active-view="customer-detail"] #view-customer-detail,
  body[data-active-view="people"] #view-people,
  body[data-active-view="purchases"] #view-purchases,
  body[data-active-view="sales"] #view-sales,
  body[data-active-view="supplier-detail"] #view-supplier-detail {
    height: auto;
    overflow: visible;
  }

  .customer-sheet-panel,
  .customer-ledger-panel,
  .supplier-sheet-panel,
  .supplier-ledger-panel {
    height: auto;
  }

  .topbar,
  .report-toolbar,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    gap: 12px;
  }

  .topbar h1 {
    font-size: 22px;
    line-height: 1.18;
  }

  .topbar p {
    font-size: 13px;
  }

  .purchase-sheet-controls,
  .sales-sheet-controls,
  .purchase-page-controls,
  .popup-entry-form,
  .multi-sale-row,
  .purchase-line-row {
    grid-template-columns: 1fr;
  }

  .sheet-toolbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .entry-modal-card {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
  }

  .popup-entry-form {
    max-height: calc(100vh - 74px);
    padding: 8px;
  }

  .popup-entry-actions {
    flex-direction: column;
  }

  .purchase-line-items,
  .multi-sale-fields {
    padding: 8px 6px;
  }

  .purchase-line-total,
  .multi-sale-total {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .topbar-actions,
  .panel-actions,
  .report-actions,
  .filter-row,
  .form-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .topbar-actions > *,
  .panel-actions > *,
  .filter-row > *,
  .form-actions > * {
    max-width: 100%;
  }

  .link-button,
  .primary-button,
  .secondary-button,
  .mini-button {
    min-height: 42px;
    white-space: normal;
  }

  .kpi-grid,
  .compact-kpis,
  .dashboard-cash-box-grid,
  .detail-grid,
  .schema-grid,
  .partner-grid {
    grid-template-columns: 1fr;
  }

  .multi-sale-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: stretch;
  }

  .multi-sale-row label:first-child {
    grid-column: 1 / -1;
  }

  .multi-sale-actions {
    align-self: end;
  }

  .multi-sale-header {
    display: none;
  }

  .multi-sale-actions {
    justify-content: flex-end;
  }

  .panel,
  .report-toolbar {
    padding: 14px;
  }

  .customer-sheet-panel,
  .customer-ledger-panel,
  .supplier-sheet-panel,
  .supplier-ledger-panel {
    padding: 0;
  }

  .customer-sheet-toolbar,
  .customer-ledger-toolbar,
  .supplier-sheet-toolbar,
  .supplier-ledger-toolbar {
    align-items: stretch;
    gap: 8px;
  }

  .customer-sheet-toolbar h2,
  .customer-ledger-toolbar h2,
  .supplier-sheet-toolbar h2,
  .supplier-ledger-toolbar h2 {
    min-width: 0;
  }

  .customer-sheet-toolbar .panel-actions,
  .customer-ledger-toolbar .panel-actions,
  .supplier-sheet-toolbar .panel-actions,
  .supplier-ledger-toolbar .panel-actions {
    width: 100%;
  }

  .customer-sheet-toolbar .inline-search,
  .supplier-sheet-toolbar .inline-search {
    width: 100%;
  }

  .sheet-subbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .stock-toolbar {
    align-items: stretch;
  }

  .stock-toolbar h2 {
    min-width: 0;
  }

  .stock-toolbar .panel-actions {
    width: 100%;
  }

  .stock-toolbar .inline-search,
  .stock-toolbar select,
  .stock-toolbar label {
    width: 100%;
  }

  .purchase-invoice-layout {
    grid-template-columns: 1fr;
  }

  .purchase-sheet-panel {
    min-height: auto;
  }

  .purchase-sheet-toolbar {
    align-items: stretch;
    gap: 8px;
  }

  .purchase-sheet-toolbar h2 {
    min-width: 0;
  }

  .purchase-sheet-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .purchase-sheet-controls .inline-search,
  .purchase-sheet-controls .primary-button,
  .purchase-sheet-controls .secondary-button,
  .purchase-sheet-controls .mini-button {
    width: 100%;
  }

  .purchase-invoice-summary dl {
    grid-template-columns: 1fr;
  }

  .kpi strong,
  .dashboard-cash-box strong {
    font-size: clamp(20px, 6vw, 24px);
  }

  .ledger-info-row {
    grid-template-columns: 1fr 1fr;
  }

  .ledger-info-row .kpi:nth-child(2n) {
    border-right: 0;
  }

  .ledger-info-row .kpi {
    border-bottom: 1px solid var(--line);
  }

  .compact-filter-row {
    align-items: stretch;
  }

  .compact-filter-row label {
    flex: 1 1 140px;
    min-width: 0;
    max-width: none;
  }

  .ledger-entry-form {
    grid-template-columns: 1fr 1fr;
  }

  .ledger-entry-form label:first-child,
  .ledger-entry-form label:nth-child(6),
  .ledger-actions {
    grid-column: 1 / -1;
  }

  .ledger-actions {
    justify-content: flex-start;
  }

  .sheet-summary {
    width: auto;
    margin: 8px;
  }

  .customer-main-table,
  .customer-ledger-table,
  .supplier-main-table,
  .supplier-ledger-table {
    min-width: 0;
  }

  .customer-main-table thead,
  .customer-ledger-table thead,
  .supplier-main-table thead,
  .supplier-ledger-table thead {
    display: none;
  }

  .customer-main-table,
  .customer-main-table tbody,
  .customer-main-table tr,
  .customer-main-table td,
  .customer-ledger-table,
  .customer-ledger-table tbody,
  .customer-ledger-table tr,
  .customer-ledger-table td,
  .supplier-main-table,
  .supplier-main-table tbody,
  .supplier-main-table tr,
  .supplier-main-table td,
  .supplier-ledger-table,
  .supplier-ledger-table tbody,
  .supplier-ledger-table tr,
  .supplier-ledger-table td {
    display: block;
    width: 100%;
  }

  .customer-main-table tr,
  .customer-ledger-table tr,
  .supplier-main-table tr,
  .supplier-ledger-table tr {
    margin: 8px;
    width: calc(100% - 16px);
    border: 1px solid var(--line);
    border-left: 3px solid var(--brand-red);
    background: #ffffff;
  }

  .customer-main-table td,
  .customer-ledger-table td,
  .supplier-main-table td,
  .supplier-ledger-table td {
    min-height: 30px;
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 8px;
    padding: 6px 8px;
    border: 0;
    border-bottom: 1px solid var(--line);
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .customer-main-table td:last-child,
  .customer-ledger-table td:last-child,
  .supplier-main-table td:last-child,
  .supplier-ledger-table td:last-child {
    border-bottom: 0;
  }

  .customer-main-table td::before,
  .customer-ledger-table td::before,
  .supplier-main-table td::before,
  .supplier-ledger-table td::before {
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
  }

  .customer-main-table td:nth-child(1)::before { content: "Customer"; }
  .customer-main-table td:nth-child(2)::before { content: "Phone"; }
  .customer-main-table td:nth-child(3)::before { content: "Address"; }
  .customer-main-table td:nth-child(4)::before { content: "User"; }
  .customer-main-table td:nth-child(5)::before { content: "Download"; }

  .customer-ledger-table td:nth-child(1)::before { content: "Date"; }
  .customer-ledger-table td:nth-child(2)::before { content: "Type"; }
  .customer-ledger-table td:nth-child(3)::before { content: "Details"; }
  .customer-ledger-table td:nth-child(4)::before { content: "Sales / Paid"; }
  .customer-ledger-table td:nth-child(5)::before { content: "Received"; }
  .customer-ledger-table td:nth-child(6)::before { content: "Balance"; }
  .customer-ledger-table td:nth-child(7)::before { content: "Currency"; }
  .customer-ledger-table td:nth-child(8)::before { content: "Action"; }

  .supplier-main-table td:nth-child(1)::before { content: "Supplier"; }
  .supplier-main-table td:nth-child(2)::before { content: "Phone"; }
  .supplier-main-table td:nth-child(3)::before { content: "Country"; }
  .supplier-main-table td:nth-child(4)::before { content: "Purchases"; }
  .supplier-main-table td:nth-child(5)::before { content: "Expense"; }
  .supplier-main-table td:nth-child(6)::before { content: "Paid"; }
  .supplier-main-table td:nth-child(7)::before { content: "Balance"; }
  .supplier-main-table td:nth-child(8)::before { content: "User"; }
  .supplier-main-table td:nth-child(9)::before { content: "Download"; }

  .supplier-ledger-table td:nth-child(1)::before { content: "Date"; }
  .supplier-ledger-table td:nth-child(2)::before { content: "Type"; }
  .supplier-ledger-table td:nth-child(3)::before { content: "Details"; }
  .supplier-ledger-table td:nth-child(4)::before { content: "Purchased"; }
  .supplier-ledger-table td:nth-child(5)::before { content: "Expense"; }
  .supplier-ledger-table td:nth-child(6)::before { content: "Paid"; }
  .supplier-ledger-table td:nth-child(7)::before { content: "Received"; }
  .supplier-ledger-table td:nth-child(8)::before { content: "Balance"; }
  .supplier-ledger-table td:nth-child(9)::before { content: "Currency"; }
  .supplier-ledger-table td:nth-child(10)::before { content: "Action"; }

  .customer-main-table .amount,
  .customer-ledger-table .amount,
  .supplier-main-table .amount,
  .supplier-ledger-table .amount {
    text-align: left;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .section-grid,
  #view-sales .section-grid,
  .split-grid,
  .two-forms {
    grid-template-columns: minmax(0, 1fr);
  }

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

  table {
    min-width: 680px;
  }

  #view-dashboard table {
    min-width: 560px;
  }

  .segmented {
    width: 100%;
    overflow-x: auto;
  }

  .segment {
    flex: 1;
    min-width: 112px;
  }
}

/* Spinghar final branding fixes: white text/icons on every red UI surface */
.primary-button,
.primary-button *,
.nav-button.active,
.nav-button.active *,
.mobile-menu-link.active,
.mobile-menu-link.active *,
.red-card,
.red-card *,
.cash-total,
.cash-total *,
.bg-red,
.bg-red *,
.btn-red,
.btn-red *,
.red-header,
.red-header *,
.sheet-table thead th,
.sheet-table thead th *,
.invoice-table thead th,
.invoice-table thead th *,
.tag.danger,
.tag.danger *,
.badge.danger,
.badge.danger * {
  color: #fff !important;
  fill: none;
  stroke: #fff !important;
}

.primary-button svg,
.nav-button.active svg,
.mobile-menu-link.active svg,
.red-card svg,
.cash-total svg,
.bg-red svg,
.btn-red svg,
.red-header svg {
  color: #fff !important;
  stroke: #fff !important;
}

/* Keep red buttons readable during hover/focus states */
.primary-button:hover,
.primary-button:focus-visible,
.btn-red:hover,
.btn-red:focus-visible {
  color: #fff !important;
}

/* Customer action buttons in main customer sheet */
#customerSheetRows .action-buttons {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

/* Final table/readability and action icon fixes */
.table-wrap,
.table-wrapper,
.panel table {
  overflow-x: auto;
}

table th,
.sheet-table th,
.data-table th,
.partner-accounts-table th,
.investment-table th {
  color: #000000 !important;
  font-weight: 800 !important;
}

table td,
.sheet-table td,
.data-table td,
.partner-accounts-table td,
.investment-table td {
  color: #111111 !important;
}

/* Keep readable white text only on red/dark backgrounds */
table th[style*="background: var(--brand-red)"],
table th[style*="background:#e60000"],
table th[style*="background: #e60000"],
.red-header th,
.bg-red th,
.btn-red,
.btn-red *,
.primary-button,
.primary-button *,
.active-red,
.active-red *,
.red-card,
.red-card *,
.dashboard-cash-total-usd,
.dashboard-cash-total-usd * {
  color: #ffffff !important;
  stroke: #ffffff !important;
}

/* Actions column must have enough room and never hide icons */
th:last-child,
td:last-child,
th.actions,
td.actions {
  min-width: 150px;
  white-space: nowrap;
}

td:last-child .action-buttons,
td.actions .action-buttons,
.action-buttons {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 6px !important;
  flex-wrap: nowrap !important;
}

.row-action,
.action-btn {
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  min-height: 34px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border: 1px solid #d9e1ea !important;
  border-radius: 8px !important;
  background: #ffffff !important;
  color: #111111 !important;
  overflow: visible !important;
}

.row-action:hover,
.action-btn:hover {
  background: #fff5f5 !important;
  border-color: var(--brand-red) !important;
  color: var(--brand-red) !important;
}

.row-action.danger,
.action-btn.danger,
.row-action.delete,
.action-btn.delete {
  color: var(--brand-red) !important;
  background: #ffffff !important;
}

.row-action svg,
.row-action i,
.action-btn svg,
.action-btn i {
  width: 16px !important;
  height: 16px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  color: currentColor !important;
  stroke: currentColor !important;
  fill: none;
}

/* Safe icon fallback if Lucide CDN does not load or icons are not hydrated */
i[data-lucide]::before {
  display: inline-block;
  font-style: normal;
  font-size: 15px;
  line-height: 1;
  color: currentColor;
}

i[data-lucide="eye"]::before { content: "👁"; }
i[data-lucide="pencil"]::before { content: "✎"; }
i[data-lucide="trash-2"]::before { content: "🗑"; }
i[data-lucide="printer"]::before { content: "⎙"; }
i[data-lucide="file-down"]::before { content: "⇩"; }
i[data-lucide="plus"]::before { content: "+"; }
i[data-lucide="x"]::before { content: "×"; }

@media (max-width: 900px) {
  #saleForm.sales-sheet-controls.popup-entry-form {
    grid-template-columns: 1fr;
  }

  th:last-child,
  td:last-child,
  th.actions,
  td.actions {
    min-width: 140px;
  }

  .row-action,
  .action-btn {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
  }
}


/* FINAL FIX: table header readability and action icon reliability */
.table-wrap table th,
.compact-table table th,
.sheet-table th,
.stock-table th,
.purchase-transactions-table th,
.sales-transactions-table th,
.customer-main-table th,
.customer-ledger-table th,
.supplier-main-table th,
.supplier-ledger-table th,
.investment-table th,
.partner-table th,
table thead th,
table th {
  color: #0f172a !important;
  -webkit-text-fill-color: #0f172a !important;
  font-weight: 800 !important;
  opacity: 1 !important;
  text-shadow: none !important;
}

/* Keep white text only when the real table header background is red/dark */
table th.red-header,
table th.bg-red,
table thead.red-header th,
table thead.bg-red th,
table.table-red th,
table.table-dark th,
.red-table th,
.dark-table th {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}

/* Robust action button/icon rendering in all table action columns */
.action-buttons,
td:last-child .action-buttons,
td.actions .action-buttons {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 7px !important;
  flex-wrap: nowrap !important;
  min-width: max-content !important;
}

.row-action,
.action-btn,
button.row-action {
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  min-height: 34px !important;
  max-width: 34px !important;
  max-height: 34px !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border: 1px solid #d8e0ea !important;
  border-radius: 8px !important;
  background: #ffffff !important;
  color: #111827 !important;
  -webkit-text-fill-color: currentColor !important;
  line-height: 1 !important;
  vertical-align: middle !important;
  overflow: visible !important;
  opacity: 1 !important;
}

.row-action.danger,
.action-btn.danger,
button.row-action.danger {
  color: #e60000 !important;
  -webkit-text-fill-color: #e60000 !important;
}

.row-action svg,
.action-btn svg,
button.row-action svg,
.row-action i,
.action-btn i,
button.row-action i {
  width: 17px !important;
  height: 17px !important;
  min-width: 17px !important;
  min-height: 17px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  color: currentColor !important;
  stroke: currentColor !important;
  fill: none !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* If Lucide JS/CDN fails, show a simple built-in icon instead of empty squares */
.row-action i[data-lucide]::before,
.action-btn i[data-lucide]::before,
button.row-action i[data-lucide]::before {
  content: "•";
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 17px;
  height: 17px;
  color: currentColor !important;
  -webkit-text-fill-color: currentColor !important;
  font-family: Arial, sans-serif !important;
  font-style: normal !important;
  font-weight: 800 !important;
  font-size: 15px !important;
  line-height: 1 !important;
}
.row-action i[data-lucide="eye"]::before { content: "◉"; }
.row-action i[data-lucide="pencil"]::before { content: "✎"; }
.row-action i[data-lucide="trash-2"]::before { content: "×"; }
.row-action i[data-lucide="printer"]::before { content: "⎙"; }
.row-action i[data-lucide="file-down"]::before { content: "⇩"; }
.row-action i[data-lucide="plus"]::before { content: "+"; }
.row-action i[data-lucide="x"]::before { content: "×"; }

.table-wrap,
.sheet-table-wrap,
.stock-table-wrap,
.sales-table-wrap,
.purchase-table-wrap,
.sales-transactions-table-wrap,
.purchase-transactions-table-wrap {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
}

th:last-child,
td:last-child,
th.actions,
td.actions {
  min-width: 150px !important;
  width: 150px;
  white-space: nowrap !important;
}

@media (max-width: 768px) {
  th:last-child,
  td:last-child,
  th.actions,
  td.actions {
    min-width: 132px !important;
    width: 132px;
  }
  .row-action,
  .action-btn,
  button.row-action {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
  }
}

/* FINAL UI FIX: readable light tables and reliable action icons */
table thead th,
.data-table thead th,
.table thead th,
.transactions-table thead th,
.ledger-table thead th,
.sheet-table thead th,
.purchase-transactions-table thead th,
.sales-transactions-table thead th,
.customer-main-table thead th,
.customer-ledger-table thead th,
.supplier-main-table thead th,
.supplier-ledger-table thead th,
.partner-accounts-table thead th,
.investment-table thead th {
  color: #000 !important;
  -webkit-text-fill-color: #000 !important;
  font-weight: 700 !important;
  opacity: 1 !important;
  text-shadow: none !important;
}

table tbody td,
.data-table tbody td,
.table tbody td,
.transactions-table tbody td,
.ledger-table tbody td,
.sheet-table tbody td,
.purchase-transactions-table tbody td,
.sales-transactions-table tbody td,
.customer-main-table tbody td,
.customer-ledger-table tbody td,
.supplier-main-table tbody td,
.supplier-ledger-table tbody td,
.partner-accounts-table tbody td,
.investment-table tbody td {
  color: #111 !important;
  -webkit-text-fill-color: #111 !important;
  opacity: 1 !important;
}

table thead.red-header th,
table thead.bg-red th,
table thead.dark-header th,
table.table-red thead th,
table.table-dark thead th,
.red-table thead th,
.dark-table thead th,
.red-header table thead th,
.bg-red table thead th,
.dark-header table thead th {
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
}

.action-buttons,
.actions-cell {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 6px !important;
  flex-wrap: nowrap !important;
  min-width: max-content !important;
}

.row-action:not(.text-row-action),
.action-btn {
  width: 32px !important;
  height: 32px !important;
  min-width: 32px !important;
  min-height: 32px !important;
  max-width: 32px !important;
  max-height: 32px !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border: 1px solid #d9e1ea !important;
  border-radius: 8px !important;
  background: #fff !important;
  color: #111 !important;
  -webkit-text-fill-color: currentColor !important;
  line-height: 1 !important;
  opacity: 1 !important;
  overflow: visible !important;
}

.row-action.text-row-action {
  width: auto !important;
  max-width: none !important;
  padding: 0 10px !important;
}

.row-action.delete,
.row-action.danger,
.action-btn.delete,
.action-btn.danger {
  color: #e60000 !important;
  -webkit-text-fill-color: #e60000 !important;
}

body .row-action.delete svg,
body .row-action.delete svg *,
body .row-action.danger svg,
body .row-action.danger svg *,
body .action-btn.delete svg,
body .action-btn.delete svg *,
body .action-btn.danger svg,
body .action-btn.danger svg * {
  color: #e60000 !important;
  stroke: #e60000 !important;
  fill: none !important;
  -webkit-text-fill-color: #e60000 !important;
}

.row-action svg,
.row-action i,
.action-btn svg,
.action-btn i {
  width: 16px !important;
  height: 16px !important;
  min-width: 16px !important;
  min-height: 16px !important;
  display: block !important;
  color: currentColor !important;
  stroke: currentColor !important;
  fill: none !important;
  stroke-width: 2 !important;
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.row-action i[data-lucide]::before,
.action-btn i[data-lucide]::before {
  content: none !important;
}

.action-icon-label {
  display: inline-block;
  max-width: 28px;
  overflow: hidden;
  color: currentColor !important;
  -webkit-text-fill-color: currentColor !important;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
}

th.actions,
td.actions,
.actions-column,
th:last-child,
td:last-child {
  min-width: 150px !important;
  width: 150px !important;
  white-space: nowrap !important;
}

.table-wrapper,
.table-responsive,
.table-wrap,
.sheet-table-wrap {
  overflow-x: auto !important;
  width: 100% !important;
  -webkit-overflow-scrolling: touch;
}

body .table-wrap table thead th,
body .compact-table table thead th,
body .panel table thead th,
body table.sheet-table thead th,
body table.data-table thead th,
body table.table thead th,
body table.transactions-table thead th,
body table.ledger-table thead th,
body table.purchase-transactions-table thead th,
body table.sales-transactions-table thead th,
body table.customer-main-table thead th,
body table.customer-ledger-table thead th,
body table.supplier-main-table thead th,
body table.supplier-ledger-table thead th,
body table.partner-accounts-table thead th,
body table.investment-table thead th,
body table thead th {
  color: #000 !important;
  -webkit-text-fill-color: #000 !important;
  font-weight: 700 !important;
  opacity: 1 !important;
}

body .table-wrap table tbody td,
body .compact-table table tbody td,
body .panel table tbody td,
body table.sheet-table tbody td,
body table.data-table tbody td,
body table.table tbody td,
body table.transactions-table tbody td,
body table.ledger-table tbody td,
body table.purchase-transactions-table tbody td,
body table.sales-transactions-table tbody td,
body table.customer-main-table tbody td,
body table.customer-ledger-table tbody td,
body table.supplier-main-table tbody td,
body table.supplier-ledger-table tbody td,
body table.partner-accounts-table tbody td,
body table.investment-table tbody td,
body table tbody td {
  color: #111 !important;
  -webkit-text-fill-color: #111 !important;
  opacity: 1 !important;
}

body table thead.red-header th,
body table thead.bg-red th,
body table thead.dark-header th,
body table.table-red thead th,
body table.table-dark thead th,
body .red-table thead th,
body .dark-table thead th,
body .red-header table thead th,
body .bg-red table thead th,
body .dark-header table thead th {
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
}

body[data-active-view="transactions"] .roz-namcha-panel .panel-head {
  align-items: flex-start;
  gap: 14px;
}

body[data-active-view="transactions"] .roz-namcha-panel .panel-actions {
  align-items: center;
  gap: 8px;
}

body[data-active-view="transactions"] #openDailyCashModalButton {
  min-height: 38px;
}

body[data-active-view="transactions"] .kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

body[data-active-view="transactions"] .kpi strong {
  font-size: 18px;
  line-height: 1.25;
  white-space: normal;
  overflow: visible;
  overflow-wrap: anywhere;
}

body[data-active-view="transactions"] #dailyCashDetailPanel,
body[data-active-view="transactions"] .roz-namcha-table-panel,
body[data-active-view="transactions"] .roz-namcha-panel > .panel:not(.hidden-modal-source) {
  border-color: #d9e1e7;
}

body[data-active-view="transactions"] #dailyCashRows td,
body[data-active-view="transactions"] #transactionRows td {
  vertical-align: middle;
}

body[data-active-view="transactions"] #dailyCashRows tr:hover,
body[data-active-view="transactions"] #transactionRows tr:hover {
  background: #f6fafb;
}

@media (max-width: 760px) {
  body[data-active-view="transactions"] .roz-namcha-panel .panel-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  body[data-active-view="transactions"] .roz-namcha-panel .panel-actions .inline-search,
  body[data-active-view="transactions"] .roz-namcha-panel .panel-actions #transactionSummary {
    grid-column: 1 / -1;
  }

  body[data-active-view="transactions"] .roz-namcha-panel .panel-actions button,
  body[data-active-view="transactions"] .roz-namcha-panel .panel-actions label {
    width: 100%;
  }
}


/* === Dashboard compact redesign requested 2026-06 === */
@media (min-width: 901px) {
  .sidebar {
    width: 180px !important;
    min-width: 180px !important;
    padding: 14px 12px !important;
  }
  .app-shell {
    margin-left: 180px !important;
    padding: 18px 20px !important;
  }
  .brand-logo {
    width: 48px;
    height: 48px;
  }
  .brand strong {
    font-size: 15px;
    line-height: 1.1;
  }
  .brand span {
    font-size: 12px;
  }
  .nav-button {
    min-height: 42px;
    padding: 10px 12px;
    font-size: 14px;
  }
}

body:not([data-active-view="dashboard"]) .dashboard-top-filter {
  display: none !important;
}

body[data-active-view="dashboard"] .topbar {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto;
  align-items: start;
  gap: 14px;
  margin-bottom: 14px;
}

body[data-active-view="dashboard"] .topbar h1 {
  font-size: clamp(24px, 2.05vw, 30px);
  letter-spacing: -0.02em;
}

body[data-active-view="dashboard"] .topbar p {
  font-size: 13px;
  margin-top: 5px;
}

body[data-active-view="dashboard"] .topbar-actions {
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: nowrap;
  align-items: center;
}

.dashboard-top-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0;
}

.dashboard-top-filter label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  height: 38px;
  min-width: 0;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
}

.dashboard-top-filter input[type="date"] {
  min-height: 0;
  height: 34px;
  width: 122px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 12px;
  color: var(--ink);
  box-shadow: none;
}

.dashboard-top-filter svg,
.topbar-actions .status-pill svg,
.topbar-actions .link-button svg,
.icon-action-button svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.filter-separator {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.dashboard-date-chip {
  display: none;
}

.icon-action-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
}

.topbar-actions .status-pill,
.topbar-actions .link-button {
  min-height: 38px;
  height: 38px;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 13px;
  gap: 6px;
}

body[data-active-view="dashboard"] #view-dashboard {
  max-width: 1280px;
}

body[data-active-view="dashboard"] .dashboard-main-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(142px, 1fr));
  gap: 14px;
  align-items: stretch;
}

body[data-active-view="dashboard"] #dashboardKpis,
body[data-active-view="dashboard"] #dashboardCashBoxes {
  display: contents;
}

body[data-active-view="dashboard"] .kpi,
body[data-active-view="dashboard"] .dashboard-cash-box {
  min-height: 126px;
  margin: 0;
  padding: 17px 18px;
  border-radius: 9px;
  box-shadow: 0 10px 26px rgba(17, 17, 17, 0.06);
  background: #fff;
  border: 1px solid #e1e7ee;
}

body[data-active-view="dashboard"] .kpi span,
body[data-active-view="dashboard"] .dashboard-cash-box span {
  font-size: 13px;
  font-weight: 700;
  color: #526072;
}

body[data-active-view="dashboard"] .kpi strong,
body[data-active-view="dashboard"] .dashboard-cash-box strong {
  margin-top: 22px;
  font-size: clamp(20px, 1.45vw, 26px);
  font-weight: 600;
  line-height: 1.05;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}

body[data-active-view="dashboard"] .kpi small,
body[data-active-view="dashboard"] .dashboard-cash-box small {
  display: block;
  margin-top: 9px;
  color: #64748b;
  font-size: 12px;
  line-height: 1.25;
}

body[data-active-view="dashboard"] .dashboard-cash-box {
  cursor: pointer;
}

.dashboard-summary-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 14px;
}

.dashboard-summary-card {
  margin: 0;
  padding: 0;
  overflow: hidden;
  border-radius: 9px;
  border: 1px solid #e1e7ee;
  background: #fff;
  box-shadow: 0 10px 26px rgba(17, 17, 17, 0.055);
}

.summary-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid #e8edf3;
}

.summary-card-head h3 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 14px;
  line-height: 1.2;
  color: #111;
}

.summary-card-head h3 svg {
  width: 18px;
  height: 18px;
  color: #2563eb;
}

.summary-card-head span {
  color: #64748b;
  font-size: 12px;
}

.compact-summary-table {
  overflow-x: auto;
}

.compact-summary-table table {
  min-width: 100%;
  width: 100%;
}

.compact-summary-table th {
  color: #111 !important;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  background: #f8fafc;
}

.compact-summary-table td {
  color: #111 !important;
  font-size: 13px;
  padding: 9px 14px;
}

.compact-summary-table td.amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 1260px) and (min-width: 901px) {
  body[data-active-view="dashboard"] .dashboard-main-grid {
    grid-template-columns: repeat(5, minmax(126px, 1fr));
    gap: 12px;
  }
  body[data-active-view="dashboard"] .kpi,
  body[data-active-view="dashboard"] .dashboard-cash-box {
    padding: 14px;
    min-height: 116px;
  }
  body[data-active-view="dashboard"] .kpi strong,
  body[data-active-view="dashboard"] .dashboard-cash-box strong {
    font-size: clamp(18px, 1.35vw, 23px);
  }
  .dashboard-top-filter input[type="date"] {
    width: 108px;
  }
  .topbar-actions .link-button span {
    max-width: 84px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 1080px) and (min-width: 901px) {
  body[data-active-view="dashboard"] .topbar {
    grid-template-columns: 1fr;
  }
  body[data-active-view="dashboard"] .topbar-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  body[data-active-view="dashboard"] .dashboard-main-grid {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
  }
  .dashboard-summary-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  body[data-active-view="dashboard"] .topbar {
    display: block;
  }
  body[data-active-view="dashboard"] .topbar-actions {
    margin-top: 12px;
    flex-wrap: wrap;
    justify-content: flex-start;
  }
  .dashboard-top-filter {
    width: 100%;
    flex-wrap: wrap;
  }
  .dashboard-top-filter label {
    flex: 1 1 130px;
  }
  .dashboard-top-filter input[type="date"] {
    width: 100%;
  }
  body[data-active-view="dashboard"] .dashboard-main-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }
  body[data-active-view="dashboard"] #dashboardKpis,
  body[data-active-view="dashboard"] #dashboardCashBoxes {
    display: contents;
  }
  .dashboard-summary-grid {
    grid-template-columns: 1fr;
  }
}


/* Final functional fixes: WhatsApp share + sales stock hint + expense USD preview */
.row-action.whatsapp-action {
  color: #16a34a !important;
  border-color: rgba(22, 163, 74, 0.28) !important;
  background: #f0fdf4 !important;
}
.row-action.whatsapp-action svg {
  stroke: currentColor !important;
  fill: none !important;
}
.sale-stock-hint {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.25;
  color: #16a34a;
  font-weight: 700;
  white-space: nowrap;
}
.sale-stock-hint.low { color: #d97706; }
.sale-stock-hint.out { color: #dc2626; }
.expense-usd-preview input {
  background: #f8fafc;
  color: #111827;
  font-weight: 700;
}
@media (max-width: 900px) {
  .sale-stock-hint { white-space: normal; }
}


/* Final invoice/WhatsApp/expense exchange polish */
.whatsapp-action { color: #16a34a !important; }
.whatsapp-action svg { stroke: #16a34a !important; }
.whatsapp-share-card { max-width: 520px; }
.whatsapp-share-card textarea { min-height: 140px; resize: vertical; }
.exchange-rate-field:not(.hidden) { display: block !important; }
.expense-usd-preview input { font-weight: 700; color: #166534; background: #f0fdf4; }
.sale-stock-hint { display: block; margin-top: 5px; font-size: 12px; font-weight: 700; color: #166534; }
.sale-stock-hint.low { color: #b45309; }
.sale-stock-hint.out { color: #dc2626; }


/* Final targeted fixes: expense exchange-rate field + role-safe UI */
.expense-currency-rate-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr);
  gap: 12px;
  align-items: end;
}
.expense-currency-rate-row .exchange-rate-field:not(.hidden) {
  display: block !important;
}
.expense-currency-rate-row .exchange-rate-title {
  display: block;
  margin-bottom: 8px;
}
.expense-currency-rate-row .exchange-rate-field input[readonly] {
  background: #f8fafc;
  font-weight: 700;
  color: #6b7280;
}
.expense-usd-preview {
  margin-top: -2px;
}
.expense-usd-preview input[readonly] {
  background: #f8fafc;
  color: #111827;
  font-size: 14px;
  font-weight: 700;
}
body.view-only .whatsapp-action,
body.view-only .share-action,
body.view-only .print-action,
body.view-only button[data-print-kind],
body.view-only button[data-whatsapp-kind],
body.view-only button[data-sale-action='pdf'] {
  display: none !important;
}
#userForm input:disabled,
#userForm select:disabled,
#userForm button:disabled {
  opacity: .55;
  cursor: not-allowed;
}
@media (max-width: 760px) {
  .expense-currency-rate-row {
    grid-template-columns: 1fr;
  }
}


/* Expense form reset: exact AFN exchange-rate layout */
.expense-form-panel-reset { max-width: 640px; width: min(640px, calc(100vw - 28px)); }
.expense-entry-form .form-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: end; }
.expense-currency-rate-row { display: grid !important; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important; gap: 12px !important; align-items: end !important; }
.expense-currency-rate-row #expenseRateLabel,
.expense-currency-rate-row .exchange-rate-field { display: block !important; visibility: visible !important; opacity: 1 !important; }
#expenseRateLabel input { display: block !important; width: 100% !important; }
#expenseRateLabel .exchange-rate-title { display: block; margin-bottom: 8px; color: #6b7280; font-weight: 700; }
.expense-usd-preview { display: block !important; }
.expense-usd-preview input[readonly] { width: 100%; background: #f8fafc; color: #111827; font-size: 14px; font-weight: 800; }
@media (max-width: 720px) { .expense-entry-form .form-row, .expense-currency-rate-row { grid-template-columns: 1fr !important; } }


.currency-filter-buttons {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.currency-filter-buttons .mini-button.active {
  background: var(--brand-red);
  color: #fff;
  border-color: var(--brand-red);
}

.exchange-modal-card {
  max-width: 620px;
}

.exchange-payment-form input[readonly] {
  font-weight: 700;
  background: #f8fafc;
}

.exchange-payment-form .form-row {
  align-items: end;
}

@media (max-width: 720px) {
  .exchange-modal-card {
    max-width: calc(100vw - 20px);
  }
}

/* Re-coded Return page and popup */
.return-popup.hidden {
  display: none !important;
}
.return-popup {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.return-popup:not(.hidden) {
  display: flex !important;
}
.return-popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
}
.return-popup-card {
  position: relative;
  z-index: 1;
  width: min(760px, 96vw);
  max-height: calc(100vh - 36px);
  overflow: auto;
  background: #fff;
  border-radius: 14px;
}
.return-entry-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 14px;
}
.return-entry-form label {
  display: grid;
  gap: 6px;
}
.return-entry-form input,
.return-entry-form select {
  width: 100%;
}
.return-note-field,
.return-form-actions {
  grid-column: 1 / -1;
}
#returnStockHint {
  color: #166534;
  font-weight: 700;
  font-size: 12px;
}
@media (max-width: 760px) {
  .return-entry-form {
    grid-template-columns: 1fr;
  }
}

/* FINAL runtime return popup */
.return-popup.hidden { display: none !important; }
.return-popup {
  position: fixed !important;
  inset: 0 !important;
  z-index: 2147483000 !important;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.return-popup:not(.hidden) { display: flex !important; }
.return-popup-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.return-popup-card {
  position: relative;
  z-index: 1;
  width: min(760px, 96vw);
  max-height: calc(100vh - 36px);
  overflow: auto;
  background: #fff;
  border-radius: 14px;
}
.return-entry-form { display: grid; grid-template-columns: repeat(2, minmax(180px, 1fr)); gap: 14px; }
.return-entry-form label { display: grid; gap: 6px; }
.return-entry-form input, .return-entry-form select { width: 100%; }
.return-note-field, .return-form-actions { grid-column: 1 / -1; }
#returnStockHint { color: #166534; font-weight: 700; font-size: 12px; }
@media (max-width: 760px) { .return-entry-form { grid-template-columns: 1fr; } }
