/* ROE v2 — shared styles. Reuses the v1 navy palette for visual continuity. */

:root {
  --navy: #2E4A6B;
  --navy-dark: #1B2D43;
  --navy-deep: #243C58;
  --bg: #F6F8FA;
  --surface: #FFFFFF;
  --border: #E4E8EE;
  --text: #1B2430;
  --muted: #667085;
  --muted-2: #98A2B3;
  --accent: #3A5D85;
  --ok: #12A150;
  --ok-bg: #E6F6EC;
  --warn: #C99A3E;
  --warn-bg: #FDF3E3;
  --danger: #C0392B;
  --danger-bg: #FCEAE7;
  --info: #2E6FC9;
  --info-bg: #E7F0FC;
  --track: #F0F4F9;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }

/* ─── Top bar ─── */
.topbar {
  background: var(--navy-dark); color: #fff;
  padding: 14px 28px; display: flex; align-items: center; gap: 28px;
  box-shadow: 0 1px 3px rgba(16,24,40,.08);
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 16px; }
.brand .logo {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, #3A5D85, #243C58);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800;
}
.brand .sub { color: #B9C2CE; font-size: 11px; font-weight: 500; margin-top: 1px; }
.brand-meta { display: flex; flex-direction: column; }
.nav { display: flex; gap: 4px; margin-left: 16px; }
.nav a { padding: 8px 14px; border-radius: 6px; color: #C3D1E1; font-size: 13px; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(255,255,255,.12); color: #fff; }
.topbar-spacer { flex: 1; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding-left: 16px; border-left: 1px solid rgba(255,255,255,.12);
}
.user-chip .avatar {
  width: 30px; height: 30px; border-radius: 50%; background: #5A7BA0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}
.user-chip .uname { font-size: 13px; font-weight: 600; }
.user-chip .urole { font-size: 10px; color: #98A9BF; }
.user-chip .logout-link { color: #98A9BF; font-size: 11px; margin-left: 8px; cursor: pointer; }
.user-chip .logout-link:hover { color: #fff; }

/* ─── Page layout ─── */
.page { padding: 24px 28px; max-width: 1680px; margin: 0 auto; }
.page h1 { font-size: 22px; color: var(--navy); margin: 0 0 6px; }
.page .lead { color: var(--muted); font-size: 13px; margin: 0 0 22px; }

/* ─── Cards / panels ─── */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 18px 20px; margin-bottom: 16px;
}
.panel h2 { font-size: 15px; color: var(--navy); margin: 0 0 12px; }

/* ─── Tables ─── */
table.data {
  width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
table.data th, table.data td {
  text-align: left; padding: 10px 12px; font-size: 13px;
  border-bottom: 1px solid var(--border);
}
table.data th {
  background: #F8FAFC; color: var(--muted); text-transform: uppercase;
  font-size: 11px; letter-spacing: .5px; font-weight: 600;
}
table.data tbody tr:hover { background: #F7FAFF; cursor: pointer; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data .num    { text-align: right;  font-variant-numeric: tabular-nums; }
table.data .center { text-align: center; font-variant-numeric: tabular-nums; }

/* Redacted financial value — shown to users without houses.financials.
   No real numbers ship from the server in this state; the display
   string here is just a placeholder and is blurred for emphasis. */
.blurred-value {
  display: inline-block;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
  color: var(--muted-2);
  background: linear-gradient(90deg, rgba(229,231,235,.55), rgba(243,244,246,.35));
  border-radius: 4px;
  padding: 0 6px;
  filter: blur(3px);
  user-select: none;
  cursor: not-allowed;
}
.status-pill {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px;
}
.status-pill.planning   { background: #EAF2FB; color: var(--accent); }
.status-pill.active     { background: var(--ok-bg);   color: var(--ok); }
.status-pill.drawn      { background: var(--info-bg); color: var(--info); }
.status-pill.handed_over{ background: #F0F4F9;       color: var(--muted); }
.status-pill.archived   { background: #F0F4F9;       color: var(--muted-2); }

/* ─── Forms ─── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; background: #fff; font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent);
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 6px; border: 1px solid var(--border);
  background: #fff; color: var(--text); font-weight: 500; font-size: 13px;
}
.btn:hover { border-color: var(--navy); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-deep); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: #fff; }
.btn.danger:hover { background: var(--danger-bg); }
.btn.small { padding: 4px 10px; font-size: 12px; }

/* ─── Login ─── */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--navy-dark);
}
.login-card {
  background: #fff; border-radius: 12px; padding: 32px 36px;
  width: 380px; box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.login-card .brand-block { text-align: center; margin-bottom: 24px; }
.login-card .brand-block .logo {
  width: 48px; height: 48px; border-radius: 10px; margin: 0 auto 12px;
  background: linear-gradient(135deg, #3A5D85, #243C58);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 18px;
}
.login-card h1 { font-size: 18px; margin: 0 0 4px; color: var(--navy); }
.login-card .sub { color: var(--muted); font-size: 12px; margin: 0; }
.login-card .err {
  background: var(--danger-bg); color: var(--danger);
  padding: 10px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 14px;
}
.login-card form { margin-top: 18px; }
.login-card .btn.primary { width: 100%; justify-content: center; padding: 12px; font-size: 14px; }

/* ─── Tabs (admin) ─── */
.tabbar {
  display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px;
}
.tabbar a {
  padding: 10px 16px; font-size: 13px; color: var(--muted); font-weight: 500;
  border-bottom: 2px solid transparent;
}
.tabbar a.active { color: var(--navy); border-bottom-color: var(--navy); font-weight: 600; }
.tabbar a:hover { color: var(--text); }

/* ─── Cluster colour chips ─── */
.cluster-chip {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600; color: #fff;
}

/* ─── Gantt ─── */
.gantt {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; overflow-x: auto; padding: 16px;
}
.gantt-row {
  display: grid; grid-template-columns: 240px 1fr;
  align-items: center; gap: 12px; padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}
.gantt-row:last-child { border-bottom: none; }
.gantt-row .label { font-size: 12px; color: var(--text); font-weight: 500; }
.gantt-row .bar-track {
  position: relative; height: 20px; background: var(--track); border-radius: 4px;
}
.gantt-row .bar {
  position: absolute; top: 2px; height: 16px; border-radius: 3px;
  background: var(--navy); color: #fff; font-size: 10px; padding: 0 6px;
  display: flex; align-items: center; white-space: nowrap; overflow: hidden;
}

/* ─── Modal ─── */
.modal-bg {
  position: fixed; inset: 0; background: rgba(20,30,50,.45); display: none;
  align-items: center; justify-content: center; z-index: 1000;
}
.modal-bg.open { display: flex; }
.modal {
  background: #fff; border-radius: 10px; padding: 24px 28px; min-width: 460px;
  max-width: 600px; max-height: 85vh; overflow: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal h2 { margin: 0 0 16px; color: var(--navy); font-size: 17px; }
.modal .actions {
  display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px;
}

/* ─── Misc ─── */
.muted { color: var(--muted); }
.small { font-size: 12px; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; font-size: 13px; }
.kv .k { color: var(--muted); }
.checkbox-list { display: flex; flex-direction: column; gap: 8px; }
.checkbox-list label {
  display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 6px; cursor: pointer;
  background: #fff;
}
.checkbox-list label:hover { background: var(--track); }
.checkbox-list label .desc { font-size: 11px; color: var(--muted); margin-top: 2px; }
.toast {
  position: fixed; bottom: 20px; right: 20px;
  padding: 10px 16px; border-radius: 6px; font-size: 13px;
  background: var(--navy); color: #fff;
  box-shadow: 0 6px 20px rgba(0,0,0,.2); z-index: 2000;
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.toast.show { opacity: 1; }
.toast.danger { background: var(--danger); }
.toast.ok { background: var(--ok); }

/* ─── Impersonation banner + View-as dropdown ─── */
.impersonation-banner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 10px 18px; font-size: 13px;
  background: #FEF3C7; color: #78350F;
  border-bottom: 1px solid #FCD34D;
}
.impersonation-banner button { background: #fff; }

.view-as-btn { margin-right: 12px; }

.view-as-panel {
  position: absolute; top: 56px; right: 18px; z-index: 1500;
  width: 360px; max-height: 480px; overflow-y: auto;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,.12);
}
.view-as-header {
  padding: 10px 14px; font-weight: 600; color: var(--navy);
  border-bottom: 1px solid var(--border); font-size: 13px;
}
.view-as-list { list-style: none; margin: 0; padding: 6px; }
.view-as-list li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: 6px; gap: 12px;
}
.view-as-list li:hover { background: var(--track); }
.view-as-name { font-size: 13px; color: var(--navy); font-weight: 500; }
.view-as-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ─── Collapsible panel sections (Timeline, Milestones, Financials, …) ─── */
.section-toggle {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; user-select: none; margin: 0 0 14px 0;
  font-size: 15px;
}

/* ─── Task tree (parent/child rows in cluster tables) ─── */
table.data tr.task-parent > td { font-weight: 500; }
table.data tr.task-child > td  { background: rgba(94,24,154,.025); }
.task-tree-toggle { font-size: 11px; }
.section-arrow {
  display: inline-block; width: 14px; color: var(--muted);
  font-size: 11px;
}
.section-chip {
  display: inline-block; padding: 5px 14px; border-radius: 14px;
  color: #fff; font-size: 13px; font-weight: 600;
  letter-spacing: .3px;
}
.section-actions { margin-left: auto; }
.section-body { /* default block, collapse via inline display:none */ }
