/* board.css — منسوخ حرفياً من <style> في index.html (اللوحة القديمة) للحفاظ على نفس الشكل. */
:root {
    --primary-dark: #1F4E79;
    --primary-medium: #2E75B6;
    --primary-light: #E8F0F8;
    --accent-gold: #c6a664;
    --accent-gold-light: #dcc594;
    --accent-gold-dark: #9a7a3e;
    --bg-surface: #f4f6f8;
    --bg-white: #ffffff;
    --text-main: #1a1c1b;
    --text-muted: #5f6361;
    --border-heavy: #cfd6d3;
    --border-light: #e1e5e3;
    --st-none: #eef1f3;
    --st-prog: #c6a664;
    --st-done: #2E8B57;
    --st-na: #d9dee2;
    --cut: #C0392B;
    --ngl-color: #8B5E3C;
    --pgl-color: #1F4E79;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body > * { min-width: 0; max-width: 100%; }
body { font-family: 'Tajawal', 'Segoe UI', Tahoma, sans-serif; background: var(--bg-surface); color: var(--text-main); min-height: 100vh; display: flex; flex-direction: column; overflow-x: hidden; -webkit-font-smoothing: antialiased; }
svg text { font-family: 'Tajawal', 'Segoe UI', Tahoma, sans-serif; }

/* ===== HEADER ===== */
.header { background: white; border-bottom: 4px solid var(--primary-dark); padding: 16px 0; box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
.header-container { max-width: 1400px; margin: 0 auto; padding: 0 32px; display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.brand-block { display: flex; align-items: center; gap: 12px; }
.brand-text-block { display: flex; flex-direction: column; }
.brand-ar { font-size: 18px; font-weight: 800; color: var(--primary-dark); line-height: 1.2; }
.brand-en { font-size: 9px; color: #94a3b8; letter-spacing: 0.2em; font-weight: 600; margin-top: 2px; }
.brand-meta { font-size: 11px; color: var(--text-muted); font-weight: 600; text-align: left; line-height: 1.7; direction: ltr; }
.title-section { max-width: 1400px; width: 100%; margin: 28px auto 20px; padding: 0 32px; text-align: center; }
.page-title { font-size: 28px; font-weight: 900; color: var(--primary-dark); margin-bottom: 8px; line-height: 1.3; }
.page-subtitle { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.title-divider { width: 80px; height: 3px; background: var(--accent-gold); margin: 12px auto 0; border-radius: 2px; }

/* ===== NAV ===== */
.section-nav { max-width: 1400px; width: 100%; margin: 0 auto 18px; padding: 0 32px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.section-nav a { text-decoration: none; padding: 7px 14px; border-radius: 20px; background: white; border: 1px solid var(--border-heavy); color: var(--primary-dark); font-size: 12px; font-weight: 700; }
.section-nav a:hover { background: var(--primary-light); border-color: var(--primary-medium); }

/* ===== MAIN ===== */
main { flex-grow: 1; max-width: 1400px; width: 100%; margin: 0 auto; padding: 0 32px 32px; }
.section { margin-top: 26px; }
.section-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; margin-bottom: 12px; flex-wrap: wrap; }
.section-title { font-size: 19px; font-weight: 900; color: var(--primary-dark); }
.section-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 3px; line-height: 1.6; max-width: 900px; }
.technical-panel { background: white; border: 1px solid var(--border-heavy); box-shadow: 0 1px 4px rgba(0,0,0,0.05); border-radius: 12px; }

/* Toolbar / filter bar */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 18px; margin-bottom: 14px; }
.filter-bar-label { font-size: 10px; font-weight: 800; color: var(--text-muted); letter-spacing: 0.1em; margin-left: 4px; }
.filter-toggle, .btn { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; padding: 6px 11px; border-radius: 6px; border: 1px solid var(--border-light); font-size: 12px; font-weight: 700; background: white; color: var(--text-main); font-family: inherit; }
.filter-toggle:hover, .btn:hover { background: var(--primary-light); }
.filter-toggle.active { background: var(--primary-dark); color: white; border-color: var(--primary-dark); }
.btn.primary { background: var(--primary-dark); color: white; border-color: var(--primary-dark); }
.btn.primary:hover { background: var(--primary-medium); }
.btn.danger { color: var(--cut); border-color: #f1c4bf; }
.btn.danger:hover { background: #fdecea; }
.filter-toggle .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
select.sel, input.inp { padding: 6px 10px; border: 1px solid var(--border-heavy); border-radius: 6px; font-family: inherit; font-size: 12px; font-weight: 700; background: white; color: var(--primary-dark); }
.spacer { margin-right: auto; }
.storage-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 12px; font-size: 11px; font-weight: 800; background: #eef1f3; color: var(--text-muted); }
.storage-pill.gas { background: #e6f4ea; color: #1e7b45; }
.storage-pill.live { background: #e8f0fa; color: #1F4E79; }
.storage-pill.stale { background: #fdf0e3; color: #9a5b12; }
.ro-val { display: inline-block; padding: 3px 9px; border-radius: 5px; background: #eef1f3; color: var(--text-muted);
    font-size: 11px; font-weight: 800; border: 1px solid var(--border-light); }
.data-banner { display: flex; align-items: center; gap: 10px; margin: 8px 0 0; padding: 9px 14px; border-radius: 6px;
    background: #e8f0fa; border: 1px solid #b9d0e8; color: #1F4E79; font-size: 12px; font-weight: 700; }
.data-banner .db-txt { flex: 1; }
.data-banner .db-x { border: none; background: transparent; color: inherit; cursor: pointer; font-size: 14px; font-weight: 900; padding: 0 4px; }
.storage-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* Stats */
.stats-bar { display: grid; grid-template-columns: repeat(6, 1fr); padding: 18px 20px; gap: 10px; }
.stat-item { text-align: center; border-right: 1px solid var(--border-light); padding: 4px; }
.stat-item:first-child { border-right: none; }
.stat-value { font-size: 24px; font-weight: 900; line-height: 1; direction: ltr; color: var(--primary-dark); }
.stat-label { font-size: 10px; font-weight: 700; color: var(--text-muted); letter-spacing: 0.04em; margin-top: 6px; }
.stat-sub { font-size: 10px; color: var(--text-muted); margin-top: 3px; }

/* Overview table */
.overview-body { padding: 12px 14px; max-height: 560px; overflow-x: hidden; overflow-y: auto; }
.overview-body::-webkit-scrollbar { width: 6px; height: 6px; }
.overview-body::-webkit-scrollbar-thumb { background: var(--border-heavy); border-radius: 10px; }
table.matrix { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12.5px; }
table.matrix th { background: var(--primary-dark); color: white; font-weight: 800; font-size: 11px; padding: 7px 5px; text-align: center; line-height: 1.25; border-bottom: 2px solid var(--accent-gold); cursor: pointer; white-space: nowrap; }
table.matrix th.th-road { text-align: right; padding-right: 10px; min-width: 170px; }
table.matrix td { padding: 4px 5px; border-bottom: 1px solid var(--border-light); text-align: center; vertical-align: middle; white-space: nowrap; }
table.matrix tr.road-row { cursor: pointer; }
table.matrix tr.road-row:hover td { background: #f1f5f9; }
table.matrix tr.road-row.selected td { background: #FFF2CC; }
table.matrix td.road-cell { text-align: right; }
table.matrix td.road-cell .code { font-weight: 900; color: var(--primary-dark); direction: ltr; display: inline-block; font-size: 13px; }
table.matrix td.road-cell .len { font-size: 10.5px; color: var(--text-muted); margin-right: 6px; }
.cat-pill { display: inline-block; min-width: 46px; padding: 2px 8px; border-radius: 12px; color: white; font-size: 10px; font-weight: 800; text-align: center; }
.cat-main { background: #1F4E79; } .cat-sec { background: #2E75B6; } .cat-ped { background: #7F9DBD; } .cat-existing { background: #7f8c8d; }
.pbar { position: relative; height: 16px; background: var(--st-none); border-radius: 8px; overflow: hidden; min-width: 120px; direction: ltr; }
.pbar .done { position: absolute; left: 0; top: 0; bottom: 0; background: var(--st-done); }
.pbar .prog { position: absolute; top: 0; bottom: 0; background: var(--st-prog); }
.pbar span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 800; color: var(--text-main); }

/* Road header card (as in the sketch) */
.road-card { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr 1fr 1fr; gap: 12px; padding: 16px 20px; align-items: center; }
.road-card .kv { border-right: 1px solid var(--border-light); padding-right: 12px; }
.road-card .kv:first-child { border-right: none; padding-right: 0; }
.road-card .k { font-size: 10px; font-weight: 800; color: var(--text-muted); letter-spacing: 0.06em; }
.road-card .v { font-size: 20px; font-weight: 900; color: var(--primary-dark); direction: ltr; text-align: right; line-height: 1.2; }
.road-card .v small { font-size: 11px; color: var(--text-muted); font-weight: 700; }

/* Tracking grid — عمود أسماء الصفوف برّه منطقة التمرير الأفقي (frozen.js)، من غير position: sticky */
.grid-wrap { padding: 0 0 6px; }
table.track { border-collapse: separate; border-spacing: 0; font-size: 11.5px; min-width: 100%; }
table.track th, table.track td { border-bottom: 1px solid var(--border-light); border-left: 1px solid var(--border-light); text-align: center; vertical-align: middle; }
table.track thead th, table.track tfoot th { background: var(--primary-dark); color: white; font-weight: 800; padding: 6px 4px; font-size: 11px; direction: ltr; cursor: pointer; min-width: 58px; white-space: nowrap; }
table.track thead th.sel, table.track tfoot th.sel { background: var(--accent-gold-dark); }
table.track thead th .mk, table.track tfoot th .mk { display: block; font-size: 9px; opacity: 0.8; font-weight: 700; }
table.track th.rowh { background: var(--primary-light); color: var(--primary-dark); font-weight: 900; min-width: 120px; text-align: right; padding: 6px 10px; white-space: nowrap; cursor: pointer; }
table.track thead th.corner, table.track tfoot th.corner { background: var(--primary-dark); color: white; text-align: right; direction: rtl; padding-right: 10px; }
table.track tr.meta td { background: #fbfcfd; color: var(--text-muted); font-weight: 700; font-size: 10.5px; padding: 3px 4px; direction: ltr; }
table.track tr.meta th.rowh { background: #f1f5f9; font-size: 11px; }
table.track tr.meta td.cut { color: var(--cut); font-weight: 900; }
table.track tr.meta td.fill { color: var(--st-done); font-weight: 900; }
table.track td.c { padding: 3px; }
.cellbox { display: flex; align-items: center; justify-content: center; height: 30px; min-width: 50px; border-radius: 6px; background: var(--st-none); cursor: default; font-size: 10.5px; font-weight: 800; color: var(--text-muted); direction: ltr; transition: transform .08s; user-select: none; }
.cellbox:hover { box-shadow: 0 0 0 2px var(--accent-gold-light); }
.cellbox.s1 { background: var(--st-prog); color: white; }
.cellbox.s2 { background: var(--st-done); color: white; }
.cellbox.na { background: repeating-linear-gradient(45deg, #e9edf0 0 4px, #f7f9fa 4px 8px); cursor: default; color: #b3bac0; }
.cellbox.na:hover { transform: none; box-shadow: none; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; padding: 10px 18px; font-size: 11px; font-weight: 700; color: var(--text-muted); border-top: 1px solid var(--border-light); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.cellbox.s3 { background: var(--cut); color: white; }
.cellbox.p25 { background: #f6d9b3; color: #6b4a1a; } .cellbox.p50 { background: #e9b96e; color: #4a3210; } .cellbox.p75 { background: var(--st-prog); color: white; } .cellbox.p100 { background: var(--st-done); color: white; }
.road-card { grid-template-columns: 1.3fr 0.8fr 0.8fr 1.4fr 1.4fr 1fr; }
.qbar { position: relative; height: 12px; background: var(--st-none); border-radius: 6px; overflow: hidden; margin-top: 6px; direction: ltr; }
.qbar > div { position: absolute; left: 0; top: 0; bottom: 0; }
#pavInputs input { width: 62px; padding: 4px 6px; border: 1px solid var(--border-heavy); border-radius: 6px; font-family: inherit; font-weight: 800; direction: ltr; }
#pavInputs label { font-size: 11px; font-weight: 800; color: var(--primary-dark); display: inline-flex; align-items: center; gap: 4px; }

/* Two-column area for cross-section + long profile */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }
.diagram-area { padding: 16px 18px; position: relative; overflow: hidden; }
.diagram-area svg { width: 100%; height: auto; display: block; }
.diagram-legend { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 10px; font-size: 11px; font-weight: 700; color: var(--text-muted); }
.diagram-legend span { display: inline-flex; align-items: center; gap: 5px; }
.diagram-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.diagram-legend b { width: 18px; height: 0; border-top: 3px solid; display: inline-block; }
.range-row { display: flex; align-items: center; gap: 10px; padding: 8px 18px; border-bottom: 1px solid var(--border-light); font-size: 12px; font-weight: 700; color: var(--primary-dark); }
.range-row input[type=range] { flex: 1; accent-color: var(--primary-dark); }
.range-row .val { direction: ltr; min-width: 90px; text-align: left; font-weight: 900; }

/* Tooltip */
.tooltip { position: fixed; background: var(--primary-dark); color: white; padding: 8px 12px; border-radius: 6px; font-size: 12px; font-weight: 600; pointer-events: none; opacity: 0; transition: opacity 0.15s; z-index: 200; border: 1px solid var(--accent-gold); max-width: 280px; line-height: 1.5; }
.tooltip.visible { opacity: 1; }

/* Method */
.method { padding: 18px 22px; font-size: 13px; line-height: 1.9; }
.method h3 { font-size: 14px; color: var(--primary-dark); margin: 10px 0 4px; }
.method ol, .method ul { padding-right: 20px; }
.method code { background: #f1f5f9; padding: 1px 6px; border-radius: 4px; font-size: 12px; direction: ltr; display: inline-block; }

footer { text-align: center; font-size: 11px; color: var(--text-muted); padding: 22px; border-top: 1px solid var(--border-light); background: white; margin-top: 30px; line-height: 1.9; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--primary-dark); color: white; padding: 10px 18px; border-radius: 8px; font-size: 12px; font-weight: 700; opacity: 0; transition: opacity .2s; z-index: 300; pointer-events: none; border: 1px solid var(--accent-gold); }
.toast.show { opacity: 1; }

@media (max-width: 768px) {
    main { padding: 0 14px 24px; }
    .header-container, .title-section, .section-nav { padding: 0 14px; }
    .page-title { font-size: 20px !important; }
    .stats-bar { grid-template-columns: 1fr 1fr 1fr !important; gap: 8px !important; }
    .road-card { grid-template-columns: 1fr 1fr; }
    .road-card .kv { border-right: none; padding-right: 0; }
    .diagram-area { padding: 10px !important; }
    table.track th.rowh { min-width: 86px; padding: 4px 6px; }
    .brand-meta { display: none; }
}
@media (max-width: 480px) { .page-title { font-size: 17px !important; } .header-container { flex-wrap: wrap; justify-content: center; gap: 12px; } .stats-bar { grid-template-columns: 1fr 1fr !important; } }
@media print {
    .section-nav, .filter-bar, .btn, .legend, .range-row, .storage-pill, .data-banner, #overviewSection, #methodSection, .toast { display: none !important; }
    body { background: white; }
    .technical-panel { box-shadow: none; border: 1px solid #999; break-inside: avoid; }
    main { padding: 0; max-width: none; }
    @page { size: A3 landscape; margin: 10mm; }
}
