/* Simin UI kit — brand palette from «سند تم رنگی سیمین». RTL first, simple for non-expert staff. */
@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-Bold.woff2) format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --gold: #B9822F; --gold-light: #D4A553; --gold-glow: #EBCB88;
  --bronze: #925E18; --bronze-dark: #653B0C;
  --petrol: #044264; --petrol-dark: #022A40; --petrol-soft: #295C73;
  --cream: #EFE6D4; --cream-light: #F7F2E7; --white: #FFFFFF;
  --text: #2B2B2B; --text-2: #5C5A55; --border: #DDD2BC; --disabled: #A9A398;
  --ok: #276B43; --warn: #A86B00; --err: #B3261E; --info: #1E5F8C;
  --ok-bg: #E6F2EA; --warn-bg: #FBF1DC; --err-bg: #FBE7E5; --info-bg: #E4EEF6;
  --radius: 10px; --shadow: 0 1px 3px rgba(2,42,64,.08), 0 4px 14px rgba(2,42,64,.06);
}
* { box-sizing: border-box; }
html { direction: rtl; }
body { margin: 0; font-family: Vazirmatn, Tahoma, sans-serif; background: var(--cream-light); color: var(--text); font-size: 15px; line-height: 1.7; }
a { color: var(--bronze); }
h1, h2, h3 { color: var(--petrol-dark); line-height: 1.4; margin: 0 0 .6em; }
h1 { font-size: 1.45rem; }
h1:focus { outline: none; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }

/* Shell */
.topbar { background: var(--petrol); color: var(--white); display: flex; align-items: center; gap: 16px; padding: 8px 20px; position: sticky; top: 0; z-index: 10; }
.topbar .brand { display: flex; align-items: center; gap: 10px; color: var(--white); text-decoration: none; font-weight: 700; }
.topbar .brand img { width: 38px; height: 38px; border-radius: 50%; background: var(--cream); }
.topbar .brand small { display: block; font-weight: 400; color: var(--gold-glow); font-size: .75rem; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: .85rem; color: var(--cream); }
.topbar form { margin: 0; }
.topbar .link-btn { background: none; border: 1px solid rgba(255,255,255,.35); color: var(--white); border-radius: 8px; padding: 4px 12px; font: inherit; cursor: pointer; }
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 54px); }
.side { background: var(--white); border-left: 1px solid var(--border); padding: 16px 10px; }
.side a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--petrol-dark); text-decoration: none; margin-bottom: 2px; }
.side a:hover, .side a.active { background: var(--cream); }
.side img.side-logo { display: block; margin: 0 12px 12px; }
.side .sep { border-top: 1px solid var(--border); margin: 10px 4px; }
.main { padding: 22px 26px; max-width: 1180px; width: 100%; min-width: 0; overflow-wrap: anywhere; }
.main > *, .card, .split > *, .fields > *, .grid > * { min-width: 0; }
.main img, .main svg, .main video { max-width: 100%; }
.table-wrap { overflow-x: auto; max-width: 100%; }
@media (max-width: 1100px) { .shell { grid-template-columns: 180px 1fr; } .main { padding: 18px 16px; } .split { grid-template-columns: 1fr; } }
@media (max-width: 860px) { .shell { grid-template-columns: 1fr; } .side { display: flex; overflow-x: auto; border: 0; border-bottom: 1px solid var(--border); padding: 6px; } .side a { white-space: nowrap; } .side .sep { display: none; } .main { padding: 16px; } }

/* Cards & layout */
.card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr)); }
/* Dashboard stat tiles: all tiles share one row on desktop and wrap evenly on small screens */
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }
.muted { color: var(--text-2); font-size: .88rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }

/* Stat tiles */
.stat { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: inherit; display: block; }
.stat { min-width: 0; }
.stat b { display: block; font-size: 1.6rem; color: var(--petrol); }
.stat:hover { border-color: var(--gold); }
.stat span { color: var(--text-2); font-size: .88rem; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-weight: 500; color: var(--petrol-dark); font-size: .92rem; }
.field label .req { color: var(--err); margin-inline-start: 2px; }
.field .hint { color: var(--text-2); font-size: .8rem; }
.field .err { color: var(--err); font-size: .82rem; }
input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=file]), select, textarea {
  font: inherit; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--white); color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold-light); outline-offset: 0; border-color: var(--gold); }
