/* ==========================================================================
   Gold Club — design system
   Minimal, luxurious, RTL-first. Light and dark are both first-class.
   ========================================================================== */

/* ------------------------------------------------------------------ fonts */
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Medium.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

/* ----------------------------------------------------------------- tokens */
:root {
  color-scheme: light;

  --gold: #b8912a;
  --gold-bright: #d4af37;
  --gold-soft: rgba(212, 175, 55, 0.12);
  --gold-line: rgba(212, 175, 55, 0.32);

  --bg: #f7f5f1;
  --bg-elev: #fffefc;
  --surface: #ffffff;
  --surface-2: #f4f1ec;
  --surface-3: #edeae4;

  --text: #191510;
  --text-2: #5f574b;
  --text-3: #918776;

  --line: #e7e2d9;
  --line-strong: #d8d1c4;

  --success: #17795e;
  --success-bg: rgba(23, 121, 94, 0.1);
  --danger: #b3261e;
  --danger-bg: rgba(179, 38, 30, 0.09);
  --info: #1f6feb;
  --info-bg: rgba(31, 111, 235, 0.1);
  --warn: #9a6700;
  --warn-bg: rgba(154, 103, 0, 0.1);

  --sale: #17795e;
  --sale-bg: rgba(23, 121, 94, 0.1);
  --purchase: #8a5a00;
  --purchase-bg: rgba(138, 90, 0, 0.1);

  --shadow-1: 0 1px 2px rgba(30, 22, 8, 0.05), 0 1px 3px rgba(30, 22, 8, 0.04);
  --shadow-2: 0 2px 6px rgba(30, 22, 8, 0.06), 0 8px 24px rgba(30, 22, 8, 0.06);
  --shadow-3: 0 12px 48px rgba(30, 22, 8, 0.14);

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 26px;
  --r-full: 999px;

  --sidebar-w: 244px;
  --topbar-h: 68px;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --fast: 0.16s var(--ease);
  --slow: 0.32s var(--ease);
}

:root[data-theme='dark'] {
  color-scheme: dark;

  --gold: #e0c069;
  --gold-bright: #f0d68a;
  --gold-soft: rgba(224, 192, 105, 0.13);
  --gold-line: rgba(224, 192, 105, 0.3);

  --bg: #100e0b;
  --bg-elev: #17140f;
  --surface: #1b1712;
  --surface-2: #221d17;
  --surface-3: #2b251d;

  --text: #f4efe6;
  --text-2: #b6ab99;
  --text-3: #837a6c;

  --line: #2c261e;
  --line-strong: #3b342a;

  --success: #4ec9a4;
  --success-bg: rgba(78, 201, 164, 0.12);
  --danger: #ff8078;
  --danger-bg: rgba(255, 128, 120, 0.12);
  --info: #74a9ff;
  --info-bg: rgba(116, 169, 255, 0.12);
  --warn: #e2b04a;
  --warn-bg: rgba(226, 176, 74, 0.12);

  --sale: #4ec9a4;
  --sale-bg: rgba(78, 201, 164, 0.12);
  --purchase: #e2b04a;
  --purchase-bg: rgba(226, 176, 74, 0.12);

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 2px 8px rgba(0, 0, 0, 0.45), 0 12px 32px rgba(0, 0, 0, 0.35);
  --shadow-3: 0 16px 56px rgba(0, 0, 0, 0.6);
}

/* ------------------------------------------------------------------ reset */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Vazirmatn', 'Segoe UI', Tahoma, system-ui, sans-serif;
  font-size: 14.5px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background var(--slow), color var(--slow);
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.4; letter-spacing: -0.01em; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; padding: 0; }

/* Latin numerals inside Persian text read better with tabular figures. */
.num, .money, .amount, table td, table th { font-variant-numeric: tabular-nums; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: var(--r-full);
  border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 6px;
}

/* --------------------------------------------------------------- app shell */
#app { min-height: 100%; }

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* Sidebar sits on the right — the RTL "start" edge. */
.sidebar {
  grid-column: 1;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 22px 16px;
  background: var(--bg-elev);
  border-inline-start: 1px solid var(--line);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 20px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--gold-bright), var(--gold));
  color: #201800;
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 4px 14px rgba(212, 175, 55, 0.3);
  overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }

