/* ============ Theme ============ */
:root {
  --sidebar-w: 264px;
  --ink: #0f172a; --ink-2: #334155; --muted: #64748b; --line: #e6e9f2;
  --bg: #f4f6fb; --card: #ffffff;
  --brand-1: #4f46e5; --brand-2: #7c3aed; --brand-3: #06b6d4;
  --brand-grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --glow: 0 8px 24px -6px rgba(99, 102, 241, .55);
  --radius: 16px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 30px -12px rgba(15, 23, 42, .12);
  --bs-primary: #4f46e5; --bs-primary-rgb: 79, 70, 229;
  --bs-link-color: #4f46e5; --bs-link-color-rgb: 79, 70, 229; --bs-link-hover-color: #3730a3;
  --bs-body-color: #0f172a; --bs-border-color: #e6e9f2;
  --bs-body-font-family: "Inter", "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
}
[dir=rtl] { --bs-body-font-family: "Cairo", "Inter", Tahoma, "Segoe UI", Arial, sans-serif; }
body { font-family: var(--bs-body-font-family); font-size: .92rem; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
body.app { background:
  radial-gradient(1200px 500px at 110% -10%, rgba(124, 58, 237, .08), transparent 60%),
  radial-gradient(900px 400px at -10% 0%, rgba(6, 182, 212, .07), transparent 60%), var(--bg); background-attachment: fixed; }
a { text-decoration: none; }
.min-w-0 { min-width: 0; }
::selection { background: rgba(99, 102, 241, .2); }

/* ============ Shell ============ */
.shell { display: flex; min-height: 100vh; }
@media (min-width: 992px) {
  .shell { background: linear-gradient(to right, #131c3a var(--sidebar-w), transparent var(--sidebar-w)); }
  [dir=rtl] .shell { background: linear-gradient(to left, #131c3a var(--sidebar-w), transparent var(--sidebar-w)); }
}
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 1.5rem; flex: 1; }
@media (max-width: 575px) { .content { padding: 1rem; } }

/* Sidebar */
.sidebar { overflow-x: hidden; width: var(--sidebar-w); background: linear-gradient(180deg, #0f172a 0%, #111b35 55%, #1a1446 100%); color: #cbd5e1; border: 0 !important; }
@media (min-width: 992px) { .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; flex: 0 0 var(--sidebar-w); } }
@media (max-width: 991.98px) { .sidebar.offcanvas-lg { --bs-offcanvas-width: 280px; background: linear-gradient(180deg, #0f172a 0%, #1a1446 100%); } }
.sidebar::-webkit-scrollbar { width: 6px; } .sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 3px; }
.brand { display: flex; align-items: center; gap: .7rem; padding: 1.25rem 1.1rem 1rem; color: #fff; }
.brand-mark { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-grad); box-shadow: var(--glow); font-size: 1.1rem; }
.brand-logo { width: 40px; height: 40px; object-fit: contain; background: #fff; border-radius: 10px; padding: 3px; }
.brand-name { font-weight: 700; font-size: 1rem; line-height: 1.2; letter-spacing: -.01em; }
.side-nav { padding: .25rem .75rem 1.5rem; }
.nav-group { font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; color: #64748b; margin: 1.1rem .6rem .4rem; font-weight: 600; }
[dir=rtl] .nav-group { letter-spacing: 0; font-size: .76rem; }
.side-link { display: flex; align-items: center; gap: .75rem; padding: .55rem .75rem; margin: 2px 0; border-radius: 10px; color: #cbd5e1; font-weight: 500; transition: all .18s ease; position: relative; }
.side-link span { flex: 1; min-width: 0; line-height: 1.35; }
.side-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; color: #94a3b8; transition: color .18s; }
.side-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side-link:hover i { color: #c7d2fe; }
.side-link.active { background: var(--brand-grad); color: #fff; box-shadow: 0 6px 20px -4px rgba(124, 58, 237, .6), inset 0 1px 0 rgba(255, 255, 255, .15); }
.side-link.active i { color: #fff; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem; padding: .7rem 1.5rem; background: rgba(255, 255, 255, .72); backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px); border-bottom: 1px solid rgba(15, 23, 42, .06); }
.topbar-title { font-weight: 600; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; background: #fff; border: 1px solid var(--line); font-size: 1.3rem; display: grid; place-items: center; padding: 0; }
.pill-btn { border-radius: 999px; background: #fff; border: 1px solid var(--line); font-weight: 500; padding: .38rem .9rem; color: var(--ink-2); }
.pill-btn:hover { border-color: #c7d2fe; color: var(--brand-1); box-shadow: 0 0 0 4px rgba(99, 102, 241, .08); }
.user-chip { display: flex; align-items: center; gap: .5rem; border-radius: 999px; background: #fff; border: 1px solid var(--line); padding: .25rem .8rem .25rem .3rem; font-weight: 500; }
[dir=rtl] .user-chip { padding: .25rem .3rem .25rem .8rem; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-grad); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .85rem; box-shadow: var(--glow); }
.dropdown-menu { border: 1px solid var(--line); border-radius: 12px; padding: .4rem; }
.dropdown-item { border-radius: 8px; padding: .5rem .75rem; }

/* ============ Page parts ============ */
.page-head { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: 1.1rem; }
.page-head h1 { font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; margin: 0; }
[dir=rtl] .page-head h1 { letter-spacing: 0; }
.page-intro { display: flex; gap: .7rem; align-items: flex-start; background: linear-gradient(135deg, rgba(79, 70, 229, .07), rgba(6, 182, 212, .06)); border: 1px solid rgba(99, 102, 241, .16); color: #312e81; border-radius: 14px; padding: .75rem 1rem; margin-bottom: 1.1rem; font-size: .9rem; }
.page-intro i { color: var(--brand-1); font-size: 1.1rem; margin-top: -1px; }
.card { border: 1px solid rgba(15, 23, 42, .06); border-radius: var(--radius); box-shadow: var(--shadow); background: var(--card); overflow: hidden; }
.card-header { background: transparent; border-bottom: 1px solid var(--line); font-weight: 600; padding: .9rem 1.1rem; }
.card-body { padding: 1.25rem; }
.card > .table-responsive > .table, .card > .table { margin-bottom: 0; }
h2.h6, h3.h6 { font-weight: 700; color: var(--ink); }
.filters { background: #fff; border: 1px solid rgba(15, 23, 42, .06); border-radius: 14px; padding: .85rem 1rem; margin-bottom: 1.1rem; box-shadow: var(--shadow); }
.filters .form-label { color: var(--muted); font-weight: 500; }
.alert { border-radius: 12px; border: 0; box-shadow: var(--shadow); }
.alert-success { background: #ecfdf5; color: #065f46; }
.alert-danger { background: #fef2f2; color: #991b1b; }
.alert-warning { background: #fffbeb; color: #92400e; }
.alert-info { background: #eff6ff; color: #1e40af; }
.badge { border-radius: 999px; font-weight: 600; padding: .38em .7em; }
.nav-pills .nav-link { border-radius: 999px; color: var(--ink-2); font-weight: 500; }
.nav-pills .nav-link.active { background: var(--brand-grad); box-shadow: var(--glow); }
.list-group-item { border-color: var(--line); padding: .85rem 1.1rem; }
.list-group-item-action:hover { background: #f5f7ff; }

/* Buttons */
.btn { border-radius: var(--radius-sm); font-weight: 500; transition: all .18s ease; }
.btn-sm { border-radius: 9px; }
.btn-primary { background: var(--brand-grad); border: 0; box-shadow: 0 4px 14px -4px rgba(79, 70, 229, .55); }
.btn-primary:hover, .btn-primary:focus { background: var(--brand-grad); filter: brightness(1.08); box-shadow: 0 8px 24px -6px rgba(124, 58, 237, .7); transform: translateY(-1px); }
.btn-success { background: linear-gradient(135deg, #10b981, #059669); border: 0; box-shadow: 0 4px 14px -4px rgba(16, 185, 129, .55); }
.btn-success:hover { background: linear-gradient(135deg, #10b981, #059669); filter: brightness(1.07); box-shadow: 0 8px 22px -6px rgba(16, 185, 129, .7); transform: translateY(-1px); }
.btn-outline-primary, .btn-outline-secondary, .btn-outline-success, .btn-outline-danger, .btn-outline-warning { background: #fff; }
.btn-outline-secondary { border-color: var(--line); color: var(--ink-2); }
.btn-outline-secondary:hover { background: #f8fafc; border-color: #cbd5e1; color: var(--ink); }
.btn-outline-primary { border-color: #c7d2fe; color: var(--brand-1); }
.btn-outline-primary:hover { background: #eef2ff; color: #3730a3; border-color: #a5b4fc; box-shadow: 0 0 0 4px rgba(99, 102, 241, .08); }
.btn-outline-success { border-color: #a7f3d0; color: #047857; }
.btn-outline-success:hover { background: #ecfdf5; color: #065f46; border-color: #6ee7b7; }
.btn-outline-danger { border-color: #fecaca; color: #b91c1c; }
.btn-outline-danger:hover { background: #fef2f2; color: #991b1b; border-color: #fca5a5; }
.btn-outline-warning { border-color: #fde68a; color: #b45309; }
.btn-outline-warning:hover { background: #fffbeb; color: #92400e; }
.btn-group > .btn { box-shadow: none; }
.btn-link { color: var(--brand-1); font-weight: 500; }

/* Forms */
.form-control, .form-select { border-radius: var(--radius-sm); border-color: #dfe3ee; padding: .5rem .8rem; background-color: #fff; transition: border-color .15s, box-shadow .15s; }
.form-control-sm, .form-select-sm { border-radius: 9px; padding: .35rem .65rem; }
.form-select { padding-inline-end: 2.4rem; }
.form-select-sm { padding-inline-end: 2rem; }
.form-control:focus, .form-select:focus { border-color: #818cf8; box-shadow: 0 0 0 4px rgba(99, 102, 241, .15), 0 0 18px -4px rgba(99, 102, 241, .35); }
.form-label { font-weight: 500; color: var(--ink-2); margin-bottom: .35rem; }
.form-text { color: var(--muted); font-size: .8rem; }
.form-check-input:checked { background-color: var(--brand-1); border-color: var(--brand-1); }
.form-check-input:focus { box-shadow: 0 0 0 4px rgba(99, 102, 241, .15); }
input.date-input, input.flatpickr-input[readonly] { background-color: #fff; cursor: pointer; }
.date-wrap { position: relative; }
.date-wrap > i { position: absolute; inset-inline-end: .7rem; top: 50%; transform: translateY(-50%); color: #818cf8; pointer-events: none; font-size: .95rem; }
.date-wrap .form-control { padding-inline-end: 2.1rem; }

/* Tables */
.table { --bs-table-bg: transparent; --bs-table-hover-bg: #f5f7ff; color: var(--ink); }
.table > :not(caption) > * > * { padding: .7rem .9rem; border-bottom-color: #eef1f6; }
.table-sm > :not(caption) > * > * { padding: .55rem .8rem; }
.table thead th { background: #f8fafc; color: var(--muted); font-weight: 600; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; border-bottom: 1px solid var(--line); }
[dir=rtl] .table thead th { letter-spacing: 0; font-size: .8rem; }
.table tfoot td, .table tfoot th { font-weight: 700; background: #f8fafc; border-top: 2px solid var(--line); }
.table-bordered > :not(caption) > * > * { border-color: #eef1f6; }
td.num, th.num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-group { font-weight: 600; background: #fafbff; }
.table-primary { --bs-table-bg: #eef2ff; --bs-table-color: #312e81; }
.tree-1 { padding-inline-start: 1.5rem !important; } .tree-2 { padding-inline-start: 2.75rem !important; }
.tree-3 { padding-inline-start: 4rem !important; } .tree-4 { padding-inline-start: 5.25rem !important; }
.lines-table { background: #fafbff; border-radius: 12px; }
.lines-table .prod { min-width: 240px; }
.lines-table td { vertical-align: middle; }
.table td { vertical-align: middle; }
.lines-table input, .lines-table select { min-width: 70px; }

/* Stat cards (home) */
.stat { position: relative; overflow: hidden; border-radius: var(--radius); background: #fff; border: 1px solid rgba(15, 23, 42, .06); box-shadow: var(--shadow); padding: 1.1rem 1.15rem; transition: transform .2s, box-shadow .2s; }
.stat:hover { transform: translateY(-3px); box-shadow: 0 18px 40px -18px rgba(79, 70, 229, .45); }
.stat .ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-size: 1.15rem; margin-bottom: .75rem; }
.stat .l { color: var(--muted); font-size: .8rem; font-weight: 500; }
.stat .v { font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; margin-top: .15rem; }
.stat .cur { color: var(--muted); font-size: .75rem; font-weight: 500; }
.stat::after { content: ""; position: absolute; width: 120px; height: 120px; border-radius: 50%; inset-inline-end: -40px; top: -40px; opacity: .08; background: radial-gradient(circle, rgba(99, 102, 241, .9), rgba(124, 58, 237, .4)); }
.g-indigo { background: linear-gradient(135deg, #6366f1, #4f46e5); box-shadow: 0 8px 18px -6px rgba(79, 70, 229, .6); }
.g-violet { background: linear-gradient(135deg, #a855f7, #7c3aed); box-shadow: 0 8px 18px -6px rgba(124, 58, 237, .6); }
.g-cyan { background: linear-gradient(135deg, #22d3ee, #0891b2); box-shadow: 0 8px 18px -6px rgba(8, 145, 178, .6); }
.g-amber { background: linear-gradient(135deg, #fbbf24, #f59e0b); box-shadow: 0 8px 18px -6px rgba(245, 158, 11, .6); }
.g-rose { background: linear-gradient(135deg, #fb7185, #e11d48); box-shadow: 0 8px 18px -6px rgba(225, 29, 72, .55); }
.g-emerald { background: linear-gradient(135deg, #34d399, #059669); box-shadow: 0 8px 18px -6px rgba(5, 150, 105, .6); }
.quick-actions .btn { border-radius: 12px; padding: .55rem 1rem; }
.bar { background: var(--brand-grad); border-radius: 8px 8px 3px 3px; box-shadow: 0 6px 16px -6px rgba(124, 58, 237, .7); transition: filter .2s; }
.bar:hover { filter: brightness(1.15); }

/* Stock box on product */
.stock-box { background: linear-gradient(135deg, rgba(16, 185, 129, .07), rgba(6, 182, 212, .06)); border: 1px solid rgba(16, 185, 129, .22); border-radius: 14px; padding: 1rem 1.1rem; }

/* ============ Date picker (flatpickr) ============ */
.flatpickr-calendar { border-radius: 16px; border: 1px solid var(--line); box-shadow: 0 24px 60px -20px rgba(15, 23, 42, .35), 0 0 0 1px rgba(99, 102, 241, .05); font-family: var(--bs-body-font-family); }
.flatpickr-calendar.arrowTop::before, .flatpickr-calendar.arrowTop::after { display: none; }
.flatpickr-months .flatpickr-month { height: 44px; }
.flatpickr-current-month { font-size: 1rem; font-weight: 600; padding-top: 10px; }
.flatpickr-current-month .flatpickr-monthDropdown-months { font-weight: 600; border-radius: 8px; }
.flatpickr-months .flatpickr-prev-month, .flatpickr-months .flatpickr-next-month { top: 8px; border-radius: 10px; padding: 8px; }
.flatpickr-months .flatpickr-prev-month:hover svg, .flatpickr-months .flatpickr-next-month:hover svg { fill: var(--brand-1); }
span.flatpickr-weekday { color: var(--muted); font-weight: 600; font-size: .75rem; }
.flatpickr-day { border-radius: 10px; font-weight: 500; color: var(--ink); }
.flatpickr-day:hover { background: #eef2ff; border-color: #eef2ff; }
.flatpickr-day.today { border-color: #a5b4fc; }
.flatpickr-day.selected, .flatpickr-day.selected:hover, .flatpickr-monthSelect-month.selected { background: var(--brand-grad) !important; border-color: transparent !important; color: #fff !important; box-shadow: var(--glow); }
.flatpickr-day.prevMonthDay, .flatpickr-day.nextMonthDay { color: #cbd5e1; }
.flatpickr-monthSelect-month { border-radius: 10px; }
.flatpickr-time input:hover, .flatpickr-time .flatpickr-am-pm:hover, .flatpickr-time input:focus { background: #eef2ff; }
.fp-footer { display: flex; justify-content: space-between; gap: .5rem; padding: 8px 10px; border-top: 1px solid var(--line); margin-top: 4px; }
.fp-footer button { border: 0; background: #eef2ff; color: var(--brand-1); font-weight: 600; border-radius: 8px; padding: .3rem .8rem; font-size: .8rem; }
.fp-footer button:hover { background: var(--brand-grad); color: #fff; }

/* ============ Login ============ */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem;
  background: radial-gradient(700px 400px at 15% 20%, rgba(124, 58, 237, .55), transparent 60%),
              radial-gradient(600px 400px at 85% 80%, rgba(6, 182, 212, .45), transparent 60%),
              linear-gradient(135deg, #0f172a, #1e1b4b); }
.login-card { width: 100%; max-width: 400px; background: rgba(255, 255, 255, .92); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid rgba(255, 255, 255, .6); border-radius: 22px; padding: 2rem; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .5), 0 0 60px -20px rgba(124, 58, 237, .6); }
.login-card .brand-mark { width: 56px; height: 56px; font-size: 1.5rem; border-radius: 16px; margin: 0 auto .9rem; }
.login-card .form-control { padding: .7rem .9rem; }
.login-card .btn-primary { padding: .7rem; font-weight: 600; }

/* ============ Print ============ */
.pdf-mode .no-print, .pdf-mode .btn, .pdf-mode .filters, .pdf-mode .alert, .pdf-mode .page-intro { display: none !important; }
.pdf-mode .d-print-block { display: block !important; }
.pdf-mode .d-print-flex { display: flex !important; }
html:has(body.pdf-mode), body.pdf-mode { overflow: hidden; margin: 0; }
.pdf-mode .doc { width: 100%; max-width: none; padding: 0 10px !important; margin: 0; }
.pdf-mode, .pdf-mode * { font-family: Tahoma, "Segoe UI", Arial, sans-serif !important; }
.pdf-mode .table-responsive { overflow: visible !important; }
bdi[dir=ltr] { direction: ltr; unicode-bidi: isolate; }
.pdf-mode bdi[dir=ltr] { display: inline-block; }
.pdf-mode .card-body { padding: 0 !important; }
.pdf-mode a { color: inherit !important; text-decoration: none; }
.pdf-mode, .pdf-mode * { letter-spacing: normal !important; font-variant-ligatures: normal !important; }
.zatca-qr .qr img { width: 150px; height: 150px; image-rendering: pixelated; }
.zatca-qr { display: inline-block; }
.print-header { border-bottom: 2px solid #111; padding-bottom: .75rem; margin-bottom: 1rem; }
.print-logo { max-height: 70px; max-width: 160px; object-fit: contain; }
.doc-title { font-size: 1.25rem; font-weight: 700; margin: .5rem 0 1rem; }
body.print-mode { background: #fff; }
.print-mode .table { font-size: .82rem; }
.print-mode .card { box-shadow: none; border: 0; border-radius: 0; }
.print-mode .table thead th { background: #f1f1f1; color: #111; }
@media print {
  .no-print, .topbar, .sidebar, .btn, .filters, .alert, .page-intro { display: none !important; }
  body, body.app { background: #fff !important; font-size: 11px; }
  .content { padding: 0 !important; }
  .card { border: 0 !important; box-shadow: none !important; border-radius: 0 !important; }
  .card-body { padding: 0 !important; }
  .table { font-size: 10.5px; }
  .table thead th { background: #eee !important; color: #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { color: inherit !important; }
  @page { margin: 12mm; }
}

/* ============ Phone layout ============ */
/* Tables marked by app.js (data-label on every cell) turn into labelled cards on phones. */
@media (max-width: 575.98px) {
  .page-intro { display: none; }
  .page-head { gap: .5rem; margin-bottom: .8rem; }
  .page-head h1 { font-size: 1.25rem; width: 100%; }
  .page-head .btn, .page-head .btn-group .btn { font-size: .78rem; padding: .3rem .55rem; }
  .card { border-radius: 14px; }

  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tfoot, table.stack tr, table.stack td, table.stack th { display: block; width: 100%; }
  table.stack tr { position: relative; padding: .55rem .9rem; border-bottom: 1px solid var(--line, #e5e7eb); }
  table.stack tbody tr:nth-child(even) { background: rgba(99, 102, 241, .025); }
  table.stack td, table.stack tfoot th { display: flex; justify-content: space-between; align-items: center; gap: 1rem; border: 0 !important; padding: .18rem 0 !important; text-align: end; min-height: 1.6rem; }
  table.stack td::before { content: attr(data-label); color: var(--muted, #64748b); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; text-align: start; flex: 0 0 auto; max-width: 45%; }
  [dir=rtl] table.stack td::before { letter-spacing: 0; text-transform: none; font-size: .8rem; }
  table.stack td[data-label=""]::before, table.stack td:not([data-label])::before { content: none; }
  table.stack td.stack-title { font-weight: 700; font-size: 1rem; justify-content: flex-start; padding-bottom: .3rem !important; }
  table.stack td.stack-title::before { content: none; }
  table.stack td.stack-actions { justify-content: flex-end; gap: .4rem; padding-top: .45rem !important; }
  table.stack td.stack-actions::before { content: none; }
  table.stack td:empty { display: none; }
  table.stack tfoot tr { background: #f8fafc; font-weight: 700; }
  table.stack .num { text-align: end; }
  table.stack a { white-space: nowrap; }
  .table-responsive { overflow-x: visible; }

  /* Invoice / stock / journal line editors: one card per line */
  .lines-table thead { display: none; }
  .lines-table, .lines-table tbody, .lines-table tfoot { display: block; }
  .lines-table tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem .6rem; padding: .75rem; margin-bottom: .6rem; background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; position: relative; }
  .lines-table tbody td { display: block; padding: 0 !important; border: 0 !important; }
  .lines-table tbody td::before { content: attr(data-label); display: block; font-size: .7rem; font-weight: 600; color: var(--muted, #64748b); margin-bottom: .15rem; }
  .lines-table tbody td:first-child { grid-column: 1 / -1; padding-inline-end: 2.2rem !important; }
  .lines-table tbody td.lt { grid-column: 1 / -1; text-align: end; font-weight: 700; font-size: 1rem; }
  .lines-table tbody td:last-child { position: absolute; top: .55rem; inset-inline-end: .55rem; }
  .lines-table tbody td:last-child::before { content: none; }
  .lines-table .prod { min-width: 0; }
  .lines-table input, .lines-table select { min-width: 0; width: 100%; font-size: 16px; }
  .lines-table tfoot tr { display: flex; justify-content: space-between; padding: .4rem .75rem; }
  .lines-table tfoot td { border: 0; }

  /* inputs at 16px stop iPhone from zooming in on focus */
  .form-control, .form-select { font-size: 16px; }
}

/* Bottom app bar (phones and tablets) */
.bottom-nav { display: none; }
@media (max-width: 991.98px) {
  body.app { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1030; background: rgba(255, 255, 255, .96); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid rgba(15, 23, 42, .08); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; align-items: flex-end; box-shadow: 0 -6px 24px rgba(15, 23, 42, .06); }
  .bottom-nav a, .bottom-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .68rem; color: #64748b; text-decoration: none; background: none; border: 0; padding: 4px 0; }
  .bottom-nav i { font-size: 1.3rem; line-height: 1; }
  .bottom-nav .active { color: var(--brand-1, #4f46e5); font-weight: 600; }
  .bottom-nav .fab { flex: 0 0 auto; margin-top: -26px; }
  .bottom-nav .fab span.circle { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 1.6rem;
    background: linear-gradient(135deg, #4f46e5, #7c3aed); box-shadow: 0 8px 20px rgba(79, 70, 229, .45); border: 4px solid #fff; }
}
@media print { .bottom-nav { display: none !important; } }

/* Running as an installed app */
@media (display-mode: standalone) { .topbar { padding-top: max(.7rem, env(safe-area-inset-top)); } }
.install-hint { display: none; }

.support-icon { width: 58px; height: 58px; border-radius: 18px; display: inline-grid; place-items: center; font-size: 1.7rem; color: #fff; background: linear-gradient(135deg, #4f46e5, #7c3aed); box-shadow: 0 8px 20px rgba(79, 70, 229, .35); }

/* Wide logos: white wordmark in the dark sidebar; previews in Setup */
.brand-wordmark { height: 38px; max-width: 190px; object-fit: contain; object-position: left center; }
[dir=rtl] .brand-wordmark { object-position: right center; }
.logo-preview { display: inline-flex; align-items: center; height: 56px; padding: 6px 10px; border: 1px solid #e5e7eb; border-radius: 10px; background: #fff; }
.logo-preview.dark { background: #0f172a; border-color: #0f172a; }
.logo-preview img { max-height: 44px; max-width: 200px; object-fit: contain; }
.login-card img { object-fit: contain; }
.login-logo { background: #fff; padding: 10px 18px; border-radius: 14px; box-shadow: 0 6px 18px rgba(15, 23, 42, .08); box-sizing: content-box; }
