/* realvirtual portal — one stylesheet for customer, internal and projects.
   Tokens from DESIGN.md; contrast fixes per PLAN.md 3.0 (button #d12f66, link #c42a5e). */

:root {
  --magenta: #e94078;        /* callout edge only — fails AA as text/button on white */
  --magenta-strong: #d12f66; /* buttons, 4.9:1 with white */
  --magenta-hover: #b0244f;
  --link: #c42a5e;
  --link-hover: #9e1f49;
  --pink: #ff6b9d;           /* on dark only */
  --dark: #15161c;
  --dark2: #22232c;
  --ink: #20242e;
  --muted: #5d6473;
  --soft: #f6f7fb;
  --soft2: #eef0f6;
  --line: #e4e7f0;
  --surface: #ffffff;
  --ok-fg: #11603f; --ok-bg: #e8f6ef; --ok-line: #bfe5d3;
  --warn-fg: #7a4200; --warn-bg: #fff4e0; --warn-line: #f0cf93;
  --err-fg: #a11d1d; --err-bg: #fdecec; --err-line: #f1bfbf;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: Consolas, "Cascadia Mono", ui-monospace, monospace;
  --r-sm: 7px; --r-md: 10px; --r-lg: 12px;
  --page: 1240px;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--soft); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.55; }