.brand-text { min-width: 0; }
.brand-name {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-sub { font-size: 11.5px; color: var(--text-3); letter-spacing: 0.04em; }

.nav { display: flex; flex-direction: column; gap: 3px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  color: var(--text-2);
  font-weight: 500;
  font-size: 14px;
  position: relative;
  transition: background var(--fast), color var(--fast);
}
.nav-item svg { width: 19px; height: 19px; flex: none; opacity: 0.85; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--gold-soft);
  color: var(--text);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  inset-inline-start: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 22px;
  border-radius: var(--r-full);
  background: var(--gold);
}
.nav-item.active svg { opacity: 1; color: var(--gold); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.user-avatar {
  width: 32px; height: 32px; flex: none;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 13px; font-weight: 600;
}
.user-name { font-size: 13px; font-weight: 500; line-height: 1.3; }
.user-role { font-size: 11px; color: var(--text-3); }

/* ------------------------------------------------------------------ topbar */
.main { grid-column: 2; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 26px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar-title { display: flex; flex-direction: column; line-height: 1.35; }
.topbar-title strong { font-size: 15px; font-weight: 600; }
.topbar-title span { font-size: 12px; color: var(--text-3); }

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

.page {
  padding: 26px;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
  animation: rise var(--slow);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.page-head {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-head h1 { display: flex; align-items: center; gap: 10px; }
.page-head .sub { color: var(--text-3); font-size: 13px; }
.page-head .spacer { margin-inline-start: auto; }

/* ----------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid transparent;
  white-space: nowrap;
  transition: background var(--fast), border-color var(--fast),
              transform var(--fast), box-shadow var(--fast), opacity var(--fast);
}
.btn svg { width: 17px; height: 17px; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; pointer-events: none; }

.btn-primary {
  background: linear-gradient(160deg, var(--gold-bright), var(--gold));
  color: #1d1500;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(212, 175, 55, 0.26);
}
.btn-primary:hover { box-shadow: 0 4px 18px rgba(212, 175, 55, 0.36); }

.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line-strong); }

.btn-quiet { background: transparent; color: var(--text-2); }
.btn-quiet:hover { background: var(--surface-2); color: var(--text); }

.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 18%, transparent); }

.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn-sm svg { width: 15px; height: 15px; }
.btn-lg { padding: 12px 22px; font-size: 15px; border-radius: var(--r-md); }
.btn-block { width: 100%; }

.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: var(--r-md);
  color: var(--text-2);
  border: 1px solid transparent;
  transition: background var(--fast), color var(--fast), border-color var(--fast);
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ------------------------------------------------------------------- cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.card-pad { padding: 20px; }

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.card-head h3 { font-size: 14.5px; }
.card-head .spacer { margin-inline-start: auto; }
.card-body { padding: 20px; }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-auto { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

/* -------------------------------------------------------------------- stat */
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 17px 18px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--fast), transform var(--fast);
}
.stat:hover { border-color: var(--line-strong); }
.stat-label { font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.stat-label svg { width: 15px; height: 15px; }
.stat-value { font-size: 1.4rem; font-weight: 600; letter-spacing: -0.02em; }
.stat-value small { font-size: 0.62em; font-weight: 500; color: var(--text-3); margin-inline-start: 3px; }
.stat-foot { font-size: 11.5px; color: var(--text-3); }
.stat.accent { background: linear-gradient(150deg, var(--gold-soft), transparent 65%); }

/* ------------------------------------------------------------------ inputs */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 5px;
}
.field .hint { font-size: 11.5px; color: var(--text-3); }
.field .req { color: var(--gold); }

.input, .select, .textarea {
  width: 100%;
  padding: 10px 13px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-size: 14px;
  transition: border-color var(--fast), box-shadow var(--fast), background var(--fast);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-strong); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
  background: var(--surface);
}
.textarea { resize: vertical; min-height: 82px; line-height: 1.8; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23918776' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  background-size: 16px;
  padding-inline-start: 13px;
  padding-inline-end: 36px;
}

.input.err, .select.err, .textarea.err {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-bg);
}
.field-err { font-size: 12px; color: var(--danger); }

