/* ============================================================
   ElyonEdge Project Manager — design system
   RAG discipline: Green = on standard · Amber = at risk, named
   recovery action · Red = act today · Grey = not started/auto
   ============================================================ */
:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --panel-2: #f8fafd;
  --ink: #16233b;
  --ink-2: #5b6b85;
  --ink-3: #8b98ad;
  --line: #e3e9f2;
  --brand: #0f3d6e;
  --brand-2: #1663b0;
  --accent: #c9a227;
  --green: #1e8e4e;
  --green-bg: #e4f5ea;
  --amber: #b97d10;
  --amber-bg: #fdf3dd;
  --red: #c43d3d;
  --red-bg: #fde8e8;
  --grey: #8b98ad;
  --grey-bg: #eef1f6;
  --blue-bg: #e8f1fb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(22, 35, 59, .07), 0 6px 18px rgba(22, 35, 59, .05);
  --sidebar-w: 244px;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"], :root:not([data-theme]) {
    --bg: #0f1524; --panel: #171f33; --panel-2: #1c2640; --ink: #e8edf6;
    --ink-2: #a7b4ca; --ink-3: #74829c; --line: #263152;
    --brand: #6ea8dd; --brand-2: #8dbcec; --accent: #d9b64a;
    --green-bg: #143223; --amber-bg: #33270e; --red-bg: #371a1a;
    --grey-bg: #202a42; --blue-bg: #16294a;
    --shadow: 0 1px 3px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14.5px; line-height: 1.5;
}
h1, h2, h3, h4 { margin: 0 0 .35em; line-height: 1.25; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: .3em 0; }

