/* SubTrack - stylesheet (no framework). Uses logical properties so that RTL (Arabic) works out of the box. */
:root {
  --bg:#f4f6f9; --card:#fff; --line:#e5e7eb; --line2:#f1f3f5; --txt:#1f2937; --muted:#6b7280; --muted2:#9ca3af;
  --blue:#2563eb; --blue-d:#1d4ed8; --red:#b91c1c; --green:#047857; --amber:#b45309; --nav:#111827;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust:100%; }
body {
  margin:0; font-family:-apple-system,"Segoe UI",Roboto,"Noto Sans","Noto Sans Arabic","Noto Sans Devanagari",Tahoma,Helvetica,Arial,sans-serif;
  background:var(--bg); color:var(--txt); font-size:14px;
}
a { color:var(--blue); text-decoration:none; }
a:hover { text-decoration:underline; }
bdi { unicode-bidi:isolate; }

/* ---------- Topbar ---------- */
.topbar { display:flex; align-items:center; gap:14px; background:var(--nav); color:#fff; padding:0 16px; height:56px; }
.topbar .brand { display:flex; align-items:center; gap:8px; color:#fff; font-weight:700; font-size:16px; letter-spacing:.2px; white-space:nowrap; }
.topbar .brand:hover { text-decoration:none; }
.topbar .brand img { display:block; }
.topbar nav { display:flex; gap:4px; flex:1; }
.topbar nav a { color:#cbd5e1; padding:8px 14px; border-radius:6px; }
.topbar nav a:hover { background:#1f2937; color:#fff; text-decoration:none; }
.topbar nav a.on { background:var(--blue); color:#fff; }
.topbar .logout { color:#9ca3af; font-size:13px; white-space:nowrap; }
main { max-width:1340px; margin:24px auto; padding:0 16px 60px; }
.foot { text-align:center; color:var(--muted2); font-size:12px; padding:16px; }

.lang-select { margin:0; }
.lang-select select { width:auto; padding:5px 8px; font-size:13px; border-radius:6px; }
.lang-select.dark select { background:#1f2937; color:#e5e7eb; border:1px solid #374151; }

/* ---------- Titles / buttons ---------- */
h1 { font-size:22px; margin:0 0 16px; }
h2 { font-size:16px; margin:24px 0 10px; }
.page-head { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:10px; margin-bottom:16px; }
.page-head > div:last-child { display:flex; flex-wrap:wrap; gap:8px; }
.btn { display:inline-flex; align-items:center; justify-content:center; gap:0; padding:8px 14px; border-radius:6px; border:1px solid #d1d5db; background:#fff; color:#374151; cursor:pointer; font-size:14px; font-family:inherit; line-height:1.25; }
.btn:hover { background:#f9fafb; text-decoration:none; }
.btn.primary { background:var(--blue); border-color:var(--blue); color:#fff; }
.btn.primary:hover { background:var(--blue-d); }
.btn.danger { background:#fff; border-color:#fca5a5; color:var(--red); }
.btn.danger:hover { background:#fef2f2; }
.btn.small { padding:4px 9px; font-size:12.5px; }
.btn.block { width:100%; display:flex; }
.btn .ico + .btn-lbl, .btn .ico { flex:0 0 auto; }
.btn.primary .ico, .btn.danger .ico { margin-inline-end:6px; }
.btn .ico + .btn-lbl { margin-inline-start:6px; }
.btn.small .ico { margin-inline-end:0; }
.push-end { margin-inline-start:auto; }

/* ---------- Utility ---------- */
.txt-red { color:var(--red); }
.txt-muted { color:var(--muted2); }
.txt-muted2 { color:var(--muted); }
.txt-amber { color:var(--amber); }
.txt-end { text-align:end !important; }
.b { font-weight:700; }
.mt3 { margin-top:3px; } .mt8 { margin-top:8px; } .mb0 { margin-bottom:0 !important; } .mb4 { margin-bottom:4px; }
.pad16 { padding:16px; }
.w900 { max-width:900px; } .w820 { max-width:820px; }
input.w70 { width:74px !important; display:inline-block; }
.w44 { width:44px; }
.self-end { align-self:end; }
.inline-form { display:flex; gap:8px; margin:0; }
.inline-form select { width:auto; }
.sub-line { color:var(--muted2); font-size:12px; }
.head-note { font-weight:400; color:var(--muted); }
.grp-count { font-weight:400; color:var(--muted); text-transform:none; letter-spacing:0; }
.grp-due { color:var(--red); float:right; }
[dir=rtl] .grp-due { float:left; }
.arr { display:inline-block; }
[dir=rtl] .arr { transform:scaleX(-1); }
td.wrap { white-space:normal; }
.radio-line { font-weight:400 !important; display:flex; flex-wrap:wrap; gap:8px; align-items:center; margin-bottom:8px; }
.radio-line input[type=radio], table.pick input[type=checkbox], #tout { width:auto; margin:0; }

/* ---------- Stat cards ---------- */
.cards { display:grid; grid-template-columns:repeat(auto-fit,minmax(190px,1fr)); gap:14px; margin-bottom:18px; }
.card { background:var(--card); border:1px solid var(--line); border-radius:10px; padding:16px; min-width:0; }
.card .lbl { color:var(--muted); font-size:12px; text-transform:uppercase; letter-spacing:.4px; }
[dir=rtl] .card .lbl, [lang=hi] .card .lbl, [lang=ar] th { letter-spacing:0; }
.card .val { font-size:22px; font-weight:700; margin-top:6px; overflow-wrap:anywhere; }
.card .val.val-sm { font-size:19px; }
.card .hint { line-height:1.45; }
.card.green .val { color:var(--green); }
.card.red   .val { color:var(--red); }
.card.blue  .val { color:var(--blue-d); }
.card.orange .val{ color:var(--amber); }

/* ---------- Tables ---------- */
.panel { background:var(--card); border:1px solid var(--line); border-radius:10px; overflow-x:auto; margin-bottom:22px; }
.panel > table { min-width:100%; }
.panel .panel-head { padding:12px 16px; border-bottom:1px solid var(--line); font-weight:600; display:flex; justify-content:space-between; align-items:center; gap:10px; }
table { width:100%; border-collapse:collapse; }
th, td { padding:10px 14px; text-align:start; border-bottom:1px solid var(--line2); white-space:nowrap; }
th { background:#f9fafb; font-size:12px; color:var(--muted); text-transform:uppercase; letter-spacing:.4px; }
tbody tr:hover { background:#f9fbff; }
td.num, th.num { text-align:end; font-variant-numeric:tabular-nums; }
tr.row-late td { background:#fff7f7; }
tr.row-off td { background:#fafafa; color:var(--muted2); }
tr.row-off td a { color:var(--muted); }
.empty { padding:26px; text-align:center; color:var(--muted2); }

@media (max-width:1250px) {
  td.actions-cell.serre .btn-lbl { display:none; }
  td.actions-cell.serre .btn .ico { margin:0; }
}

.grp td { background:#eef2f7; font-weight:700; font-size:12.5px; text-transform:uppercase;
           letter-spacing:.4px; color:#374151; border-bottom:1px solid var(--line); }
tr.grp:hover td { background:#eef2f7; }

/* ---------- Badges ---------- */
.badge { display:inline-block; padding:3px 9px; border-radius:999px; font-size:12px; font-weight:600; white-space:nowrap; }
.badge.ok    { background:#d1fae5; color:#065f46; }
.badge.warn  { background:#fef3c7; color:#92400e; }
.badge.late  { background:#fee2e2; color:#991b1b; }
.badge.muted { background:var(--line); color:#4b5563; }

/* ---------- Forms ---------- */
form.card-form { background:var(--card); border:1px solid var(--line); border-radius:10px; padding:20px; max-width:820px; }
.grid2 { display:grid; grid-template-columns:1fr 1fr; gap:14px 18px; }
label { display:block; font-size:12.5px; color:#4b5563; margin-bottom:5px; font-weight:600; }
input[type=text],input[type=search],input[type=tel],input[type=date],input[type=month],input[type=number],input[type=email],input[type=password],select,textarea {
  width:100%; padding:9px 11px; border:1px solid #d1d5db; border-radius:6px; font-size:14px; background:#fff; font-family:inherit; color:inherit;
}
input:focus,select:focus,textarea:focus { outline:none; border-color:var(--blue); box-shadow:0 0 0 3px rgba(37,99,235,.12); }
.field { margin-bottom:14px; min-width:0; }
.hint { font-size:12px; color:var(--muted); margin-top:5px; }
.actions { margin-top:18px; display:flex; flex-wrap:wrap; gap:10px; }

/* ---------- Filters ---------- */
.filters { display:flex; gap:10px; flex-wrap:wrap; margin-bottom:14px; align-items:center; }
.filters input, .filters select { width:auto; min-width:170px; }
.filters-total { margin-inline-start:auto; color:var(--muted); }

.flash { background:#d1fae5; border:1px solid #6ee7b7; color:#065f46; padding:10px 14px; border-radius:8px; margin-bottom:16px; }
.alert { background:#fee2e2; border:1px solid #fca5a5; color:#991b1b; padding:10px 14px; border-radius:8px; margin-bottom:14px; }

/* ---------- Login ---------- */
.login-page { display:flex; align-items:center; justify-content:center; min-height:100vh; background:var(--nav); padding:16px; }
.login-wrap { width:100%; max-width:360px; display:flex; flex-direction:column; align-items:center; gap:14px; }
.login-box { background:#fff; padding:30px 28px; border-radius:12px; width:100%; }
.login-logo { text-align:center; }
.login-box h1 { text-align:center; margin:8px 0 4px; }
.login-sub { text-align:center; color:var(--muted); margin:0 0 16px; }
.login-box label { margin-top:12px; }
.login-box .btn { margin-top:18px; padding:11px; }
.lang-select.light select { background:#1f2937; color:#e5e7eb; border:1px solid #374151; }

/* ---------- Receipt ---------- */
.recu-tools { max-width:720px; margin:0 auto 14px; display:flex; gap:10px; justify-content:flex-end; }
.recu { background:#fff; max-width:720px; margin:0 auto; padding:40px; border:1px solid var(--line); border-radius:10px; }
.recu-head { display:flex; justify-content:space-between; align-items:flex-start; gap:12px; border-bottom:2px solid #111827; padding-bottom:14px; margin-bottom:22px; }
.recu-brand { display:flex; align-items:center; gap:8px; font-weight:700; color:#374151; margin-bottom:8px; }
.recu h1 { font-size:26px; margin-bottom:4px; }
.recu .big { font-size:30px; font-weight:800; color:#065f46; }
.recu-table { margin-bottom:22px; }
.recu-table td { border-bottom:1px dashed var(--line); white-space:normal; }
.recu-table td.k { color:var(--muted); width:200px; }
.recu-amount { background:#f0fdf4; border:1px solid #86efac; border-radius:10px; padding:18px; text-align:center; margin-bottom:22px; }
.recu-amount-lbl { color:var(--muted); text-transform:uppercase; font-size:12px; letter-spacing:1px; }
.recu-foot { margin-top:26px; color:var(--muted2); font-size:12px; border-top:1px solid var(--line2); padding-top:12px; }
@media print {
  .topbar,.foot,.no-print { display:none !important; }
  body { background:#fff; }
  main { margin:0; padding:0; max-width:none; }
  .recu { border:none; }
}

/* ---------- Icons, sorting, amounts ---------- */
.ico { width:15px; height:15px; vertical-align:-3px; }
td.actions-cell { text-align:end; }
td.actions-cell .btn { margin-inline-start:4px; }

th.sortable { padding:0; }
th.sortable a { display:block; padding:10px 14px; color:var(--muted); }
th.sortable a:hover { background:#eef2ff; color:var(--blue-d); text-decoration:none; }
th.sortable.num a { text-align:end; }
th.sortable a .fleche { color:var(--blue); }

input.money { text-align:end; font-variant-numeric:tabular-nums; letter-spacing:.3px; direction:ltr; }
[dir=rtl] input.money { text-align:left; }
.suffix { position:relative; }
.suffix .dev { position:absolute; inset-inline-end:11px; top:50%; transform:translateY(-50%); color:var(--muted2); font-size:12px; pointer-events:none; }
.suffix input { padding-inline-end:52px; }
[dir=rtl] .suffix .dev { inset-inline-end:auto; right:11px; }
[dir=rtl] .suffix input { padding-inline-end:11px; padding-right:52px; }

.tri-mobile { display:none; }
.tri-mobile label { margin-bottom:6px; }
.tri-mobile select { width:100%; }
.tri-row { display:flex; gap:8px; }

/* ---------- Tablet / mobile ---------- */
@media (max-width:980px) {
  .topbar .brand span { display:none; }
}
@media (max-width:820px) {
  .topbar { height:auto; min-height:52px; padding:8px 10px; flex-wrap:wrap; gap:8px; }
  .topbar .brand { order:0; }
  .topbar .lang-select { order:1; margin-inline-start:auto; }
  .topbar .logout { font-size:12px; order:2; flex:0 0 auto; }
  .topbar nav { order:3; flex:1 1 100%; min-width:0; overflow-x:auto; -webkit-overflow-scrolling:touch; }
  .topbar nav a { padding:7px 11px; font-size:13px; white-space:nowrap; }
  main { margin:14px auto; padding:0 16px 40px; }
  h1 { font-size:19px; }
  .page-head { flex-direction:column; align-items:stretch; }
  .page-head > div:last-child { display:flex; gap:8px; }
  .page-head > div:last-child .btn { flex:1 1 auto; text-align:center; }
  .cards { grid-template-columns:1fr 1fr; gap:10px; }
  .card { padding:12px; }
  .card .val { font-size:18px; }
  .filters { flex-direction:column; align-items:stretch; }
  .filters > div, .filters input, .filters select, .filters .btn { width:100%; min-width:0; }
  .filters-total { margin-inline-start:0 !important; text-align:center; }
  form.card-form { padding:16px; }
  td.actions-cell .btn-lbl { display:none; }
  td.actions-cell .btn .ico { margin:0; }
  .tri-mobile { display:block; margin-bottom:12px; }
  .btn.small { padding:7px 10px; }
  .grp-due { float:none; display:block; margin-top:3px; }

  /* Tables -> stacked cards */
  table thead { display:none; }
  table, table tbody, table tr, table td { display:block; width:100%; }
  table tfoot, table tfoot tr, table tfoot th { display:block; width:100%; text-align:end !important; }
  table tr { border-bottom:1px solid var(--line); padding:6px 0 10px; }
  table tr:last-child { border-bottom:none; }
  table td { display:flex; justify-content:space-between; align-items:center; gap:14px;
             border:none; padding:5px 14px; white-space:normal; text-align:end; }
  table td:before { content:attr(data-label); color:var(--muted); font-size:12px; font-weight:600;
                    text-transform:uppercase; letter-spacing:.3px; text-align:start; flex:0 0 auto; max-width:50%; }
  table td:first-child { padding-top:10px; font-size:15px; justify-content:flex-start; text-align:start; }
  table td:first-child:before { content:''; }
  table td.actions-cell { justify-content:flex-end; padding-top:8px; }
  table td.actions-cell:before { content:''; }
  table.pick tr { display:grid; grid-template-columns:34px 1fr; }
  table.pick td { grid-column:2; }
  table.pick td:first-child { grid-column:1; grid-row:1 / span 5; padding:12px 0 0 12px; align-items:flex-start; }
  [dir=rtl] table.pick td:first-child { padding:12px 12px 0 0; }
  table.pick tr.grp { display:flex; align-items:center; }
  table.pick tr.grp td { display:block; width:auto; padding:10px 12px; }
  table.pick tr.grp td:last-child { flex:1; text-align:start; }
  table.pick td:nth-child(2):before { content:''; }
  table.pick td:nth-child(2) { justify-content:flex-start; font-size:15px; }
  table.recu-table { display:table; }
  table.recu-table tbody { display:table-row-group; }
  table.recu-table tr { display:table-row; padding:0; border:none; }
  table.recu-table td { display:table-cell; text-align:start; padding:8px 6px; border-bottom:1px dashed var(--line); font-size:14px; }
  table.recu-table td:first-child { padding-top:8px; font-size:14px; }
  table.recu-table td:before { content:none; }
  .panel .panel-head { flex-wrap:wrap; gap:6px; font-size:14px; }
  .recu { padding:20px; }
  .recu-table td.k { width:40%; }
}
@media (max-width:520px) {
  .cards { grid-template-columns:1fr 1fr; }
  .grid2 { grid-template-columns:1fr; }
  .recu-head { flex-direction:column; }
}

/* ---------- Charts ---------- */
.viz-panel { overflow-x:auto; }
.viz-box { padding:14px 16px 6px; }
svg.viz { width:100%; height:auto; display:block; min-width:620px; }
.hbar { display:flex; flex-direction:column; gap:12px; }
.hbar-row { display:grid; grid-template-columns:minmax(90px,150px) 1fr 68px; align-items:center; gap:12px; }
.hbar-lbl { font-size:12.5px; color:#374151; text-align:end; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.hbar-track { background:#f3f4f6; height:18px; border-start-end-radius:4px; border-end-end-radius:4px; }
.hbar-fill { height:18px; border-start-end-radius:4px; border-end-end-radius:4px; transition:width .2s; }
.hbar-row:hover .hbar-track { background:#eaf1fb; }
.hbar-val { font-size:12.5px; font-weight:600; color:#374151; }
svg.viz text { font-family:inherit; }
.viz-col:hover rect[fill="transparent"] { fill:rgba(37,99,235,.05); }
.viz-legende { display:flex; flex-wrap:wrap; gap:16px; font-weight:400; font-size:12.5px; color:var(--muted); }
.viz-legende i { display:inline-block; width:10px; height:10px; border-radius:3px; margin-inline-end:6px; }
.viz-duo { display:grid; grid-template-columns:1fr 1fr; gap:22px; }
@media (max-width:1000px) { .viz-duo { grid-template-columns:1fr; } }
@media (max-width:520px) { .hbar-row { grid-template-columns:minmax(70px,110px) 1fr 52px; gap:8px; } }

/* ---------- Installer ---------- */
.inst-wrap { max-width:680px; margin:40px auto; padding:0 16px; }
.inst-box { background:#fff; border:1px solid var(--line); border-radius:12px; padding:28px; }
.inst-top { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:12px; }
.inst-brand { display:flex; align-items:center; gap:10px; font-weight:700; font-size:18px; }
.inst-box h1 { margin:0 0 6px; }
.inst-box h2 { margin:22px 0 10px; font-size:13px; text-transform:uppercase; letter-spacing:.5px; color:var(--muted); }
.inst-sub { color:var(--muted); margin-bottom:22px; }
.inst-step { background:#f9fafb; border-inline-start:3px solid var(--blue); padding:10px 14px; border-radius:6px; margin-bottom:18px; color:#374151; }
.inst-done { background:#d1fae5; border:1px solid #6ee7b7; color:#065f46; padding:14px; border-radius:8px; margin-bottom:16px; }
.inst-done li { margin:3px 0; }
.check-line { font-weight:400 !important; display:flex; gap:8px; align-items:flex-start; }
.check-line input { width:auto; margin-top:2px; }
@media (max-width:520px) { .inst-wrap { margin:16px auto; } .inst-box { padding:18px; } }

/* ---------- Users, account, roles ---------- */
.topbar .me { color:#e5e7eb; font-size:13px; white-space:nowrap; display:flex; align-items:center; gap:6px; padding:5px 8px; border-radius:6px; }
.topbar .me:hover, .topbar .me.on { background:#1f2937; text-decoration:none; }
.role-tag { font-size:11px; background:#374151; color:#e5e7eb; padding:1px 7px; border-radius:10px; }
.role-badge { display:inline-block; font-size:12px; padding:2px 9px; border-radius:10px; background:#e0e7ff; color:#3730a3; }
.role-badge.staff { background:#f3f4f6; color:#374151; }
.inline-form { display:flex; gap:6px; align-items:center; flex-wrap:wrap; margin:0; }
.inline-form input { width:auto; min-width:0; flex:1 1 140px; padding:6px 8px; }
.help-box { background:#f8fafc; border:1px solid var(--line); border-radius:8px; padding:12px 14px; color:var(--muted); margin:0 0 16px; }
.help-box b { color:var(--txt); }
.is-disabled { opacity:.55; }

/* ---------- Live demo ---------- */
.demo-strip { background:#fef3c7; color:#78350f; text-align:center; font-size:13px; padding:6px 16px; border-bottom:1px solid #fcd34d; }
.demo-box { background:#fffbeb; border:1px solid #fcd34d; border-radius:10px; padding:12px; margin:0 0 6px; }
.demo-title { font-weight:700; color:#92400e; font-size:13px; text-transform:uppercase; letter-spacing:.4px; }
.demo-box p { margin:4px 0 10px; color:#78350f; font-size:13px; }
.demo-accounts { display:flex; flex-direction:column; gap:6px; }
.demo-fill { display:flex; align-items:center; gap:8px; width:100%; background:#fff; border:1px solid #fcd34d; border-radius:8px; padding:8px 10px; cursor:pointer; font:inherit; color:var(--txt); text-align:start; }
.demo-fill:hover { background:#fef3c7; }
.demo-fill b { min-width:58px; }
.demo-fill span { flex:1; font-family:Consolas,Menlo,monospace; font-size:12.5px; color:#374151; }
.demo-fill em { font-style:normal; font-size:12px; color:var(--blue); font-weight:600; white-space:nowrap; }
@media (max-width:820px) {
  .topbar .me { order:2; font-size:12px; padding:4px 6px; }
  .topbar .me .role-tag { display:none; }
}
@media print { .demo-strip { display:none !important; } }
.mt0 { margin-top:0; }