.input-suffix { position: relative; }
.input-suffix .suffix {
  position: absolute;
  inset-inline-start: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--text-3);
  pointer-events: none;
}
.input-suffix .input { padding-inline-start: 54px; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
}
.switch-row + .switch-row { border-top: 1px solid var(--line); }

/* ------------------------------------------------------------------ search */
.search {
  position: relative;
  flex: 1;
  max-width: 460px;
}
.search > svg {
  position: absolute;
  inset-inline-start: 13px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px; height: 17px;
  color: var(--text-3);
  pointer-events: none;
}
.search .input { padding-inline-start: 40px; border-radius: var(--r-full); }

.search-pop {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-start: 0;
  inset-inline-end: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
  overflow: hidden;
  z-index: 40;
  max-height: 380px;
  overflow-y: auto;
  animation: rise 0.18s var(--ease);
}
.search-group {
  padding: 8px 14px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-3);
}
.search-row {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 14px;
  text-align: start;
  transition: background var(--fast);
}
.search-row:hover, .search-row.on { background: var(--surface-2); }
.search-row .r-title { font-size: 13.5px; font-weight: 500; }
.search-row .r-sub { font-size: 11.5px; color: var(--text-3); }

/* ------------------------------------------------------------------ avatar */
.avatar {
  border-radius: var(--r-full);
  object-fit: cover;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  font-weight: 600;
  color: var(--text-2);
  flex: none;
  overflow: hidden;
  border: 1px solid var(--line);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.s { width: 36px; height: 36px; font-size: 13px; }
.avatar.m { width: 48px; height: 48px; font-size: 16px; }
.avatar.l { width: 84px; height: 84px; font-size: 26px; }

/* ------------------------------------------------------------------ badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--text-2);
  white-space: nowrap;
}
.badge svg { width: 13px; height: 13px; }
.badge.sale { background: var(--sale-bg); color: var(--sale); }
.badge.purchase { background: var(--purchase-bg); color: var(--purchase); }
.badge.gold { background: var(--gold-soft); color: var(--gold); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.success { background: var(--success-bg); color: var(--success); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.dot::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: var(--r-full);
  background: currentColor;
}

.level-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  cursor: pointer;
  transition: all var(--fast);
}
.tag-pill.on { border-color: var(--gold); background: var(--gold-soft); color: var(--gold); }

/* ------------------------------------------------------------- customer card */
.customer-card {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  text-align: start;
  width: 100%;
  transition: border-color var(--fast), box-shadow var(--fast), transform var(--fast);
}
.customer-card:hover {
  border-color: var(--gold-line);
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
}
.customer-card .cc-body { min-width: 0; flex: 1; }
.customer-card .cc-name {
  font-weight: 600;
  font-size: 14.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.customer-card .cc-meta { font-size: 12px; color: var(--text-3); }
.customer-card .cc-tags { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }

/* --------------------------------------------------------------- snapshot */
.snapshot {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-xl);
  border: 1px solid var(--line);
  background:
    radial-gradient(120% 140% at 100% 0%, var(--gold-soft), transparent 55%),
    var(--surface);
  padding: 24px;
  box-shadow: var(--shadow-1);
}
.snapshot::after {
  content: '';
  position: absolute;
  inset-inline-end: -60px;
  top: -80px;
  width: 240px; height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--gold-soft), transparent 70%);
  pointer-events: none;
}
.snapshot-top { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.snapshot-id { min-width: 0; flex: 1; }
.snapshot-id h1 { font-size: 1.35rem; margin-bottom: 2px; }
.snapshot-meta {
  display: flex; flex-wrap: wrap; gap: 6px 16px;
  font-size: 12.5px; color: var(--text-2); margin-top: 6px;
}
.snapshot-meta span { display: inline-flex; align-items: center; gap: 5px; }
.snapshot-meta svg { width: 14px; height: 14px; color: var(--text-3); }

/* Flex rather than grid: with an odd number of cells a grid leaves a visible
   hole in the last row, whereas flex lets the final cell take the slack. */
.snapshot-stats {
  display: flex;
  flex-wrap: wrap;
  margin-top: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.snapshot-stats > div {
  flex: 1 1 118px;
  padding: 12px 14px;
  border-inline-start: 1px solid var(--line);
}
.snapshot-stats > div:first-child { border-inline-start: none; }
.snapshot-stats .k { font-size: 11.5px; color: var(--text-3); }
.snapshot-stats .v { font-size: 15px; font-weight: 600; }

.snapshot-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

/* ------------------------------------------------------------ transactions */
.tx-card {
  display: block;
  width: 100%;
  text-align: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  transition: border-color var(--fast), box-shadow var(--fast);
}
.tx-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-1); }
.tx-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tx-title { font-weight: 600; font-size: 14.5px; }
.tx-code { font-size: 11.5px; color: var(--text-3); letter-spacing: 0.04em; }
.tx-amount { margin-inline-start: auto; font-size: 15px; font-weight: 600; }
.tx-amount small { font-size: 11px; color: var(--text-3); font-weight: 400; }

