:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #eef3ed;
  --text: #20241f;
  --muted: #667065;
  --line: #dfe4dc;
  --primary: #176f5f;
  --primary-dark: #0f4b43;
  --accent: #b2772e;
  --danger: #b63d32;
  --success: #247647;
  --shadow: 0 18px 45px rgba(31, 38, 33, 0.11);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: "Cairo", Arial, sans-serif;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.75), rgba(244, 245, 242, 0.92)),
    var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 8px 12px;
  outline: none;
}

input[type="number"],
input[type="tel"],
.number-input,
[inputmode="decimal"],
#customerPhone,
#saleCustomerPhone,
#loginPassword {
  direction: ltr;
  text-align: right;
  unicode-bidi: plaintext;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 111, 95, 0.12);
}

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

label span {
  color: var(--muted);
}

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

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

td {
  font-size: 13px;
}

td strong {
  display: block;
  font-size: 13px;
}

td small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 24px;
  padding: 24px;
  align-items: stretch;
}

.login-brand-panel {
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(17, 56, 50, 0.83), rgba(17, 56, 50, 0.88)),
    url("https://images.unsplash.com/photo-1600607687939-ce8a6c25118c?auto=format&fit=crop&w=1600&q=80");
  background-size: cover;
  background-position: center;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 48px;
  min-height: 520px;
}

.login-brand-panel h1 {
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1.16;
  max-width: 850px;
  margin: 6px 0 18px;
}

.login-brand-panel p {
  max-width: 650px;
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 17px;
}

.login-card {
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.login-card h2 {
  margin: 0;
  font-size: 25px;
}

.signature-strip {
  width: fit-content;
  margin-top: 24px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  padding: 7px 10px;
  background: rgba(0, 0, 0, 0.12);
}

.signature-strip strong {
  color: #fff;
  display: block;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
}

.hint-box {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 12px;
  display: grid;
  gap: 2px;
  color: var(--muted);
  font-size: 13px;
}

.hint-box strong {
  color: var(--text);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  min-height: 100vh;
  background: #112b27;
  color: #fff;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
}

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

.brand-area span {
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: #f3c16b;
  color: #17221f;
  font-weight: 900;
  letter-spacing: 0;
}

.brand-mark.large {
  width: 68px;
  height: 68px;
  font-size: 24px;
  margin-bottom: 18px;
}

.brand-mark.invoice {
  width: 54px;
  height: 54px;
  margin-bottom: 8px;
}

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

.nav-item {
  width: 100%;
  min-height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  text-align: right;
  transition: 160ms ease;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.nav-icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.1);
  color: #f3c16b;
  flex: 0 0 auto;
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding: 16px 10px 2px;
  display: grid;
  gap: 2px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
}

.sidebar-footer strong {
  color: #fff;
  font-size: 14px;
}

.workspace {
  min-width: 0;
}

.topbar {
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 28px;
  background: rgba(244, 245, 242, 0.9);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid rgba(223, 228, 220, 0.8);
}

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

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

.user-chip {
  min-width: 150px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 8px 12px;
  display: grid;
  gap: 2px;
}

.user-chip span {
  font-weight: 800;
}

.user-chip small {
  color: var(--muted);
}

.page {
  padding: 24px 28px 40px;
  display: grid;
  gap: 20px;
}

.hero-band {
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(18, 54, 49, 0.92), rgba(23, 111, 95, 0.74)),
    url("https://images.unsplash.com/photo-1600566753190-17f0baa2a6c3?auto=format&fit=crop&w=1400&q=80");
  background-size: cover;
  background-position: center;
  color: #fff;
  min-height: 210px;
  padding: 30px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
}

.hero-band h2 {
  max-width: 760px;
  margin: 6px 0 10px;
  font-size: clamp(25px, 3vw, 42px);
  line-height: 1.2;
}

.hero-band p {
  max-width: 720px;
  margin: 0;
  color: rgba(255, 255, 255, 0.75);
}

.hero-signature {
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(0, 0, 0, 0.18);
  border-radius: var(--radius);
  padding: 12px 16px;
  min-width: 180px;
}

