/* ============================================================
   era.css — ERA Workflow Manager site skin ("The Rail", Plan 28)
   One stylesheet for every shared-layout page. Restyles the
   EXISTING class names from layout.ejs so markup keeps working.
   Loaded by layout.ejs with ?v=<commit sha> for cache busting.
   ============================================================ */

:root {
  /* brand + warm neutrals */
  --rust: #B43C28;
  --rust-hover: #9C3322;
  --rust-soft: #FAF3F1;
  --ink: #26221D;
  --text: #23201D;
  --muted: #85796E;
  --line: #E5E1DC;
  --line-soft: #F3F0EC;
  --ground: #F7F6F4;
  --card: #FFFFFF;
  /* semantic (chips + alerts), separate from the brand accent */
  --good: #226240;  --good-bg: #E3EFE7;
  --warn: #935611;  --warn-bg: #FBEEDD;
  --bad:  #A03422;  --bad-bg:  #F8E6E2;
  --info: #1D5FA8;  --info-bg: #E7EEF7;
  --radius: 8px;
  /* legacy aliases — pages reference these var names directly */
  --dark-gray: #3A342E;
  --light-gray: var(--line);
  --label-bg: var(--line-soft);
  --white: #FFFFFF;
  --success: var(--good);
  --warning: var(--warn);
  --error: var(--bad);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--ground);
  color: var(--text);
  min-height: 100vh;
  font-size: 13px;
}

h1 { font-size: 19px; font-weight: 650; color: var(--ink); letter-spacing: -0.01em; }

/* ── NAVBAR ─────────────────────────────────────────────── */
/* Plan 34 rebrand: the banner carries the CRE Keystone brand colors
   (Edge Charcoal + Brick Red per cre-keystone-brand-tokens), not the
   warm ink of the rest of the admin skin. */
