/* BTS - Bill Tracking System */
:root {
  --navy: #0f2a43; --navy-2: #173a5c; --navy-3: #234b72;
  --gold: #c8963e; --gold-2: #e5b967;
  --primary: #1e5a8a; --primary-d: #164a73; --primary-l: #e6f0f8;
  --bg: #f3f5f8; --card: #fff; --line: #dfe4ea; --line-2: #eef1f5;
  --text: #1c2733; --muted: #66758a; --ok: #15803d; --warn: #b45309; --bad: #b91c1c;
  --radius: 10px; --shadow: 0 1px 2px rgba(15,42,67,.06), 0 4px 14px rgba(15,42,67,.05);
  --font: "Segoe UI", Tahoma, "Noto Naskh Arabic", "Geeza Pro", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; } a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; }
h1 { font-size: 1.55rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; }
.muted { color: var(--muted); } .small { font-size: .85em; } .nowrap { white-space: nowrap; }
.ar { direction: rtl; unicode-bidi: plaintext; font-family: "Noto Naskh Arabic", "Segoe UI", Tahoma, serif; }
[dir=auto], .bidi { unicode-bidi: plaintext; }
mark { background: #fde68a; padding: 0 2px; border-radius: 2px; }
code, .mono { font-family: Consolas, "Courier New", monospace; font-size: .92em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* Layout */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--navy); color: #cbd7e4; padding: 0 0 20px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { padding: 18px 20px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand b { color: #fff; font-size: 1.15rem; letter-spacing: .5px; } .brand b span { color: var(--gold-2); }
.brand small { display: block; color: #8ea4bb; font-size: .72rem; margin-top: 2px; }
.nav { padding: 10px 10px 0; }
.nav h6 { margin: 16px 10px 6px; font-size: .68rem; text-transform: uppercase; letter-spacing: 1.2px; color: #6f89a3; font-weight: 600; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin: 1px 0; border-radius: 8px; color: #cbd7e4; font-size: .92rem; }
.nav a:hover { background: var(--navy-2); text-decoration: none; color: #fff; }
.nav a.active { background: var(--navy-3); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav .ic { width: 18px; text-align: center; opacity: .85; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 10px 24px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar .qs { flex: 1; max-width: 520px; position: relative; }
.topbar .qs input { width: 100%; padding: 8px 12px 8px 34px; border: 1px solid var(--line); border-radius: 20px; background: var(--bg); }
.topbar .qs:before { content: "⌕"; position: absolute; left: 12px; top: 6px; color: var(--muted); font-size: 1.1rem; }
.topbar .sp { flex: 1; }
.iconbtn { position: relative; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: #fff; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--text); font-size: 1rem; }
.iconbtn:hover { background: var(--bg); text-decoration: none; }
.iconbtn .dot { position: absolute; top: -4px; right: -4px; background: var(--bad); color: #fff; border-radius: 10px; font-size: .65rem; padding: 1px 5px; min-width: 16px; text-align: center; }
.userbox { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--navy-3); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; }
.userbox .nm { font-weight: 600; line-height: 1.1; } .userbox .rl { font-size: .72rem; color: var(--muted); }
.content { padding: 22px 26px 60px; max-width: 1500px; width: 100%; }
.pagehead { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.pagehead .t { flex: 1; min-width: 240px; } .pagehead h1 { margin-bottom: 2px; }
.crumbs { font-size: .8rem; color: var(--muted); margin-bottom: 4px; } .crumbs a { color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Cards, grid */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; }
.card > .hd { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--line-2); }
.card > .hd h2, .card > .hd h3 { margin: 0; flex: 1; }
.card > .bd { padding: 16px 18px; } .card > .bd.flush { padding: 0; }
.grid { display: grid; gap: 18px; } .g2 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
.g-main { grid-template-columns: minmax(0, 1fr) 340px; }
@media (max-width: 1100px) { .g3, .g4, .g-main { grid-template-columns: 1fr 1fr; } }
@media (max-width: 800px) { .app { grid-template-columns: 1fr; } .sidebar { position: static; height: auto; } .g2, .g3, .g4, .g-main { grid-template-columns: 1fr; } }
.stat { padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; }
.stat .n { font-size: 1.9rem; font-weight: 700; line-height: 1.1; } .stat .l { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .6px; }
.stat.warn .n { color: var(--warn); } .stat.bad .n { color: var(--bad); }
.stat a { color: inherit; } 

/* Tables */
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; padding: 9px 14px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
table.t td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.t tr:hover td { background: #fafcff; }
table.t tr:last-child td { border-bottom: 0; }
.tablewrap { overflow-x: auto; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* Badges / chips */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: .75rem; font-weight: 600; color: var(--c, #64748b); background: color-mix(in srgb, var(--c, #64748b) 13%, #fff); border: 1px solid color-mix(in srgb, var(--c, #64748b) 30%, #fff); white-space: nowrap; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--line-2); color: #3b4a5c; font-size: .78rem; margin: 1px 2px 1px 0; }
.prio-urgent { color: var(--bad); font-weight: 700; } .prio-high { color: var(--warn); font-weight: 600; }

/* Buttons & forms */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--text); cursor: pointer; font: inherit; font-weight: 500; line-height: 1.3; }
.btn:hover { background: var(--bg); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; } .btn.primary:hover { background: var(--primary-d); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn.danger { background: #fff; border-color: #f0b4b4; color: var(--bad); } .btn.danger:hover { background: #fef2f2; }
.btn.sm { padding: 3px 10px; font-size: .82rem; } .btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }
form.inline { display: inline; }
.field { margin-bottom: 14px; } .field > label, label.l { display: block; font-weight: 600; font-size: .82rem; margin-bottom: 4px; color: #33445a; }
.field .hint { color: var(--muted); font-size: .78rem; margin-top: 3px; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], input[type=datetime-local], input[type=search], input[type=time], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #cdd5de; border-radius: 8px; background: #fff; font: inherit; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 40%, transparent); border-color: var(--primary); }
textarea { min-height: 90px; resize: vertical; } select[multiple] { min-height: 130px; }
.row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.row.r2 { grid-template-columns: 1fr 1fr; } .row.r3 { grid-template-columns: repeat(3, 1fr); } .row.r4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 800px) { .row.r2, .row.r3, .row.r4 { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-weight: 400; } .check input { width: auto; }
.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 2px 14px; max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.formbar { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 14px 18px; border-bottom: 1px solid var(--line-2); background: #fafbfc; border-radius: var(--radius) var(--radius) 0 0; }
.filters .field { margin: 0; min-width: 150px; } .filters .field.wide { min-width: 260px; flex: 1; }
/* toggle chips for yes/no filters (replace bare checkboxes) */
.fchips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.fchip { display: inline-flex; align-items: center; gap: 7px; margin: 0; padding: 7px 13px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--text); font-size: .88rem; font-weight: 500; line-height: 1.3; cursor: pointer; user-select: none; transition: background .12s, border-color .12s, color .12s; }
.fchip:hover { border-color: #c3ccd7; background: var(--bg); }
.fchip input { width: 15px; height: 15px; margin: 0; accent-color: var(--primary); cursor: pointer; flex: none; }
.fchip:has(input:checked) { background: var(--primary-l); border-color: var(--primary); color: var(--primary-d); }
.fchip:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Flash */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.flash.success { background: #ecfdf3; border-color: #a7e3bd; color: #14532d; } .flash.error, .flash.danger { background: #fef2f2; border-color: #f2b8b8; color: #7f1d1d; }
.flash.warning { background: #fffbeb; border-color: #f4d58a; color: #7a4a05; } .flash.info { background: #eff6ff; border-color: #b6d0f4; color: #1e3a8a; }
ul.errs { margin: 6px 0 0 18px; padding: 0; }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 16px; border-bottom: 3px solid transparent; color: var(--muted); font-weight: 600; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; } .tabs a.on { color: var(--primary); border-bottom-color: var(--primary); }
.tabs .cnt { background: var(--line-2); border-radius: 10px; padding: 0 7px; font-size: .72rem; margin-left: 4px; }

/* Definition lists */
dl.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; margin: 0; } dl.kv dt { color: var(--muted); font-size: .84rem; } dl.kv dd { margin: 0; }

/* Stage stepper */
.stepper { display: flex; align-items: center; gap: 0; overflow-x: auto; padding: 4px 0 8px; }
.step { display: flex; align-items: center; flex: 1; min-width: 100px; }
.step .dot { width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 2px solid #c3ccd7; display: flex; align-items: center; justify-content: center; font-size: .72rem; font-weight: 700; color: #8795a8; flex: none; }
.step .lbl { margin: 0 8px; font-size: .78rem; color: var(--muted); line-height: 1.15; }
.step:after { content: ""; flex: 1; height: 2px; background: #d6dde5; min-width: 12px; } .step:last-child:after { display: none; }
.step.done .dot { background: var(--ok); border-color: var(--ok); color: #fff; } .step.done:after { background: var(--ok); } .step.done .lbl { color: var(--text); }
.step.cur .dot { background: var(--c, var(--primary)); border-color: var(--c, var(--primary)); color: #fff; box-shadow: 0 0 0 4px color-mix(in srgb, var(--c, var(--primary)) 20%, transparent); }
.step.cur .lbl { color: var(--text); font-weight: 700; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 16px 16px; } .timeline li:before { content: ""; position: absolute; left: -25px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--c, var(--primary)); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); }
.timeline .when { font-size: .78rem; color: var(--muted); }

/* Checklist of requirements */
ul.reqs { list-style: none; margin: 8px 0; padding: 0; } ul.reqs li { padding: 3px 0 3px 24px; position: relative; font-size: .86rem; }
ul.reqs li:before { content: "✕"; position: absolute; left: 2px; color: var(--bad); font-weight: 700; } ul.reqs li.ok:before { content: "✓"; color: var(--ok); }
ul.reqs li.ok { color: #3b4a5c; } ul.reqs li:not(.ok) { color: var(--bad); }
.tr-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: #fcfdfe; }
.tr-card.ready { border-color: #a7e3bd; background: #f7fdf9; }

/* Bars */
.bar { height: 10px; background: var(--line-2); border-radius: 6px; overflow: hidden; } .bar > i { display: block; height: 100%; background: var(--primary); }
.hbars .r { display: grid; grid-template-columns: 180px 1fr 50px; gap: 10px; align-items: center; margin: 7px 0; font-size: .88rem; }
.hbars .r .v { text-align: right; font-weight: 600; }
.gantt { position: relative; }
.gantt .seg { display: inline-block; height: 14px; vertical-align: middle; }
.chartbox { position: relative; height: 280px; } .chartbox.sm { height: 220px; }

/* Modal (dialog) */
dialog { border: 0; border-radius: 12px; padding: 0; box-shadow: 0 20px 60px rgba(0,0,0,.3); width: min(620px, 94vw); max-height: 90vh; }
dialog::backdrop { background: rgba(15,42,67,.5); }
dialog .mh { padding: 14px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; } dialog .mh h3 { margin: 0; flex: 1; }
dialog .mb { padding: 18px 20px; overflow-y: auto; max-height: 68vh; } dialog .mf { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; background: #fafbfc; }
dialog.wide { width: min(880px, 96vw); }
.x { background: none; border: 0; font-size: 1.4rem; cursor: pointer; color: var(--muted); }

/* Notifications dropdown page */
.notif { display: block; padding: 12px 18px; border-bottom: 1px solid var(--line-2); color: inherit; }
.notif.unread { background: #f4f9ff; } .notif:hover { text-decoration: none; background: #eef5fc; }
.notif .tt { font-weight: 600; }

/* Auth pages */
.authwrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--navy) 0%, var(--navy-3) 100%); padding: 20px; }
.authcard { background: #fff; width: 100%; max-width: 420px; border-radius: 14px; padding: 32px 32px 26px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.authcard .brand { padding: 0 0 18px; border: 0; text-align: center; } .authcard .brand b { color: var(--navy); font-size: 1.5rem; } .authcard .brand small { color: var(--muted); }
.authcard.wide { max-width: 560px; }
.qr { display: flex; justify-content: center; padding: 12px; } .secret { font-family: Consolas, monospace; background: var(--bg); padding: 8px 12px; border-radius: 8px; letter-spacing: 2px; text-align: center; word-break: break-all; }
.codes { columns: 2; font-family: Consolas, monospace; background: var(--bg); padding: 12px 18px; border-radius: 8px; }

/* Session banner */
#idlebar { display: none; position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #7c2d12; color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 999; box-shadow: 0 6px 24px rgba(0,0,0,.3); }
#idlebar button { margin-left: 12px; }

.pager { display: flex; gap: 6px; padding: 12px 18px; align-items: center; justify-content: space-between; border-top: 1px solid var(--line-2); }
.pager a, .pager span.cur { padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; } .pager span.cur { background: var(--primary); color: #fff; border-color: var(--primary); }
.pager .pg { display: flex; gap: 4px; }
.snippet { font-size: .84rem; color: #4a5a6e; margin-top: 4px; }
.sidepanel .card { margin-bottom: 14px; }
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }
.callout { border-left: 4px solid var(--gold); background: #fffaf0; padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.callout.bad { border-color: var(--bad); background: #fef6f6; } .callout.ok { border-color: var(--ok); background: #f4fbf6; }
.cal-day { padding: 8px 18px; background: #f6f8fb; font-weight: 600; font-size: .85rem; color: #3b4a5c; border-bottom: 1px solid var(--line-2); }
.ev { display: flex; gap: 14px; padding: 10px 18px; border-bottom: 1px solid var(--line-2); } .ev .tm { width: 54px; color: var(--muted); font-weight: 600; flex: none; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 4px 18px; }
.perm-mod { margin-bottom: 14px; } .perm-mod h4 { text-transform: capitalize; margin: 10px 0 4px; font-size: .9rem; border-bottom: 1px solid var(--line-2); padding-bottom: 3px; }
.sev-critical { color: var(--bad); font-weight: 700; } .sev-warning { color: var(--warn); font-weight: 600; }
.ok-t { color: var(--ok); font-weight: 600; } .bad-t { color: var(--bad); font-weight: 600; } .warn-t { color: var(--warn); font-weight: 600; }
.drop { border: 2px dashed #b8c4d2; border-radius: 10px; padding: 18px; text-align: center; background: #fafcff; }
details.dd > summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.kbd { border: 1px solid #c9d2dd; border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-size: .78rem; background: #fff; }
@media print { .sidebar, .topbar, .actions, .no-print { display: none !important; } .app { display: block; } .content { padding: 0; } .card { box-shadow: none; } }

/* dashboard KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; border-top: 4px solid var(--c, var(--primary)); color: inherit; display: flex; flex-direction: column; gap: 2px; }
.kpi:hover { text-decoration: none; transform: translateY(-1px); }
.kpi .v { font-size: 1.9rem; font-weight: 700; color: var(--c, var(--primary)); line-height: 1.1; }
.kpi .l { font-size: .82rem; color: var(--muted); }

/* form helpers */
.chk, .check { display: flex; align-items: center; gap: 6px; font-weight: 400; font-size: .9rem; cursor: pointer; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fafbfc; max-height: 260px; overflow: auto; }
.checks .grp { grid-column: 1 / -1; font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 6px; }
.sp { flex: 1; }
.ft-actions { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }
tr.row-bad td { background: #fff5f5; }