.hero-signature span,
.hero-signature strong {
  display: block;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.login-brand-panel .eyebrow,
.hero-band .eyebrow {
  color: #f3c16b;
}

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

.metric-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
  min-height: 118px;
  display: grid;
  align-content: space-between;
  gap: 8px;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric-card strong {
  font-size: 24px;
  line-height: 1.25;
}

.metric-card small {
  color: var(--muted);
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 28px rgba(28, 36, 30, 0.05);
  padding: 18px;
  min-width: 0;
}

.panel.inner {
  box-shadow: none;
}

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

.panel-head h3 {
  margin: 0;
  font-size: 18px;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 16px;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(330px, 0.42fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.split-layout.reverse {
  grid-template-columns: minmax(380px, 0.55fr) minmax(0, 1fr);
}

.invoice-reference-layout {
  display: grid;
  grid-template-columns: minmax(340px, 0.45fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.invoice-list-panel {
  position: sticky;
  top: 104px;
}

.invoice-preview-panel {
  min-height: 68vh;
}

.invoice-preview-frame {
  min-height: 54vh;
  display: grid;
  align-items: start;
}

.invoice-preview-frame .invoice-paper {
  width: 100%;
  border: 1px solid var(--line);
  box-shadow: none;
  padding: 24px;
}

.invoice-reference-profit {
  display: block;
  width: fit-content;
  margin: -2px 0 8px auto;
}

.reference-upload-panel {
  margin-bottom: 16px;
}

.reference-compression-card {
  border: 1px solid #dce7dc;
  border-radius: var(--radius);
  background: #f8faf7;
  padding: 12px;
  margin-top: 4px;
}

.reference-compression-card small {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.7;
  margin-top: 6px;
}

.reference-layout {
  display: grid;
  grid-template-columns: minmax(330px, 0.42fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.reference-list-panel {
  position: sticky;
  top: 104px;
}

.reference-filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(130px, 170px);
  gap: 8px;
  align-items: end;
  margin-bottom: 12px;
}

.reference-filters .search-box {
  min-width: 0;
}

.reference-results {
  max-height: 520px;
  overflow: auto;
  padding-left: 2px;
}

.reference-preview-panel {
  min-height: 70vh;
}

.reference-meta {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.reference-viewer {
  margin-top: 14px;
  min-height: 62vh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8faf7;
  overflow: hidden;
}

.reference-viewer iframe,
.reference-viewer img {
  display: block;
  width: 100%;
  height: 62vh;
  border: 0;
  background: #fff;
}

.reference-viewer img {
  height: auto;
  min-height: 360px;
  object-fit: contain;
  padding: 14px;
}

.sales-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.form-panel {
  position: sticky;
  top: 104px;
}

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

.form-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 14px;
}

.price-rule-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.price-rule-card {
  display: grid;
  gap: 10px;
  border: 1px solid #dce7dc;
  border-radius: var(--radius);
  background: #f8faf7;
  padding: 12px;
}

.price-rule-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.price-rule-head strong {
  font-size: 14px;
}

.price-rule-head small {
  color: var(--primary);
  direction: ltr;
  font-weight: 900;
}

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

.invoice-actions {
  align-items: center;
  justify-content: space-between;
}

.invoice-action-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.silent-profit {
  margin-right: auto;
  color: #637269;
  direction: ltr;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  opacity: 0.78;
  white-space: nowrap;
}

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

.search-box {
  min-width: min(100%, 420px);
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
  background: #fff;
}

.search-box span {
  color: var(--muted);
}

.search-box input {
  border: 0;
  box-shadow: none;
  padding-inline: 0;
}

.primary,
.secondary,
.ghost,
.danger {
  min-height: 42px;
  border-radius: var(--radius);
  padding: 9px 15px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.primary {
  background: var(--primary);
  color: #fff;
}

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

.secondary {
  background: #eadbc4;
  color: #2d251a;
}

.ghost {
  background: #eef3ed;
  color: var(--text);
}

.danger {
  background: #f5dedb;
  color: var(--danger);
}

.full {
  width: 100%;
}

.icon-btn {
  width: 40px;
  min-width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius);
  font-size: 18px;
}

.row-actions {
  white-space: nowrap;
}

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

.table-wrap.tall {
  max-height: calc(100vh - 220px);
}

.invoice-lines {
  max-height: 360px;
  margin-block: 10px;
}

.empty-state,
.empty-cell {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
  color: var(--muted);
  padding: 18px;
  text-align: center;
  font-weight: 700;
}

.empty-cell {
  border: 0;
}

.stock-pill {
  display: inline-grid;
  place-items: center;
  min-width: 54px;
  min-height: 28px;
  border-radius: 999px;
  background: #e3f3ea;
  color: var(--success);
  font-weight: 900;
}

.stock-pill.danger {
  background: #f5dedb;
  color: var(--danger);
}

.type-pill {
  display: inline-grid;
  place-items: center;
  min-width: 64px;
  min-height: 26px;
  border-radius: 999px;
  background: #eef3ef;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.type-pill.merchant {
  background: #fff2d9;
  color: #9b5b0b;
}

.type-pill.consumer {
  background: #e3f3ea;
  color: var(--success);
}

.selected-row {
  background: #f8faf7;
}

.debt-text {
  color: var(--danger);
}

.credit-text {
  color: var(--success);
}

.muted-line {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.customer-profile {
  display: grid;
  gap: 14px;
}

.profile-balance {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8faf7;
  padding: 10px 14px;
  min-width: 180px;
  display: grid;
  gap: 5px;
}

.profile-balance span,
.profile-balance strong {
  display: block;
}

.profile-balance span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.profile-balance strong {
  font-size: 20px;
}

.profile-balance.has-debt {
  background: #fff8eb;
  border-color: #eadbc4;
}

.profile-balance.has-debt strong {
  color: var(--danger);
}

.profile-balance.has-credit {
  background: #f0f8f4;
  border-color: #cfe8d8;
}

.profile-balance.has-credit strong {
  color: var(--success);
}

.profile-balance button {
  min-height: 34px;
  padding: 6px 10px;
  margin-top: 4px;
}

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

.compact-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fbfcfa;
}

.compact-row strong,
.compact-row span {
  display: block;
}

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

.product-picker {
  position: sticky;
  top: 104px;
}

.product-picker.panel {
  padding: 14px;
}

.product-picker .panel-head {
  margin-bottom: 10px;
}

.product-picker .panel-head h3 {
  font-size: 16px;
}

.product-picker .search-box input {
  min-height: 38px;
}

.picker-filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(135px, 170px);
  gap: 8px;
  align-items: end;
}

.picker-filters .search-box {
  min-width: 0;
}

.brand-filter span {
  font-size: 11px;
}

.brand-filter select {
  min-height: 40px;
}

.product-grid {
  display: grid;
  gap: 5px;
  margin-top: 8px;
}

.product-tile {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  min-height: 58px;
  padding: 7px 9px;
  text-align: right;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "name price"
    "meta stock";
  align-items: center;
  gap: 2px 10px;
  transition: 140ms ease;
}

.product-tile:hover:not(:disabled) {
  border-color: var(--primary);
  box-shadow: 0 10px 20px rgba(23, 111, 95, 0.08);
}

.product-tile strong,
.product-tile span,
.product-tile b,
.product-tile small {
  display: block;
  min-width: 0;
}

.product-tile strong {
  grid-area: name;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.35;
}

.product-tile span,
.product-tile small {
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-tile span {
  grid-area: meta;
}

.product-tile small {
  grid-area: stock;
  justify-self: end;
}

.product-tile b {
  grid-area: price;
  color: var(--primary);
  font-size: 13px;
  line-height: 1.25;
  white-space: nowrap;
  justify-self: end;
}

.invoice-builder {
  min-height: 520px;
}

.mini-input {
  min-width: 74px;
  width: 86px;
  min-height: 36px;
  padding: 6px 8px;
}

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

.inline-control select {
  width: 88px;
  min-height: 36px;
  padding: 4px 8px;
}

.discount-row,
.date-range {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
}

.discount-row label,
.date-range label {
  min-width: 180px;
}

.document-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8faf7;
  padding: 6px;
  margin-bottom: 14px;
}

.document-switch button {
  min-height: 40px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.document-switch button.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 18px rgba(23, 111, 95, 0.14);
}

.notice-box {
  border: 1px solid #eadbc4;
  border-radius: var(--radius);
  background: #fff8eb;
  color: #6d4a1e;
  padding: 12px;
  font-size: 13px;
  font-weight: 800;
  margin-top: 12px;
}

.payment-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfa;
  padding: 12px;
  margin-top: 12px;
}

.draft-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: -4px 0 12px;
}

.draft-tabs button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  min-height: 34px;
  padding: 6px 10px;
  font-weight: 800;
}

.draft-tabs button.active {
  border-color: var(--primary);
  background: #edf7f3;
  color: var(--primary);
}

.draft-tabs .new-draft {
  border-color: #d9e7dc;
  color: var(--success);
}

.draft-tabs .close-draft {
  border-color: #f0d0cb;
  color: var(--danger);
}

.panel-head.slim {
  margin-bottom: 10px;
}

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

.payment-grid small {
  color: var(--muted);
  font-size: 11px;
}

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

.lookup-field {
  position: relative;
}

.selected-lookup {
  border: 1px solid #dce7dc;
  border-radius: 6px;
  background: #f8faf7;
  padding: 7px 34px 7px 9px;
  margin-top: 6px;
  position: relative;
}

.selected-lookup strong,
.selected-lookup small {
  display: block;
}

.selected-lookup small {
  color: var(--muted);
  font-size: 11px;
}

.selected-lookup button {
  position: absolute;
  inset-inline-start: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: #f5dedb;
  color: var(--danger);
  font-weight: 900;
}

.lookup-results {
  display: grid;
  gap: 5px;
  margin-top: 7px;
}

.lookup-results button,
.lookup-empty {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  text-align: right;
}

.lookup-results button.active,
.lookup-results button:hover {
  border-color: var(--primary);
  background: #f2f8f5;
}

.lookup-results strong,
.lookup-results small {
  display: block;
}

.lookup-results strong {
  font-size: 13px;
}

.lookup-results small,
.lookup-empty {
  color: var(--muted);
  font-size: 11px;
}

.return-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px 160px auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
}

.return-results {
  max-height: 260px;
  overflow: auto;
  padding-left: 2px;
  margin-bottom: 12px;
}

.invoice-results {
  max-height: 520px;
  overflow: auto;
  padding-left: 2px;
}

.customer-analysis-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  border: 1px solid #dce7dc;
  border-radius: var(--radius);
  background: #f8faf7;
  padding: 12px;
  margin-bottom: 14px;
}