.navbar {
  background: #1F2328;
  color: #fff;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.navbar .brand {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.01em;
}
.navbar .brand span.era { color: #B43C28; }
.navbar nav { display: flex; align-items: center; gap: 4px; }
.navbar nav a {
  color: rgba(255,255,255,0.62);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 11px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.navbar nav a:hover { color: #fff; background: rgba(255,255,255,0.08); }
.nav-dropdown { position: relative; }
.nav-dropdown > a { cursor: pointer; }
.nav-dropdown > a::after { content: ' \25BE'; font-size: 9px; opacity: 0.7; }
.nav-dropdown .dropdown-menu {
  display: none; position: absolute; top: 100%; left: 0; margin-top: 4px;
  background: var(--ink); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px; min-width: 190px; padding: 5px 0; z-index: 1000;
  box-shadow: 0 10px 28px rgba(28,22,16,0.4);
}
.nav-dropdown:hover .dropdown-menu { display: block; }
.nav-dropdown .dropdown-menu a {
  display: block; padding: 7px 16px; color: rgba(255,255,255,0.62);
  text-decoration: none; font-size: 12.5px; border-radius: 0; white-space: nowrap;
}
.nav-dropdown .dropdown-menu a:hover { color: #fff; background: rgba(255,255,255,0.08); }
.navbar .user-info {
  font-size: 12.5px;
  color: rgba(255,255,255,0.55);
  display: flex;
  align-items: center;
  gap: 12px;
}
.navbar .user-info .username { color: #fff; font-weight: 500; }

/* ── CONTAINER ──────────────────────────────────────────── */
.container { max-width: 1400px; margin: 0 auto; padding: 24px; }

/* ── CARDS ──────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 16px;
}
.card h2 {
  font-size: 14px;
  font-weight: 650;
  color: var(--ink);
  margin-bottom: 14px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}
.card h3 { color: var(--ink); }

/* ── BUTTONS ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 15px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 550;
  font-family: inherit;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  line-height: 1.35;
}
.btn-primary { background: var(--rust); color: #fff; }
.btn-primary:hover { background: var(--rust-hover); }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--muted); }
.btn-outline { background: #fff; color: var(--text); border-color: var(--line); }
.btn-outline:hover { border-color: var(--muted); color: var(--ink); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { background: #8A2C1C; }
.btn-success { background: var(--good); color: #fff; }
.btn-success:hover { background: #1B5134; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ── FORMS ──────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 5px;
}
.form-group input,
.form-group select,
.form-group textarea,
.form-input {
  width: 100%;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.form-input:focus {
  outline: none;
  border-color: var(--rust);
  box-shadow: 0 0 0 2px rgba(180,60,40,0.12);
}
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

/* ── TABLES ─────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th {
  background: #FBFAF8;
  color: var(--muted);
  padding: 7px 12px;
  text-align: left;
  font-size: 10.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--line);
}
td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
  color: var(--text);
}
tr:hover td { background: #FBFAF8; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── STATUS BADGES (pill chips) ─────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.6;
}
.badge-active,
.badge-completed { background: var(--good-bg); color: var(--good); }
.badge-in_progress,
.badge-draft,
.badge-ready,
.badge-review,
.badge-admin { background: var(--info-bg); color: var(--info); }
.badge-pending,
.badge-processing { background: var(--warn-bg); color: var(--warn); }
.badge-error,
.badge-cancelled { background: var(--bad-bg); color: var(--bad); }
.badge-skipped,
.badge-on_hold,
.badge-closed { background: var(--line-soft); color: var(--muted); }
.badge-manager { background: #EDE7F6; color: #5E35B1; }
.badge-appraiser { background: var(--line-soft); color: var(--text); }
.badge-staff { background: var(--warn-bg); color: var(--warn); }
.badge-external { background: var(--line-soft); color: var(--muted); }

/* ── STEP LIST (legacy flat list, kept for compat) ──────── */
.step-list { list-style: none; }
.step-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  border-radius: 6px;
  margin-bottom: 2px;
  transition: background 0.15s;
  text-decoration: none;
  color: var(--text);
}
.step-list li:hover { background: var(--line-soft); }
.step-list li.active { background: var(--rust-soft); border-left: 3px solid var(--rust); }
.step-list li .step-icon { font-size: 18px; width: 26px; text-align: center; }
.step-list li .step-name { font-weight: 500; font-size: 13px; flex: 1; }
.step-list a { text-decoration: none; color: inherit; display: flex; align-items: center; gap: 12px; flex: 1; }

/* ── STEP NODES (Plan 28 sidebar status marks) ──────────── */
.node {
  width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  position: relative;
  border: 1.5px solid var(--line);
  background: #fff;
}
.node-done { background: var(--rust); border-color: var(--rust); }
.node-done::after {
  content: ''; width: 7px; height: 4px;
  border-left: 1.5px solid #fff; border-bottom: 1.5px solid #fff;
  transform: rotate(-45deg) translate(0.5px, -0.5px);
}
.node-open { border-color: var(--rust); }
.node-open::after {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--rust);
}
.node-pending { border-color: var(--line); }
.node-skipped { border-style: dashed; border-color: #C9C2BA; }
.node-error { border-color: var(--bad); }
.node-error::after {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--bad);
}
.node-processing { border-color: var(--warn); }
.node-processing::after {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--warn);
  animation: eraNodePulse 1.2s ease-in-out infinite;
}
@keyframes eraNodePulse {
  0%, 100% { opacity: 1; } 50% { opacity: 0.3; }
}

/* ── UPLOAD AREA ────────────────────────────────────────── */
.upload-area {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  background: #FBFAF8;
  color: var(--muted);
  transition: border-color 0.15s;
}
.upload-area:hover { border-color: var(--rust); }
.upload-area input[type="file"] { display: none; }
.upload-area label { cursor: pointer; }

/* ── ALERTS ─────────────────────────────────────────────── */
.alert {
  padding: 11px 15px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13px;
  border: 1px solid transparent;
}
.alert-error { background: var(--bad-bg); color: var(--bad); border-color: #EFC9C1; }
.alert-success { background: var(--good-bg); color: var(--good); border-color: #C3DECC; }
.alert-info { background: var(--info-bg); color: var(--info); border-color: #C6D8ED; }
.alert-warning { background: var(--warn-bg); color: var(--warn); border-color: #EFD9BB; }

/* ── GRID LAYOUT ────────────────────────────────────────── */
.project-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
}
@media (max-width: 768px) {
  .project-layout { grid-template-columns: 1fr; }
}

/* ── EMPTY STATE ────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px; color: var(--muted); }
.empty-state .icon { font-size: 48px; margin-bottom: 16px; }
.empty-state p { margin-bottom: 16px; }

/* ── FILE LIST ──────────────────────────────────────────── */
.file-list { list-style: none; }
.file-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}
.file-list li .file-name { flex: 1; }
.file-list li .file-size { color: var(--muted); margin-right: 12px; }

/* ── STAT CARDS ─────────────────────────────────────────── */
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
}
.stat-card .stat-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted); margin-bottom: 4px;
}
.stat-card .stat-value {
  font-size: 22px; font-weight: 650; color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ── FILTER BAR ─────────────────────────────────────────── */
.filter-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px;
}

/* ── KEY-VALUE GRID (Plan 28 detail cards) ──────────────── */
.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px 20px;
}
.kv-grid .kv-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted); margin-bottom: 2px;
}
.kv-grid .kv-value { font-size: 13px; color: var(--text); }
.kv-grid .kv-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* pills for yes/no feature lists (e.g. Approaches to Value) */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 10px; border-radius: 999px; font-size: 12px;
  border: 1px solid var(--line); color: var(--muted); background: #fff;
}
.pill.on { border-color: #C3DECC; background: var(--good-bg); color: var(--good); }
.pill.on::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--good); }
.pill.off { text-decoration: line-through; opacity: 0.7; }

