:root {
    --bai-green: #007f5f;
    --bai-green-dark: #005b45;
    --bai-green-soft: #e6f3ed;
    --bai-orange: #f58220;
    --bai-orange-soft: #fff1e5;
    --bai-navy: #17365d;
    --bai-red: #bf2633;
    --bai-yellow: #e7a018;
    --bai-surface: #f3f7f5;
    --bai-line: #d8e4df;
    --bai-text: #17332b;
    --sidebar-width: 268px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    color: var(--bai-text);
    background: var(--bai-surface);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    font-size: 14px;
}
a { color: inherit; }
.role-viewer .editor-only { display: none !important; }
.app-shell { min-height: 100vh; }
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width) !important;
    background:
        radial-gradient(circle at 15% 8%, rgba(245, 130, 32, .18), transparent 22%),
        linear-gradient(175deg, #083f32 0%, #005b45 52%, #00392c 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 1040;
}
.sidebar-brand { display: flex; align-items: center; gap: 13px; padding: 28px 24px 20px; }
.sidebar-brand img { width: 74px; height: 42px; object-fit: contain; background: #fff; border-radius: 10px; padding: 6px; }
.brand-kicker, .topbar-kicker, .section-kicker {
    text-transform: uppercase;
    letter-spacing: .13em;
    font-size: 11px;
    font-weight: 800;
}
.brand-kicker { color: rgba(255, 255, 255, .6); }
.brand-title { font-size: 18px; font-weight: 700; }
.sidebar-nav { padding: 18px 14px; display: grid; gap: 5px; }
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 13px;
    border-radius: 10px;
    text-decoration: none;
    color: rgba(255, 255, 255, .75);
    font-weight: 600;
    transition: .2s ease;
}
.sidebar-link:hover, .sidebar-link.active { color: #fff; background: rgba(255, 255, 255, .12); }
.sidebar-link.active { box-shadow: inset 3px 0 0 var(--bai-orange); }
.nav-icon { width: 22px; text-align: center; font-size: 17px; }
.sidebar-footer { margin-top: auto; padding: 18px 24px 24px; border-top: 1px solid rgba(255,255,255,.12); }
.main-content { margin-left: var(--sidebar-width); min-height: 100vh; }
.topbar {
    min-height: 82px;
    padding: 17px 28px;
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(255, 255, 255, .94);
    border-bottom: 1px solid var(--bai-line);
    position: sticky;
    top: 0;
    z-index: 1030;
    backdrop-filter: blur(12px);
}
.topbar-kicker, .section-kicker { color: var(--bai-green); }
.topbar-title { margin: 2px 0 0; font-size: 24px; line-height: 1.1; }
.data-badge, .hint-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 11px;
    border: 1px solid var(--bai-line);
    border-radius: 999px;
    background: #fff;
    color: #587069;
    font-size: 12px;
    font-weight: 600;
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #16a267; box-shadow: 0 0 0 4px rgba(22,162,103,.12); }
.page-content { padding: 24px 28px 44px; max-width: 1800px; margin: 0 auto; }
.btn-bai { color: #fff; background: var(--bai-green); border-color: var(--bai-green); }
.btn-bai:hover, .btn-bai:focus { color: #fff; background: var(--bai-green-dark); border-color: var(--bai-green-dark); }
.bg-bai { background: var(--bai-green) !important; }
.tracking-wide { letter-spacing: .13em; }

.hero-summary {
    padding: 32px;
    border-radius: 20px;
    background:
        linear-gradient(120deg, rgba(0, 127, 95, .98), rgba(0, 77, 61, .98)),
        url("../images/bai-logo.png") right 40px center / 220px auto no-repeat;
    color: #fff;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    box-shadow: 0 16px 36px rgba(0, 77, 61, .16);
}
.hero-summary .section-kicker { color: #9be5c7; }
.hero-summary h2 { max-width: 760px; margin: 8px 0; font-size: clamp(26px, 3vw, 40px); font-weight: 750; }
.hero-summary p { max-width: 830px; margin: 0; color: rgba(255,255,255,.75); font-size: 15px; }
.hero-actions { display: flex; gap: 10px; white-space: nowrap; }
.hero-actions .btn-outline-light:hover { color: var(--bai-green-dark); }

.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
.metric-card {
    min-height: 128px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border: 1px solid var(--bai-line);
    border-radius: 15px;
    background: #fff;
    color: inherit;
    text-decoration: none;
    box-shadow: 0 7px 18px rgba(33, 72, 59, .04);
    transition: transform .18s ease, box-shadow .18s ease;
}
a.metric-card:hover { transform: translateY(-2px); box-shadow: 0 12px 25px rgba(33, 72, 59, .1); }
.metric-card strong { font-size: 34px; line-height: 1.1; margin: 7px 0 5px; color: var(--bai-navy); }
.metric-card small { color: #72837e; }
.metric-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; color: #667c75; }
.metric-primary { background: var(--bai-green-soft); border-color: #b9ddce; }
.metric-primary strong { color: var(--bai-green-dark); }
.metric-danger { background: #fff0f0; border-color: #f0c6c8; }
.metric-danger strong, .metric-danger-soft strong { color: var(--bai-red); }
.metric-warning { background: #fff7df; border-color: #edd89c; }
.metric-warning strong { color: #c37900; }
.metric-danger-soft { background: #fff7f7; }

.content-card {
    background: #fff;
    border: 1px solid var(--bai-line);
    border-radius: 17px;
    padding: 22px;
    box-shadow: 0 7px 22px rgba(33, 72, 59, .04);
}
.content-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.section-title { margin: 4px 0 0; font-size: 21px; font-weight: 720; }
.section-subtitle { color: #6e817a; }
.form-label { font-size: 12px; font-weight: 700; color: #536a62; margin-bottom: 6px; }
.form-control, .form-select { border-color: #cfded8; min-height: 40px; }
.form-control:focus, .form-select:focus { border-color: var(--bai-green); box-shadow: 0 0 0 .2rem rgba(0, 127, 95, .12); }

.process-list { display: grid; }
.process-row {
    display: grid;
    grid-template-columns: 235px minmax(160px, 1fr) 60px;
    align-items: center;
    gap: 16px;
    padding: 11px 8px;
    text-decoration: none;
    border-bottom: 1px solid #edf2f0;
    border-radius: 8px;
}
.process-row:hover { background: #f6faf8; }
.process-label { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 4px; }
.process-label strong { color: var(--bai-green-dark); font-size: 15px; }
.process-label span { color: #536d64; font-size: 12px; }
.process-label small { background: var(--bai-orange-soft); color: #ae5a0d; padding: 3px 6px; border-radius: 10px; font-size: 9px; }
.process-bar { height: 12px; background: #eff3f1; border-radius: 999px; overflow: hidden; display: flex; }
.process-bar span { height: 100%; }
.risk-high, .bg-risk-high { background: var(--bai-red) !important; }
.risk-medium, .bg-risk-medium { background: var(--bai-orange) !important; }
.risk-low, .bg-risk-low { background: #5f9179 !important; }
.risk-empty { background: #e8efec; }
.process-count { text-align: right; color: #75857f; }
.process-count strong { color: var(--bai-red); font-size: 16px; }
.legend-row { display: flex; gap: 16px; justify-content: flex-end; margin-top: 14px; color: #6e7f79; font-size: 11px; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }

.chart-wrap { height: 320px; position: relative; }
.chart-wrap-sm { height: 230px; }
.status-shortcuts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.status-shortcuts a { display: flex; justify-content: space-between; padding: 8px 10px; border-radius: 8px; background: #f6f8f7; text-decoration: none; font-size: 12px; }
.status-shortcuts a:hover { background: var(--bai-green-soft); }

.stage-map { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 12px; }
.stage-node {
    position: relative;
    min-height: 142px;
    border: 1px solid var(--bai-line);
    border-radius: 13px;
    padding: 16px;
    text-decoration: none;
    background: linear-gradient(160deg, #fff, #f7faf8);
    transition: .18s ease;
}
.stage-node:hover, .stage-node.active { border-color: var(--bai-green); box-shadow: 0 10px 20px rgba(0, 127, 95, .09); transform: translateY(-2px); }
.stage-index { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: var(--bai-green-soft); color: var(--bai-green-dark); font-weight: 800; font-size: 11px; }
.stage-name { min-height: 39px; margin: 10px 0 5px; font-weight: 700; }
.stage-count { font-size: 20px; font-weight: 750; color: var(--bai-navy); }
.stage-risk-line { display: flex; gap: 8px; margin-top: 7px; font-size: 11px; font-weight: 700; }
.text-risk-high { color: var(--bai-red); }
.text-risk-medium { color: var(--bai-orange); }
.text-risk-low { color: #4b8569; }

.matrix-grid { display: grid; grid-template-columns: 120px repeat(3, minmax(130px, 1fr)); border: 1px solid #c9d7e0; border-radius: 12px; overflow: hidden; }
.matrix-corner, .matrix-axis { min-height: 46px; display: grid; place-items: center; background: #f4f7f9; border-right: 1px solid #d1dde4; border-bottom: 1px solid #d1dde4; font-size: 11px; font-weight: 800; color: #4e6572; }
.matrix-axis-y { min-height: 100px; color: var(--bai-navy); }
.matrix-cell {
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    border-right: 1px solid rgba(77, 101, 114, .2);
    border-bottom: 1px solid rgba(77, 101, 114, .2);
    text-decoration: none;
    transition: filter .18s ease, box-shadow .18s ease;
}
.matrix-cell:hover, .matrix-cell.selected { filter: saturate(1.25); box-shadow: inset 0 0 0 3px var(--bai-green); z-index: 1; }
.matrix-cell strong { font-size: 25px; color: var(--bai-navy); }
.matrix-cell span { font-weight: 750; color: var(--bai-navy); }
.matrix-cell small { font-size: 10px; color: #536877; }
.matrix-green { background: #e2f0d9; }
.matrix-yellow { background: #fff2c9; }
.matrix-red { background: #f6d1d2; }
.matrix-blue { background: #dceaf5; }
.matrix-orange { background: #fbe3d4; }
.matrix-peach { background: #f9e8da; }
.matrix-gray { background: #eef1f4; }

.budget-main { padding: 18px; border-radius: 13px; background: var(--bai-green-soft); display: flex; flex-direction: column; margin-bottom: 20px; }
.budget-main span, .budget-row span { color: #62786f; font-size: 12px; }
.budget-main strong { color: var(--bai-green-dark); font-size: 27px; margin-top: 5px; }
.budget-row { margin-top: 17px; }
.budget-row > div:first-child { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; }
.budget-row .progress { height: 9px; }
.budget-row small { display: block; margin-top: 5px; color: #778781; }
.budget-note { margin-top: 22px; padding: 13px; background: #f7f9f8; border-left: 3px solid var(--bai-orange); color: #61756e; font-size: 12px; }

.timeline-list { max-height: 376px; overflow-y: auto; }
.timeline-item { display: grid; grid-template-columns: 70px 1fr auto; gap: 13px; align-items: center; padding: 12px 4px; border-bottom: 1px solid #edf2f0; text-decoration: none; }
.timeline-item:hover { background: #f8faf9; }
.timeline-date { display: grid; text-align: center; border-right: 1px solid var(--bai-line); }
.timeline-date strong { font-size: 21px; color: var(--bai-green-dark); }
.timeline-date span { font-size: 10px; color: #71827c; }
.timeline-content { min-width: 0; }
.timeline-content > * { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timeline-content span, .timeline-content small { color: #72837d; font-size: 10px; }

.finding-list { display: grid; gap: 12px; }
.finding-card { border: 1px solid var(--bai-line) !important; border-radius: 13px !important; overflow: hidden; }
.finding-summary { display: grid; grid-template-columns: 104px minmax(280px, 1fr) 220px 64px; gap: 16px; align-items: center; padding: 16px 18px; background: #fff !important; box-shadow: none !important; }
.finding-summary::after { position: absolute; right: 12px; }
.finding-code-wrap { display: flex; align-items: center; gap: 9px; }
.finding-code-wrap div { display: grid; }
.finding-code-wrap small { color: #88958f; font-size: 9px; }
.risk-pill { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; color: #fff; font-weight: 800; }
.risk-h { background: var(--bai-red); }
.risk-m { background: var(--bai-orange); }
.risk-l { background: #5f9179; }
.finding-title-wrap > strong { font-size: 14px; }
.finding-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 5px; color: #6e817a; font-size: 10px; }
.finding-meta span:not(:last-child)::after { content: "·"; margin-left: 12px; }
.finding-progress-wrap { font-size: 10px; color: #687c74; }
.finding-progress-wrap .progress { height: 6px; margin-top: 6px; }
.finding-priority { display: grid; justify-items: center; padding-right: 14px; }
.finding-priority span { font-weight: 850; font-size: 16px; color: var(--bai-navy); }
.finding-priority small { color: #75857f; }
.accordion-body { background: #fbfdfc; padding: 20px; }
.finding-detail-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.finding-detail-grid > div { padding: 11px; background: #fff; border: 1px solid #e4ece8; border-radius: 9px; }
.finding-detail-grid span, .update-strip span { display: block; color: #6a7f77; font-size: 9px; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; }
.finding-detail-grid p, .update-strip p { margin: 5px 0 0; font-size: 12px; }
.update-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-top: 12px; }
.update-strip > div { padding: 12px; background: var(--bai-green-soft); border-radius: 9px; }
.update-strip .is-blocker { background: #fff0f0; }
.action-toolbar, .package-toolbar { display: flex; flex-wrap: wrap; gap: 7px; margin: 16px 0 12px; }
.package-list { display: grid; gap: 12px; }
.package-card { border: 1px solid #dce6e2; border-radius: 12px; background: #fff; overflow: hidden; }
.package-header { padding: 15px; display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid #edf2f0; }
.package-id, .item-id { color: var(--bai-green); font-weight: 800; font-size: 10px; letter-spacing: .06em; }
.package-header h4 { font-size: 15px; margin: 3px 0 4px; }
.package-header p { margin: 0; color: #6b7e77; font-size: 11px; }
.package-head-actions { display: flex; align-items: flex-start; gap: 7px; white-space: nowrap; }
.priority-pill { background: var(--bai-navy); color: #fff; padding: 4px 7px; border-radius: 5px; font-size: 10px; font-weight: 800; }
.status-badge { font-size: 9px; font-weight: 700; }
.status-not-started { color: #596b65; background: #e9eeec; }
.status-in-progress { color: #986000; background: #fff0c2; }
.status-in-review { color: #1f5d8a; background: #deeffb; }
.status-blocked { color: #a31321; background: #fbdde0; }
.status-done { color: #056344; background: #dff2e9; }
.status-on-hold { color: #6b547e; background: #eee5f4; }
.package-metrics { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1px; background: #edf2f0; border-bottom: 1px solid #edf2f0; }
.package-metrics > div { padding: 10px 13px; background: #f9fbfa; display: grid; }
.package-metrics span { color: #72827d; font-size: 9px; text-transform: uppercase; }
.package-metrics strong { font-size: 11px; margin-top: 3px; }
.package-toolbar { padding: 0 13px; }
.work-item-table { font-size: 11px; }
.work-item-table thead th { padding: 8px 12px; color: #60756d; background: #f6f9f7; font-size: 9px; text-transform: uppercase; letter-spacing: .06em; }
.work-item-table tbody td { padding: 9px 12px; }
.empty-state { padding: 18px; text-align: center; color: #768881; border: 1px dashed #cbdad4; border-radius: 10px; background: #f9fbfa; }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(420px, .85fr); }
.login-visual { display: grid; place-items: center; padding: 60px; background: radial-gradient(circle at 20% 20%, rgba(245,130,32,.18), transparent 26%), linear-gradient(140deg, #00392c, #007f5f); color: #fff; }
.login-visual-content { max-width: 700px; }
.login-logo { width: 160px; background: #fff; border-radius: 16px; padding: 13px; margin-bottom: 38px; }
.login-visual h1 { font-size: clamp(38px, 5vw, 65px); line-height: 1.05; margin-bottom: 24px; }
.login-visual p { font-size: 18px; color: rgba(255,255,255,.73); max-width: 620px; }
.login-feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 42px; }
.login-feature-grid > div { padding: 18px; border: 1px solid rgba(255,255,255,.18); border-radius: 12px; background: rgba(255,255,255,.08); }
.login-feature-grid strong, .login-feature-grid span { display: block; }
.login-feature-grid strong { font-size: 22px; color: #fff; }
.login-feature-grid span { font-size: 11px; color: rgba(255,255,255,.62); }
.login-panel { display: grid; place-items: center; padding: 40px; background: #f7faf8; }
.login-card { width: min(450px, 100%); padding: 36px; border: 1px solid var(--bai-line); border-radius: 18px; background: #fff; box-shadow: 0 20px 50px rgba(0, 63, 49, .1); }

.role-guide { display: grid; gap: 16px; }
.role-guide > div { display: flex; gap: 12px; align-items: flex-start; }
.role-guide p { margin: 2px 0 0; color: #71827c; font-size: 12px; }
.role-icon { flex: 0 0 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; font-weight: 800; }
.role-admin { background: #f9d6d8; color: var(--bai-red); }
.role-editor { background: var(--bai-green-soft); color: var(--bai-green); }
.role-viewer { background: #e5edf5; color: var(--bai-navy); }
.user-cell { display: flex; gap: 10px; align-items: center; }
.user-cell > span { width: 34px; height: 34px; display: grid; place-items: center; background: var(--bai-green-soft); color: var(--bai-green-dark); border-radius: 50%; font-weight: 800; }
.user-cell div { display: grid; }
.user-cell small { color: #71827c; }
.admin-edit-row td { background: #f8faf9; padding: 18px !important; }

.report-cover { display: flex; gap: 26px; align-items: center; padding: 28px; color: #fff; background: linear-gradient(125deg, var(--bai-green-dark), var(--bai-green)); border-radius: 16px; }
.report-cover img { width: 120px; background: #fff; padding: 12px; border-radius: 12px; }
.report-cover .section-kicker { color: #9be5c7; }
.report-cover h2 { margin: 5px 0; font-size: 30px; }
.report-cover p { margin: 0; color: rgba(255,255,255,.72); }
.report-section { padding: 26px 0; border-bottom: 1px solid var(--bai-line); }
.report-section h3 { font-size: 19px; margin-bottom: 16px; }
.report-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.report-metrics > div { display: grid; padding: 16px; background: #f5f8f6; border-radius: 10px; }
.report-metrics span { color: #6e817a; font-size: 11px; }
.report-metrics strong { color: var(--bai-navy); font-size: 22px; margin-top: 4px; }
.report-table { font-size: 11px; }
.report-matrix { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.report-matrix > div { min-height: 110px; padding: 15px; border-radius: 9px; display: grid; align-content: center; text-align: center; }
.report-matrix span { font-weight: 800; color: #566b62; }
.report-matrix strong { font-size: 27px; color: var(--bai-navy); }
.report-matrix small { color: #5d6e68; }
.report-footer { text-align: center; color: #788881; font-size: 10px; padding: 20px; }

@media (max-width: 1399px) {
    .metric-grid { grid-template-columns: repeat(3, 1fr); }
    .finding-detail-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 991.98px) {
    .main-content { margin-left: 0; }
    .sidebar { position: fixed; }
    .topbar { padding: 14px 18px; }
    .page-content { padding: 18px; }
    .data-badge { display: none; }
    .hero-summary { align-items: flex-start; flex-direction: column; }
    .finding-summary { grid-template-columns: 90px 1fr 54px; }
    .finding-progress-wrap { display: none; }
    .login-shell { grid-template-columns: 1fr; }
    .login-visual { display: none; }
    .login-panel { min-height: 100vh; }
}
@media (max-width: 767.98px) {
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .process-row { grid-template-columns: 145px 1fr 44px; gap: 8px; }
    .process-label { grid-template-columns: 38px 1fr; }
    .process-label small { display: none; }
    .matrix-grid { grid-template-columns: 76px repeat(3, minmax(96px, 1fr)); overflow-x: auto; }
    .matrix-cell { min-height: 120px; padding: 7px; }
    .finding-summary { grid-template-columns: 82px 1fr; }
    .finding-priority { display: none; }
    .finding-detail-grid { grid-template-columns: repeat(2, 1fr); }
    .package-metrics { grid-template-columns: repeat(2, 1fr); }
    .report-metrics { grid-template-columns: repeat(2, 1fr); }
}

@media print {
    body { background: #fff; font-size: 10px; }
    .sidebar, .topbar, .alert, .btn, .pagination { display: none !important; }
    .main-content { margin: 0; }
    .page-content { max-width: none; padding: 0; }
    .content-card { border: 0; box-shadow: none; }
    .executive-report { color: #000; }
    .report-page-break { break-before: page; }
    .report-cover { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
    .report-matrix > div, .report-metrics > div { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
    @page { size: A4 landscape; margin: 12mm; }
}