.customer-analysis-filters .form-actions {
  margin-top: 0;
  align-items: end;
  justify-content: flex-start;
  white-space: nowrap;
}

.customer-period-summary,
.customer-product-summary {
  margin-bottom: 12px;
}

.customer-withdrawals-panel {
  margin-top: 16px;
}

.statement-products {
  margin-top: 18px;
}

.statement-products h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.statement-period-totals {
  margin-bottom: 14px;
}

.summary-box {
  border-radius: var(--radius);
  background: #f8faf7;
  border: 1px solid var(--line);
  padding: 12px;
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.summary-box.flat {
  margin-top: 0;
}

.summary-box div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.summary-box strong {
  color: var(--text);
}

.summary-box .total,
.summary-box .profit {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.summary-box .total strong {
  font-size: 22px;
  color: var(--primary);
}

.summary-box .profit strong {
  color: var(--success);
}

.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-direction: row;
  font-size: 13px;
  color: var(--text);
}

.check-line input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--primary);
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

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

.segmented button {
  min-height: 40px;
  border-radius: var(--radius);
  padding: 8px 12px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 800;
}

.report-paper {
  display: grid;
  gap: 16px;
}

.print-report {
  background: #fff;
  padding: 18px;
  border-radius: var(--radius);
}

.report-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid var(--line);
  padding: 20px;
}