/* ── WORKFLOW SIDEBAR (job workspace, Plan 28 B+D) ──────── */
.step-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  min-height: calc(100vh - 120px);
  transition: grid-template-columns 0.25s ease;
}
.step-layout.sidebar-collapsed { grid-template-columns: 52px 1fr; gap: 10px; }
@media (max-width: 900px) {
  .step-layout { grid-template-columns: 1fr; }
  .step-layout > .step-sidebar { display: none; }
}
.step-sidebar {
  position: sticky;
  top: 16px;
  align-self: start;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}
.step-sidebar::-webkit-scrollbar { width: 4px; }
.step-sidebar::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }
.ss-card { padding: 4px 0 0; }

.ss-home {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  text-decoration: none; color: var(--rust);
  font-size: 12.5px; font-weight: 650;
  border-bottom: 1px solid var(--line-soft);
}
.ss-home:hover { background: var(--rust-soft); }

/* pinned configuration strip (Workflow Options / Project Library) */
.ss-config { list-style: none; margin: 0; padding: 4px 0; border-bottom: 1px solid var(--line-soft); }
.ss-config .ss-item { font-size: 12px; color: var(--muted); }
.ss-config .ss-item:hover { color: var(--ink); }
.ss-config .ss-item.active { color: var(--rust); }

/* phase groups */
.ss-phase { border-bottom: 1px solid var(--line-soft); }
.ss-phase-head {
  display: flex; align-items: center; gap: 7px; width: 100%;
  padding: 9px 14px; border: none; background: none; cursor: pointer;
  font-family: inherit; font-size: 11px; font-weight: 650;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
  text-align: left;
}
.ss-phase-head:hover { color: var(--ink); }
.ss-phase-chevron {
  display: inline-block; width: 0; height: 0; flex-shrink: 0;
  border-top: 4px solid transparent; border-bottom: 4px solid transparent;
  border-left: 5px solid currentColor;
  transition: transform 0.15s;
}
.ss-phase.open .ss-phase-chevron { transform: rotate(90deg); }
.ss-phase-count {
  margin-left: auto; font-size: 10.5px; font-weight: 600;
  color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: 0;
}
.ss-phase-pill {
  margin-left: auto; font-size: 9.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--good); background: var(--good-bg);
  border-radius: 999px; padding: 1px 8px;
}
.ss-phase > .ss-list { display: none; padding-bottom: 5px; }
.ss-phase.open > .ss-list { display: block; }

/* step items */
.ss-list { list-style: none; margin: 0; padding: 0; }
.ss-item {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 12px; margin: 1px 6px; border-radius: 6px;
  text-decoration: none; color: var(--text); font-size: 12.5px;
  position: relative; transition: background 0.15s;
}
.ss-item:hover { background: var(--line-soft); }
.ss-item.active { background: var(--rust-soft); font-weight: 600; color: var(--rust); }
.ss-item.disabled { opacity: 0.45; pointer-events: none; }
.ss-item.skipped { opacity: 0.55; }
.ss-item.skipped .ss-name { text-decoration: line-through; }
.ss-item.sub { padding-left: 30px; }
.ss-item .ss-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ss-item .node { flex-shrink: 0; }
/* Plan 52 Phase 2: a tagged-field change upstream flagged this section for
   re-finalization (output_data.stale_reason). */
