/* PM Dashboard. Palette: navy, blue, white and light gray. */
:root {
  --navy: #14213d;
  --navy-2: #1d2f57;
  --blue: #2563eb;
  --blue-dark: #1e4fc4;
  --blue-soft: #e8efff;
  --white: #ffffff;
  --gray-50: #f7f8fb;
  --gray-100: #f1f3f8;
  --gray-200: #e3e7ef;
  --gray-300: #cdd3de;
  --gray-500: #6b7385;
  --gray-700: #374151;
  --text: #1b2433;
  --green: #137a4c;
  --green-soft: #e4f6ec;
  --amber: #9a5b00;
  --amber-soft: #fff3da;
  --red: #b42318;
  --red-soft: #fde7e5;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 33, 61, 0.06), 0 2px 8px rgba(20, 33, 61, 0.04);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--gray-100);
  min-height: 100vh;
}
h1, h2, h3 { margin: 0; color: var(--navy); line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid rgba(37, 99, 235, 0.45); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--gray-500); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }

.skip-link { position: absolute; left: -999px; top: 8px; background: var(--white); padding: 8px 12px; z-index: 100; }
.skip-link:focus { left: 8px; }

.boot { display: grid; place-items: center; min-height: 100vh; gap: 12px; color: var(--gray-500); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--gray-200); border-top-color: var(--blue); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Shell -------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--navy); color: #d7def0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { padding: 20px 18px 16px; color: var(--white); font-weight: 700; font-size: 16px; display: flex; gap: 10px; align-items: center; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--blue); display: grid; place-items: center; font-size: 14px; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 6px 10px; }
.nav a { color: #d7def0; padding: 9px 10px; border-radius: 8px; display: flex; align-items: center; gap: 10px; }
.nav a:hover { background: var(--navy-2); text-decoration: none; color: var(--white); }
.nav a[aria-current="page"] { background: var(--blue); color: var(--white); }
.nav .count { margin-left: auto; background: var(--white); color: var(--navy); border-radius: 999px; padding: 0 7px; font-size: 11px; font-weight: 700; }
.sidebar-foot { margin-top: auto; padding: 14px 18px; font-size: 12px; color: #9fb0d4; border-top: 1px solid var(--navy-2); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { background: var(--white); border-bottom: 1px solid var(--gray-200); padding: 12px 24px; display: flex; gap: 12px; align-items: center; position: sticky; top: 0; z-index: 20; flex-wrap: wrap; }
.menu-btn { display: none; }
.content { padding: 24px; display: grid; gap: 18px; align-content: start; }
.page-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.page-head .sub { color: var(--gray-500); font-size: 13px; }
.mode-banner { background: #fff8e6; color: #6b4300; border-bottom: 1px solid #f2d59b; padding: 8px 24px; font-size: 13px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.mode-banner.live { background: var(--green-soft); color: #0c4d2f; border-color: #b8e2cb; }
.user-chip { display: flex; gap: 10px; align-items: center; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--blue-soft); color: var(--blue-dark); display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.role { font-size: 12px; color: var(--gray-500); }

/* ---- Cards, KPIs, grids -------------------------------------------------- */
.card { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.card-head { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.card-head .spacer { min-width: 8px; }
.grid { display: grid; gap: 16px; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.kpi { border-top: 3px solid var(--blue); }
.kpi.warn { border-top-color: #e0a100; }
.kpi.bad { border-top-color: var(--red); }
.kpi.good { border-top-color: var(--green); }
.kpi .label { color: var(--gray-500); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; display: flex; gap: 6px; align-items: center; }
.kpi .value { font-size: 20px; font-weight: 700; color: var(--navy); margin-top: 6px; font-variant-numeric: tabular-nums; line-height: 1.2; }
h1:focus { outline: none; }
.kpi .hint { color: var(--gray-500); font-size: 12px; margin-top: 4px; }
.formula { font-size: 12px; color: var(--gray-500); background: var(--gray-50); border: 1px dashed var(--gray-300); border-radius: 8px; padding: 8px 10px; margin-top: 10px; }
details.help summary { cursor: pointer; color: var(--blue); font-size: 12px; }
.info-dot { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--gray-200); color: var(--gray-700); font-size: 11px; cursor: help; }

/* ---- Buttons, inputs ------------------------------------------------------ */
.btn { border: 1px solid var(--gray-300); background: var(--white); color: var(--navy); padding: 7px 12px; border-radius: 8px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; min-height: 36px; white-space: nowrap; }
.btn:hover { border-color: var(--blue); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: var(--white); }
.btn-primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn-danger { color: var(--red); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 4px 9px; min-height: 30px; font-size: 13px; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--gray-300); border-radius: 8px; overflow: hidden; background: var(--white); }
.seg button { border: 0; background: transparent; padding: 7px 12px; cursor: pointer; color: var(--gray-700); }
.seg button[aria-pressed="true"] { background: var(--navy); color: var(--white); }
.input, .select, .textarea {
  border: 1px solid var(--gray-300); background: var(--white); border-radius: 8px; padding: 8px 10px; min-height: 36px; min-width: 0; width: 100%;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--blue); outline: 3px solid rgba(37, 99, 235, 0.2); }
.textarea { min-height: 80px; resize: vertical; }
.search { width: 240px; max-width: 100%; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.filters > label { display: grid; gap: 4px; font-size: 12px; color: var(--gray-500); min-width: 140px; }
.filters label.check { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--gray-700); font-size: 13px; }
.check { display: flex; gap: 6px; align-items: center; font-size: 13px; }

/* ---- Forms ------------------------------------------------------------------- */
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form .full { grid-column: 1 / -1; }
.field { display: grid; gap: 4px; min-width: 0; }
.field > span { font-size: 12px; color: var(--gray-700); font-weight: 600; }
.field .req { color: var(--red); }
.field .hint { font-size: 12px; color: var(--gray-500); }
.field .error { font-size: 12px; color: var(--red); }
.field.invalid .input, .field.invalid .select, .field.invalid .textarea { border-color: var(--red); background: #fffbfa; }
.form-error { grid-column: 1 / -1; background: var(--red-soft); color: var(--red); border-radius: 8px; padding: 10px 12px; }
@media (max-width: 640px) { .form { grid-template-columns: 1fr; } }

/* ---- Tables --------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--gray-200); border-radius: 8px; background: var(--white); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--gray-200); text-align: left; vertical-align: top; }
th { background: var(--gray-50); font-size: 12px; color: var(--gray-700); font-weight: 700; position: sticky; top: 0; white-space: nowrap; }
th button { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
th button:focus-visible { outline: 3px solid rgba(37, 99, 235, 0.45); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbff; }
tr.clickable { cursor: pointer; }
td.actions { white-space: nowrap; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 10px 2px; color: var(--gray-500); font-size: 13px; }
.pager .btn-group { gap: 4px; }

/* ---- Badges, progress ------------------------------------------------------ */
.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 600; background: var(--gray-200); color: var(--gray-700); white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.blue { background: var(--blue-soft); color: var(--blue-dark); }
.badge.navy { background: var(--navy); color: var(--white); }
.bar { height: 8px; background: var(--gray-200); border-radius: 999px; overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; background: var(--blue); border-radius: inherit; }
.bar.green > span { background: var(--green); }
.bar.amber > span { background: #e0a100; }
.bar.red > span { background: var(--red); }

/* ---- Alerts & empty states ------------------------------------------------- */
.alert-list { display: grid; gap: 8px; }
.alert { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; border: 1px solid var(--gray-200); border-left: 4px solid var(--blue); border-radius: 8px; padding: 10px 12px; background: var(--white); }
.alert.critical { border-left-color: var(--red); background: #fffafa; }
.alert.warning { border-left-color: #e0a100; background: #fffdf6; }
.alert .title { font-weight: 600; color: var(--navy); }
.alert .detail { color: var(--gray-700); font-size: 13px; }
.empty { text-align: center; padding: 34px 16px; color: var(--gray-500); display: grid; gap: 8px; justify-items: center; }
.empty strong { color: var(--navy); }
.notice { background: var(--blue-soft); color: #1c3c86; border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.notice.warn { background: var(--amber-soft); color: #6b4300; }

/* ---- Tabs ------------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--gray-200); overflow-x: auto; }
.tabs button { border: 0; background: transparent; padding: 10px 12px; cursor: pointer; color: var(--gray-500); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--navy); border-bottom-color: var(--blue); font-weight: 600; }

/* ---- Modal & toast ------------------------------------------------------------ */
.overlay { position: fixed; inset: 0; background: rgba(20, 33, 61, 0.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--white); border-radius: 12px; width: min(760px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); }
.modal header { padding: 16px 18px; border-bottom: 1px solid var(--gray-200); display: flex; gap: 10px; align-items: center; position: sticky; top: 0; background: var(--white); }
.modal .body { padding: 18px; display: grid; gap: 14px; }
.modal footer { padding: 12px 18px; border-top: 1px solid var(--gray-200); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; position: sticky; bottom: 0; background: var(--white); }
.toasts { position: fixed; bottom: 16px; right: 16px; display: grid; gap: 8px; z-index: 60; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--navy); color: var(--white); padding: 12px 14px; border-radius: 10px; box-shadow: var(--shadow); }
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

/* ---- Charts ------------------------------------------------------------------ */
.chart { width: 100%; height: auto; display: block; }
.chart text { font-size: 11px; fill: var(--gray-500); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--gray-700); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }
.chart-foot { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }

/* ---- Kanban & timeline ----------------------------------------------------------- */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(230px, 1fr)); gap: 12px; overflow-x: auto; }
.kanban-col { background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 10px; padding: 10px; min-height: 240px; display: grid; gap: 8px; align-content: start; }
.kanban-col.over { border-color: var(--blue); background: var(--blue-soft); }
.kanban-col h3 { display: flex; justify-content: space-between; }
.task-card { background: var(--white); border: 1px solid var(--gray-200); border-radius: 8px; padding: 10px; cursor: grab; display: grid; gap: 6px; box-shadow: var(--shadow); }
.task-card:active { cursor: grabbing; }
.task-card.overdue { border-left: 4px solid var(--red); }
.timeline { position: relative; overflow-x: auto; border: 1px solid var(--gray-200); border-radius: 8px; background: var(--white); }
.tl-row { display: grid; grid-template-columns: 260px 1fr; min-width: 720px; border-bottom: 1px solid var(--gray-200); }
.tl-row:last-child { border-bottom: 0; }
.tl-label { padding: 8px 10px; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-track { position: relative; height: 34px; margin: 6px 0; background: repeating-linear-gradient(90deg, transparent 0 calc(100% / 12 - 1px), var(--gray-200) calc(100% / 12 - 1px) calc(100% / 12)); border-radius: 4px; }
.tl-bar { position: absolute; top: 4px; height: 26px; border-radius: 6px; background: var(--blue); color: var(--white); font-size: 12px; padding: 4px 8px; overflow: hidden; white-space: nowrap; }
.tl-bar.done { background: var(--green); }
.tl-bar.late { background: var(--red); }
.tl-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--navy); }
.tl-head { display: grid; grid-template-columns: 260px 1fr; min-width: 720px; background: var(--gray-50); font-size: 12px; color: var(--gray-500); border-bottom: 1px solid var(--gray-200); }

/* Person card */
.person-hero { display: flex; gap: 16px; align-items: center; padding: 16px; border-radius: var(--radius); background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 60%, var(--blue) 140%); color: var(--white); }
.person-hero .muted { color: #c9d6f2; }
.person-hero .badge { background: rgba(255,255,255,.14); color: var(--white); }
.person-avatar { width: 60px; height: 60px; border-radius: 50%; background: var(--white); color: var(--navy); display: grid; place-items: center; font-weight: 800; font-size: 20px; flex: none; }
.person-name { color: var(--white); font-size: 22px; overflow-wrap: anywhere; }
.stat { display: grid; gap: 8px; border-top: 3px solid var(--blue); }
.stat.good { border-top-color: var(--green); }
.stat.bad { border-top-color: var(--red); }
.stat-icon { width: 26px; height: 26px; border-radius: 8px; background: var(--blue-soft); color: var(--blue-dark); display: grid; place-items: center; font-size: 14px; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; }
.facts { display: grid; gap: 12px; }
.fact { display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: 10px; background: var(--gray-50); border: 1px solid var(--gray-200); }
.fact-icon { width: 34px; height: 34px; border-radius: 10px; background: var(--navy); color: var(--white); display: grid; place-items: center; flex: none; font-size: 15px; }
.fact-value { font-weight: 600; overflow-wrap: anywhere; }
.alloc-row { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 10px 12px; border: 1px solid var(--gray-200); border-radius: 10px; background: var(--white); cursor: pointer; color: inherit; font: inherit; }
.alloc-row:hover { border-color: var(--blue); background: #fafbff; }
.alloc-row.static { cursor: default; }
.alloc-row.static:hover { border-color: var(--gray-200); background: var(--white); }
.row-icon { width: 30px; height: 30px; border-radius: 8px; background: var(--blue-soft); color: var(--blue-dark); display: grid; place-items: center; flex: none; }
.row-main { flex: 1; min-width: 0; }
.row-meter { width: 150px; flex: none; display: grid; gap: 4px; justify-items: end; }
.row-meter .bar { width: 100%; }
@media (max-width: 640px) { .row-meter { width: 96px; } .alloc-row { flex-wrap: wrap; } .person-hero { flex-direction: column; text-align: center; } }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* ---- Login ----------------------------------------------------------------------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(160deg, var(--navy) 0 40%, var(--gray-100) 40%); }
.auth-card { width: min(440px, 100%); background: var(--white); border-radius: 14px; padding: 26px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18); display: grid; gap: 14px; }
.auth-card .brand-mark { color: var(--white); }
.demo-accounts { display: grid; gap: 6px; font-size: 13px; }
.demo-accounts button { text-align: left; border: 1px solid var(--gray-200); background: var(--gray-50); border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.demo-accounts button:hover { border-color: var(--blue); }

/* ---- Responsive ----------------------------------------------------------------------- */
@media (max-width: 1024px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 250px; transform: translateX(-100%); transition: transform 0.2s ease; z-index: 40; box-shadow: 0 0 30px rgba(0,0,0,0.3); }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 35; }
}
@media (max-width: 640px) {
  .content { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .mode-banner { padding: 8px 16px; }
  .search { width: 100%; }
  .filters > label, .filters > .field { min-width: 0; width: 100%; }
  .filters select.select, .filters input.input { width: 100% !important; }
  .filters > .btn, .filters > .btn-ghost { width: 100%; justify-content: center; }
  .filters .spacer { display: none; }
  .kpi .value { font-size: 19px; }
  .grid.two { grid-template-columns: 1fr; }
}
@media print {
  .sidebar, .topbar, .mode-banner, .no-print, .toasts { display: none !important; }
  .shell { display: block; }
  body { background: var(--white); }
  .content { padding: 0; }
  .card { box-shadow: none; border-color: #ccc; }
  .table-wrap { overflow: visible; }
}