.report-head h2 {
  margin: 4px 0;
}

.report-head span,
.report-head strong {
  color: var(--muted);
}

.bars {
  display: grid;
  gap: 12px;
}

.daily-statement {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.daily-statement .wide {
  grid-column: 1 / -1;
}

.bar-row {
  display: grid;
  gap: 8px;
}

.bar-row > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.bar-row strong {
  font-size: 13px;
}

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

.bar-row i {
  display: block;
  height: 9px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--primary) var(--bar), transparent var(--bar)),
    #e6ebe4;
}

.printable-card {
  max-width: 980px;
  margin-inline: auto;
  width: 100%;
}

.invoice-paper {
  background: #fff;
  color: var(--text);
  border-radius: var(--radius);
  padding: 28px;
}

.invoice-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  border-bottom: 2px solid var(--text);
  padding-bottom: 16px;
}

.invoice-logo-side {
  display: flex;
  justify-content: flex-start;
}

.invoice-meta {
  display: grid;
  align-content: start;
  gap: 6px;
  text-align: right;
}

.invoice-meta strong {
  font-size: 26px;
  font-weight: 900;
  line-height: 1.15;
}

.invoice-meta span {
  font-size: 14px;
  font-weight: 800;
  color: var(--muted);
}

.invoice-customer {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  padding: 16px 0 12px;
  color: var(--text);
}

