/* MGS — components & layout. Values come from tokens.css; RTL via logical properties. */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&family=IBM+Plex+Sans:wght@500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-sans); font-size: 18px; line-height: 30px;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--gold-ink); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1, h2, h3, p { margin: 0; }
svg.i { width: 22px; height: 22px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 18px; height: 18px; }
svg.i.lg { width: 28px; height: 28px; }

/* ---------- Figures ---------- */
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums lining-nums; direction: ltr; unicode-bidi: isolate; display: inline-block; }
.fig { display: inline-flex; align-items: baseline; gap: var(--space-2); flex-wrap: nowrap; white-space: nowrap; }
.stat > .fig { align-self: flex-start; }
.fig .unit { font-family: var(--font-sans); font-size: 15px; font-weight: 600; color: var(--ink-muted); }
.fig-xl .num { font-size: 34px; line-height: 40px; font-weight: 700; }
.fig-lg .num { font-size: 26px; line-height: 32px; font-weight: 700; }
.fig-md .num { font-size: 18px; line-height: 26px; font-weight: 600; }
.t-in { color: var(--money-in); } .t-out { color: var(--money-out); } .t-gold { color: var(--gold-ink); }
.t-due { color: var(--due); } .t-overdue { color: var(--overdue); } .t-done { color: var(--done); } .t-pending { color: var(--pending); }
.t-muted { color: var(--ink-muted); }
.caption { font-size: 13px; line-height: 20px; font-weight: 500; color: var(--ink-muted); }
.label-t { font-size: 15px; line-height: 22px; font-weight: 600; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-inline-end: 1px solid var(--border);
  display: flex; flex-direction: column; padding: var(--space-4);
}
.brand { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-1) var(--space-4); text-decoration: none; color: var(--ink); }
.logo-tile { background: var(--logo-tile); border-radius: var(--radius-md); padding: 6px 8px; display: inline-flex; line-height: 0; }
.logo-tile img { height: 28px; width: auto; display: block; }
.brand-name { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name b { font-size: 15px; white-space: nowrap; }
.brand-name span { font-size: 12px; color: var(--ink-muted); font-family: var(--font-num); direction: ltr; text-align: end; }
.nav { display: flex; flex-direction: column; gap: 4px; margin-top: var(--space-2); }
.nav a {
  display: flex; align-items: center; gap: var(--space-3); min-height: 52px; padding: 0 var(--space-3);
  border-radius: var(--radius-md); color: var(--ink); text-decoration: none; font-size: 17px; font-weight: 600;
  border-inline-start: 4px solid transparent;
}
.nav a:hover { background: var(--surface-3); }
.nav a[aria-current="page"] { background: var(--gold-soft); border-inline-start-color: var(--gold); color: var(--ink); }
.nav a[aria-current="page"] svg { color: var(--gold); }
.nav a .lock { margin-inline-start: auto; color: var(--ink-muted); }
.side-foot { margin-top: auto; padding-top: var(--space-4); display: grid; gap: var(--space-2); }
.demo-flag { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--due); background: var(--due-soft); border-radius: var(--radius-sm); padding: 2px 10px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-5); min-height: 68px;
}
.topbar .crumb { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.topbar .crumb h1 { font-size: 21px; line-height: 30px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.top-brand { display: none; }
.icon-btn {
  position: relative; display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: var(--radius-md);
  background: transparent; border: 1px solid var(--border); cursor: pointer; color: var(--ink);
}
.icon-btn:hover { background: var(--surface-3); }
.badge-count {
  position: absolute; top: -4px; inset-inline-end: -4px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: var(--radius-pill);
  background: var(--overdue); color: #fff; font: 700 12px/22px var(--font-num); text-align: center;
}
[data-theme="dark"] .badge-count { color: #101114; }
.user-chip { display: inline-flex; align-items: center; gap: var(--space-2); height: 48px; padding: 0 var(--space-3); border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--gold-soft); color: var(--gold-ink); display: grid; place-items: center; font-weight: 700; font-size: 15px; }
.content { padding: var(--space-5); max-width: 1240px; width: 100%; margin: 0 auto; flex: 1; }
.demo-banner { display: flex; align-items: center; gap: var(--space-2); font-size: 14px; line-height: 22px; color: var(--ink-muted); padding: 8px var(--space-5); border-bottom: 1px dashed var(--border); }
.demo-banner b { color: var(--due); }

.bottom-nav { display: none; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); flex-wrap: wrap; }
.page-head h2 { font-size: 26px; line-height: 38px; }
.page-head p { color: var(--ink-muted); font-size: 16px; line-height: 26px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-muted); text-decoration: none; font-size: 15px; font-weight: 600; margin-bottom: var(--space-2); min-height: 32px; }
.back-link:hover { color: var(--ink); }
.section { margin-top: var(--space-6); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.section-title h3 { font-size: 18px; line-height: 28px; font-weight: 700; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-5); min-width: 0; }
.card.tight { padding: var(--space-4); }
.card h3 { font-size: 18px; line-height: 28px; font-weight: 700; }
.grid { display: grid; gap: var(--space-4); }
.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)); }
.stack { display: grid; gap: var(--space-3); }
.row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.between { justify-content: space-between; }

.stat { display: flex; flex-direction: column; gap: var(--space-2); }
.stat-head { display: flex; align-items: center; gap: var(--space-2); color: var(--ink-muted); font-size: 15px; font-weight: 600; line-height: 22px; }
.stat-head .ico { width: 36px; height: 36px; border-radius: var(--radius-md); display: grid; place-items: center; flex: none; }
.ico.in { background: var(--money-in-soft); color: var(--money-in); }
.ico.out { background: var(--money-out-soft); color: var(--money-out); }
.ico.gold { background: var(--gold-soft); color: var(--gold-ink); }
.ico.due { background: var(--due-soft); color: var(--due); }
.ico.overdue { background: var(--overdue-soft); color: var(--overdue); }
.ico.done { background: var(--done-soft); color: var(--done); }
.ico.pending { background: var(--pending-soft); color: var(--pending); }
.stat .sub { font-size: 14px; color: var(--ink-muted); line-height: 22px; }
.stat a.more { font-size: 15px; font-weight: 600; text-decoration: none; margin-top: auto; }

/* Karat breakdown — never summed across karats */
.karats { display: grid; gap: 6px; }
.karat-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 8px 12px; border-radius: var(--radius-md); background: var(--surface-2); }
.karat-chip { display: inline-flex; align-items: center; gap: 4px; padding: 0 10px; height: 28px; border: 1.5px solid var(--gold); color: var(--gold-ink); border-radius: var(--radius-sm); font-size: 14px; font-weight: 700; white-space: nowrap; }
.karat-chip .num { font-weight: 700; }
.karat-row .fig .num { font-size: 20px; line-height: 28px; font-weight: 700; color: var(--gold-ink); }
.karat-row.zero .fig .num { color: var(--ink-muted); font-weight: 600; }
.karat-note { font-size: 13px; color: var(--ink-muted); line-height: 20px; display: flex; gap: 6px; align-items: center; }

