:root {
  /* Azule brand tokens */
  --c-primary: #1F4666;
  --c-accent: #58D7E8;
  --c-jade: #B6DEDF;
  --c-sunrise: #FF6146;
  --c-aqua-tint: #DEF7FA;
  --c-grey-tint: #E4E5E6;
  --c-sunrise-tint: #FFDFDA;
  --c-berry: #AC145A;
  --c-honey: #FFBF3F;
  --c-sea: #50A684;
  --c-rose: #FF8DA1;
  --c-iris: #702F8A;
  --c-white: #FFFFFF;
  --c-page-bg: #F4F6F8;
  --c-text: #1F4666;
  --c-text-muted: #5C7387;
  --c-border: #E4E5E6;
  --c-border-strong: #c8ccd0;

  --shadow-sm: 0 1px 2px rgba(31, 70, 102, 0.08);
  --shadow-md: 0 2px 8px rgba(31, 70, 102, 0.12);
  --radius: 4px;
  --radius-lg: 8px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: var(--font); color: var(--c-text); background: var(--c-page-bg); }
body { min-height: 100vh; }
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }

/* Top bar -------------------------------------------------------- */
.topbar {
  background: var(--c-primary);
  color: var(--c-white);
  padding: 10px var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
}
.topbar .brand {
  display: flex; align-items: center; gap: var(--space-3);
  font-weight: 700; letter-spacing: 0.4px; font-size: 15px;
}
.topbar .brand svg { height: 26px; }
.topbar .crumbs { font-size: 12px; opacity: 0.85; flex: 1; }
.topbar .crumbs strong { color: var(--c-accent); font-weight: 600; }
.topbar .crumbs a { color: var(--c-white); opacity: 0.85; }
.topbar .right { display: flex; align-items: center; gap: var(--space-3); }

/* Persona pill --------------------------------------------------- */
.persona {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  color: var(--c-white);
  padding: 5px 10px 5px 8px;
  border-radius: 16px;
  font-size: 12px;
  display: inline-flex; align-items: center; gap: 8px;
  cursor: pointer;
}
.persona .avatar {
  background: var(--c-accent); color: var(--c-primary);
  width: 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 11px;
}
.persona .role { opacity: 0.85; font-size: 11px; margin-left: 4px; }

/* NEW-callouts toggle -------------------------------------------- */
.toggle {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  padding: 5px 10px; border-radius: 16px; font-size: 12px;
  color: var(--c-white); cursor: pointer;
  user-select: none;
}
.toggle .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--c-sunrise);
  box-shadow: 0 0 0 2px rgba(255,97,70,0.25);
}
.toggle.off .dot { background: rgba(255,255,255,0.3); box-shadow: none; }
body[data-callouts="off"] .new-pill,
body[data-callouts="off"] .section-ribbon,
body[data-callouts="off"] .num-circle,
body[data-callouts="off"] .legend-callouts { display: none !important; }
body[data-callouts="off"] .section-ribbon-host { border-left: none !important; padding-left: 0 !important; }

/* Command bar ---------------------------------------------------- */
.commandbar {
  background: var(--c-white);
  border-bottom: 1px solid var(--c-border);
  padding: 6px var(--space-6);
  display: flex; gap: 2px; align-items: center;
}
.commandbar button {
  background: transparent; border: 0; color: var(--c-primary);
  padding: 7px 12px; font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; border-radius: 3px;
}
.commandbar button:hover { background: var(--c-aqua-tint); }
.commandbar button:disabled { opacity: 0.4; cursor: default; }
.commandbar .sep { width: 1px; align-self: stretch; background: var(--c-border); margin: 4px 6px; }
.commandbar .spacer { flex: 1; }
.commandbar .icon { display: inline-block; width: 16px; text-align: center; }

/* Layout containers ---------------------------------------------- */
.page { padding: var(--space-6); max-width: 1280px; margin: 0 auto; }
.page-wide { max-width: 1440px; margin: 0 auto; padding: var(--space-6); }
.page-title { display: flex; align-items: baseline; justify-content: space-between; margin: 0 0 var(--space-5) 0; }
.page-title h1 { font-size: 22px; margin: 0; font-weight: 600; }
.page-title .meta { font-size: 12px; color: var(--c-text-muted); }
.section { background: var(--c-white); border: 1px solid var(--c-border); border-radius: var(--radius); padding: var(--space-5); margin-bottom: var(--space-5); }
.section h2 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.7px; margin: 0 0 var(--space-4) 0; color: var(--c-primary); }
.row { display: flex; gap: var(--space-4); flex-wrap: wrap; }
.row > * { flex: 1; min-width: 220px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-5); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-5); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-5); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }

/* Cards (Home hub etc) ------------------------------------------- */
.card {
  background: var(--c-white); border: 1px solid var(--c-border);
  border-radius: var(--radius-lg); padding: var(--space-5);
  text-decoration: none; color: var(--c-text);
  display: flex; flex-direction: column; gap: var(--space-3);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); text-decoration: none; }
.card .icon-lg { font-size: 28px; color: var(--c-primary); }
.card h3 { margin: 0; font-size: 16px; font-weight: 600; }
.card p { margin: 0; font-size: 13px; color: var(--c-text-muted); }
.card.admin { border-top: 3px solid var(--c-iris); }

/* Filter layout (collapsible) ------------------------------------ */
.filter-layout { display: grid; grid-template-columns: 300px 1fr; gap: var(--space-6); transition: grid-template-columns 0.18s ease; }
.filter-layout[data-filters="closed"] { grid-template-columns: 1fr; }
.filter-layout[data-filters="closed"] > aside { display: none; }
.filter-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 6px; border-radius: 9px;
  background: var(--c-accent); color: var(--c-primary);
  font-size: 10px; font-weight: 700; margin-left: 4px;
}
.filter-count[data-c="0"] { display: none; }

/* Form fields ---------------------------------------------------- */
.field { margin-bottom: var(--space-4); }
.field label {
  display: block; font-size: 11px; font-weight: 600;
  color: var(--c-primary); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px;
}
.field label .tip {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%;
  background: var(--c-aqua-tint); color: var(--c-primary);
  font-size: 10px; text-align: center; line-height: 14px;
  margin-left: 6px; cursor: pointer; font-weight: 700;
}
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--c-border-strong);
  border-bottom: 2px solid var(--c-primary);
  background: var(--c-white);
  padding: 7px 9px;
  font-size: 13px;
  border-radius: 2px 2px 0 0;
  font-family: inherit;
  color: var(--c-text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 0; border-bottom-color: var(--c-accent);
  box-shadow: inset 0 -2px 0 0 var(--c-accent);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.field-row.three { grid-template-columns: 1fr 1fr 1fr; }
.field .help { font-size: 11px; color: var(--c-text-muted); margin-top: 4px; }

/* Buttons -------------------------------------------------------- */
.btn {
  background: var(--c-primary); color: var(--c-white);
  border: 0; padding: 8px 16px; font-size: 13px; font-weight: 600;
  border-radius: 2px; cursor: pointer; letter-spacing: 0.3px;
}
.btn:hover { background: #163450; }
.btn.secondary { background: var(--c-white); color: var(--c-primary); border: 1px solid var(--c-primary); }
.btn.secondary:hover { background: var(--c-aqua-tint); }
.btn.ghost { background: transparent; color: var(--c-primary); border: 0; }
.btn.ghost:hover { background: var(--c-aqua-tint); }
.btn.danger { background: var(--c-berry); }
.btn.danger:hover { background: #8a1148; }
.btn-row { display: flex; gap: var(--space-3); justify-content: flex-end; margin-top: var(--space-4); }

/* Badges --------------------------------------------------------- */
.badge { font-size: 10px; padding: 2px 8px; border-radius: 10px; display: inline-block; font-weight: 700; letter-spacing: 0.3px; text-transform: uppercase; }
.b-approved { background: var(--c-sea); color: var(--c-white); }
.b-pending  { background: var(--c-honey); color: var(--c-primary); }
.b-draft    { background: var(--c-grey-tint); color: var(--c-primary); }
.b-rejected { background: var(--c-berry); color: var(--c-white); }
.b-closed   { background: var(--c-text-muted); color: var(--c-white); }
.b-ecreview { background: var(--c-iris); color: var(--c-white); }
.b-lca      { background: var(--c-rose); color: var(--c-primary); }
.b-ceo      { background: var(--c-sunrise); color: var(--c-primary); }

/* NEW-callout pill ----------------------------------------------- */
.new-pill {
  background: var(--c-sunrise); color: var(--c-primary);
  font-size: 9px; font-weight: 700; padding: 1px 6px; border-radius: 8px;
  text-transform: uppercase; letter-spacing: 0.5px; margin-left: 6px;
  vertical-align: middle; cursor: help;
}
.new-pill::after { content: ""; }

/* Section ribbon (whole panel is new) ---------------------------- */
.section-ribbon-host {
  border-left: 3px solid var(--c-sunrise);
  padding-left: var(--space-4) !important;
  position: relative;
}
.section-ribbon {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--c-sunrise-tint); color: var(--c-primary);
  font-size: 11px; font-weight: 600; padding: 3px 10px;
  border-radius: 10px; margin-bottom: var(--space-3);
}
.section-ribbon::before { content: "✨"; }

/* Numbered map circles + legend ---------------------------------- */
.num-circle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--c-sunrise); color: var(--c-primary);
  font-size: 10px; font-weight: 700;
  margin-right: 6px;
}
.legend-callouts {
  background: var(--c-sunrise-tint); border: 1px solid var(--c-sunrise);
  border-radius: var(--radius); padding: var(--space-3) var(--space-4);
  font-size: 12px;
  margin-top: var(--space-5);
}
.legend-callouts h4 { margin: 0 0 var(--space-2) 0; font-size: 12px; }
.legend-callouts ol { margin: 0; padding-left: 20px; }
.legend-callouts li { margin: 2px 0; }

