/*
  MH4U indicator dashboard. Brand tokens and shell copied from the course mockup
  (EU-Promens/mockup/styles.css) so both products look like one family.
  Chart colors were run through the dataviz validator on white:
  purple #7500ff + carrot #ff5300 pass every check; yellow fails contrast on white,
  so yellow is used only as a surface (hero, highlights), never as a data mark.
*/
:root {
  --purple: #7500ff;
  --purple-dark: #5c00c9;
  --purple-tint: #f1e8ff;
  --yellow: #ffd000;
  --carrot: #ff5300;
  --ink: #000;
  --muted: #5d5d66;
  --line: #e2e2e8;
  --line-strong: #8f8f9b;
  --grey-mark: #b8b8c2;
  --paper: #fff;
  --font: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 8px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 14px/1.55 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; padding: 0; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-weight: 500; letter-spacing: -0.02em; overflow-wrap: break-word; }
strong { font-weight: 600; }
a { color: var(--purple); }
:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
.sidebar :focus-visible { outline-color: var(--yellow); }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Shell (same as the course) ---------- */
.app-shell { min-height: 100vh; display: flex; }
.sidebar { width: 250px; background: var(--purple); color: #fff; display: flex; flex-direction: column; padding: 28px 18px 22px; position: fixed; inset: 0 auto 0 0; overflow-y: auto; }
.brand { padding: 0 8px 28px; }
.brand-logo { display: block; width: 176px; height: auto; }
.sidebar .brand-logo { filter: brightness(0) invert(1); }
.brand-sub { margin-top: 18px; }
.brand-sub strong { display: block; font-size: 13px; }
.brand-sub span { display: block; color: rgba(255, 255, 255, 0.9); font-size: 12px; margin-top: 3px; }
.main-nav { display: grid; gap: 4px; }
.nav-label { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: rgba(255, 255, 255, 0.75); padding: 18px 13px 6px; }
.nav-item { padding: 11px 13px; border-radius: var(--radius); color: #fff; text-align: left; font-size: 13px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.nav-item:hover { background: rgba(255, 255, 255, 0.14); }
.nav-item.active { background: var(--yellow); color: var(--ink); font-weight: 600; }
.nav-count { font-size: 11px; font-weight: 600; background: rgba(255, 255, 255, 0.2); border-radius: 20px; padding: 1px 8px; }
.nav-item.active .nav-count { background: var(--ink); color: var(--yellow); }
.sidebar-bottom { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, 0.28); padding: 18px 10px 0; font-size: 12px; color: rgba(255, 255, 255, 0.9); }
.sidebar-bottom strong { display: block; color: #fff; font-size: 13px; margin-bottom: 3px; }

.main-content { margin-left: 250px; width: calc(100% - 250px); padding: 0 54px 60px; }
.mobile-header, .mobile-nav { display: none; }
.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.breadcrumb { color: var(--muted); font-size: 12px; }
.breadcrumb span { color: var(--ink); font-weight: 500; }
.top-actions { display: flex; gap: 18px; align-items: center; }
.text-button { font-size: 12px; color: var(--muted); }
.text-button:hover { color: var(--ink); text-decoration: underline; }

.view { display: none; padding-top: 44px; }
.active-view { display: block; }
.eyebrow { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--purple); font-weight: 600; margin-bottom: 10px; }
.page-title { display: flex; justify-content: space-between; align-items: end; gap: 16px 30px; flex-wrap: wrap; }
.page-title > div { flex: 1 1 340px; min-width: 0; }
.page-title h1 { font-size: 32px; line-height: 1.15; letter-spacing: -0.03em; margin-bottom: 10px; }
.lede { color: var(--muted); line-height: 1.6; max-width: 680px; font-size: 14px; }
.section-heading { margin: 42px 0 16px; display: flex; justify-content: space-between; align-items: end; gap: 8px 24px; flex-wrap: wrap; }
.section-heading h2 { font-size: 22px; }
.section-heading p { font-size: 12px; color: var(--muted); max-width: 520px; }

.primary-button { background: var(--purple); color: #fff; border-radius: var(--radius); padding: 14px 20px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.primary-button:hover { background: var(--purple-dark); }
.secondary-button { border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 13px 18px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.secondary-button:hover { border-color: var(--purple); color: var(--purple); }
.ghost-button { font-size: 12px; color: var(--purple); font-weight: 600; }
.ghost-button:hover { text-decoration: underline; }

.draft-note { margin-top: 22px; background: var(--purple-tint); border-radius: 12px; padding: 14px 18px; font-size: 13px; line-height: 1.55; max-width: 860px; }

/* ---------- Hero numbers ---------- */
.hero { margin-top: 30px; background: var(--yellow); border-radius: var(--radius-lg); padding: 34px 38px; position: relative; overflow: hidden; }
.hero > :not(.hero-dots) { position: relative; }
.hero-dots { position: absolute; width: 300px; height: 300px; right: -90px; top: -90px; color: var(--purple); opacity: 0.16; }
.hero-main { font-size: 13px; max-width: 560px; }
.hero-main strong { display: block; font-size: 64px; line-height: 1; letter-spacing: -0.04em; color: var(--purple); margin-bottom: 10px; font-weight: 600; }
.hero-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin-top: 30px; border-top: 1px solid rgba(0, 0, 0, 0.18); }
.hero-stat { padding: 18px 18px 0 0; }
.hero-stat + .hero-stat { padding-left: 18px; border-left: 1px solid rgba(0, 0, 0, 0.18); }
.hero-stat strong { display: block; font-size: 28px; line-height: 1.1; letter-spacing: -0.03em; font-weight: 600; }
.hero-stat span { display: block; font-size: 12px; margin-top: 6px; line-height: 1.45; }

/* ---------- Cards and charts ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 26px; min-width: 0; }
.card + .card, .card-stack > .card + .card { margin-top: 0; }
.card-stack { display: grid; gap: 16px; }
.card h3 { font-size: 16px; line-height: 1.35; font-weight: 600; }
.card .sub { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.card .code { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: 0.04em; }
.chart { margin-top: 20px; }
.footnote { font-size: 12px; color: var(--muted); margin-top: 16px; line-height: 1.5; }

/* Horizontal bars: label | bar | value. 4px rounded data end, thin mark. */
.hbars { display: grid; gap: 4px; }
.hbar { display: grid; grid-template-columns: minmax(120px, 34%) 1fr 64px; gap: 12px; align-items: center; padding: 6px 0; border-radius: 6px; }
.hbar:hover { background: var(--purple-tint); }
.hbar-label { font-size: 12px; line-height: 1.35; }
.hbar-track { height: 14px; position: relative; }
.hbar-fill { position: absolute; inset: 0 auto 0 0; background: var(--purple); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar-fill.is-other { background: var(--grey-mark); }
.hbar-value { font-size: 13px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* Progress to 2027 target */
.targets { display: grid; }
.target-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) 210px; gap: 8px 18px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line); }
.target-row:last-child { border-bottom: 0; }
.target-row .code { font-size: 12px; font-weight: 600; color: var(--purple); }
.target-name { font-size: 13px; line-height: 1.4; }
.target-meter { display: grid; gap: 6px; }
.target-meter-top { display: flex; justify-content: space-between; font-size: 12px; gap: 8px; }
.target-meter-top b { font-size: 14px; font-variant-numeric: tabular-nums; }
.target-meter-top span { color: var(--muted); font-variant-numeric: tabular-nums; }
.meter { height: 8px; background: var(--purple-tint); border-radius: 5px; position: relative; overflow: hidden; }
.meter i { position: absolute; inset: 0 auto 0 0; background: var(--purple); border-radius: 5px; }
.flag { font-size: 11px; font-weight: 600; background: var(--yellow); border-radius: 20px; padding: 2px 8px; justify-self: start; }

/* Split bar (gender): two fills with a 2px surface gap */
.split { display: flex; gap: 2px; height: 28px; margin-top: 18px; }
.split i { display: block; height: 100%; min-width: 2px; }
.split i:first-child { border-radius: 4px 0 0 4px; }
.split i:last-child { border-radius: 0 4px 4px 0; }
.split .f { background: var(--purple); }
.split .m { background: var(--carrot); }
.split .u { background: var(--grey-mark); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 14px; font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend b { font-variant-numeric: tabular-nums; }

/* Column chart by quarter (SVG) */
.cols svg { display: block; width: 100%; height: auto; overflow: visible; }
.cols .grid-line { stroke: var(--line); stroke-width: 1; }
.cols .axis-text { font: 400 11px var(--font); fill: var(--muted); }
.cols .year-text { font: 600 11px var(--font); fill: var(--ink); }
.cols .col { fill: var(--purple); }
.cols .col-hit { fill: transparent; cursor: default; }
.cols .col-group:hover .col { fill: var(--purple-dark); }
.cols .val-text { font: 600 11px var(--font); fill: var(--ink); }

.table-toggle { margin-top: 14px; }
.data-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 12px; }
.data-table th, .data-table td { text-align: left; padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line); }
.data-table td.n, .data-table th.n { text-align: right; font-variant-numeric: tabular-nums; }

