:root {
  --bg: #f3f5f8; --panel: #fff; --line: #e2e6ec; --text: #1c2431; --muted: #66707f;
  --primary: #1f5fbf; --primary-dk: #174a96; --danger: #c0392b; --ok: #1f8a4c; --warn: #b7791f;
  --side: #17233a; --side-text: #c7d0e0; --radius: 8px; --shadow: 0 1px 3px rgba(20,30,50,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; } a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; font-weight: 600; } h1 { font-size: 20px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
small, .muted { color: var(--muted); }
[hidden] { display: none !important; }

/* Layout */
#app { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--side); color: var(--side-text); display: flex; flex-direction: column; flex-shrink: 0; }
.brand { padding: 18px 16px; font-size: 16px; font-weight: 700; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand small { display: block; font-weight: 400; color: var(--side-text); font-size: 11px; }
.nav { display: flex; flex-direction: column; padding: 8px; gap: 2px; }
.nav a { color: var(--side-text); padding: 9px 12px; border-radius: 6px; display: flex; gap: 10px; align-items: center; }
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.nav a.active { background: var(--primary); color: #fff; }
.nav .ico { width: 18px; text-align: center; opacity: .85; }
.side-foot { margin-top: auto; padding: 12px 16px; font-size: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.side-foot b { color: #fff; display: block; }
.side-foot a { color: var(--side-text); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: var(--panel); border-bottom: 1px solid var(--line); padding: 12px 24px; display: flex; align-items: center; gap: 12px; }
.topbar h1 { flex: 1; }
.content { padding: 20px 24px 40px; }
.menu-btn { display: none; }

/* Cards & grids */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.card-head h2 { flex: 1; margin: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .n { font-size: 26px; font-weight: 700; line-height: 1.1; }
.kpi .l { color: var(--muted); font-size: 12px; margin-top: 4px; }
.kpi.red .n { color: var(--danger); } .kpi.green .n { color: var(--ok); } .kpi.amber .n { color: var(--warn); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cols-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .cols, .cols-3 { grid-template-columns: 1fr; } }

/* Tables */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
tr.click { cursor: pointer; } tr.click:hover { background: #f6f8fb; }
td.num, th.num { text-align: right; }
.empty { color: var(--muted); padding: 18px; text-align: center; }
.sub-row td:first-child { padding-left: 34px; }
.sub-row td:first-child::before { content: "↳ "; color: var(--muted); }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.s-not_started { background: #eceff3; color: #4a5567; }
.s-in_progress { background: #dbe8fb; color: #1f4f9c; }
.s-on_hold { background: #f6e6c4; color: #7a5410; }
.s-under_review { background: #ead9f7; color: #5c2e86; }
.s-completed { background: #d6f0df; color: #1c6b3b; }
.p-low { background: #eceff3; color: #4a5567; } .p-medium { background: #e3ebf7; color: #2a4b7f; }
.p-high { background: #fde5d8; color: #9a3d12; } .p-urgent { background: #f9d3d0; color: #9b1c12; }
.role { background: #e8edf5; color: #2c3e5c; }
.overdue { color: var(--danger); font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

/* Forms & buttons */
button, .btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--text); padding: 7px 12px; border-radius: 6px; cursor: pointer; }
button:hover, .btn:hover { background: #f4f6fa; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; } .btn-primary:hover { background: var(--primary-dk); }
.btn-danger { color: var(--danger); border-color: #efc7c2; } .btn-danger:hover { background: #fdf0ee; }
.btn-sm { padding: 3px 8px; font-size: 12px; }
.btn-link { border: none; background: none; color: var(--primary); padding: 2px 4px; } .btn-link:hover { background: none; text-decoration: underline; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid #c9d0da; border-radius: 6px; background: #fff; color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bcd1f3; border-color: var(--primary); }
select.inline { width: auto; padding: 3px 6px; font-size: 12.5px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters input, .filters select { width: auto; min-width: 140px; }
.filters .grow { flex: 1; min-width: 180px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.grid .full { grid-column: 1 / -1; }
.fld label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.fld small { display: block; margin-top: 3px; font-size: 11.5px; }
.fld .check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); font-size: 13.5px; margin-top: 22px; }
.fld .check input { width: auto; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { border: none; background: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 8px 14px; color: var(--muted); }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 4px 10px; border: 1px solid var(--line); border-radius: 14px; background: #fff; cursor: pointer; font-size: 12.5px; }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 20px; }
.detail-grid .k { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.detail-grid .v { font-weight: 500; word-break: break-word; }
.tree ul { list-style: none; padding-left: 22px; margin: 4px 0; border-left: 1px dashed #c9d0da; }
.tree > ul { padding-left: 0; border: none; }
.tree li { padding: 3px 0; }
.tree .node { display: inline-flex; gap: 8px; align-items: center; }
.progress-bar { height: 6px; background: #e8ecf2; border-radius: 3px; overflow: hidden; min-width: 80px; }
.progress-bar i { display: block; height: 100%; background: var(--ok); }
pre.desc { white-space: pre-wrap; font: inherit; margin: 6px 0; color: #333; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--side); }
.login { width: 360px; background: #fff; border-radius: 10px; padding: 28px; box-shadow: 0 10px 30px rgba(0,0,0,.3); }
.login h1 { margin-bottom: 4px; } .login .fld { margin-bottom: 12px; }

/* Modal & toast */
.modal-bg { position: fixed; inset: 0; background: rgba(15,22,35,.5); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 640px; padding: 20px 22px; box-shadow: 0 12px 40px rgba(0,0,0,.3); }
.modal.wide { max-width: 860px; }
.modal h2 { margin-bottom: 14px; }
.toast { position: fixed; bottom: 20px; right: 20px; background: #1c2431; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.3); z-index: 60; max-width: 420px; }
.toast.err { background: var(--danger); } .toast.ok { background: var(--ok); }

@media (max-width: 800px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-block; }
  .content { padding: 14px; } .topbar { padding: 10px 14px; }
  .grid { grid-template-columns: 1fr; }
}
@media print { .sidebar, .topbar, .filters, .actions, button { display: none !important; } .content { padding: 0; } }