.invoice-customer div {
  border: 1px solid #e0e4dc;
  border-radius: 6px;
  background: #fbfcfa;
  padding: 9px 11px;
}

.invoice-customer span,
.invoice-customer strong {
  display: block;
}

.invoice-customer span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.invoice-customer strong {
  margin-top: 3px;
  font-size: 15px;
  font-weight: 900;
}

.invoice-table th,
.invoice-table td {
  border-color: #d8d8d8;
}

.invoice-table th {
  font-size: 13px;
  font-weight: 900;
  color: #4f594f;
}

.invoice-table td {
  font-size: 15px;
  font-weight: 800;
}

.invoice-table td:first-child {
  font-size: 16px;
  font-weight: 900;
}

.invoice-table small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  margin-top: 4px;
}

.invoice-totals {
  width: min(100%, 360px);
  margin-right: auto;
  margin-top: 18px;
  display: grid;
  gap: 8px;
}

.invoice-payments,
.invoice-notice {
  width: min(100%, 520px);
  margin-top: 18px;
  border: 1px solid #ddd;
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfa;
}

.invoice-payments h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.invoice-payments div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 14px;
}

.invoice-notice {
  color: #6d4a1e;
  background: #fff8eb;
  border-color: #eadbc4;
  font-weight: 800;
}

.invoice-totals div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #ddd;
  padding-bottom: 8px;
}

.invoice-totals .grand {
  border: 0;
  background: #f0f4ee;
  border-radius: var(--radius);
  padding: 12px;
  color: var(--primary);
  font-size: 18px;
}

.invoice-footer {
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid #ddd;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.toast {
  position: fixed;
  bottom: 22px;
  left: 22px;
  z-index: 40;
  border-radius: var(--radius);
  background: #17221f;
  color: #fff;
  box-shadow: var(--shadow);
  padding: 12px 16px;
  font-weight: 800;
}

.print-body {
  background: #fff;
  padding: 24px;
}

@media (max-width: 1100px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

	  .two-column,
	  .split-layout,
	  .split-layout.reverse,
	  .invoice-reference-layout,
	  .reference-layout,
	  .sales-layout {
	    grid-template-columns: 1fr;
	  }

	  .form-panel,
	  .product-picker,
	  .invoice-list-panel,
	  .reference-list-panel {
	    position: static;
	  }

  .customer-analysis-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .customer-analysis-filters .form-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 800px) {
  .login-page {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .login-brand-panel {
    min-height: 420px;
    padding: 28px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    position: static;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    height: auto;
    align-items: flex-start;
    padding: 16px;
  }

  .page {
    padding: 16px;
  }

  .hero-band,
  .report-head,
  .invoice-header,
  .invoice-customer,
  .invoice-footer {
    display: grid;
  }

  .hero-signature {
    min-width: 0;
  }

	  .form-grid,
	  .form-grid.compact,
    .price-rule-grid,
	  .permission-grid,
  .metric-grid,
  .payment-grid,
	  .invoice-customer,
	  .return-search,
	  .picker-filters,
	  .reference-filters,
	  .reference-meta,
	  .daily-statement {
	    grid-template-columns: 1fr;
	  }

  .toolbar {
    align-items: stretch;
  }

  .search-box,
  .date-range,
  .segmented {
    width: 100%;
  }

	  .date-range label,
	  .discount-row label {
	    min-width: 100%;
	  }

  .customer-analysis-filters {
    grid-template-columns: 1fr;
  }

  .customer-analysis-filters .form-actions {
    white-space: normal;
  }

  .topbar-actions {
    flex-shrink: 0;
  }
}

@media print {
  body {
    background: #fff;
  }

  .sidebar,
  .topbar,
  .toolbar,
  .form-actions,
  button,
  .toast {
    display: none !important;
  }

  .app-shell {
    display: block;
  }

  .page,
  .print-body {
    padding: 0;
  }

  .panel,
  .report-head,
  .metric-card {
    box-shadow: none;
    break-inside: avoid;
  }

  .invoice-paper {
    padding: 0;
  }
}