.tooltip { position: fixed; z-index: 20; pointer-events: none; background: var(--ink); color: #fff; font-size: 12px; line-height: 1.45; padding: 8px 12px; border-radius: 6px; max-width: 260px; opacity: 0; transition: opacity 0.12s; }
.tooltip.show { opacity: 1; }
.tooltip b { display: block; font-size: 14px; }

/* ---------- Data entry ---------- */
.tabs { display: flex; gap: 6px; margin-top: 30px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs .tab { white-space: nowrap; flex: none; }
.tab { padding: 12px 14px; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; gap: 8px; align-items: center; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--purple); border-color: var(--purple); font-weight: 600; }
.tab .nav-count { background: var(--purple-tint); color: var(--purple); }
.tab-panel { padding-top: 28px; }

.entry-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.6fr); gap: 24px; align-items: start; }
.form-card { padding: 32px; }
.form-section + .form-section { border-top: 1px solid var(--line); margin-top: 26px; padding-top: 26px; }
.form-section > h3 { font-size: 15px; margin-bottom: 4px; }
.form-section > .sub { margin-bottom: 18px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.fields .full { grid-column: 1 / -1; }
.field { display: grid; gap: 6px; align-content: start; }
.field label, .field .label { font-size: 12px; font-weight: 600; }
.field small { font-size: 12px; color: var(--muted); line-height: 1.45; }
.input, .select, .textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 10px; padding: 12px 14px; background: var(--paper); font-size: 14px; min-height: 46px; }
.select { appearance: none; padding-right: 40px; background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") right 14px center / 16px no-repeat; }
.textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { border-color: var(--purple); outline-offset: 0; }
.field.invalid .input, .field.invalid .select { border-color: var(--carrot); }
.field .error { color: #b33b00; font-size: 12px; }
.segmented { display: flex; gap: 6px; flex-wrap: wrap; }
.segmented label { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: 10px; font-size: 13px; font-weight: 500; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { border-color: var(--purple); background: var(--purple-tint); color: var(--purple); font-weight: 600; }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--purple); outline-offset: 2px; }
.people { display: grid; grid-template-columns: repeat(3, 1fr) 1fr; gap: 12px; align-items: end; }
.people-total { background: var(--purple-tint); border-radius: 10px; padding: 10px 14px; min-height: 46px; }
.people-total span { display: block; font-size: 11px; color: var(--purple); font-weight: 600; letter-spacing: 0.04em; }
.people-total b { font-size: 20px; font-variant-numeric: tabular-nums; }
.form-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 28px; }
.form-actions span { font-size: 12px; color: var(--muted); }