.ss-stale-pill {
  flex-shrink: 0;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 8px;
  background: rgba(230, 145, 56, 0.18);
  color: #B96A1B;
  border: 1px solid rgba(230, 145, 56, 0.45);
}

/* skip / unskip hover affordance */
.ss-skip-menu {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  display: none; z-index: 5;
}
.ss-item:hover .ss-skip-menu { display: flex; gap: 3px; }
.ss-skip-btn {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  font-size: 9.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em;
  border-radius: 4px; padding: 1px 6px; cursor: pointer; line-height: 1.5;
}
.ss-skip-btn:hover { color: var(--rust); border-color: var(--rust); }

/* progress block */
.ss-progress { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); }
.ss-progress-bar {
  height: 4px; background: var(--line-soft); border-radius: 2px;
  overflow: hidden; margin-bottom: 5px;
}
.ss-progress-fill { height: 100%; background: var(--rust); border-radius: 2px; transition: width 0.3s; }
.ss-progress-text { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* collapse toggle (step pages) */
.ss-collapse-btn {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  width: 100%; padding: 7px 8px; border: none; background: none;
  cursor: pointer; font-size: 11px; color: var(--muted); font-family: inherit;
  border-top: 1px solid var(--line-soft); margin-top: 2px;
}
.ss-collapse-btn:hover { color: var(--rust); }
.ss-collapse-btn .arrow { transition: transform 0.25s; }
.sidebar-collapsed .ss-collapse-btn .label { display: none; }
.sidebar-collapsed .ss-collapse-btn .arrow { transform: rotate(180deg); }

/* collapsed sidebar: nodes only, phases forced open, tooltips take over */
.sidebar-collapsed .step-sidebar { overflow-x: hidden; }
.sidebar-collapsed .ss-home .ss-home-label,
.sidebar-collapsed .ss-name,
.sidebar-collapsed .ss-skip-menu,
.sidebar-collapsed .ss-config,
.sidebar-collapsed .ss-progress,
.sidebar-collapsed .ss-phase-head { display: none !important; }
.sidebar-collapsed .ss-phase > .ss-list { display: block; }
.sidebar-collapsed .ss-home { justify-content: center; padding: 9px 6px; }
.sidebar-collapsed .ss-item { justify-content: center; padding: 6px; margin: 1px 4px; }
.sidebar-collapsed .ss-item.sub { padding-left: 6px; }
#ss-tooltip-float {
  position: fixed; background: var(--ink); color: #fff; font-size: 11px;
  padding: 4px 10px; border-radius: 4px; white-space: nowrap;
  pointer-events: none; z-index: 1000; display: none;
}

/* ── ERA-UI: toasts + modal confirm/prompt (era-ui.js) ──── */
.era-toast-wrap {
  position: fixed; top: 18px; right: 18px; z-index: 12000;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
}
.era-toast {
  background: var(--ink); color: #fff; font-size: 13px;
  padding: 10px 16px; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(28,22,16,0.3);
  max-width: 420px; line-height: 1.45;
  animation: eraToastIn 0.18s ease-out;
}
.era-toast.good { background: var(--good); }
.era-toast.bad { background: var(--bad); }
@keyframes eraToastIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.era-modal-bg {
  position: fixed; inset: 0; z-index: 11000;
  background: rgba(28,22,16,0.5);
  display: flex; align-items: center; justify-content: center;
}
.era-modal {
  background: #fff; border-radius: 10px; padding: 20px 22px;
  max-width: 440px; width: 92%;
  box-shadow: 0 16px 48px rgba(28,22,16,0.35);
}
.era-modal h3 {
  font-size: 15px; font-weight: 650; color: var(--ink); margin: 0 0 8px;
}
.era-modal .era-modal-msg { font-size: 13px; color: var(--text); line-height: 1.5; margin-bottom: 16px; white-space: pre-wrap; }
.era-modal .era-modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.era-modal input.era-modal-input, .era-modal textarea.era-modal-input {
  width: 100%; padding: 7px 11px; border: 1px solid var(--line);
  border-radius: 6px; font-size: 13px; font-family: inherit; margin-bottom: 16px;
}
.era-modal textarea.era-modal-input { resize: vertical; line-height: 1.45; min-height: 96px; }
.era-modal input.era-modal-input:focus, .era-modal textarea.era-modal-input:focus {
  outline: none; border-color: var(--rust);
  box-shadow: 0 0 0 2px rgba(180,60,40,0.12);
}