/* Ownership / location labels */
.own-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; padding: 2px 10px; border-radius: var(--radius-sm); line-height: 22px; white-space: nowrap; }
.own-tag.owned { background: var(--gold-soft); color: var(--gold-ink); }
.own-tag.consign { background: var(--pending-soft); color: var(--pending); border: 1px dashed var(--pending); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--control-h); padding: 0 var(--space-5); border-radius: var(--radius-md);
  border: 1.5px solid var(--border-control); background: var(--surface); color: var(--ink);
  font-size: 17px; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--gold-action); border-color: var(--gold-action); color: var(--on-gold); font-weight: 700; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.big { min-height: var(--action-h); font-size: 19px; padding: 0 var(--space-6); }
.btn.in { background: var(--money-in); border-color: var(--money-in); color: var(--surface); }
.btn.out { background: var(--money-out); border-color: var(--money-out); color: var(--surface); }
[data-theme="light"] .btn.in, [data-theme="light"] .btn.out { color: #fff; }
.btn.quiet { border-color: transparent; background: transparent; }
.btn.danger-q { color: var(--overdue); border-color: var(--overdue); }
.btn.sm { min-height: 44px; font-size: 15px; padding: 0 var(--space-4); }
.btn.block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; filter: none; }

.quick { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--space-3); }
.quick.q4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.quick.q3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.qa {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center;
  min-height: 104px; border-radius: var(--radius-lg); background: var(--surface); border: 1.5px solid var(--border);
  text-decoration: none; color: var(--ink); font-size: 18px; font-weight: 700; padding: var(--space-3);
}
.qa:hover { border-color: var(--gold); background: var(--gold-soft); }
.qa .ico { width: 48px; height: 48px; border-radius: var(--radius-md); display: grid; place-items: center; }
.qa .ico svg { width: 26px; height: 26px; }
.qa small { font-size: 13px; font-weight: 500; color: var(--ink-muted); line-height: 18px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 0 10px; height: 28px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 700; white-space: nowrap; }
.badge svg { width: 15px; height: 15px; }
.b-unpaid { background: var(--surface-2); color: var(--ink); border: 1px solid var(--border-control); }
.b-partial { background: var(--money-in-soft); color: var(--money-in); }
.b-paid { background: var(--done-soft); color: var(--done); }
.b-due { background: var(--due-soft); color: var(--due); }
.b-overdue { background: var(--overdue-soft); color: var(--overdue); }
.b-pending { background: var(--pending-soft); color: var(--pending); }
.b-gold { background: var(--gold-soft); color: var(--gold-ink); }
.b-reversed { background: var(--surface-2); color: var(--ink-muted); text-decoration: line-through; }
.b-in { background: var(--money-in-soft); color: var(--money-in); }
.b-out { background: var(--money-out-soft); color: var(--money-out); }

/* ---------- Notices ---------- */
.notice { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); font-size: 16px; line-height: 26px; border: 1px solid transparent; }
.notice svg { margin-top: 2px; }
.notice.pending { background: var(--pending-soft); color: var(--ink); border-color: var(--pending); }
.notice.pending svg { color: var(--pending); }
.notice.warn { background: var(--overdue-soft); border-color: var(--overdue); }
.notice.warn svg { color: var(--overdue); }
.notice.due { background: var(--due-soft); border-color: var(--due); }
.notice.due svg { color: var(--due); }
.notice.ok { background: var(--done-soft); border-color: var(--done); }
.notice.ok svg { color: var(--done); }
.notice.info { background: var(--surface-2); border-color: var(--border); }
.notice.config { background: transparent; border: 1.5px dashed var(--border-control); color: var(--ink-muted); }
.notice.config b { color: var(--ink); }
.pending-text { display: inline-flex; align-items: center; gap: 6px; color: var(--pending); font-weight: 700; }

/* ---------- Forms ---------- */
.form { display: grid; gap: var(--space-4); }
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .field > .flabel { font-size: 15px; line-height: 22px; font-weight: 600; }
.field .hint { font-size: 13px; line-height: 20px; color: var(--ink-muted); }
.field .err { font-size: 14px; line-height: 20px; color: var(--overdue); font-weight: 600; display: flex; gap: 6px; align-items: center; }
.input, .select, .textarea {
  width: 100%; min-height: var(--control-h); padding: 0 var(--space-4); border-radius: var(--radius-md);
  border: 1.5px solid var(--border-control); background: var(--surface); color: var(--ink); font-size: 18px;
}
.textarea { padding: var(--space-3) var(--space-4); min-height: 96px; resize: vertical; line-height: 28px; }
.input.num-in { font-family: var(--font-num); font-variant-numeric: tabular-nums; direction: ltr; text-align: right; font-size: 20px; font-weight: 600; }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--gold); }
.field.invalid .input, .field.invalid .select { border-color: var(--overdue); }
.with-unit { position: relative; }
.with-unit .u { position: absolute; inset-inline-end: var(--space-4); top: 50%; transform: translateY(-50%); color: var(--ink-muted); font-size: 15px; font-weight: 600; pointer-events: none; }
.with-unit .input { padding-inline-end: 72px; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-muted) 50%), linear-gradient(135deg, var(--ink-muted) 50%, transparent 50%); background-position: 18px 50%, 24px 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-inline-end: var(--space-4); padding-inline-start: 44px; }
.fields-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.fields-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; padding: 4px; background: var(--surface-2); border-radius: var(--radius-md); }
.seg button { min-height: 44px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font-size: 16px; font-weight: 600; color: var(--ink-muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--gold); }

.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.choice {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); text-align: start;
  padding: var(--space-5); min-height: 148px; border-radius: var(--radius-lg); border: 2px solid var(--border-control);
  background: var(--surface); cursor: pointer;
}
.choice:hover { border-color: var(--gold); }
.choice[aria-pressed="true"] { border-color: var(--gold); background: var(--gold-soft); box-shadow: inset 0 0 0 1px var(--gold); }
.choice .c-title { font-size: 22px; line-height: 32px; font-weight: 700; display: flex; align-items: center; gap: var(--space-2); }
.choice .c-desc { font-size: 16px; line-height: 26px; color: var(--ink-muted); }
.choice .tick { margin-inline-start: auto; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--border-control); display: grid; place-items: center; }
.choice[aria-pressed="true"] .tick { background: var(--gold-action); border-color: var(--gold-action); color: var(--on-gold); }
.choice .c-top { display: flex; width: 100%; align-items: center; gap: var(--space-3); }