.indicator-hint { border: 1px solid var(--purple); border-radius: 12px; padding: 16px; margin-top: 4px; }
.indicator-hint strong { display: block; font-size: 13px; margin-bottom: 6px; line-height: 1.4; }
.indicator-hint p { font-size: 12px; color: var(--muted); line-height: 1.55; }
.aside-card h3 { font-size: 15px; margin-bottom: 12px; }
.aside-card ol { margin: 0; padding-left: 18px; display: grid; gap: 10px; font-size: 12px; line-height: 1.5; color: var(--muted); }
.aside-card ol strong { color: var(--ink); }

.records { display: grid; gap: 10px; }
.record { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 6px 18px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.record .code { font-size: 12px; font-weight: 600; color: var(--purple); }
.record strong { display: block; font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.record small { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
.record-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: end; }
.status { font-size: 11px; font-weight: 600; border-radius: 20px; padding: 3px 10px; white-space: nowrap; }
.status.pending { background: var(--yellow); }
.status.approved { background: var(--purple); color: #fff; }
.status.returned { background: #ffe1d4; color: #8a2d00; }
.small-button { font-size: 12px; font-weight: 600; border-radius: var(--radius); padding: 9px 14px; min-height: 36px; }
.small-button.approve { background: var(--purple); color: #fff; }
.small-button.approve:hover { background: var(--purple-dark); }
.small-button.return { border: 1px solid var(--line-strong); }
.small-button.return:hover { border-color: var(--carrot); color: #b33b00; }
.empty { font-size: 13px; color: var(--muted); padding: 22px 0; }

.toast { position: fixed; right: 24px; bottom: 24px; max-width: calc(100% - 48px); background: var(--purple); color: #fff; padding: 14px 20px; border-radius: var(--radius); font-size: 13px; font-weight: 500; opacity: 0; transform: translateY(12px); transition: 0.25s; pointer-events: none; z-index: 30; }
.toast.show { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .sidebar { width: 200px; padding: 22px 13px; }
  .brand-logo { width: 150px; }
  .main-content { margin-left: 200px; width: calc(100% - 200px); padding: 0 28px 45px; }
  .hero-grid { grid-template-columns: 1fr 1fr; }
  .hero-stat:nth-child(3) { padding-left: 0; border-left: 0; }
  .target-row { grid-template-columns: 48px minmax(0, 1fr); }
  .target-meter { grid-column: 2; }
}
@media (max-width: 950px) {
  .grid-2, .entry-layout { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .sidebar { display: none; }
  .mobile-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 0 8px; }
  .mobile-header .brand-logo { width: 132px; }
  .main-content { margin-left: 0; width: 100%; padding: 0 16px 84px; }
  .topbar { height: 44px; }
  .top-actions { display: none; }
  .mobile-nav { display: flex; position: fixed; z-index: 5; bottom: 0; left: 0; right: 0; height: 58px; background: var(--paper); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .mobile-nav-item { flex: 1; position: relative; font-size: 11px; color: var(--muted); padding: 0 2px; }
  .mobile-nav-item.active { color: var(--purple); font-weight: 600; }
  .mobile-nav-item.active::before { content: ''; position: absolute; top: -1px; left: 14%; right: 14%; height: 3px; background: var(--purple); }
  .view { padding-top: 24px; }
  .page-title { display: block; }
  .page-title h1 { font-size: 24px; }
  .hero { padding: 24px 20px; }
  .hero-main strong { font-size: 46px; }
  .hero-stat strong { font-size: 22px; }
  .hero-stat { padding: 14px 10px 0 0; }
  .hero-stat + .hero-stat { padding-left: 10px; }
  .card, .form-card { padding: 20px; }
  .hbar { grid-template-columns: 1fr 56px; }
  .hbar-label { grid-column: 1 / -1; }
  .hbar-track { grid-column: 1; }
  .target-row { grid-template-columns: 1fr; }
  .target-meter { grid-column: 1; }
  .fields, .people { grid-template-columns: 1fr 1fr; }
  .people-total { grid-column: 1 / -1; }
  .record { grid-template-columns: 1fr; }
  .record-actions { justify-content: start; }
  .section-heading { margin-top: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  .toast, .tooltip { transition: none; transform: none; }
}
@media print {
  .sidebar, .mobile-nav, .mobile-header, .topbar, .table-toggle, [data-view="entry"] { display: none !important; }
  .main-content { margin: 0; width: 100%; padding: 0; }
  .view { display: block !important; padding-top: 24px; break-before: page; }
  .view:first-of-type { break-before: auto; }
  .view#view-entry { display: none !important; }
  .card, .hero { break-inside: avoid; }
}