.tx-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px 16px;
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px dashed var(--line);
}
.tx-grid .k { font-size: 11px; color: var(--text-3); }
.tx-grid .v { font-size: 13px; font-weight: 500; }

.tx-note {
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: 12.5px;
  color: var(--text-2);
  display: flex;
  gap: 8px;
}
.tx-note svg { width: 15px; height: 15px; flex: none; margin-top: 3px; color: var(--text-3); }

/* --------------------------------------------------------------- segmented */
.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  gap: 2px;
}
.segmented button {
  padding: 6px 15px;
  border-radius: var(--r-full);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  transition: all var(--fast);
}
.segmented button.on {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-1);
  font-weight: 600;
}

/* ---------------------------------------------------------------- timeline */
.timeline { position: relative; padding-inline-start: 22px; }
.timeline::before {
  content: '';
  position: absolute;
  inset-inline-start: 5px;
  top: 6px;
  bottom: 6px;
  width: 1.5px;
  background: linear-gradient(var(--line), transparent);
}
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item::before {
  content: '';
  position: absolute;
  inset-inline-start: -21px;
  top: 6px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--line-strong);
}
.tl-item.gold::before { border-color: var(--gold); }
.tl-item .tl-title { font-size: 13.5px; font-weight: 500; }
.tl-item .tl-meta { font-size: 11.5px; color: var(--text-3); }
.tl-item .tl-detail { font-size: 12.5px; color: var(--text-2); margin-top: 3px; }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; border-radius: var(--r-md); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 520px; }
table.tbl th {
  text-align: start;
  font-weight: 500;
  font-size: 11.5px;
  color: var(--text-3);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tbody tr { transition: background var(--fast); }
table.tbl tbody tr:hover { background: var(--surface-2); }

/* ------------------------------------------------------------------- modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 15, 5, 0.42);
  backdrop-filter: blur(3px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade 0.2s var(--ease);
  overflow-y: auto;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  animation: pop 0.24s var(--ease);
  margin: auto;
}
.modal.wide { max-width: 780px; }
.modal.narrow { max-width: 420px; }
@keyframes pop {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 16px; }
.modal-head .spacer { margin-inline-start: auto; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot {
  display: flex;
  gap: 8px;
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  background: var(--bg-elev);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}
.modal-foot .spacer { margin-inline-start: auto; }

/* ------------------------------------------------------------- calc panel */
.calc-panel {
  border-radius: var(--r-lg);
  border: 1px solid var(--gold-line);
  background: linear-gradient(160deg, var(--gold-soft), transparent 70%), var(--surface);
  padding: 16px 18px;
}
.calc-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 0;
  font-size: 13px;
}
.calc-row + .calc-row { border-top: 1px dashed var(--line); }
.calc-row .k { color: var(--text-2); }
.calc-row .k em { font-style: normal; color: var(--text-3); font-size: 11.5px; }
.calc-row .v { margin-inline-start: auto; font-weight: 500; font-variant-numeric: tabular-nums; }
.calc-total {
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1.5px solid var(--gold-line);
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.calc-total .k { font-weight: 600; font-size: 14px; }
.calc-total .v {
  margin-inline-start: auto;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.calc-total .v small { font-size: 0.6em; font-weight: 500; color: var(--text-3); }

/* ------------------------------------------------------------ empty/loading */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 52px 24px;
  text-align: center;
}
.empty-icon {
  width: 58px; height: 58px;
  display: grid; place-items: center;
  border-radius: var(--r-lg);
  background: var(--surface-2);
  color: var(--text-3);
  margin-bottom: 4px;
}
.empty-icon svg { width: 26px; height: 26px; }
.empty h3 { font-size: 15px; }
.empty p { font-size: 13px; color: var(--text-3); max-width: 340px; }

.skel {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.skel-card { height: 84px; border-radius: var(--r-lg); }
.skel-line { height: 11px; }

/* ------------------------------------------------------------------ toasts */
.toasts {
  position: fixed;
  bottom: 22px;
  inset-inline-start: 22px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-width: 380px;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 15px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-3);
  font-size: 13px;
  animation: slide 0.26s var(--ease);
}
@keyframes slide {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
.toast.out { animation: fadeout 0.2s var(--ease) forwards; }
@keyframes fadeout { to { opacity: 0; transform: translateY(6px); } }
.toast svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.toast.ok svg { color: var(--success); }
.toast.err svg { color: var(--danger); }
.toast.info svg { color: var(--info); }

/* ------------------------------------------------------------------- login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(70% 60% at 80% 0%, var(--gold-soft), transparent 60%),
    radial-gradient(60% 60% at 10% 100%, var(--gold-soft), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 396px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  padding: 34px 30px;
  animation: pop 0.4s var(--ease);
}
.login-mark {
  width: 56px; height: 56px;
  border-radius: 18px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--gold-bright), var(--gold));
  color: #201800;
  font-weight: 700;
  font-size: 20px;
  margin: 0 auto 16px;
  box-shadow: 0 8px 24px rgba(212, 175, 55, 0.32);
}

/* ---------------------------------------------------------------- receipt */
/* On screen the receipt follows the active theme; the print rules further
   down force it back to black-on-white for paper and PDF. */
.receipt-page { background: var(--surface-2); min-height: 100vh; padding: 26px 16px 60px; }
.receipt-bar {
  max-width: 780px; margin: 0 auto 18px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.receipt {
  max-width: 780px;
  margin: 0 auto;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  padding: 34px 38px;
  border-top: 4px solid var(--gold-bright);
}
.rc-head { display: flex; align-items: flex-start; gap: 16px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.rc-logo { width: 52px; height: 52px; border-radius: 14px; background: linear-gradient(145deg, #d4af37, #b8912a); color: #201800; display: grid; place-items: center; font-weight: 700; overflow: hidden; flex: none; }
.rc-logo img { width: 100%; height: 100%; object-fit: cover; }
.rc-store h2 { font-size: 17px; }
.rc-store p { font-size: 12px; color: var(--text-3); }
.rc-no { margin-inline-start: auto; text-align: end; }
.rc-no .lbl { font-size: 11px; color: var(--text-3); }
.rc-no .val { font-size: 15px; font-weight: 700; letter-spacing: 0.05em; }

.rc-section { margin-top: 18px; }
.rc-section h4 { font-size: 12px; color: var(--text-3); font-weight: 600; margin-bottom: 8px; letter-spacing: 0.04em; }
.rc-kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 9px 18px; }
.rc-kv .k { font-size: 11px; color: var(--text-3); }
.rc-kv .v { font-size: 13px; font-weight: 500; }

table.rc-tbl { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; }
table.rc-tbl td { padding: 8px 2px; border-bottom: 1px dashed var(--line); }
table.rc-tbl td:last-child { text-align: end; font-variant-numeric: tabular-nums; font-weight: 500; }
table.rc-tbl tr.total td { border-bottom: none; border-top: 2px solid #d4af37; padding-top: 12px; font-size: 15px; font-weight: 700; }
table.rc-tbl tr.total td:last-child { color: var(--gold); }

.rc-note { margin-top: 16px; padding: 11px 14px; background: var(--surface-2); border-radius: 10px; font-size: 12.5px; }
.rc-foot { margin-top: 24px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 16px; font-size: 11.5px; color: var(--text-3); }
.rc-sign { margin-top: 30px; display: flex; justify-content: space-between; gap: 40px; }
.rc-sign div { flex: 1; text-align: center; font-size: 11.5px; color: var(--text-3); }
.rc-sign .line { margin-top: 34px; border-top: 1px dotted var(--line-strong); padding-top: 5px; }

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

  /* Paper is white whatever the on-screen theme is, and none of the app
     chrome belongs on it. */
  html, body { background: #fff !important; color: #14110c !important; }
  .sidebar, .topbar, .tabbar, .scrim, .toasts, .receipt-bar, .no-print,
  .modal-backdrop { display: none !important; }
  .shell { display: block !important; }
  .main { padding: 0 !important; }
  .receipt-page { background: #fff !important; padding: 0; min-height: 0; }

  .receipt {
    background: #fff !important;
    color: #14110c !important;
    box-shadow: none;
    border: none;
    border-radius: 0;
    max-width: none;
    padding: 14px 0 0;
    border-top: 3px solid #b8912a;
  }
  .receipt * { color: inherit !important; }
  .rc-store p, .rc-no .lbl, .rc-section h4, .rc-kv .k, .rc-foot, .rc-sign div {
    color: #7a7060 !important;
  }
  .rc-head, .rc-foot { border-color: #e6e1d6 !important; }
  table.rc-tbl td { border-bottom-color: #e6e1d6 !important; }
  table.rc-tbl tr.total td { border-top-color: #b8912a !important; }
  table.rc-tbl tr.total td:last-child { color: #96731c !important; }
  .rc-note { background: #faf7f0 !important; }
  .rc-sign .line { border-top-color: #b8b0a2 !important; }
  .rc-logo { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

/* ------------------------------------------------------------- responsive */
@media (max-width: 1040px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  /* The drawer lives on the inline-start edge, which in this RTL app is the
     right-hand side; translateX(100%) parks it just off that edge. */
  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: 256px;
    transform: translateX(100%);
    transition: transform var(--slow);
    box-shadow: var(--shadow-3);
    border-inline-start: none;
    border-inline-end: 1px solid var(--line);
  }
  .sidebar.open { transform: none; }
  .main { grid-column: 1; padding-bottom: 74px; }
  .page { padding: 18px 15px 30px; }
  .topbar { padding: 0 15px; gap: 9px; }
  .topbar-title { display: none; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .modal { max-width: none; border-radius: var(--r-lg); }
  .receipt { padding: 22px 18px; }
}

@media (min-width: 861px) {
  .mobile-only { display: none !important; }
}

/* bottom bar on phones — reachable with one thumb */
.tabbar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 30;
  display: none;
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 7px 0;
  border-radius: var(--r-md);
  font-size: 10.5px;
  color: var(--text-3);
  transition: color var(--fast), background var(--fast);
}
.tabbar a svg { width: 21px; height: 21px; }
.tabbar a.active { color: var(--gold); background: var(--gold-soft); }
@media (max-width: 860px) { .tabbar { display: flex; } }

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(20, 15, 5, 0.4);
  z-index: 19;
  animation: fade 0.2s var(--ease);
}

/* A right-pointing chevron reads as "back" in RTL; flip it when it means
   "forward". Icons also get a safe default so a bare SVG never stretches. */
.chev-fwd { transform: rotate(180deg); }
svg { flex: none; }

/* ------------------------------------------------------------------ misc */
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.spacer { margin-inline-start: auto; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.center { text-align: center; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.nowrap { white-space: nowrap; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pager { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 20px; }
.pager .info { font-size: 12.5px; color: var(--text-3); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