input.ltr { direction: ltr; text-align: right; }
.invalid input, input.invalid { border-color: var(--err); background: var(--err-bg); }
.fields { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); }
.amount-words { color: var(--bronze); font-size: .82rem; }

/* Buttons */
.btn { font: inherit; font-weight: 500; border-radius: 8px; padding: 9px 18px; border: 1px solid var(--border); background: var(--white); color: var(--petrol-dark); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--gold); }
.btn-primary { background: var(--gold); color: var(--petrol-dark); border-color: var(--gold); }
.btn-primary:hover { background: var(--gold-light); }
.btn-secondary { background: var(--petrol); color: var(--white); border-color: var(--petrol); }
.btn-secondary:hover { background: var(--petrol-soft); }
.btn-ghost { background: var(--white); border-color: var(--border); color: var(--petrol-dark); }
.btn-danger { background: var(--white); border-color: var(--err); color: var(--err); }
.btn-big { font-size: 1.05rem; padding: 14px 24px; }
.btn[disabled] { background: var(--cream); color: var(--disabled); cursor: not-allowed; border-color: var(--border); }

/* Messages & pills */
.msg { border-radius: 8px; padding: 10px 14px; margin: 10px 0; border: 1px solid; }
.msg-ok { background: var(--ok-bg); border-color: #b8d9c4; color: var(--ok); }
.msg-warn { background: var(--warn-bg); border-color: #ecd49c; color: var(--warn); }
.msg-err { background: var(--err-bg); border-color: #efbab5; color: var(--err); }
.msg-info { background: var(--info-bg); border-color: #b9d0e4; color: var(--info); }
.pill { display: inline-block; border-radius: 999px; padding: 1px 10px; font-size: .8rem; background: var(--cream); color: var(--petrol-dark); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.pill-ok { background: var(--ok-bg); color: var(--ok); } .pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-err { background: var(--err-bg); color: var(--err); } .pill-info { background: var(--info-bg); color: var(--info); }

/* Tables */
table.tbl { width: 100%; border-collapse: collapse; background: var(--white); }
.tbl th { text-align: right; font-weight: 500; color: var(--text-2); font-size: .85rem; border-bottom: 2px solid var(--border); padding: 8px 10px; }
.tbl td { border-bottom: 1px solid var(--border); padding: 9px 10px; vertical-align: middle; }
.tbl tr:hover td { background: #fcf9f2; }
.num { direction: ltr; unicode-bidi: isolate; display: inline-block; }
td.num, th.num, .table td.num, .table th.num { display: table-cell; text-align: right; }
dd.num { display: block; text-align: right; }

/* Steps (sale wizard) */
.steps { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; padding: 0; list-style: none; }
.steps li { padding: 5px 12px; border-radius: 999px; background: var(--white); border: 1px solid var(--border); font-size: .82rem; color: var(--text-2); }
.steps li.done { background: var(--ok-bg); border-color: #b8d9c4; color: var(--ok); }
.steps li.done::before { content: "✓ "; }
.steps li.on { background: var(--petrol); border-color: var(--petrol); color: var(--white); }

/* Method cards (sale «روش خرید»): clean radio cards of equal height */
.methods { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); align-items: stretch; }
.method-card { display: flex; flex-direction: column; gap: 6px; border: 2px solid var(--border); border-radius: var(--radius); padding: 16px; background: var(--white); min-width: 0; }
.method-card:has(input[type=radio]:checked) { border-color: var(--gold); background: #fffaf0; box-shadow: 0 0 0 2px var(--gold-glow); }
.method-card .method-head { display: flex; align-items: center; gap: 10px; cursor: pointer; margin: 0; }
.method-card .method-head input[type=radio] { width: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--gold); }
.method-card .method-head h3 { margin: 0; }
.method-card p { margin: 0; }
.method-card .sub-options { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.method-card .sub-options label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.method-card.off { opacity: .6; background: var(--cream-light); }
.method-card.off .method-head { cursor: not-allowed; }
.method-card .why-off { color: var(--warn); font-size: .85rem; }

/* Auth pages */
.auth { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, var(--cream-light), var(--cream)); padding: 20px; }
.auth .card { width: 100%; max-width: 400px; }
.auth .logo { display: block; width: 84px; height: 84px; margin: 0 auto 8px; border-radius: 50%; }
.auth h1 { text-align: center; font-size: 1.15rem; }
.auth .sub { text-align: center; color: var(--text-2); font-size: .85rem; margin-top: -6px; margin-bottom: 14px; }
.code-input { letter-spacing: .6em; text-align: center; font-size: 1.4rem; direction: ltr; }

@media print { .topbar, .side, .no-print { display: none !important; } .shell { display: block; } .card { box-shadow: none; } }

/* Inquiries (الف۵) */
.providers { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.provider { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--white); border-radius: var(--radius); padding: 8px 14px; cursor: pointer; font: inherit; }
.provider:hover { border-color: var(--gold); }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: middle; }
.health { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.health-green { background: #2e9b57; } .health-yellow { background: #e0a400; } .health-red { background: #c0392b; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: 6px 16px; margin: 10px 0; }
.facts dt { color: var(--muted); font-size: .85rem; } .facts dd { margin: 0; font-weight: 500; }
.small { font-size: .85rem; }
.btn-sm { padding: 4px 10px; font-size: .85rem; }

/* Limit bars (الف۸) */
.bar { height: 8px; border-radius: 4px; background: var(--cream); margin: 6px 0; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--petrol); }
.bar.over i { background: var(--err); }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 9px 12px; text-align: start; vertical-align: middle; border-bottom: 1px solid var(--border); }
.table thead th { font-weight: 500; color: var(--muted); font-size: .85rem; background: #fbf8f1; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot th { border-top: 2px solid var(--border); border-bottom: 0; }
.table input:not([type=file]), .table select { min-width: 140px; }

/* Printable documents (الف۱۳ / الف۱۴) */
.print-page { max-width: 820px; margin: 24px auto; padding: 0 16px; }
.doc { background: var(--white); padding: 24px; border: 1px solid var(--line, #ddd); border-radius: 8px; }
.doc h1 { margin: 0 0 4px; font-size: 1.4rem; }
.doc h2 { font-size: 1.05rem; margin: 20px 0 8px; }
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; border-bottom: 2px solid var(--line, #ddd); padding-bottom: 12px; }
.qr svg { width: 110px; height: 110px; display: block; }
.signs { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-top: 40px; }
.signs > div { border-top: 1px dashed #888; padding-top: 6px; min-height: 70px; text-align: center; color: #555; }
.doc footer { margin-top: 24px; }
@media print {
  .noprint { display: none !important; }
  body { background: #fff !important; }
  .print-page { margin: 0; max-width: none; }
  .doc { border: 0; padding: 0; }
}

/* Lender tabs (الف۱۱) */
.tabsbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabsbar a { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--white); text-decoration: none; color: inherit; display: inline-flex; gap: 6px; align-items: center; }
.tabsbar a.on { border-color: var(--primary, #0b3c5d); box-shadow: inset 0 -3px 0 var(--primary, #0b3c5d); }
.split { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; align-items: start; }
.split > .card { margin: 0; }
.split { grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr); }
.balance { display: grid; gap: 6px; margin: 10px 0 0; }
.balance > div { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; border-bottom: 1px dashed var(--line, #e5e7eb); padding-bottom: 4px; }
.balance dt { color: var(--muted); font-size: .85rem; } .balance dd { margin: 0; font-weight: 500; white-space: nowrap; }
@media (max-width: 760px) { .split { grid-template-columns: 1fr; } }

/* File timeline (form ب۱) */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0 8px 0; border-bottom: 1px solid var(--line, #e5e0d5); }
.timeline li:last-child { border-bottom: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Support centre (ج۱۲) and inbox (و۹) */
.thread { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.bubble { max-width: 82%; padding: 10px 14px; border-radius: 12px; background: var(--white); border: 1px solid var(--border); align-self: flex-start; }
.bubble.hq { align-self: flex-end; background: var(--info-bg); border-color: #c8d9e8; }
.bubble .meta { font-size: .78rem; color: var(--text-2); margin-bottom: 4px; }
.bubble .text, .article-body { white-space: pre-line; overflow-wrap: anywhere; }
.bell { color: var(--white); text-decoration: none; position: relative; font-size: 1.1rem; padding: 2px 6px; }
.bell .count { position: absolute; top: -4px; left: -6px; background: var(--err); color: #fff; border-radius: 999px; font-size: .7rem; padding: 0 6px; line-height: 1.5; }
.help-list { list-style: none; margin: 0; padding: 0; }
.help-list li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.help-list li:last-child { border-bottom: 0; }
.plan-box { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }

/* Password show/hide */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { width: 100%; padding-left: 44px; }
.pw-eye { position: absolute; left: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; cursor: pointer; font-size: 1.1rem; opacity: .55; padding: 4px 6px; line-height: 1; }
.pw-eye.on, .pw-eye:hover, .pw-eye:focus-visible { opacity: 1; }

/* Persian date picker (data-date): type or pick */
.date-wrap { position: relative; display: block; }
.date-wrap input { width: 100%; padding-left: 44px; }
.date-btn { position: absolute; left: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; cursor: pointer; font-size: 1.05rem; padding: 4px 6px; line-height: 1; }
.cal { position: absolute; z-index: 30; top: calc(100% + 4px); right: 0; width: 280px; background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px; direction: rtl; }
.cal-head { display: flex; gap: 4px; align-items: center; margin-bottom: 6px; }
.cal-head select { flex: 1; min-width: 0; padding: 4px; font: inherit; border: 1px solid var(--border); border-radius: 6px; }
.cal-head button, .cal-foot button { border: 1px solid var(--border); background: var(--cream-light); border-radius: 6px; cursor: pointer; font: inherit; padding: 2px 10px; }
.cal-week, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal-week span { font-size: .75rem; color: var(--text-2); }
.cal-grid button { border: 0; background: none; border-radius: 6px; padding: 5px 0; cursor: pointer; font: inherit; }
.cal-grid button:hover { background: var(--cream); }
.cal-grid button.now { outline: 1px solid var(--gold); }
.cal-grid button.on { background: var(--petrol); color: var(--white); }
.cal-foot { display: flex; justify-content: space-between; margin-top: 6px; }
.table .date-wrap input { min-width: 150px; }

/* Sales site (forms هـ) */
.site { max-width: 980px; margin: 0 auto; padding: 20px 16px 40px; }
.site-nav { display: flex; gap: 16px; } .site-nav a { color: var(--cream); text-decoration: none; } .site-nav a:hover { color: var(--gold-glow); }
.site-foot { text-align: center; color: var(--text-2); font-size: .8rem; padding: 18px; }
.choice-group { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 10px; margin: 8px 0 14px; }
.choice-group label { border: 1.5px solid var(--border); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; background: var(--white); display: block; }
.choice-group label:has(input:checked) { border-color: var(--gold); background: #fffaf0; box-shadow: 0 0 0 2px var(--gold-glow); }
.choice-group input { margin-inline-end: 6px; } .choice-group small { display: block; color: var(--text-2); }
.quote-sum { position: sticky; bottom: 0; background: var(--white); border-top: 3px solid var(--gold); }
.quote-sum .total { font-size: 1.25rem; color: var(--petrol-dark); font-weight: 700; }
.invoice { background: var(--white); border: 1px solid var(--border); padding: 24px; border-radius: var(--radius); }
.invoice .head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-bottom: 2px solid var(--petrol); padding-bottom: 10px; margin-bottom: 12px; }
@media print { .site-top, .site-foot { display: none !important; } .site { max-width: none; padding: 0; } .invoice { border: 0; } }
[hidden] { display: none !important; }
@media (max-width: 700px) { .quote-sum { position: static; } .site-top .brand small { display: none; } }

/* Delivery checklist (form و۸) */
.task-row{border-top:1px solid var(--line, #e5e0d5);padding:10px 0 6px}
.task-row:first-of-type{border-top:0}
.task-head{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin-bottom:6px}
.task-extra{margin:0 0 8px;padding:8px 10px;background:var(--surface-2,rgba(0,0,0,.03));border-radius:8px}

/* Persian file picker (forms with uploads) */
.file-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.file-pick input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.file-pick .file-btn { cursor: pointer; }
.file-pick .file-name { color: var(--text-2); font-size: .88rem; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-pick input[type=file]:focus-visible + .file-btn { outline: 2px solid var(--gold-light); }

/* Sale wizard footer: leave / come back later on every step */
.step-exit { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-start; border-top: 1px dashed var(--border); margin-top: 18px; padding-top: 12px; }
.step-exit .spacer { flex: 1; }

/* Long notes that used to be single-line pills */
.note { display: block; border-radius: 8px; padding: 8px 12px; background: var(--cream); color: var(--petrol-dark); font-size: .85rem; white-space: normal; }

/* Saved record vs edit form (guarantor, cheques) */
.saved-box { border: 1px solid #b8d9c4; background: var(--ok-bg); border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; }
.saved-box h3 { color: var(--ok); margin: 0 0 4px; font-size: .95rem; }

/* Cheque step live meters */
.meters { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); margin: 10px 0 14px; }
.meter { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: var(--white); }
.meter .label { color: var(--text-2); font-size: .82rem; }
.meter b { display: block; font-size: 1.05rem; color: var(--petrol-dark); }
.meter.ok b { color: var(--ok); } .meter.over { border-color: var(--err); background: var(--err-bg); } .meter.over b { color: var(--err); }
tr.voided td { text-decoration: line-through; color: var(--disabled); }
tr.voided td.keep { text-decoration: none; }
.cal { max-width: calc(100vw - 24px); }
.cal-grid button[disabled] { color: var(--disabled); cursor: not-allowed; background: none; text-decoration: line-through; }
.cal-grid button.holiday:not([disabled]) { color: var(--err); }
.check { display: flex; gap: 6px; align-items: center; font-weight: normal; margin-top: 6px; }

/* ---- Round 2 (review items 19–41) ---- */
/* 19: values never break mid-word inside tables; only long-text columns wrap; tables scroll inside their card. */
.btn { white-space: nowrap; }
.table td, .table th, .tbl td, .tbl th { overflow-wrap: normal; word-break: normal; white-space: nowrap; }
.table td.wrap, .tbl td.wrap { white-space: normal; min-width: 140px; max-width: 360px; overflow-wrap: break-word; }
.table-wrap { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
.card > .table-wrap:first-child:last-child { margin: 0; }
.actions { display: inline-flex; gap: 6px; flex-wrap: nowrap; align-items: center; }
.actions form { margin: 0; display: inline-flex; }
@media (max-width: 1100px) { .hide-md { display: none; } }

/* 25: an input and its button sit on one line; the live hint goes under the whole row. */
.input-btn { display: flex; gap: 8px; align-items: stretch; }
.input-btn > :first-child { flex: 1 1 auto; min-width: 0; }
.input-btn > .btn { flex: none; }
.field > .row:has(> .btn) { flex-wrap: nowrap; align-items: stretch; }

/* 29: in-app confirm dialog (replaces the browser's window.confirm). */
.dlg-back { position: fixed; inset: 0; background: rgba(2,42,64,.45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.dlg { background: var(--white); border-radius: 14px; box-shadow: 0 10px 40px rgba(2,42,64,.3); width: 100%; max-width: 440px; padding: 20px 22px; direction: rtl; }
.dlg h2 { margin: 0 0 8px; font-size: 1.1rem; }
.dlg p { margin: 0 0 12px; color: var(--text-2); white-space: pre-line; }
.dlg .field { margin-bottom: 12px; }
.dlg .dlg-actions { display: flex; gap: 8px; justify-content: flex-start; flex-wrap: wrap; }
.dlg .dlg-err { color: var(--err); font-size: .85rem; min-height: 1em; }
.btn-danger-solid { background: var(--err); border-color: var(--err); color: #fff; }
.btn-danger-solid:hover { background: #8f1d17; border-color: #8f1d17; }

/* 36: in-app dropdown with the app's font and size (the native <select> stays as the form value). */
.sel { position: relative; display: block; width: 100%; }
.sel select { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.sel-btn { font: inherit; width: 100%; text-align: right; padding: 9px 12px 9px 34px; border: 1px solid var(--border); border-radius: 8px; background: var(--white); color: var(--text); cursor: pointer; position: relative; min-height: 42px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel-btn::after { content: "▾"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-2); }
.sel-btn:focus { outline: 2px solid var(--gold-light); border-color: var(--gold); }
.sel-btn[disabled] { background: var(--cream); color: var(--disabled); cursor: not-allowed; }
.sel-list { position: fixed; z-index: 90; background: var(--white); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); max-height: 280px; overflow-y: auto; padding: 4px; margin: 0; list-style: none; direction: rtl; font-size: 15px; }
.sel-list li { padding: 8px 12px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.sel-list li[aria-selected=true] { background: var(--cream); font-weight: 500; }
.sel-list li.hot { background: var(--cream-light); outline: 1px solid var(--gold-glow); }
.sel-list li[aria-disabled=true] { color: var(--disabled); cursor: not-allowed; }
.sel-list li.grp { color: var(--text-2); font-size: .8rem; cursor: default; padding-top: 10px; }

/* 27: after a save the page returns to where you were; the result shows here too. */
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 95; max-width: min(560px, calc(100vw - 24px)); box-shadow: 0 6px 24px rgba(2,42,64,.25); margin: 0; }
tr.flash td { animation: flash 2.4s ease-out; }
@keyframes flash { from { background: var(--gold-glow); } to { background: transparent; } }

/* 34: editable lists (add one row at a time, delete per row). */
.list-rows .list-row { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); }
.list-rows .list-row > input[type=text], .list-rows .list-row > input:not([type]) { flex: 1 1 auto; }
.list-rows .list-row label { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; font-weight: normal; }

/* 39: roles — list beside the selected role's permissions. */
.roles-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 14px; align-items: start; }
.role-list { list-style: none; margin: 0; padding: 0; }
.role-list a { display: flex; justify-content: space-between; gap: 8px; padding: 9px 12px; border-radius: 8px; text-decoration: none; color: var(--petrol-dark); }
.role-list a.on, .role-list a:hover { background: var(--cream); }
.perm-group { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; }
.perm-group h3 { display: flex; justify-content: space-between; align-items: center; margin: 0 0 6px; }
.perm-group label { display: flex; gap: 8px; align-items: center; padding: 4px 0; font-weight: normal; }
@media (max-width: 860px) { .roles-layout { grid-template-columns: 1fr; } }

/* 38: aligned edit forms. */
.form-grid { display: grid; gap: 14px 16px; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); align-items: start; }
.form-grid .span-all { grid-column: 1 / -1; }
.check-group { display: flex; flex-wrap: wrap; gap: 6px 18px; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.check-group label { display: inline-flex; gap: 6px; align-items: center; font-weight: normal; }
.form-foot { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.form-foot .spacer { flex: 1; }

/* 40: lenders the store has not licensed. */
.card.off { opacity: .7; background: var(--cream-light); }
/* 25: in filter rows (fields + buttons on one line) live hints float under the field so buttons stay level with the inputs. */
.row > .field { position: relative; }
.row > .field > .live, .row > .field > .date-live { position: absolute; top: 100%; inset-inline-start: 0; white-space: nowrap; line-height: 1.4; }
form.row:has(> .field > .live), .row:has(> .field > .date-live) { padding-bottom: 22px; }

/* Round 2 (cont.) */
.field-err { display: block; color: var(--err); font-size: .85rem; margin-top: 2px; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--err); box-shadow: 0 0 0 2px var(--err-bg); }
tr.muted td { color: var(--muted); }
.badge { display: inline-block; min-width: 1.4em; padding: 0 .45em; margin-inline-start: 4px; border-radius: 999px; background: var(--err); color: #fff; font-size: .75rem; line-height: 1.5; text-align: center; font-weight: 500; }
.badge-quiet { background: var(--border); color: var(--muted); }
.stat.stat-warn { border-color: #ecd49c; background: var(--warn-bg); }
.stat.stat-warn b { color: var(--warn); }
.role-list a { flex-direction: column; align-items: flex-start; }
.role-list .role-new { color: var(--petrol); font-weight: 500; }
.perm-group legend { display: flex; gap: 12px; align-items: center; font-weight: 500; padding: 0 4px; }
.perm-group legend .check { font-weight: normal; }
.perm-group > .check { display: inline-flex; width: min(100%, 320px); }
.explain ul { margin: 4px 0 8px; padding-inline-start: 20px; }
.doc-guide pre { background: #f7f4ec; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; overflow-x: auto; white-space: pre; font-size: .85rem; }
.doc-guide h2 { font-size: 1.05rem; margin: 18px 0 6px; }
.filters .fields { margin-bottom: 8px; }
@media print { .side, .topbar, .noprint, nav.tabsbar { display: none !important; } }