#app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
#sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, #0f3d6e 0%, #0a2b4e 100%);
  color: #eaf1f9; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 30;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px 12px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px; flex: 0 0 40px;
  background: linear-gradient(135deg, #c9a227, #e7c95c);
  color: #14263e; font-weight: 800; display: flex; align-items: center; justify-content: center;
  font-size: 15px; letter-spacing: .5px;
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: .4px; }
.brand-sub { font-size: 11.5px; color: #a9c3de; }
#nav { padding: 6px 10px; flex: 1; }
.nav-group-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.2px; color: #7fa1c4; margin: 14px 8px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; margin: 1px 0; border-radius: 8px; border: 0;
  background: transparent; color: #d7e4f2; font-size: 13.5px; cursor: pointer; text-align: left;
  font-family: inherit;
}
.nav-item:hover { background: rgba(255,255,255,.08); }
.nav-item.active { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
.nav-item .ico { width: 20px; text-align: center; }
.nav-item .badge { margin-left: auto; }
.sidebar-foot { padding: 14px 16px; font-size: 11px; color: #9db8d4; border-top: 1px solid rgba(255,255,255,.12); }
.motto { font-style: italic; margin-bottom: 8px; }
.plan-clock { font-weight: 600; color: #d8c46f; }

/* ---------- Signed-in user chip ---------- */
#user-chip { padding: 0 10px 4px; }
.u-chip {
  display: flex; align-items: center; gap: 9px; padding: 9px 10px;
  background: rgba(255,255,255,.10); border-radius: 10px; border: 1px solid rgba(255,255,255,.14);
}
.u-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: 0 0 32px; font-size: 12px; font-weight: 800;
  background: linear-gradient(135deg, #c9a227, #e7c95c); color: #14263e;
  display: flex; align-items: center; justify-content: center;
}
.u-name { font-weight: 700; font-size: 12.5px; color: #fff; line-height: 1.2; }
.u-role { font-size: 10.5px; color: #a9c3de; }
.u-scope { font-size: 10px; color: #d8c46f; font-weight: 700; margin-top: 1px; }
.u-out { background: none; border: 0; color: #a9c3de; cursor: pointer; font-size: 14px; padding: 2px 4px; }
.u-out:hover { color: #fff; }

/* ---------- My Team (hierarchy) in the side panel ---------- */
#my-team { padding: 4px 10px 10px; }
.mt-head { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.2px; color: #7fa1c4; margin: 8px 8px 5px; }
.mt-person {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 6px 9px; border-radius: 8px; border: 0; background: transparent;
  color: #d7e4f2; font-size: 12px; cursor: pointer; font-family: inherit;
}
.mt-person:hover { background: rgba(255,255,255,.08); }
.mt-dot {
  width: 24px; height: 24px; border-radius: 50%; flex: 0 0 24px; font-size: 10px; font-weight: 700;
  background: rgba(255,255,255,.16); color: #fff; display: flex; align-items: center; justify-content: center;
}
.mt-person .mt-n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-person .mt-r { font-size: 10px; color: #8fb0cf; }
.mt-flag { font-size: 10px; font-weight: 800; color: #ffb3b3; }

/* ---------- Main / topbar ---------- */
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#topbar {
  display: flex; align-items: center; gap: 14px; padding: 12px 22px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
#crumb { font-weight: 700; font-size: 15.5px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
#menu-btn { display: none; }
#view { padding: 20px 22px 60px; max-width: 1280px; width: 100%; margin: 0 auto; }

/* ---------- Cards / layout ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px;
}
.card.tight { padding: 12px 14px; }
.card-title { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.card-title h2, .card-title h3 { margin: 0; }
.card-title .spacer { flex: 1; }
.grid { display: grid; gap: 14px; margin-bottom: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1000px) { .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 660px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; color: var(--ink-3); }
.right { text-align: right; }
.center { text-align: center; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex .spacer { flex: 1; }
.wrap { flex-wrap: wrap; }
.mt { margin-top: 12px; } .mb { margin-bottom: 12px; }

/* ---------- RAG + badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px;
  border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .2px;
  white-space: nowrap;
}
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.grey { background: var(--grey-bg); color: var(--grey); }
.badge.blue { background: var(--blue-bg); color: var(--brand-2); }
.badge.gold { background: #f7efd4; color: #8a6d10; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: 0 0 10px; }
.dot.green { background: var(--green); } .dot.amber { background: var(--amber); }
.dot.red { background: var(--red); } .dot.grey { background: var(--grey); }
.rag-cell { text-align: center; font-size: 11px; font-weight: 700; border-radius: 6px; padding: 3px 2px; }
.rag-cell.green { background: var(--green-bg); color: var(--green); }
.rag-cell.amber { background: var(--amber-bg); color: var(--amber); }
.rag-cell.red { background: var(--red-bg); color: var(--red); }
.rag-cell.grey { background: var(--grey-bg); color: var(--grey); }

.flag-bell { font-weight: 700; font-size: 13px; cursor: pointer; padding: 4px 10px; border-radius: 8px; }
.flag-bell.has-flags { background: var(--red-bg); color: var(--red); }
.flag-bell.clear { background: var(--green-bg); color: var(--green); }

/* ---------- Stat tiles ---------- */
.stat { padding: 14px 16px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); }
.stat .label { font-size: 12px; color: var(--ink-2); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }
.stat .value { font-size: 1.7rem; font-weight: 800; margin: 2px 0; }
.stat .sub { font-size: 12px; color: var(--ink-3); }
.stat.green-edge { border-left: 4px solid var(--green); }
.stat.amber-edge { border-left: 4px solid var(--amber); }
.stat.red-edge { border-left: 4px solid var(--red); }
.stat.blue-edge { border-left: 4px solid var(--brand-2); }
.stat.gold-edge { border-left: 4px solid var(--accent); }

/* ---------- WIG scoreboard ---------- */
.wig-card { border-top: 4px solid var(--brand); }
.wig-card.w1 { border-top-color: var(--accent); }
.wig-card.w2 { border-top-color: var(--brand-2); }
.wig-card.w3 { border-top-color: var(--green); }
.measure-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.measure-row:last-child { border-bottom: 0; }
.measure-row .m-name { flex: 1; }
.measure-row .m-val { font-weight: 800; }
.bar { height: 7px; border-radius: 4px; background: var(--grey-bg); overflow: hidden; flex: 0 0 90px; }
.bar > span { display: block; height: 100%; border-radius: 4px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; padding: 8px 10px; color: var(--ink-2); font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .6px; border-bottom: 2px solid var(--line);
  white-space: nowrap; background: var(--panel);
}
table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:hover td { background: var(--panel-2); }
table.data tr.clickable { cursor: pointer; }
table.data td.nowrap, table.data th.nowrap { white-space: nowrap; }

/* ---------- Forms ---------- */
input, select, textarea, button { font-family: inherit; font-size: 13.5px; color: var(--ink); }
input[type="text"], input[type="date"], input[type="number"], input[type="email"], input[type="tel"], input[type="url"], select, textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; width: 100%; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(22, 99, 176, .15); }
label.f { display: block; margin-bottom: 10px; }
label.f > span { display: block; font-size: 11.5px; font-weight: 700; color: var(--ink-2); margin-bottom: 3px; text-transform: uppercase; letter-spacing: .5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 660px) { .form-grid { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--panel);
  cursor: pointer; font-weight: 600; font-size: 13px; color: var(--ink);
}
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn.danger { color: var(--red); border-color: var(--red); background: transparent; }
.btn.danger:hover { background: var(--red-bg); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.wa { background: #128c4b; border-color: #128c4b; color: #fff; }
.btn.zoho { background: #d3372c; border-color: #d3372c; color: #fff; }
.btn.wd { background: #1663b0; border-color: #1663b0; color: #fff; }
.icon-btn { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 5px 10px; cursor: pointer; font-size: 15px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip {
  padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); font-size: 12.5px; cursor: pointer; font-weight: 600; color: var(--ink-2);
}
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- Modal ---------- */
#modal-root:empty { display: none; }
.modal-overlay {
  position: fixed; inset: 0; background: rgba(10, 20, 40, .5); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px;
  overflow-y: auto;
}
.modal {
  background: var(--panel); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
  width: 100%; max-width: 680px; padding: 20px 22px; margin-bottom: 40px;
}
.modal.wide { max-width: 900px; }
.modal-head { display: flex; align-items: center; margin-bottom: 12px; }
.modal-head h2 { margin: 0; flex: 1; }
.modal-close { background: none; border: 0; font-size: 20px; cursor: pointer; color: var(--ink-3); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ---------- Sign-in gate ---------- */
.login-overlay { align-items: center; background: linear-gradient(160deg, #0f3d6e, #0a2b4e); }
.err-msg { color: var(--red); font-weight: 600; min-height: 18px; }
.ok-msg { color: var(--ink-2); min-height: 18px; }
#locked-screen {
  display: flex; align-items: center; justify-content: center; min-height: 60vh;
  color: var(--ink-3); font-size: 13px; text-align: center;
}

/* ---------- Toast ---------- */
#toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  font-size: 13px; box-shadow: var(--shadow); animation: toast-in .25s ease;
  max-width: 340px;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Loop stages ---------- */
.loop-track { display: flex; gap: 4px; flex-wrap: wrap; }
.loop-step {
  flex: 1; min-width: 86px; text-align: center; padding: 7px 4px; border-radius: 8px;
  font-size: 11px; font-weight: 700; background: var(--grey-bg); color: var(--ink-3);
  border: 1px solid var(--line); position: relative;
}
.loop-step.done { background: var(--green-bg); color: var(--green); border-color: var(--green); }
.loop-step.now { background: var(--blue-bg); color: var(--brand-2); border-color: var(--brand-2); }
.loop-step.late { background: var(--red-bg); color: var(--red); border-color: var(--red); }
.loop-step .ls-n { display: block; font-size: 15px; }

/* ---------- Flags ---------- */
.flag-item {
  display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px;
  border-left: 4px solid var(--red); background: var(--red-bg); border-radius: 8px; margin-bottom: 8px;
  font-size: 13px;
}
.flag-item.amber { border-left-color: var(--amber); background: var(--amber-bg); }
.flag-item .f-body { flex: 1; }
.flag-item .f-title { font-weight: 700; }
.flag-item .f-meta { font-size: 11.5px; color: var(--ink-2); margin-top: 1px; }

/* ---------- Org chart ---------- */
.org-layer { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.org-node {
  background: var(--panel); border: 1.5px solid var(--brand); border-radius: 10px;
  padding: 8px 14px; text-align: center; min-width: 150px; box-shadow: var(--shadow);
}
.org-node .o-role { font-weight: 800; font-size: 13px; }
.org-node .o-owns { font-size: 11px; color: var(--accent); font-weight: 700; }
.org-node .o-sub { font-size: 11px; color: var(--ink-2); }
.org-connector { text-align: center; color: var(--ink-3); font-size: 15px; line-height: 1.1; margin: 2px 0; }

/* ---------- Cascade (WIG tree) ---------- */
.cascade-item { border-left: 3px solid var(--line); padding: 6px 0 6px 14px; margin-left: 6px; }
.cascade-item.lvl-annual { border-left-color: var(--accent); }
.cascade-item.lvl-quarterly { border-left-color: var(--brand-2); }
.cascade-item.lvl-monthly { border-left-color: var(--green); }
.cascade-item.lvl-weekly { border-left-color: var(--ink-3); }

.progress-ring { font-weight: 800; }

/* ---------- Meeting ---------- */
.commit-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.commit-item:last-child { border-bottom: 0; }
.commit-item input[type="checkbox"] { width: 17px; height: 17px; margin-top: 2px; }
.commit-item .done-text { text-decoration: line-through; color: var(--ink-3); }

/* ---------- Print (reports) ---------- */
.report-paper { background: #fff; color: #16233b; border: 1px solid var(--line); border-radius: 10px; padding: 26px 30px; }
.report-paper h1 { color: #0f3d6e; }
.report-paper table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0 16px; }
.report-paper th, .report-paper td { border: 1px solid #d5deea; padding: 6px 9px; text-align: left; }
.report-paper th { background: #eef3f9; }
@media print {
  #sidebar, #topbar, .no-print, #toast-root { display: none !important; }
  #view { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; }
  body { background: #fff; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  #sidebar { position: fixed; left: calc(-1 * var(--sidebar-w)); transition: left .2s ease; }
  #sidebar.open { left: 0; }
  #menu-btn { display: block; }
  #view { padding: 14px 12px 60px; }
}