/* ---------- Wizard ---------- */
.wizard { max-width: 820px; margin: 0 auto; }
.steps { display: flex; gap: var(--space-2); margin-bottom: var(--space-5); counter-reset: s; }
.steps li { flex: 1; list-style: none; display: flex; align-items: center; gap: var(--space-2); font-size: 15px; font-weight: 600; color: var(--ink-muted); padding-bottom: var(--space-2); border-bottom: 3px solid var(--border); min-width: 0; }
.steps li .n { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-family: var(--font-num); font-weight: 700; flex: none; }
.steps li.on { color: var(--ink); border-color: var(--gold); }
.steps li.on .n { background: var(--gold-action); color: var(--on-gold); }
.steps li.done { color: var(--ink); border-color: var(--gold); }
.steps li.done .n { background: var(--gold-soft); color: var(--gold-ink); }
.steps ol { display: contents; }
.steps .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-title { font-size: 21px; line-height: 32px; font-weight: 700; margin-bottom: var(--space-4); }
.wiz-actions { display: flex; gap: var(--space-3); justify-content: space-between; margin-top: var(--space-5); }
.wiz-actions .btn.primary { min-width: 200px; }

.review { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.review .r-head { padding: var(--space-4) var(--space-5); background: var(--surface-2); display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.review dl { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.review .r-row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-4); padding: 12px var(--space-5); border-top: 1px solid var(--border); }
.review dt { color: var(--ink-muted); font-size: 16px; }
.review dd { margin: 0; font-weight: 600; text-align: end; }
.review .r-total { background: var(--gold-soft); }
.review .r-total dt { color: var(--ink); font-weight: 700; }
.confirm-box { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-4); border: 1.5px solid var(--border-control); border-radius: var(--radius-md); margin-top: var(--space-4); cursor: pointer; font-size: 17px; line-height: 28px; }
.confirm-box input { width: 24px; height: 24px; accent-color: var(--gold-action); flex: none; margin-top: 2px; }

.success { text-align: center; padding: var(--space-6) var(--space-4); display: grid; gap: var(--space-3); justify-items: center; }
.success .big-ico { width: 72px; height: 72px; border-radius: 50%; background: var(--done-soft); color: var(--done); display: grid; place-items: center; }
.success .big-ico svg { width: 38px; height: 38px; stroke-width: 2.4; }

/* ---------- Tables / lists ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
table.t { width: 100%; border-collapse: collapse; font-size: 16px; line-height: 24px; }
table.t th { text-align: start; font-size: 14px; font-weight: 700; color: var(--ink-muted); background: var(--surface-2); padding: 12px var(--space-3); white-space: nowrap; }
table.t td { padding: 14px var(--space-3); border-top: 1px solid var(--border); vertical-align: middle; }
table.t td.n, table.t th.n { text-align: end; }
table.t tbody tr.link { cursor: pointer; }
table.t tbody tr.link:hover { background: var(--surface-3); }
table.t tfoot td { background: var(--surface-2); font-weight: 700; border-top: 2px solid var(--border-control); }
.cell-main { font-weight: 600; }
.cell-sub { font-size: 13px; color: var(--ink-muted); line-height: 20px; }

.list { display: grid; gap: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.li { display: flex; align-items: center; gap: var(--space-3); padding: 14px var(--space-4); border-top: 1px solid var(--border); text-decoration: none; color: var(--ink); min-height: 64px; }
.li:first-child { border-top: 0; }
a.li:hover, button.li:hover { background: var(--surface-3); }
button.li { width: 100%; background: transparent; border-inline: 0; border-bottom: 0; text-align: start; cursor: pointer; }
.li .grow { flex: 1; min-width: 0; }
.li .title { font-weight: 600; font-size: 17px; line-height: 26px; overflow: hidden; text-overflow: ellipsis; }
.li .meta { font-size: 14px; color: var(--ink-muted); line-height: 22px; }
.li .end { text-align: end; display: grid; justify-items: end; gap: 2px; }
.li.unread { background: color-mix(in srgb, var(--gold-soft) 60%, transparent); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--gold); flex: none; }

/* Mobile card version of tables */
.mcards { display: none; }
.mcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4); display: grid; gap: var(--space-2); text-decoration: none; color: var(--ink); }
.mcard .mrow { display: flex; justify-content: space-between; gap: var(--space-3); align-items: baseline; font-size: 15px; }
.mcard .mrow > span:first-child { color: var(--ink-muted); }

/* ---------- Filters / search ---------- */
.toolbar { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; margin-bottom: var(--space-4); }
.search { position: relative; flex: 1 1 260px; min-width: 0; }
.search svg { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-muted); }
.search .input { padding-inline-start: 46px; }
.chips { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.chip { min-height: 44px; padding: 0 var(--space-4); border-radius: var(--radius-pill); border: 1.5px solid var(--border-control); background: var(--surface); cursor: pointer; font-size: 15px; font-weight: 600; color: var(--ink); display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.chip[aria-pressed="true"] { background: var(--gold-soft); border-color: var(--gold); color: var(--ink); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: var(--space-5); overflow-x: auto; scrollbar-width: none; }
.tabs a, .tabs button { padding: 0 var(--space-4); min-height: 48px; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--ink-muted); font-weight: 600; font-size: 16px; border: 0; background: none; border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs [aria-selected="true"] { color: var(--ink); border-bottom-color: var(--gold); }

/* ---------- Person positions ---------- */
.positions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); }
.pos { border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--surface); padding: var(--space-4); display: grid; gap: var(--space-2); align-content: start; }
.pos .p-title { display: flex; align-items: center; gap: var(--space-2); font-size: 15px; font-weight: 700; }
.pos.money-us .p-title { color: var(--money-in); }
.pos.money-them .p-title { color: var(--money-out); }
.pos.gold-us .p-title, .pos.gold-them .p-title { color: var(--gold-ink); }
.roles { display: flex; gap: 6px; flex-wrap: wrap; }
.role { font-size: 13px; font-weight: 700; padding: 2px 10px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }

