/* Medica IMS - design system. Uses logical properties so RTL (Kurdish) works automatically. */
:root {
  --brand: #0F6E84; --brand-600: #0C5C6F; --brand-700: #0B4F5F; --brand-50: #E8F3F6; --brand-100: #CFE6EC;
  --bg: #F3F6F8; --surface: #FFFFFF; --surface-2: #F8FAFB; --border: #E2E8EE; --border-strong: #CBD5DF;
  --text: #17212B; --text-2: #4B5868; --muted: #738092;
  --ok: #157F4B; --ok-bg: #E4F5EC; --warn: #A85A08; --warn-bg: #FDF1DC; --danger: #B42318; --danger-bg: #FDECEA; --info: #1D5FBF; --info-bg: #E6EFFC; --neutral-bg: #EDF1F5;
  --sidebar: #0B3440; --sidebar-2: #0F4150; --sidebar-text: #C5DCE3; --sidebar-active: #FFFFFF;
  --radius: 10px; --radius-sm: 7px; --shadow: 0 1px 2px rgba(16,32,48,.06), 0 1px 3px rgba(16,32,48,.05); --shadow-lg: 0 12px 32px rgba(16,32,48,.18);
  --font: "Segoe UI", system-ui, -apple-system, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --font-rtl: "Noto Sans Arabic", "Segoe UI", Tahoma, "Noto Naskh Arabic", system-ui, sans-serif;
  --sidebar-w: 248px; --topbar-h: 58px;
}
:root[data-theme="dark"] {
  --brand: #3BB3CC; --brand-600: #2FA0B8; --brand-700: #8AD7E6; --brand-50: #12313A; --brand-100: #1B4450;
  --bg: #0E151C; --surface: #161F29; --surface-2: #1B2631; --border: #283543; --border-strong: #3A4959;
  --text: #E6ECF2; --text-2: #B4C0CC; --muted: #8696A7;
  --ok: #4CC98A; --ok-bg: #12301F; --warn: #F0B45A; --warn-bg: #3A2A0E; --danger: #F2877C; --danger-bg: #3B1814; --info: #7FB0F5; --info-bg: #14263F; --neutral-bg: #222E3A;
  --sidebar: #0A1218; --sidebar-2: #121C25; --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 32px rgba(0,0,0,.6);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.45; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
html[dir="rtl"] body { font-family: var(--font-rtl); font-size: 14.5px; }
a { color: var(--brand); text-decoration: none; } a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
html[dir="rtl"] h1, html[dir="rtl"] h2, html[dir="rtl"] h3 { letter-spacing: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .bold { font-weight: 650; } .nowrap { white-space: nowrap; }
.right { text-align: end; } .center { text-align: center; }
.text-ok { color: var(--ok); } .text-danger { color: var(--danger); } .text-warn { color: var(--warn); }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 40; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-logo { width: 36px; height: 36px; border-radius: 9px; background: linear-gradient(135deg, #1FA3BF, #0F6E84); display: grid; place-items: center; color: #fff; flex: none; overflow: hidden; }
.brand-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.brand-name { color: #fff; font-weight: 650; font-size: 14.5px; line-height: 1.2; } .brand-sub { font-size: 11.5px; opacity: .7; }
.nav { padding: 10px 10px 16px; flex: 1; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; opacity: .55; padding: 14px 10px 6px; }
html[dir="rtl"] .nav-group { letter-spacing: 0; font-size: 12px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--sidebar-text); font-weight: 500; margin-block: 1px; }
.nav a:hover { background: var(--sidebar-2); text-decoration: none; color: #fff; }
.nav a.active { background: var(--brand); color: var(--sidebar-active); }
:root[data-theme="dark"] .nav a.active { background: #15596A; }
.nav a .count { margin-inline-start: auto; background: rgba(255,255,255,.16); font-size: 11.5px; padding: 1px 7px; border-radius: 99px; }
.nav a .count.alert { background: #D9462F; color: #fff; }
.sidebar-foot { padding: 12px 16px; font-size: 11.5px; opacity: .55; border-top: 1px solid rgba(255,255,255,.08); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; padding: 0 20px; position: sticky; top: 0; z-index: 30; }
.topbar .spacer { flex: 1; }
.global-search { position: relative; flex: 1; max-width: 440px; }
.global-search input[type] { width: 100%; padding-inline-start: 36px; background: var(--surface-2); }
.global-search .icon { position: absolute; inset-inline-start: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.content { padding: 22px 24px 48px; max-width: 1480px; width: 100%; margin: 0 auto; }
.menu-btn { display: none; }
.backdrop { display: none; }

.page-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; } .page-head .sub { color: var(--muted); margin-top: 2px; }
.page-head .actions { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; margin-bottom: 4px; }
html[dir="rtl"] .back-link svg, html[dir="rtl"] .flip-rtl { transform: scaleX(-1); }

/* ---------- cards & grid ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 14.5px; } .card-head .actions { margin-inline-start: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 16px; } .card-body.flush { padding: 0; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.cols-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } .cols-3-2 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row .grow { flex: 1; min-width: 0; }

.stat { padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start; color: inherit; transition: border-color .15s, transform .15s; }
a.stat:hover { text-decoration: none; border-color: var(--brand); transform: translateY(-1px); }
.stat-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); flex: none; }
.stat.ok .stat-icon { background: var(--ok-bg); color: var(--ok); } .stat.warn .stat-icon { background: var(--warn-bg); color: var(--warn); } .stat.danger .stat-icon { background: var(--danger-bg); color: var(--danger); } .stat.info .stat-icon { background: var(--info-bg); color: var(--info); }
.stat > div:last-child { min-width: 0; }
.stat-label { color: var(--muted); font-size: 12.5px; } .stat-value { font-size: 20px; font-weight: 680; line-height: 1.25; margin-top: 1px; } .stat-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat-value .ccy { font-size: 12px; font-weight: 600; color: var(--muted); margin-inline-start: 4px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 7px 13px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 560; cursor: pointer; white-space: nowrap; line-height: 1.3; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); border-color: var(--muted); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; } .btn.primary:hover { background: var(--brand-600); border-color: var(--brand-600); }
:root[data-theme="dark"] .btn.primary { color: #06222A; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; } .btn.danger-outline { color: var(--danger); border-color: var(--danger); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
:root[data-theme="dark"] .btn.ok, :root[data-theme="dark"] .btn.danger { color: #0B1118; }
.btn.ghost { border-color: transparent; background: transparent; } .btn.ghost:hover { background: var(--neutral-bg); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; } .btn.icon-only { padding: 7px; } .btn.sm.icon-only { padding: 4px; }
.btn-group { display: inline-flex; } .btn-group .btn { border-radius: 0; margin-inline-start: -1px; } .btn-group .btn:first-child { border-start-start-radius: var(--radius-sm); border-end-start-radius: var(--radius-sm); margin-inline-start: 0; } .btn-group .btn:last-child { border-start-end-radius: var(--radius-sm); border-end-end-radius: var(--radius-sm); }
.btn-group .btn.active { background: var(--brand-50); color: var(--brand); border-color: var(--brand); z-index: 1; }

/* ---------- forms ---------- */
input[type="text"], input[type="number"], input[type="password"], input[type="date"], input[type="email"], input[type="search"], input[type="tel"], select, textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); outline: none; transition: border-color .12s, box-shadow .12s; min-height: 34px; }
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
input:disabled, select:disabled, textarea:disabled, input[readonly] { background: var(--surface-2); color: var(--text-2); }
input[type="number"] { direction: ltr; text-align: start; }
html[dir="rtl"] input[type="number"], html[dir="rtl"] input[type="date"], html[dir="rtl"] input[type="tel"], html[dir="rtl"] input[type="email"] { text-align: end; }
input.right { text-align: end; }
label.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
label.field > span.lbl { font-size: 12.5px; font-weight: 560; color: var(--text-2); }
label.field .req { color: var(--danger); } label.field .hint { font-size: 11.5px; color: var(--muted); }
label.field.error input, label.field.error select, label.field.error textarea { border-color: var(--danger); }
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid > * { grid-column: span 12; }
.span-2 { grid-column: span 2 !important; } .span-3 { grid-column: span 3 !important; } .span-4 { grid-column: span 4 !important; } .span-6 { grid-column: span 6 !important; } .span-8 { grid-column: span 8 !important; } .span-9 { grid-column: span 9 !important; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; } .check input { width: 16px; height: 16px; accent-color: var(--brand); }
.input-group { display: flex; } .input-group > * { border-radius: 0; } .input-group > :first-child { border-start-start-radius: var(--radius-sm); border-end-start-radius: var(--radius-sm); } .input-group > :last-child { border-start-end-radius: var(--radius-sm); border-end-end-radius: var(--radius-sm); } .input-group > * + * { margin-inline-start: -1px; }
.input-group > :first-child { flex: 1 1 auto; min-width: 0; }
.input-group > select:not(:first-child), .input-group > .btn { width: auto; flex: none; }

/* ---------- toolbar / filters ---------- */
.toolbar { display: flex; gap: 8px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.toolbar .search { position: relative; flex: 1 1 220px; max-width: 340px; } .toolbar .search input[type] { padding-inline-start: 34px; }
.toolbar .search .icon { position: absolute; inset-inline-start: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.toolbar select, .toolbar input[type="date"] { width: auto; min-width: 130px; }
.toolbar .spacer { flex: 1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 4px 11px; border-radius: 99px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font-size: 12.5px; font-weight: 560; color: var(--text-2); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; } :root[data-theme="dark"] .chip.active { color: #06222A; }
.chip .n { opacity: .7; margin-inline-start: 4px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: start; font-size: 12px; font-weight: 620; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
.tbl th.sortable { cursor: pointer; user-select: none; } .tbl th.sortable:hover { color: var(--text); }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr.clickable { cursor: pointer; } .tbl tbody tr.clickable:hover { background: var(--surface-2); }
.tbl td.right, .tbl th.right { text-align: end; } .tbl td.center, .tbl th.center { text-align: center; }
.tbl tfoot td { font-weight: 650; background: var(--surface-2); border-top: 1px solid var(--border-strong); }
.tbl.compact td, .tbl.compact th { padding: 6px 10px; }
.tbl .primary { font-weight: 600; color: var(--text); } .tbl .secondary { font-size: 12px; color: var(--muted); }
.empty { padding: 44px 16px; text-align: center; color: var(--muted); } .empty svg { opacity: .45; margin-bottom: 8px; }
.pager { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12.5px; } .pager .spacer { flex: 1; }
.thumb { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; background: var(--neutral-bg); display: grid; place-items: center; color: var(--muted); flex: none; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.cell-item { display: flex; gap: 10px; align-items: center; min-width: 180px; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--neutral-bg); color: var(--text-2); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.warn { background: var(--warn-bg); color: var(--warn); } .badge.danger { background: var(--danger-bg); color: var(--danger); } .badge.info { background: var(--info-bg); color: var(--info); } .badge.brand { background: var(--brand-50); color: var(--brand); }
.badge.plain::before { display: none; }

/* ---------- key/value ---------- */
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px 18px; }
.kv .k { font-size: 12px; color: var(--muted); } .kv .v { font-weight: 560; margin-top: 1px; word-break: break-word; }
.kv .wide { grid-column: 1 / -1; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 7px 24px; align-items: center; }
.totals .grand { font-size: 17px; font-weight: 700; border-top: 2px solid var(--border-strong); padding-top: 9px; margin-top: 3px; }
.totals .lbl { color: var(--text-2); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 10px; overflow-x: auto; }
.tabs button { background: none; border: none; padding: 11px 13px; cursor: pointer; font-weight: 560; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover { color: var(--text); } .tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- modal / toast / dropdown ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10,20,30,.5); display: grid; place-items: start center; padding: 5vh 14px; overflow-y: auto; z-index: 100; animation: fade .12s; }
.modal { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; animation: pop .14s; }
.modal.lg { max-width: 860px; } .modal.xl { max-width: 1100px; } .modal.sm { max-width: 420px; }
.modal-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); } .modal-head h3 { font-size: 16px; flex: 1; }
.modal-body { padding: 18px; } .modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 12px 12px; }
@keyframes fade { from { opacity: 0; } } @keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.toasts { position: fixed; bottom: 18px; inset-inline-end: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: min(420px, calc(100vw - 36px)); }
.toast { background: #17212B; color: #fff; padding: 11px 14px; border-radius: 9px; box-shadow: var(--shadow-lg); display: flex; gap: 9px; align-items: flex-start; animation: pop .15s; }
.toast.ok { background: #136B41; } .toast.error { background: #A32015; }
.dropdown { position: relative; display: inline-block; }
.menu { position: absolute; inset-inline-end: 0; top: calc(100% + 5px); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); min-width: 200px; padding: 5px; z-index: 60; }
.menu.start { inset-inline-end: auto; inset-inline-start: 0; }
.menu button, .menu a { display: flex; width: 100%; align-items: center; gap: 9px; padding: 8px 10px; border: none; background: none; border-radius: 7px; cursor: pointer; color: var(--text); text-align: start; }
.menu button:hover, .menu a:hover { background: var(--neutral-bg); text-decoration: none; } .menu .sep { height: 1px; background: var(--border); margin: 5px 0; }
.menu .danger { color: var(--danger); }

/* ---------- picker (autocomplete) ---------- */
.picker { position: relative; }
.picker-list { position: absolute; inset-inline: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 9px; box-shadow: var(--shadow-lg); max-height: 300px; overflow-y: auto; z-index: 70; min-width: 280px; }
.picker-item { padding: 8px 11px; cursor: pointer; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: center; } .picker-item:last-child { border-bottom: none; }
.picker-item:hover, .picker-item.active { background: var(--brand-50); } .picker-item .grow { flex: 1; min-width: 0; }
.picker-empty { padding: 12px; color: var(--muted); text-align: center; }

/* ---------- inventory browser dialog ---------- */
.browse-list { border: 1px solid var(--border); border-radius: 9px; max-height: 56vh; overflow-y: auto; }
.browse-item { display: flex; gap: 10px; align-items: center; width: 100%; padding: 10px 12px; border: none; border-bottom: 1px solid var(--border); background: none; color: var(--text); text-align: start; cursor: pointer; font: inherit; }
.browse-item:last-child { border-bottom: none; } .browse-item:hover, .browse-item:active { background: var(--brand-50); }
.browse-item .grow { flex: 1; min-width: 0; } .browse-item .right { text-align: end; white-space: nowrap; }
.add-line .grow { min-width: 200px; }

/* ---------- line items editor ---------- */
.lines { width: 100%; border-collapse: collapse; }
.lines th { font-size: 12px; color: var(--muted); font-weight: 620; text-align: start; padding: 8px 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.lines td { padding: 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.lines td.right, .lines th.right { text-align: end; }
.lines input, .lines select, .lines textarea { padding: 5px 8px; min-height: 31px; }
.lines textarea { min-height: 31px; height: 31px; font-size: 12.5px; }
.lines .line-total { font-weight: 620; padding-top: 12px; }
.lines .idx { color: var(--muted); padding-top: 12px; width: 26px; }

/* ---------- alerts / misc ---------- */
.alert { padding: 10px 13px; border-radius: 9px; background: var(--info-bg); color: var(--info); display: flex; gap: 9px; align-items: flex-start; border: 1px solid color-mix(in srgb, currentColor 22%, transparent); }
.alert.warn { background: var(--warn-bg); color: var(--warn); } .alert.danger { background: var(--danger-bg); color: var(--danger); } .alert.ok { background: var(--ok-bg); color: var(--ok); }
.progress { height: 7px; background: var(--neutral-bg); border-radius: 99px; overflow: hidden; min-width: 70px; } .progress > i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.progress.ok > i { background: var(--ok); } .progress.warn > i { background: var(--warn); }
.steps { display: flex; gap: 0; flex-wrap: wrap; } .step { display: flex; align-items: center; gap: 7px; padding: 6px 12px 6px 6px; color: var(--muted); font-size: 12.5px; font-weight: 560; }
.step .dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--neutral-bg); font-size: 11.5px; } .step.done { color: var(--ok); } .step.done .dot { background: var(--ok); color: #fff; } .step.current { color: var(--brand); } .step.current .dot { background: var(--brand); color: #fff; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; margin: 40px auto; } @keyframes spin { to { transform: rotate(360deg); } }
.item-photo { width: 100%; aspect-ratio: 4/3; border-radius: var(--radius); background: var(--neutral-bg); display: grid; place-items: center; color: var(--muted); overflow: hidden; border: 1px solid var(--border); } .item-photo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.chart { width: 100%; height: auto; display: block; } .chart text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); } .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; }
.list-plain { list-style: none; margin: 0; padding: 0; } .list-plain li { display: flex; gap: 10px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--border); } .list-plain li:last-child { border-bottom: none; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-50); color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
hr.sep { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
pre.terms { white-space: pre-wrap; font: inherit; margin: 0; color: var(--text-2); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: linear-gradient(150deg, #0B3440 0%, #0F6E84 62%, #1C9BB6 100%); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.login-art h1 { font-size: 34px; line-height: 1.15; max-width: 460px; } .login-art p { opacity: .85; max-width: 440px; font-size: 15px; }
.login-art .flow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; } .login-art .flow span { background: rgba(255,255,255,.14); padding: 5px 11px; border-radius: 99px; font-size: 12.5px; }
.login-form { display: grid; place-items: center; padding: 28px; }
.login-box { width: 100%; max-width: 360px; } .login-box h2 { font-size: 22px; margin-bottom: 4px; }

/* mixed-direction content: keep English data readable inside the Kurdish (RTL) interface */
html[dir="rtl"] .tbl td, html[dir="rtl"] .kv .v, html[dir="rtl"] pre.terms, html[dir="rtl"] .page-head h1, html[dir="rtl"] .picker-item .grow > div, html[dir="rtl"] .lines td .bold, html[dir="rtl"] .lines td .small { unicode-bidi: plaintext; text-align: right; }
html[dir="rtl"] .tbl td.right { text-align: left; } html[dir="rtl"] .tbl td.center { text-align: center; }
html[dir="rtl"] .tbl td .primary, html[dir="rtl"] .tbl td .secondary { unicode-bidi: plaintext; }
html[dir="rtl"] input[type="text"], html[dir="rtl"] textarea { unicode-bidi: plaintext; }

/* nested cards (list views inside tabbed cards) */
.card .card:not(.stat) { border: none; box-shadow: none; border-radius: 0; }
.item-top { grid-template-columns: minmax(200px, 280px) minmax(0, 1fr); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) { .cols-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: min(84vw, 280px); transform: translateX(-102%); transition: transform .2s; }
  html[dir="rtl"] .sidebar { transform: translateX(102%); }
  .app.nav-open .sidebar { transform: none; } .app.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(10,20,30,.45); z-index: 35; }
  .menu-btn { display: inline-flex; }
  .cols-2-1, .cols-3-2, .cols-3, .item-top { grid-template-columns: minmax(0, 1fr); }
  .content { padding: 16px 14px 40px; } .topbar { padding: 0 12px; } .topbar .spacer { display: none; } .global-search { max-width: none; min-width: 0; }
  .login { grid-template-columns: 1fr; } .login-art { display: none; }
}
@media (max-width: 640px) {
  .cols-4, .cols-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .cols-2 { grid-template-columns: minmax(0, 1fr); }
  .stat { padding: 11px 12px; gap: 9px; } .stat-icon { width: 32px; height: 32px; } .stat-value { white-space: normal; overflow-wrap: anywhere; font-size: 16px; } .stat-value .ccy { display: inline-block; }
  .form-grid > * { grid-column: span 12 !important; } .form-grid > .span-6.keep, .form-grid > .span-4.keep, .form-grid > .span-3.keep { grid-column: span 6 !important; }
  .page-head h1 { font-size: 19px; } .hide-sm { display: none !important; }
  .page-head .actions { margin-inline-start: 0; width: 100%; }
  .modal-backdrop { padding: 0; } .modal { border-radius: 0; min-height: 100vh; max-width: none !important; display: flex; flex-direction: column; } .modal-body { flex: 1; }
  .topbar .user-name { display: none; }
  .modal-foot { position: sticky; bottom: 0; border-radius: 0; z-index: 2; } .modal-head { position: sticky; top: 0; background: var(--surface); z-index: 2; }
  .browse-list { max-height: none; } .add-line > .btn { flex: 1 1 100%; justify-content: center; } .add-line .grow { flex: 1 1 100%; max-width: none !important; }
}
.pw-warning { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 16px; background: var(--danger); color: #fff; font-weight: 560; } .pw-warning .grow { flex: 1 1 200px; } .pw-warning .btn { background: #fff; color: var(--danger); border-color: #fff; }

/* ---------- phones and small tablets: tables become cards ---------- */
@media (max-width: 820px) {
  .table-wrap { overflow-x: visible; }
  table.tbl, .tbl tbody, .tbl tfoot { display: block; width: 100%; } .tbl thead { display: none; }
  .tbl tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px 14px; padding: 13px 14px; border-bottom: 1px solid var(--border); align-items: start; }
  .tbl tbody tr:last-child { border-bottom: none; }
  .tbl td, .tbl.compact td { display: block; padding: 0; border: none; text-align: start !important; min-width: 0; overflow-wrap: anywhere; }
  .tbl td.lead { grid-column: 1 / -1; order: -1; font-size: 15px; font-weight: 600; }
  .tbl td.blank, .tbl td.idx { display: none; }
  .tbl td[data-label]::before { content: attr(data-label); display: block; font-size: 11.5px; font-weight: 400; color: var(--muted); margin-bottom: 1px; }
  .tbl td.lead[data-label]::before { display: none; }
  .tbl td.act { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
  .tbl td.act.blank { display: none; }
  .tbl tfoot tr { background: var(--surface-2); border-top: 1px solid var(--border-strong); border-bottom: none; }
  .tbl tfoot td { background: none; border: none; }
  .tbl tbody tr.clickable:active { background: var(--surface-2); }
  html[dir="rtl"] .tbl td { text-align: right !important; }

  .lines.mcards, .lines.mcards tbody { display: block; width: 100%; } .lines.mcards thead { display: none; }
  .lines.mcards tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .lines.mcards td { display: block; border: none; padding: 0 !important; width: auto !important; min-width: 0 !important; text-align: start; }
  .lines.mcards td input, .lines.mcards td select { width: 100% !important; }
  .lines.mcards td.idx { display: none; } .lines.mcards td.wide, .lines.mcards td[colspan] { grid-column: 1 / -1; }
  .lines.mcards td[data-label]::before { content: attr(data-label); display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 3px; text-align: start; font-weight: 400; }
  .lines.mcards td.line-total { text-align: start; font-weight: 650; font-size: 15px; } .lines.mcards td.rm { justify-self: end; align-self: end; }
  .modal-body .lines.mcards tr { padding-inline: 0; }

  .toolbar .search { flex: 1 1 100%; max-width: none; }
  .toolbar select, .toolbar input[type="date"] { flex: 1 1 140px; min-width: 0; }
  .toolbar .spacer { display: none; }
  .tabs { scrollbar-width: none; } .tabs::-webkit-scrollbar { display: none; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; } .chips::-webkit-scrollbar { display: none; } .chip { white-space: nowrap; flex: none; }
  .pager { flex-wrap: wrap; }
}

/* ---------- touch screens: bigger targets, no zoom-on-focus ---------- */
@media (max-width: 820px), (pointer: coarse) {
  input[type="text"], input[type="number"], input[type="password"], input[type="date"], input[type="email"], input[type="search"], input[type="tel"], select, textarea { font-size: 16px; min-height: 42px; }
  .lines input, .lines select, .lines textarea { min-height: 40px; font-size: 16px; } .lines textarea { height: 40px; }
  .btn { min-height: 42px; padding: 9px 14px; } .btn.icon-only { min-width: 42px; padding: 9px; }
  .btn.sm { min-height: 36px; padding: 6px 11px; font-size: 13px; } .btn.sm.icon-only { min-width: 36px; padding: 6px; }
  .chip { padding: 8px 13px; font-size: 13px; }
  .tabs button { padding: 13px 14px; }
  .menu button, .menu a { padding: 12px; }
  .picker-item { padding: 11px 12px; }
  .nav a { padding-block: 11px; }
  label.check { min-height: 36px; }
}

/* ---------- phones ---------- */
@media (max-width: 640px) {
  .tbl tr, .lines.mcards tr { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content { padding: 14px 12px calc(40px + env(safe-area-inset-bottom)); }
  .card-head { padding: 12px 14px; flex-wrap: wrap; } .card-body { padding: 14px; }
  .page-head { margin-bottom: 14px; gap: 10px; }
  .page-head .actions > .btn, .page-head .actions > .dropdown { flex: 1 1 auto; } .page-head .actions > .dropdown > .btn { width: 100%; }
  .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
  .global-search { max-width: none; min-width: 0; } .topbar .spacer { display: none; }
  .lang-switch .btn { padding-inline: 8px; } .lang-switch .btn svg { display: none; }
  .topbar { gap: 6px; padding: 0 8px; padding-top: env(safe-area-inset-top); height: calc(var(--topbar-h) + env(safe-area-inset-top)); }
  .toasts { inset-inline: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); max-width: none; }
  .menu { max-width: calc(100vw - 24px); }
  .modal-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); } .modal-foot .btn { flex: 1 1 auto; }
  .totals { font-size: 14px; }
  .row > .btn { flex: 1 1 auto; }
}

@media print { .sidebar, .topbar, .actions, .toolbar, .pager, .no-print { display: none !important; } .app { display: block; } .content { padding: 0; max-width: none; } .card { box-shadow: none; border-color: #ccc; } body { background: #fff; } }