a { color: var(--link); }
a:hover { color: var(--link-hover); }
:focus-visible { outline: 2px solid var(--magenta-strong); outline-offset: 2px; }
h1 { font-size: 2rem; line-height: 1.14; letter-spacing: -.01em; margin: 4px 0 0; }
h2 { font-size: 1.05rem; line-height: 1.3; margin: 0; }
p { margin: 0; }
.mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kick { font-size: 11px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; color: var(--link); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- prototype bar ---- */
.proto { background: #fff4e0; border-bottom: 1px solid var(--warn-line); font-size: 13px; }
.proto-in { max-width: var(--page); margin: 0 auto; padding: 6px 24px; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.proto b { color: var(--warn-fg); letter-spacing: .12em; }
.proto a { color: var(--ink); text-decoration: none; padding: 2px 8px; border-radius: 999px; border: 1px solid transparent; }
.proto a.on { border-color: var(--warn-fg); font-weight: 600; }

/* ---- navigation ---- */
.nav { background: var(--dark); color: #fff; }
.nav-in { max-width: var(--page); margin: 0 auto; padding: 0 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 0 20px; min-height: 56px; }
.brand { font-weight: 700; color: #fff; text-decoration: none; letter-spacing: -.01em; }
.brand span { color: var(--pink); font-weight: 600; }
.brand:hover { color: #fff; }
.role { font-size: 10.5px; font-weight: 700; letter-spacing: .15em; color: var(--pink); border: 1px solid rgba(255,107,157,.5); border-radius: 999px; padding: 1px 8px; }
.nav a.l { color: rgba(255,255,255,.8); text-decoration: none; font-size: 14px; padding: 16px 0 14px; border-bottom: 2px solid transparent; }
.nav a.l:hover { color: #fff; }
.nav a.l[aria-current="page"] { color: #fff; font-weight: 600; border-bottom-color: var(--pink); }
.nav .sp { flex: 1; }
.nav .me { color: rgba(255,255,255,.8); font-size: 13px; }
.nav form.signout { margin: 0; }
.nav .linkbtn { background: none; border: 0; cursor: pointer; font: inherit; color: rgba(255,255,255,.8); font-size: 14px; padding: 16px 0 14px; }
.nav .linkbtn:hover { color: #fff; }

/* Internal navigation (Thomas 29.10.): top bar with brand, INTERNAL, search and user; grouped sidebar below it.
   Below 900px the sidebar folds behind the menu button (CSS-only checkbox). */
.internal-top { position: sticky; top: 0; z-index: 20; }
.internal-top .nav-in { max-width: none; padding: 0 20px; gap: 0 16px; flex-wrap: nowrap; }
.internal-top .gsearch { flex: 0 1 360px; }
.internal-top .gsearch input { width: 100%; }
.internal-top .me { margin-left: auto; color: rgba(255,255,255,.8); font-size: 13px; white-space: nowrap; }
.internal-top .linkbtn { padding: 0; }
.menu-btn { display: none; color: #fff; font-size: 20px; line-height: 1; cursor: pointer; padding: 6px 4px; }
.internal-shell { display: grid; grid-template-columns: 208px minmax(0, 1fr); min-height: calc(100vh - 56px); }
.internal-shell > .menu-toggle { display: none; }
.sidebar { position: sticky; top: 56px; align-self: start; height: calc(100vh - 56px); overflow-y: auto; background: var(--dark); color: #fff; padding: 18px 0 16px; }
.side-nav { display: flex; flex-direction: column; gap: 16px; }
.side-group { display: flex; flex-direction: column; }
.side-kicker { padding: 0 24px 5px; color: var(--pink); font-size: .66rem; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; }
.side-link { display: block; border-left: 3px solid transparent; padding: 7px 18px 7px 21px; color: rgba(255,255,255,.8); font-size: 14px; line-height: 1.35; text-decoration: none; }
.side-link:hover { color: #fff; }
.side-link[aria-current="page"] { border-left-color: var(--pink); color: #fff; font-weight: 700; }
.internal-content { min-width: 0; }
.internal-content .wrap { max-width: var(--page); }

@media (max-width: 899px) {
  .menu-btn { display: block; }
  .internal-top .nav-in { flex-wrap: wrap; padding: 6px 16px; gap: 6px 14px; }
  .internal-top .gsearch { flex: 1 1 100%; order: 5; }
  .internal-top .me { display: none; }
  .internal-shell { display: block; min-height: 0; }
  .internal-shell > .menu-toggle { display: block; }
  .menu-toggle:focus-visible ~ .sidebar { outline: 2px solid var(--pink); outline-offset: -3px; }
  .menu-toggle:not(:checked) ~ .sidebar { display: none; }
  .sidebar { position: static; height: auto; padding-top: 8px; }
}

/* ---- page ---- */
.wrap { max-width: var(--page); margin: 0 auto; padding: 26px 24px 64px; display: flex; flex-direction: column; gap: 20px; }
.head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 14px; }
.crumb { font-size: 13px; color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.main-col { flex: 999 1 620px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.side-col { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---- cards ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); min-width: 0; }
.card-h { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.card-b { padding: 14px 16px; }
.card-f { padding: 12px 16px; border-top: 1px solid var(--line); }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; padding: 12px 16px; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.grp { background: var(--soft); font-size: 11px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; color: var(--muted); padding: 6px 16px !important; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1px; background: var(--line); overflow: hidden; }
.facts > div { background: var(--surface); padding: 12px 16px; min-width: 0; }
.facts .k { display: block; font-size: 12px; color: var(--muted); }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; font-size: 14px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; min-width: 0; }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: var(--r-md); font: inherit; font-weight: 700; font-size: 14px; text-decoration: none; border: 1px solid transparent; cursor: pointer; white-space: nowrap; }
.btn-p { background: var(--magenta-strong); color: #fff; }
.btn-p:hover { background: var(--magenta-hover); color: #fff; }
.btn-s { background: var(--soft); color: var(--ink); border-color: var(--line); }
.btn-s:hover { background: var(--soft2); color: var(--ink); }
.btn-t { background: transparent; color: var(--link); padding: 0 10px; }
.btn-t:hover { background: var(--soft); color: var(--link-hover); }
.btn-block { display: flex; width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
form.inline { display: inline; margin: 0; }

/* ---- segmented filter ---- */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--surface); }
.seg a { display: inline-flex; align-items: center; min-height: 42px; padding: 0 14px; text-decoration: none; color: var(--ink); font-size: 14px; border-left: 1px solid var(--line); }
.seg a:first-child { border-left: 0; }
.seg a[aria-current="true"] { background: var(--dark); color: #fff; font-weight: 600; }

/* ---- tables ---- */
.tbox { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { background: var(--dark); color: #fff; font-weight: 600; text-align: left; padding: 8px 14px; white-space: nowrap; }
td { padding: 8px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr:nth-child(even) td { background: var(--soft); }
tfoot td { background: var(--surface); }

/* ---- status chips: colour never alone, always text ---- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 1px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; border: 1px solid; }
.chip.ok { color: var(--ok-fg); background: var(--ok-bg); border-color: var(--ok-line); }
.chip.warn { color: var(--warn-fg); background: var(--warn-bg); border-color: var(--warn-line); }
.chip.err { color: var(--err-fg); background: var(--err-bg); border-color: var(--err-line); }
.chip.neutral { color: #4a505d; background: var(--soft); border-color: var(--line); }
.chip.dark { color: #fff; background: var(--ink); border-color: var(--ink); }

/* ---- banners & callout ---- */
.banner { border-radius: var(--r-md); padding: 16px 18px; display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: center; border: 1px solid var(--line); background: var(--surface); }
.banner.ok { background: var(--ok-bg); border-color: var(--ok-line); }
.wide-input { width: min(100%, 720px); }
.f.check { flex-direction: row; align-items: center; gap: 8px; }
details.card-f > summary { cursor: pointer; font-weight: 600; }
.point + .point { border-top: 1px solid var(--line); }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
ul.files { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
details.card-f[open] > summary { margin-bottom: 12px; }
.banner.warn { background: #fff8eb; border-color: var(--warn-line); }
.banner.err { background: #fdf1f1; border-color: var(--err-line); }
.banner .txt { display: flex; flex-direction: column; gap: 4px; flex: 1 1 420px; }
.callout { border-left: 4px solid var(--magenta); background: linear-gradient(90deg, rgba(233,64,120,.07), rgba(233,64,120,0)); border-radius: 0 var(--r-md) var(--r-md) 0; padding: 12px 16px; }
.callout .lb { font-size: 11px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; color: var(--link); }

/* ---- forms ---- */
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); min-width: 0; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); min-height: 44px; padding: 0 12px; }
textarea { padding: 10px 12px; min-height: 88px; }
input:focus, select:focus, textarea:focus { border-color: var(--magenta-strong); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--magenta-strong); outline-offset: 2px; }
.formrow { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.formrow > label.f { flex: 1 1 140px; }
.formrow > label.f.wide { flex: 4 1 280px; }
input[type="checkbox"] { min-height: 0; width: 18px; height: 18px; accent-color: var(--magenta-strong); }

/* ---- meter (native progress) ---- */
progress.meter { appearance: none; -webkit-appearance: none; display: block; width: 100%; height: 10px; border: 0; border-radius: 5px; background: var(--soft2); overflow: hidden; color: var(--ink); }
progress.meter::-webkit-progress-bar { background: var(--soft2); }
progress.meter::-webkit-progress-value { background: var(--ink); }
progress.meter::-moz-progress-bar { background: var(--ink); }
progress.meter.warn::-webkit-progress-value { background: var(--warn-fg); }
progress.meter.warn::-moz-progress-bar { background: var(--warn-fg); }
progress.meter.over::-webkit-progress-value { background: var(--err-fg); }
progress.meter.over::-moz-progress-bar { background: var(--err-fg); }

/* ---- small layout utilities (no inline styles: CSP style-src 'self') ---- */
.mt4 { margin-top: 4px; } .mt6 { margin-top: 6px; } .mt8 { margin-top: 8px; } .mt10 { margin-top: 10px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mb4 { margin-bottom: 4px; } .mb10 { margin-bottom: 10px; } .mb14 { margin-bottom: 14px; }
.amt-gap { margin: 6px 0 4px; } .amt-gap2 { margin: 6px 0; }
.between { justify-content: space-between; }
.center { text-align: center; }
.block { display: block !important; }
.stack12 { display: flex; flex-direction: column; gap: 12px; }
.spacer10 { height: 10px; }
.sep { border-top: 1px solid var(--line); margin: 16px 0; }
.f420 { flex: 1 1 420px; } .f380 { flex: 1 1 380px; min-width: 0; } .f140 { flex: 1 1 140px; }
.w160 { min-width: 160px; }
.h1-mono { font-family: var(--mono); font-size: 1.6rem; }

/* ---- preview page ---- */
.preview { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.dark-strip { background: var(--dark2); color: rgba(255,255,255,.85); font-size: 13px; }
.dark-strip > div { max-width: var(--page); margin: 0 auto; padding: 7px 24px; }

/* ---- pay page ---- */
.narrow { max-width: 640px; }
.amount { font-size: 2.2rem; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; line-height: 1.1; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* table island (sort + per-column filter) and global search */
th[aria-sort] { padding: 0; }
th button.sort { all: unset; display: block; padding: 8px 14px; cursor: pointer; white-space: nowrap; }
th button.sort:focus-visible { outline: 2px solid var(--pink); outline-offset: -2px; }
th button.sort::after { content: " ↕"; opacity: .45; }
th[aria-sort="ascending"] button.sort::after { content: " ▲"; opacity: 1; }
th[aria-sort="descending"] button.sort::after { content: " ▼"; opacity: 1; }
tr.filters th { background: var(--soft2); padding: 6px 8px; border-bottom: 1px solid var(--line); }
tr.filters input { width: 100%; min-width: 60px; font: inherit; font-size: 13px; font-weight: 400; padding: 4px 8px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); }
tr.filters input:focus { border-color: var(--magenta-strong); outline: none; }
.ttools { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.ttools > span { margin-right: auto; }
.tfilter, .tclear { font: inherit; font-size: 13px; cursor: pointer; border-radius: var(--r-sm); }
.tfilter { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 28px; color: var(--ink);
  border: 1px solid var(--line); background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%235d6473' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 3.5 3.5'/%3E%3C/svg%3E") no-repeat 9px center; }
.tfilter:hover, .tfilter[aria-expanded="true"] { border-color: var(--muted); }
.tfilter.on { color: var(--magenta-strong); border-color: var(--magenta-strong); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23d12f66' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 3.5 3.5'/%3E%3C/svg%3E"); }
.tclear { border: 0; background: none; color: var(--link); padding: 4px 2px; }
.tclear:hover { color: var(--link-hover); text-decoration: underline; }
.gsearch input { width: 230px; font: inherit; font-size: 13px; padding: 6px 12px 6px 32px; border-radius: 999px;
  border: 1px solid #3a3d49; background: var(--dark2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23a3a8b5' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 3.5 3.5'/%3E%3C/svg%3E") no-repeat 11px center; color: #fff; }
.gsearch input:focus { border-color: var(--pink); outline: none; background-color: #2b2d38; }
.gsearch input:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }
.gsearch input::placeholder { color: #a3a8b5; }
tr.filters select { width: 100%; min-width: 70px; font: inherit; font-size: 13px; font-weight: 400; padding: 3px 6px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); }
tr.filters select:focus { border-color: var(--magenta-strong); outline: none; }

/* live search list */
.gsearch { position: relative; }
.live { position: absolute; right: 0; top: calc(100% + 6px); width: 460px; max-height: 70vh; overflow-y: auto; z-index: 20;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: 0 12px 32px rgba(21, 22, 28, .18); }
.live-hit { display: grid; grid-template-columns: 70px 1fr; gap: 0 10px; padding: 8px 14px; text-decoration: none; color: var(--ink);
  border-bottom: 1px solid var(--soft2); }
.live-hit[aria-selected="true"], .live-hit:hover { background: var(--soft); }
.live-kind { grid-row: span 2; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding-top: 2px; }
.live-title { font-weight: 600; font-size: 14px; }
.live-detail { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-all { display: block; padding: 8px 14px; font-size: 13px; text-align: right; }

/* internal notes (F26) */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.note-form { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.note-form textarea { width: 100%; font: inherit; font-size: 14px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: var(--r-sm); resize: vertical; min-height: 64px; }
.note-form textarea:focus { border-color: var(--magenta-strong); outline: none; }
.note-actions { display: flex; justify-content: flex-end; margin-top: 6px; }
.note-text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }

/* reports (revenue) */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; }
.kpi-l { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.kpi-v { font-size: 1.6rem; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-v.t-ok { color: var(--ok-fg); }
.kpi-v.t-err { color: var(--err-fg); }
.kpi-n { font-size: 12px; color: var(--muted); }
.chart { width: 100%; }
.chart-line { height: 340px; padding: 8px 12px 0; }
.chart-pie { height: 300px; }
.half { flex: 1 1 460px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; }
.swatch.s0 { background: #c4c8d0; } .swatch.s1 { background: #2a78d6; } .swatch.s2 { background: #eb6834; }
.swatch.s3 { background: #1baf7a; } .swatch.s4 { background: #eda100; } .swatch.s5 { background: #e87ba4; }
details.card-f summary { cursor: pointer; color: var(--link); }
details.card-f[open] summary { margin-bottom: 8px; }
.report-notes { margin: 0; padding-left: 18px; }
.line-desc { white-space: pre-wrap; margin-top: 2px; max-width: 70ch; }
.nowrap { white-space: nowrap; }
.adjust-kind { display: block; width: 100%; margin: 4px 0 8px; font: inherit; font-size: 13px; padding: 5px 8px; border: 1px solid var(--line); border-radius: var(--r-sm); }

/* direct PDF link beside a document number (document tables) */
.pdf-link { display: inline-flex; vertical-align: -2px; margin-left: 6px; color: var(--muted, #6b7280); }
.pdf-link:hover { color: var(--ink); }

/* budget bar (customer projects) */
.bar { height: 6px; border-radius: 3px; background: var(--soft); overflow: hidden; margin-top: 6px; }
.bar > span { display: block; height: 100%; background: var(--ok-fg); }
.bar > span.warn { background: var(--warn-fg); }
.bar > span.err { background: var(--err-fg); }

/* Files page: upload row, copy buttons */
.files-upload { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.files-upload .field { display: flex; flex-direction: column; gap: 4px; }
.files-status { flex: 1 0 100%; min-height: 1.4em; overflow-wrap: anywhere; }
.files-status.ok { color: var(--ok-fg); }
.files-status.err { color: var(--err-fg); }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.device-release { margin-bottom: 8px; }
details.release { margin-top: 4px; max-width: 34rem; }
details.release > summary { display: inline-flex; cursor: pointer; list-style: none; }
details.release > summary::-webkit-details-marker { display: none; }
details.release > p { color: var(--muted); }
td.file-name { overflow-wrap: anywhere; max-width: 360px; }
.btn[hidden] { display: none; }