/* ---------- Notification panel / dialog ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 60; display: flex; justify-content: flex-start; }
.panel { width: min(440px, 100%); height: 100%; background: var(--surface); box-shadow: var(--shadow-pop); display: flex; flex-direction: column; border-inline-start: 1px solid var(--border); }
.panel-head { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4); border-bottom: 1px solid var(--border); }
.panel-body { overflow-y: auto; flex: 1; }
.dialog-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 70; display: grid; place-items: center; padding: var(--space-4); }
.dialog { width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); padding: var(--space-5); display: grid; gap: var(--space-4); border: 1px solid var(--border); }
.toast { position: fixed; bottom: 24px; inset-inline-start: 50%; transform: translateX(50%); z-index: 80; background: var(--surface); border: 1px solid var(--done); box-shadow: var(--shadow-pop); border-radius: var(--radius-md); padding: 12px 20px; display: flex; align-items: center; gap: 10px; font-weight: 600; max-width: calc(100vw - 32px); }
.toast svg { color: var(--done); }
.menu { position: absolute; top: 60px; inset-inline-end: 24px; z-index: 50; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); padding: var(--space-2); min-width: 260px; display: grid; gap: 2px; }
.menu button, .menu a { display: flex; align-items: center; gap: var(--space-3); min-height: 48px; padding: 0 var(--space-3); border: 0; background: none; border-radius: var(--radius-md); cursor: pointer; text-decoration: none; color: var(--ink); font-size: 16px; font-weight: 600; text-align: start; }
.menu button:hover, .menu a:hover { background: var(--surface-3); }
.menu .sep { height: 1px; background: var(--border); margin: 4px 0; }

/* ---------- Empty / lock ---------- */
.empty { text-align: center; padding: var(--space-7) var(--space-4); color: var(--ink-muted); display: grid; gap: var(--space-3); justify-items: center; }
.empty svg { width: 40px; height: 40px; color: var(--ink-muted); }
.empty b { color: var(--ink); font-size: 18px; }
.locked { border: 1.5px dashed var(--border-control); border-radius: var(--radius-lg); padding: var(--space-6); text-align: center; display: grid; gap: var(--space-3); justify-items: center; color: var(--ink-muted); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: var(--space-4); background: var(--bg); }
.login-card { width: min(460px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-6) var(--space-5); display: grid; gap: var(--space-4); }
.login-card .logo-tile { justify-self: center; padding: 14px 18px; }
.login-card .logo-tile img { height: 92px; }
.role-pick { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.role-pick .choice { min-height: 100px; padding: var(--space-4); }
.role-pick .c-title { font-size: 18px; line-height: 26px; }

/* ---------- Reports ---------- */
.report-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
.report-tile { display: flex; gap: var(--space-3); align-items: center; padding: var(--space-4); min-height: 84px; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--surface); text-decoration: none; color: var(--ink); font-weight: 700; font-size: 17px; }
.report-tile:hover { border-color: var(--gold); }
.report-tile small { display: block; font-weight: 500; font-size: 13px; color: var(--ink-muted); line-height: 20px; }
.print-head { display: none; }

/* ---------- Sticky action bar (mobile forms) ---------- */
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: var(--space-3) 0; border-top: 1px solid var(--border); margin-top: var(--space-4); z-index: 5; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .g4, .positions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .report-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .top-brand { display: inline-flex; }
  .top-brand img { height: 30px; }
  .topbar { padding: var(--space-2) var(--space-4); min-height: 60px; }
  .topbar .crumb h1 { font-size: 18px; }
  .content { padding-block: var(--space-4) 104px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .demo-banner { padding: 6px var(--space-4); font-size: 13px; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); position: fixed; bottom: 0; inset-inline: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--border); padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 60px; text-decoration: none; color: var(--ink-muted); font-size: 11.5px; font-weight: 600; border-radius: var(--radius-md); line-height: 16px; text-align: center; }
  .bottom-nav a[aria-current="page"] { color: var(--ink); background: var(--gold-soft); }
  .bottom-nav a[aria-current="page"] svg { color: var(--gold); }
  .user-chip .u-name { display: none; }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .menu { inset-inline-end: 12px; }
  .sticky-actions { bottom: 68px; }
}
@media (max-width: 640px) {
  body { font-size: 17px; }
  .g2, .g3, .g4, .positions, .fields-2, .fields-3, .report-grid { grid-template-columns: minmax(0, 1fr); }
  .quick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick .qa:last-child { grid-column: 1 / -1; }
  .quick.q4, .quick.q3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick.q4 .qa:last-child { grid-column: auto; }
  .demo-banner .long { display: none; }
  .qa { min-height: 92px; }
  .choices, .role-pick { grid-template-columns: minmax(0, 1fr); }
  .choice { min-height: 0; }
  .card { padding: var(--space-4); }
  .page-head h2 { font-size: 22px; line-height: 32px; }
  .fig-xl .num { font-size: 30px; line-height: 36px; }
  .steps .t { display: none; }
  .steps li { justify-content: center; }
  .wiz-actions { flex-direction: column-reverse; }
  .wiz-actions .btn { width: 100%; }
  .table-wrap.cards-on-mobile { display: none; }
  .mcards { display: grid; gap: var(--space-3); }
  .review .r-row { padding: 12px var(--space-4); flex-wrap: wrap; }
  .topbar .crumb h1 { font-size: 17px; }
  .user-chip { padding: 0 8px; }
  .page-head .btn { width: 100%; }
  .toolbar .chips { width: 100%; }
}