/* List / table --------------------------------------------------- */
.list { background: var(--c-white); border: 1px solid var(--c-border); border-radius: var(--radius); overflow: hidden; }
.list .head, .list .row-r {
  display: grid; padding: 10px var(--space-4); font-size: 13px;
  align-items: center;
}
.list .head {
  background: #FAFBFC; color: var(--c-primary);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 700;
  border-bottom: 1px solid var(--c-border);
}
.list .row-r { border-bottom: 1px solid #F2F3F5; }
.list .row-r:hover { background: var(--c-aqua-tint); }
.list a.row-r { color: var(--c-text); text-decoration: none; }
.list a.row-r:hover { text-decoration: none; }

/* Tabs ----------------------------------------------------------- */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--c-border); margin-bottom: var(--space-5); }
.tabs a {
  padding: 10px 18px; font-size: 13px; font-weight: 600;
  color: var(--c-text-muted); border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tabs a:hover { color: var(--c-primary); text-decoration: none; }
.tabs a.active { color: var(--c-primary); border-bottom-color: var(--c-accent); }
.tabs a.new-tab { color: var(--c-sunrise); }
.tabs a.new-tab.active { color: var(--c-primary); }

/* Modal ---------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(31,70,102,0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 60px 20px; z-index: 100;
}
.modal {
  background: var(--c-white); width: 100%; max-width: 560px;
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  overflow: hidden;
}
.modal.wide { max-width: 760px; }
.modal-header {
  background: var(--c-primary); color: var(--c-white);
  padding: var(--space-4) var(--space-5);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h2 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-header button {
  background: transparent; border: 0; color: var(--c-white);
  font-size: 18px; cursor: pointer;
}
.modal-body { padding: var(--space-5); max-height: 70vh; overflow: auto; }

/* Tooltip popover ------------------------------------------------ */
.tooltip-pop {
  position: absolute; background: var(--c-primary); color: var(--c-white);
  padding: 10px 14px; border-radius: var(--radius); font-size: 12px;
  max-width: 320px; box-shadow: var(--shadow-md);
  z-index: 90;
}
.tooltip-pop::before {
  content: ""; position: absolute; top: -6px; left: 14px;
  border-left: 6px solid transparent; border-right: 6px solid transparent;
  border-bottom: 6px solid var(--c-primary);
}

/* Approval flow viz --------------------------------------------- */
.flow { display: flex; gap: var(--space-3); align-items: stretch; flex-wrap: wrap; }
.flow .step {
  background: var(--c-white); border: 1px solid var(--c-border);
  border-radius: var(--radius); padding: var(--space-3) var(--space-4);
  min-width: 160px; flex: 0 0 auto;
}
.flow .step.done { border-left: 3px solid var(--c-sea); }
.flow .step.current { border-left: 3px solid var(--c-honey); background: #FFF9EB; }
.flow .step.pending { border-left: 3px solid var(--c-border-strong); opacity: 0.6; }
.flow .step h4 { margin: 0 0 4px 0; font-size: 12px; }
.flow .step p { margin: 0; font-size: 11px; color: var(--c-text-muted); }
.flow .arrow { align-self: center; color: var(--c-text-muted); font-size: 18px; }

/* Chips / typeahead --------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--c-aqua-tint); color: var(--c-primary);
  padding: 4px 8px 4px 10px; border-radius: 12px; font-size: 12px;
  margin: 2px;
}
.chip button { background: transparent; border: 0; color: var(--c-primary); cursor: pointer; padding: 0 2px; }
.suggest {
  background: var(--c-white); border: 1px solid var(--c-border);
  border-radius: var(--radius); margin-top: 4px; box-shadow: var(--shadow-sm);
  max-height: 160px; overflow: auto;
}
.suggest div { padding: 6px 10px; font-size: 12px; cursor: pointer; }
.suggest div:hover { background: var(--c-aqua-tint); }
.suggest .sub { font-size: 10px; color: var(--c-text-muted); }

/* Banner / alerts ----------------------------------------------- */
.alert {
  padding: var(--space-3) var(--space-4); border-radius: var(--radius);
  font-size: 13px; margin-bottom: var(--space-4);
  display: flex; gap: 10px; align-items: flex-start;
}
.alert.warn { background: #FFF9EB; border: 1px solid var(--c-honey); color: #6E5300; }
.alert.info { background: var(--c-aqua-tint); border: 1px solid var(--c-accent); }
.alert.good { background: #E5F4EC; border: 1px solid var(--c-sea); color: #1E4D38; }
.alert .icon { font-size: 16px; line-height: 1; }

/* PDF preview ---------------------------------------------------- */
.pdf-page {
  background: var(--c-white); width: 100%; max-width: 820px; margin: 0 auto;
  box-shadow: 0 0 0 1px var(--c-border), 0 8px 32px rgba(0,0,0,0.08);
  padding: 56px 56px 80px;
  font-size: 12px; line-height: 1.5;
}
.pdf-page h1 { font-size: 22px; margin: 0 0 4px 0; }
.pdf-page .pdf-meta { color: var(--c-text-muted); font-size: 11px; }
.pdf-page table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.pdf-page table td { padding: 6px 0; border-bottom: 1px solid #eee; vertical-align: top; }
.pdf-page table td:first-child { width: 36%; color: var(--c-text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }

/* Email preview ------------------------------------------------- */
.email {
  background: var(--c-white); max-width: 720px; margin: 32px auto;
  border: 1px solid var(--c-border); border-radius: var(--radius);
  overflow: hidden;
}
.email .from {
  background: #FAFBFC; padding: var(--space-4); border-bottom: 1px solid var(--c-border);
  font-size: 12px;
}
.email .from strong { display: block; color: var(--c-primary); font-size: 13px; }
.email .subject { padding: var(--space-4) var(--space-5) 0; font-size: 16px; font-weight: 600; }
.email .body { padding: var(--space-4) var(--space-5) var(--space-6); font-size: 13px; line-height: 1.55; }

/* Dashboard charts ---------------------------------------------- */
.chart-card { background: var(--c-white); border: 1px solid var(--c-border); border-radius: var(--radius); padding: var(--space-4); }
.chart-card h3 { margin: 0 0 var(--space-3) 0; font-size: 13px; font-weight: 600; }
.bar { display: grid; grid-template-columns: 110px 1fr 50px; gap: 10px; align-items: center; font-size: 12px; margin-bottom: 6px; }
.bar .bar-fill { background: var(--c-aqua-tint); height: 14px; border-radius: 2px; position: relative; }
.bar .bar-fill > span { display: block; background: var(--c-primary); height: 100%; border-radius: 2px; }
.donut svg { display: block; margin: 0 auto; }
.kpi { display: flex; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-5); }
.kpi .k { flex: 1; min-width: 140px; background: var(--c-white); border: 1px solid var(--c-border); border-radius: var(--radius); padding: var(--space-3); }
.kpi .k .v { font-size: 22px; font-weight: 700; color: var(--c-primary); }
.kpi .k .l { font-size: 11px; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* ===== app-only additions (keep Demo 1 design; add SPA controls) ========== */
/* Fixed/sticky navbars: topbar stays on top, command bar sticks under it */
.topbar { position: sticky; top: 0; z-index: 50; height: 64px; padding: 4px 0; }  /* fixed nav height; inner container provides the horizontal padding */
.topbar .brand { gap: 8px; }
/* align the top-bar content (logo / title / nav) with the WORKING pages'
   content column (.page-wide, the wider container used by the list/dashboard) */
.topbar-inner { display: flex; align-items: center; gap: var(--space-6); width: 100%; max-width: 1440px; margin: 0 auto; padding: 0 var(--space-6); }
.topbar-inner .crumbs { flex: 1; }
.commandbar { position: sticky; top: 64px; z-index: 40; }
.tooltip-pop { z-index: 95; }
.muted { color: var(--c-text-muted); }
.cap { text-transform: capitalize; }
.boot { display:grid; place-items:center; height:100vh; color:var(--c-text-muted); }
.boot-error { max-width:520px; margin:12vh auto; text-align:center; background:#fff; border:1px solid var(--c-border); border-radius:var(--radius-lg); padding:32px; box-shadow:var(--shadow-md); }
.boot-error h2 { color:var(--c-sunrise); }
.empty { padding:26px; text-align:center; color:var(--c-text-muted); }

/* persona as a styled select (acts like the Demo 1 persona pill) */
select.persona { appearance:none; -webkit-appearance:none; background:rgba(255,255,255,0.08); border:1px solid rgba(255,255,255,0.18); color:var(--c-white); padding:5px 26px 5px 10px; border-radius:16px; font-size:12px; max-width:280px; cursor:pointer; }
select.persona option { color:var(--c-text); }

/* DB menu (pill like the Demo 1 toggle) */
.dbmenu { position:relative; }
.dbmenu-pop { position:absolute; right:0; top:34px; background:#fff; color:var(--c-text); border:1px solid var(--c-border); border-radius:var(--radius); box-shadow:var(--shadow-md); display:flex; flex-direction:column; min-width:180px; overflow:hidden; z-index:120; }
.dbmenu-pop > * { padding:9px 12px; background:none; border:0; text-align:left; font-size:13px; color:var(--c-text); cursor:pointer; }
.dbmenu-pop > *:hover { background:var(--c-aqua-tint); }

/* home action tiles + module badge */
.card .big { font-size:30px; font-weight:700; color:var(--c-primary); line-height:1; }
.card .mc-badge { margin-top:auto; align-self:flex-start; }
.card.is-soon { opacity:0.72; }

/* key/value detail table (matches Demo 1 pdf table look) */
.kv { width:100%; border-collapse:collapse; }
.kv td { padding:8px 0; border-bottom:1px solid #F2F3F5; vertical-align:top; font-size:13px; }
.kv td:first-child { width:34%; color:var(--c-text-muted); font-size:11px; text-transform:uppercase; letter-spacing:0.5px; padding-right:12px; }
.kv-2 { display:grid; grid-template-columns:1fr 1fr; gap:0 var(--space-6); }
@media (max-width:760px){ .kv-2 { grid-template-columns:1fr; } }

/* approval flow comments */
.flow .step .cmt { margin-top:6px; font-style:italic; color:var(--c-text-muted); font-size:11px; }
.checks { display:flex; flex-wrap:wrap; gap:6px 16px; }
.checks label { display:flex; align-items:center; gap:6px; font-size:13px; font-weight:400; color:var(--c-text); text-transform:none; letter-spacing:0; }
.checks input { width:auto; }

/* toast (not in Demo 1; minimal, on-brand) */
.toasts { position:fixed; bottom:22px; left:50%; transform:translateX(-50%); z-index:200; display:flex; flex-direction:column; gap:8px; }
.toast { background:var(--c-primary); color:#fff; padding:10px 18px; border-radius:var(--radius); box-shadow:var(--shadow-md); font-size:13px; transition:opacity .3s; }
.toast.bad { background:var(--c-berry); }
.toast.hide { opacity:0; }