/* ---------- Print ---------- */
@media print {
  :root, [data-theme] { --bg: #fff; --surface: #fff; --surface-2: #f3f3f3; --ink: #000; --ink-muted: #444; --border: #bbb; --gold-ink: #6b4e0f; }
  body { background: #fff; font-size: 13px; line-height: 20px; }
  .sidebar, .topbar, .bottom-nav, .demo-banner, .no-print, .toolbar, .chips, .tabs, .btn { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; max-width: none; }
  .print-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #000; padding-bottom: 8px; margin-bottom: 12px; }
  .print-head .logo-tile img { height: 40px; }
  .card, .table-wrap, .pos { break-inside: avoid; border-color: #bbb; }
  .table-wrap.cards-on-mobile { display: block !important; }
  .mcards { display: none !important; }
  .fig-xl .num { font-size: 22px; line-height: 28px; }
  .fig-lg .num { font-size: 18px; }
  a { color: #000; text-decoration: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .chip, .choice, .qa, .nav a, .li { transition: background-color .15s ease, border-color .15s ease; }
}
.print-only { display: none; }
@media print { .print-only { display: block; margin-top: 16px; } .success .row { display: none; } }

/* =====================================================================
   MGS v2 — visual polish layer (same classes, same logic)
   Direction: "vault & ledger" — dark rail, calm elevated paper, gold hallmarks.
   ===================================================================== */
body { background: var(--bg); }
[data-theme="light"] body { background: linear-gradient(180deg, #f3f4f7 0, var(--bg) 320px); }

/* ---- Rail (sidebar) ---- */
.sidebar { background: var(--rail); border-inline-end: 0; color: var(--rail-ink); padding: 20px 16px; gap: 4px; }
.brand { padding: 4px 4px 20px; border-bottom: 1px solid var(--rail-line); margin-bottom: 12px; color: var(--rail-ink); }
.sidebar .logo-tile { background: transparent; padding: 0; }
.sidebar .logo-tile img { height: 34px; }
.brand-name b { color: var(--rail-ink); font-size: 14px; }
.brand-name span { color: var(--rail-muted); font-size: 11px; letter-spacing: .3px; }
.nav-label { font-size: 12px; font-weight: 600; color: var(--rail-muted); padding: 4px 12px; letter-spacing: .2px; }
.nav a { color: var(--rail-ink); border-inline-start: 3px solid transparent; font-size: 16px; min-height: 50px; border-radius: 10px; }
.nav a svg { color: var(--rail-muted); }
.nav a:hover { background: rgba(255,255,255,0.05); }
.nav a[aria-current="page"] { background: var(--rail-active); border-inline-start-color: var(--gold); color: #fff; }
.nav a[aria-current="page"] svg { color: #e2c25a; }
.nav a .lock { color: var(--rail-muted); }
.side-foot { border-top: 1px solid var(--rail-line); padding-top: 16px; }
.side-user { display: flex; align-items: center; gap: 10px; color: var(--rail-ink); }
.side-user .avatar { background: #2a2414; color: #e2c25a; width: 38px; height: 38px; font-size: 16px; border: 1px solid #5a4a1c; }
.side-user small { display: block; color: var(--rail-muted); font-size: 12px; line-height: 16px; }
.sidebar .demo-flag { background: rgba(255,163,77,0.12); color: #ffb366; font-weight: 600; }

/* ---- Top bar ---- */
.topbar { background: color-mix(in srgb, var(--bg) 88%, transparent); border-bottom: 1px solid var(--border); min-height: 72px; }
.crumb .sec-ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--gold-soft); color: var(--gold-ink); flex: none; }
.topbar .crumb h1 { font-size: 20px; }
.top-demo { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--due); background: var(--due-soft); border-radius: var(--radius-pill); padding: 3px 12px; white-space: nowrap; }
.demo-banner { display: none; }
.icon-btn, .user-chip { background: var(--surface); box-shadow: var(--shadow-card); }

/* ---- Paper: cards, lists, tables ---- */
.card, .list, .table-wrap, .pos, .review, .report-tile, .mcard, .qa { box-shadow: var(--shadow-card); }
.card { border-radius: 16px; }
.card .list { border: 0; box-shadow: none; background: transparent; border-radius: 0; margin-inline: -8px; }
.card .list .li { padding-inline: 8px; border-radius: 10px; border-top-color: var(--border); }
.li { gap: 14px; }
.li .ico, .li > .ico { flex: none; }
.li .end .fig .num { font-weight: 700; }
.list .li:hover { background: var(--surface-2); }
table.t tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
table.t th { font-size: 13px; letter-spacing: .2px; padding-block: 14px; }
table.t td { padding-block: 16px; }
.table-wrap { border-radius: 16px; }

/* ---- Headings ---- */
.page-head { align-items: flex-end; padding-bottom: 4px; }
.page-head h2 { font-size: 28px; line-height: 40px; letter-spacing: -.2px; text-wrap: balance; }
.page-head p { margin-top: 2px; }
.section-title h3, .card h3 { font-size: 17px; }
.stat-head { font-size: 14.5px; }
.stat-head .ico { width: 40px; height: 40px; border-radius: 12px; }
.stat .fig-lg .num { font-size: 28px; line-height: 34px; }

/* ---- Hallmark karat stamp ---- */
.karat-chip { height: 30px; padding: 0 3px 0 10px; gap: 6px; border: 1.5px solid var(--gold); background: var(--surface); border-radius: 7px; font-size: 13px; color: var(--gold-ink); }
.karat-chip .num { background: var(--gold-action); color: var(--on-gold); border-radius: 4px; padding: 0 7px; line-height: 22px; font-size: 14px; }
.karat-row { padding: 10px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid transparent; }
.karat-row .fig .num { font-size: 22px; }
.karat-row.zero { background: transparent; border: 1px dashed var(--border); }

/* ---- Buttons: gold leaf primary ---- */
.btn { border-radius: 12px; }
.btn.primary { background: linear-gradient(180deg, color-mix(in srgb, var(--gold-action) 90%, #fff) 0%, var(--gold-action) 55%, color-mix(in srgb, var(--gold-action) 88%, #000) 100%); box-shadow: inset 0 1px 0 rgba(255,255,255,0.28), 0 2px 8px color-mix(in srgb, var(--gold-action) 35%, transparent); border-color: color-mix(in srgb, var(--gold-action) 80%, #000); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.primary[disabled] { box-shadow: none; }
.btn.in, .btn.out { box-shadow: 0 2px 8px rgba(0,0,0,0.12); }

/* ---- Quick actions ---- */
.qa { border: 1px solid var(--border); border-radius: 16px; gap: 8px; min-height: 116px; }
.qa .ico { width: 54px; height: 54px; border-radius: 50%; }
.qa:hover { border-color: var(--gold); background: var(--surface); transform: translateY(-1px); }
.quick.q4 .qa, .quick.q3 .qa { flex-direction: row; justify-content: flex-start; text-align: start; min-height: 84px; padding: 16px 18px; }
.quick.q4 .qa small, .quick.q3 .qa small { display: block; }
.qa-txt { display: grid; gap: 0; }

/* ---- Dashboard hero band ---- */
.hero { position: relative; overflow: hidden; border-radius: 20px; padding: 24px 28px; background: var(--rail); color: var(--rail-ink); display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: center; margin-bottom: 20px; border: 1px solid #2c2617; }
.hero::after { content: ""; position: absolute; inset-inline-end: -40px; top: -60px; width: 260px; height: 260px; border-radius: 50%; border: 1px solid rgba(212,175,55,0.18); pointer-events: none; }
.hero::before { content: ""; position: absolute; inset-inline-end: 10px; top: -10px; width: 160px; height: 160px; border-radius: 50%; border: 1px solid rgba(212,175,55,0.12); pointer-events: none; }
.hero .h-greet b { display: block; font-size: 26px; line-height: 36px; color: #fff; }
.hero .h-greet span { color: var(--rail-muted); font-size: 15px; }
.hero .h-kpi { border-inline-start: 1px solid var(--rail-line); padding-inline-start: 24px; display: grid; gap: 4px; }
.hero .h-kpi .lbl { font-size: 14px; color: var(--rail-muted); display: flex; align-items: center; gap: 6px; }
.hero .h-kpi .fig .num { font-size: 30px; line-height: 38px; font-weight: 700; }
.hero .h-kpi .fig .unit { color: var(--rail-muted); }
.hero .k-in .num { color: #8dbcff; } .hero .k-out .num { color: #ff938a; }
.hero .h-kpi small { color: var(--rail-muted); font-size: 13px; }
.hero-alerts { display: flex; gap: 8px; flex-wrap: wrap; grid-column: 1 / -1; border-top: 1px solid var(--rail-line); padding-top: 16px; }
.hero-alerts a { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 999px; text-decoration: none; font-size: 14px; font-weight: 600; background: rgba(255,255,255,0.06); color: var(--rail-ink); border: 1px solid rgba(255,255,255,0.08); }
.hero-alerts a:hover { background: rgba(255,255,255,0.1); }
.hero-alerts .n { font-family: var(--font-num); font-weight: 700; }
.hero-alerts .od svg { color: #ff8a8a; } .hero-alerts .du svg { color: #ffb366; } .hero-alerts .pe svg { color: #c3a6ff; } .hero-alerts .nt svg { color: #e2c25a; }

/* ---- Money balance tiles ---- */
.bal { display: grid; gap: 10px; border-radius: 16px; padding: 22px 24px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-card); text-decoration: none; color: var(--ink); }
.bal.in { background: linear-gradient(180deg, var(--money-in-soft), var(--surface) 70%); }
.bal.out { background: linear-gradient(180deg, var(--money-out-soft), var(--surface) 70%); }
.bal .fig .num { font-size: 34px; line-height: 42px; font-weight: 700; }
.bal .b-foot { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--ink-muted); flex-wrap: wrap; }
.bal:hover { border-color: var(--border-control); }

/* ---- Person header & positions ---- */
.p-head { display: flex; gap: 18px; align-items: center; padding: 22px 24px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-card); flex-wrap: wrap; margin-bottom: 16px; }
.p-head .mono { width: 64px; height: 64px; border-radius: 16px; background: var(--rail); color: #e2c25a; display: grid; place-items: center; font-size: 28px; font-weight: 700; flex: none; border: 1px solid #3a3020; }
.p-head .who { flex: 1; min-width: 200px; display: grid; gap: 6px; }
.p-head h2 { font-size: 26px; line-height: 36px; }
.p-head .meta { color: var(--ink-muted); font-size: 15px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.positions { align-items: start; }
.pos { border-radius: 16px; padding: 18px 20px; gap: 10px; }
.pos .p-title { font-size: 14.5px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.pos .fig-lg .num { font-size: 28px; }
.pos.money-us { background: linear-gradient(180deg, var(--money-in-soft), var(--surface) 60%); }
.pos.money-them { background: linear-gradient(180deg, var(--money-out-soft), var(--surface) 60%); }
.pos.gold-us, .pos.gold-them { background: linear-gradient(180deg, var(--gold-soft), var(--surface) 60%); }

/* ---- Wizard ---- */
.wizard > .card { padding: 28px; }
.steps { gap: 0; }
.steps li { border-bottom: 0; flex-direction: column; gap: 6px; text-align: center; position: relative; padding-bottom: 0; }
.steps li::before { content: ""; position: absolute; top: 15px; inset-inline-start: 50%; width: 100%; height: 2px; background: var(--border); z-index: 0; }
.steps li:last-child::before { display: none; }
.steps li.done::before { background: var(--gold); }
.steps li .n { position: relative; z-index: 1; width: 32px; height: 32px; border: 2px solid var(--border); background: var(--surface); }
.steps li.on .n { border-color: var(--gold-action); box-shadow: 0 0 0 4px var(--gold-soft); }
.steps li.done .n { border-color: var(--gold); }
.choice { border-radius: 16px; border-width: 1.5px; }
.choice[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--gold-soft), inset 0 0 0 1px var(--gold); }
.review { border-radius: 16px; }
.review .r-total dd .fig .num { font-size: 24px; }
.confirm-box { border-radius: 12px; background: var(--surface-2); border-color: var(--border); }
.confirm-box:has(input:checked) { border-color: var(--done); background: var(--done-soft); }
.notice { border-radius: 12px; }
.input, .select, .textarea { border-radius: 12px; border-width: 1.5px; background: var(--surface); }
.input:hover, .select:hover { border-color: var(--gold); }
.seg { border-radius: 12px; }
.success .big-ico { width: 84px; height: 84px; box-shadow: 0 0 0 10px var(--done-soft); background: var(--done); color: var(--surface); }

/* ---- Login: split vault ---- */
.login { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding: 0; place-items: stretch; }
.login-side { background: var(--rail); color: var(--rail-ink); display: grid; place-items: center; align-content: center; gap: 20px; padding: 48px; text-align: center; position: relative; overflow: hidden; }
.login-side img { width: min(380px, 80%); height: auto; }
.login-side p { color: var(--rail-muted); max-width: 360px; font-size: 16px; line-height: 28px; }
.login-main { display: grid; place-items: center; padding: 32px 16px; }
.login-card { box-shadow: var(--shadow-card); border-radius: 20px; }
.login-card > .logo-tile { display: none; }

/* ---- Responsive for new pieces ---- */
@media (max-width: 1100px) { .hero { grid-template-columns: minmax(0,1fr) minmax(0,1fr); } .hero .h-greet { grid-column: 1 / -1; } .hero .h-kpi:nth-of-type(2) { border-inline-start: 0; padding-inline-start: 0; } }
@media (max-width: 900px) {
  .topbar { min-height: 64px; }
  .crumb .sec-ico { display: none; }
  .top-brand.logo-tile { background: var(--rail); padding: 6px 8px; }
  .top-demo { display: none; }
  .demo-banner { display: flex; }
  .bottom-nav { box-shadow: 0 -4px 16px rgba(0,0,0,0.08); }
  .login { grid-template-columns: minmax(0,1fr); }
  .login-side { padding: 28px 16px; }
  .login-side img { width: 220px; }
  .login-side p { display: none; }
}
@media (max-width: 640px) {
  .hero { padding: 20px; gap: 16px; border-radius: 16px; }
  .hero .h-kpi { border-inline-start: 0; padding-inline-start: 0; }
  .hero .h-kpi .fig .num { font-size: 24px; }
  .hero .h-greet b { font-size: 22px; }
  .bal .fig .num { font-size: 28px; }
  .p-head { padding: 18px; }
  .p-head .mono { width: 52px; height: 52px; font-size: 22px; }
  .quick.q4 .qa, .quick.q3 .qa { flex-direction: column; text-align: center; justify-content: center; }
  .wizard > .card { padding: 18px; }
  .steps li .t { display: none; }
}
@media print { .hero { background: #fff; color: #000; border: 1px solid #999; } .hero * { color: #000 !important; } .sidebar { display: none !important; } }
@media (prefers-reduced-motion: reduce) { .qa:hover { transform: none; } }
.card.stack, .stack { align-content: start; }
.grid.g2 > .card.stack .more, .grid.g2 > .card.stack a.more { margin-top: 4px; }
@media (max-width: 480px) { .topbar .crumb { display: none; } .topbar .spacer { flex: 1; } }
.pos .karat-row { flex-wrap: wrap; row-gap: 4px; }
.card .sticky-actions, .wizard .wiz-actions { background: transparent; }
.login-side img, .sidebar .logo-tile img { mix-blend-mode: lighten; }

/* ---- Lines, company split, bag/daily ---- */
.lines { display: grid; gap: 12px; }
.line-row { border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; background: var(--surface-2); }
.line-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.line-no { width: 26px; height: 26px; border-radius: 50%; background: var(--gold-action); color: var(--on-gold); display: grid; place-items: center; font: 700 13px var(--font-num); }
.line-mk { margin-inline-start: auto; font-size: 14px; color: var(--ink-muted); }
.line-mk .fig .num { font-size: 15px; }
.icon-btn.sm-icon { width: 40px; height: 40px; }
.line-grid { display: grid; grid-template-columns: 1.1fr 1.3fr 1fr 1fr 1fr; gap: 12px; align-items: start; }
.line-grid .seg button { min-height: 52px; }
.add-line { margin-top: 12px; border-style: dashed; }
.co-tag { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 6px; background: var(--surface-3); color: var(--ink); font-size: 13px; font-weight: 700; white-space: nowrap; }
.co-line { width: 100%; font-size: 12.5px; color: var(--ink-muted); line-height: 18px; }
.karat-row.has-co { flex-wrap: wrap; row-gap: 2px; }
.split { display: grid; gap: 8px; }
.split-row { display: grid; grid-template-columns: 150px 110px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); }
.split-row .err { grid-column: 1 / -1; }
.split-row .input { min-height: 46px; }
.place { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.place-opt { display: flex; gap: 12px; align-items: center; text-align: start; padding: 14px 16px; border-radius: 14px; border: 1.5px solid var(--border-control); background: var(--surface); cursor: pointer; }
.place-opt small { display: block; color: var(--ink-muted); font-size: 13px; line-height: 18px; }
.place-opt b { font-size: 17px; }
.place-opt[aria-pressed="true"] { border-color: var(--gold); background: var(--gold-soft); box-shadow: 0 0 0 3px var(--gold-soft); }
.place-opt svg { color: var(--gold-ink); }
.karat-totals { display: flex; flex-wrap: wrap; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--gold-soft); margin-top: 12px; align-items: center; }
.daily-badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 6px; background: var(--money-in-soft); color: var(--money-in); font-size: 13px; font-weight: 700; }
@media (max-width: 1100px) { .line-grid { grid-template-columns: 1fr 1fr; } .line-grid > .field:nth-child(2) { grid-column: 1 / -1; } }
@media (max-width: 640px) { .line-grid { grid-template-columns: 1fr 1fr; } .line-grid > .field:first-child, .line-grid > .field:nth-child(2), .line-grid > .field:nth-child(3) { grid-column: 1 / -1; } .split-row { grid-template-columns: 1fr auto; } .split-row .with-unit { grid-column: 1 / -1; } }
/* numbers are LTR inside RTL: keep the unit on the left and pad that side */
.with-unit .input.num-in { padding-left: 64px; padding-right: 14px; }
.with-unit .u { inset-inline-end: 12px; font-size: 13px; }
.wizard.wide { max-width: 1120px; }
.line-grid .with-unit .input.num-in { padding-left: 52px; }
/* live mode (PHP backend): no demo labels */
[data-mode="live"] .demo-only, [data-mode="live"] .demo-flag { display: none !important; }
@media (max-width: 640px) { .karat-row { flex-wrap: wrap; row-gap: 4px; } .karat-row .caption { flex-basis: 100%; } }
/* automatic tahwifa equivalents */
.eq { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--ink-muted); background: var(--surface-3); border-radius: 6px; padding: 1px 8px; white-space: nowrap; margin-inline-start: 6px; }
.eq .num { font-weight: 700; color: var(--gold-ink); }
.karat-row .eq { margin-inline-start: auto; }
.karat-row.eq-total { background: var(--gold-soft); border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent); }
.eq-label { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; color: var(--gold-ink); }
td .eq { display: block; width: max-content; margin: 2px 0 0 auto; }
.end .eq { margin: 0; }
/* login */
.with-icon { position: relative; }
.with-icon > svg { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-muted); pointer-events: none; }
.with-icon .input { padding-inline-start: 46px; }
.input.ltr-in { direction: ltr; text-align: right; font-family: var(--font-num); }
.with-icon .pw-toggle { position: absolute; inset-inline-end: 8px; top: 50%; transform: translateY(-50%); border: 0; background: var(--surface-2); color: var(--ink); border-radius: 8px; padding: 6px 12px; font-size: 13px; font-weight: 700; cursor: pointer; }
.with-icon .input[name=password] { padding-inline-end: 84px; }
.hint.caps { color: var(--due); display: flex; gap: 6px; align-items: center; font-weight: 600; }
.demo-accounts { display: grid; gap: 8px; padding: 12px; border-radius: 12px; border: 1px dashed var(--border-control); }
.demo-accounts .chip { min-height: 38px; font-size: 13px; }
/* database viewer */
.db-table summary { display: flex; gap: 12px; align-items: center; cursor: pointer; list-style: none; flex-wrap: wrap; min-height: 44px; }
.db-table summary::-webkit-details-marker { display: none; }
.db-table summary .meta { flex: 1; color: var(--ink-muted); font-size: 14px; min-width: 160px; }
.db-name { font-weight: 700; font-size: 17px; color: var(--gold-ink); direction: ltr; }
.db-cols { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; direction: ltr; justify-content: flex-end; }
.db-col { display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; }
.db-col.pk { border-color: var(--gold); background: var(--gold-soft); }
.db-col.fk { border-style: dashed; border-color: var(--border-control); }
table.db-rows { font-size: 13px; direction: ltr; }
table.db-rows th, table.db-rows td { text-align: left; white-space: nowrap; padding: 8px 10px; }
.karat-row { flex-wrap: wrap; row-gap: 4px; min-width: 0; }
.karat-row .eq { max-width: 100%; }
.grid > * { min-width: 0; }
.hint.caps[hidden] { display: none; }

/* ---------- التحييفة تحت كل وزن ---------- */
.wk { display: inline-flex; flex-direction: column; align-items: flex-end; line-height: 1.15; vertical-align: middle; gap: 2px; }
td .wk, .n .wk { align-items: flex-end; }
.wk .eq-u { font-size: 12px; font-weight: 600; color: var(--ink-muted); white-space: nowrap; font-variant-numeric: tabular-nums; background: var(--surface-3); border-radius: 6px; padding: 0 6px; }
.wk .eq-u::before { content: "تحييفة "; font-weight: 500; }
.wk .eq-u small { font-size: 10.5px; font-weight: 700; color: var(--gold-ink); margin-inline-start: 2px; }
.karat-row .wk { margin-inline-start: auto; }
.fig-xl + .eq-u, .wk .fig-xl ~ .eq-u { font-size: 13px; }
td .wk .eq-u::before { content: "≈ "; }
/* مصنعية بالجرام / جملة */
.mk-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.mk-switch { min-height: 0; }
.mk-switch button { min-height: 32px; padding: 4px 12px; font-size: 14px; }

/* ---------- Charts ---------- */
.chart { margin: 0; gap: 10px; }
.chart-t { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; flex-wrap: wrap; }
.chart-t .legend { margin-inline-start: auto; font-weight: 500; font-size: 13px; color: var(--ink-muted); display: inline-flex; gap: 6px; align-items: center; }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.lg.in { background: var(--money-in); } .lg.out { background: var(--overdue); }
.bar-row { display: grid; grid-template-columns: minmax(90px, 30%) 1fr auto; align-items: center; gap: 10px; font-size: 14px; }
.bar-l { font-weight: 600; display: flex; flex-direction: column; min-width: 0; }
.bar-l small { font-weight: 500; color: var(--ink-muted); font-size: 12px; }
.bar-l .eq-u { font-size: 11px; color: var(--ink-muted); }
.bar-track { height: 14px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar { display: block; height: 100%; border-radius: 999px; background: var(--gold); }
.bar.done { background: var(--done); } .bar.out { background: var(--overdue); opacity: .85; } .bar.neg { background: var(--overdue); } .bar.in { background: var(--money-in); }
.bar-v { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; font-size: 14px; }
.cols { display: flex; align-items: flex-end; gap: 6px; height: 190px; overflow-x: auto; padding-top: 18px; }
.col { flex: 1 0 34px; display: flex; flex-direction: column; align-items: center; height: 100%; gap: 4px; }
.col-bar { flex: 1; width: 70%; max-width: 38px; display: flex; align-items: flex-end; gap: 2px; }
.col-bar > span { flex: 1; border-radius: 6px 6px 2px 2px; min-height: 0; }
.col-bar .gold { background: var(--gold); } .col-bar .done { background: var(--done); } .col-bar .in { background: var(--money-in); } .col-bar .out, .col-bar .neg { background: var(--overdue); opacity: .85; }
.col-v { font-size: 11px; font-weight: 700; color: var(--ink-muted); white-space: nowrap; min-height: 14px; }
.col-l { font-size: 11px; color: var(--ink-muted); white-space: nowrap; }
@media (max-width: 640px) { .bar-row { grid-template-columns: minmax(70px, 34%) 1fr auto; font-size: 13px; } }
/* الحساب القديم */
.old-t td, .old-t th { white-space: nowrap; }
.old-t td:nth-child(2), .old-t th:nth-child(2) { white-space: normal; min-width: 220px; }
/* زرار الخروج — ظاهر على طول جنب اسم المستخدم */
.logout-btn { height: 48px; gap: 6px; }
@media (max-width: 640px) { .logout-btn span { display: none; } .logout-btn { width: 48px; padding: 0; justify-content: center; } }

/* ===== الشكل البسيط ===== */
.home-acts { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--space-3); }
.home-acts.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.home-acts.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.home-act { display: flex; flex-direction: column; gap: 8px; justify-content: center; min-height: 128px; padding: var(--space-4); border-radius: var(--radius-lg); background: var(--surface); border: 1.5px solid var(--border); box-shadow: var(--shadow-card); color: var(--ink); text-decoration: none; transition: border-color .15s, background .15s; }
.home-act:hover { border-color: var(--gold); background: var(--gold-soft); }
.home-act b { font-size: 21px; line-height: 30px; }
.home-act small { font-size: 14px; color: var(--ink-muted); line-height: 20px; }
.ha-ico { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; }
.ha-ico.in { background: var(--money-in-soft); color: var(--money-in); }
.ha-ico.out { background: var(--money-out-soft); color: var(--money-out); }
.ha-ico.gold { background: var(--gold-soft); color: var(--gold-ink); }
.ha-ico.mu { background: var(--surface-2); color: var(--ink); }
.hero.simple { grid-template-columns: 1.2fr 1fr 1fr; }
.hk-row { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.hk b { font-family: var(--font-num); font-size: 28px; line-height: 36px; font-weight: 700; color: var(--gold-ink); direction: ltr; unicode-bidi: isolate; display: inline-block; }
.hk small { font-size: 14px; opacity: .75; }
.big-choice { display: flex !important; flex-direction: row !important; align-items: center; gap: 16px; padding: 18px !important; min-height: 0 !important; text-decoration: none; color: var(--ink); }
.big-choice.rec { border-color: var(--gold); background: var(--gold-soft); }
.big-choice.off { opacity: .55; cursor: not-allowed; }
.bc-ico { width: 56px; height: 56px; flex: none; border-radius: 14px; display: grid; place-items: center; background: var(--surface-2); }
.bc-ico.in { color: var(--money-in); } .bc-ico.out { color: var(--money-out); } .bc-ico.gold { color: var(--gold-ink); } .bc-ico.mu { color: var(--ink-muted); }
.bc-txt { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.bc-txt b { font-size: 20px; line-height: 30px; }
.bc-txt > span { font-size: 15px; color: var(--ink-muted); line-height: 22px; }
.who-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-radius: var(--radius-md); background: var(--surface-2); font-size: 16px; }
.who-bar b { font-size: 18px; }
.pick-list .li[hidden] { display: none; }
.p-bal { background: var(--rail); color: var(--rail-ink, #f5f5f5); border-radius: var(--radius-lg); padding: var(--space-4); display: flex; flex-direction: column; gap: 10px; }
.pb-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; font-size: 17px; }
.pb-row + .pb-row { border-top: 1px solid var(--rail-line, #2e3137); padding-top: 10px; }
.pb-k { display: inline-flex; align-items: center; gap: 8px; margin-inline-start: 14px; }
@media (max-width: 900px) { .home-acts { grid-template-columns: repeat(2, minmax(0, 1fr)); } .home-acts:not(.two):not(.three) > .home-act:last-child:nth-child(odd) { grid-column: 1 / -1; min-height: 72px; flex-direction: row; align-items: center; } .hero.simple { grid-template-columns: 1fr 1fr; } .hero.simple .h-greet { grid-column: 1 / -1; } }
@media (max-width: 640px) { .home-act { min-height: 112px; } .home-acts.three { grid-template-columns: repeat(3, minmax(0, 1fr)); } .home-acts.three .home-act { padding: 12px; } .home-acts.three .home-act small { display: none; } .hk b { font-size: 22px; } }
