:root {
  --ink: #252423; --ink-2: #3B3A39; --muted: #605E5C; --line: #E1DFDD; --line-2: #EDEBE9;
  --canvas: #E9E8E6; --tile: #FFFFFF; --soft: #F3F2F1;
  --blue: #118DFF; --navy: #12239E; --orange: #E66C37; --grey: #B3B0AD; --red: #C4314B; --green: #107C10;
  --link: #0F6CBD;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); background: var(--canvas); font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); }
.boot { padding: 40px; color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* shell */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { background: var(--ink); color: #fff; display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: 8px 24px; padding: 10px 20px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-title { font-size: 15px; font-weight: 600; }
.brand-sub { font-size: 12px; color: #D2D0CE; }
.topbar-right { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-size: 12px; color: #D2D0CE; }
.topbar-right strong { color: #fff; font-weight: 600; }
.topbtn { background: transparent; border: 1px solid #605E5C; color: #fff; border-radius: 2px; padding: 5px 10px;
  min-height: 32px; cursor: pointer; }
.topbtn:hover { background: #3B3A39; }
.body { flex: 1; display: flex; flex-wrap: wrap; align-items: stretch; }
.main { flex: 999 1 640px; min-width: 0; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.pane { flex: 1 1 240px; max-width: 100%; background: var(--tile); border-left: 1px solid var(--line);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 16px; }
.tabs { background: var(--soft); border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 2px;
  padding: 0 12px; position: sticky; bottom: 0; z-index: 5; }
.tab { border: none; border-top: 3px solid transparent; background: transparent; padding: 10px 16px; min-height: 44px;
  cursor: pointer; font-size: 13px; }
.tab:hover { background: #fff; }
.tab[aria-current="page"] { border-top-color: var(--blue); background: #fff; font-weight: 600; }
.tab-sep { width: 1px; background: var(--line); margin: 10px 6px; }

/* tiles */
.grid { display: grid; gap: 12px; }
.g-kpi { grid-template-columns: repeat(auto-fit, minmax(min(165px, 100%), 1fr)); }
.g-2 { grid-template-columns: repeat(auto-fit, minmax(min(440px, 100%), 1fr)); }
.g-3 { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.tile { background: var(--tile); border: 1px solid var(--line); border-radius: 2px; padding: 12px 16px 16px; min-width: 0; }
.tile h2 { margin: 0 0 10px; font-size: 14px; font-weight: 600; }
.tile-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 12px; margin-bottom: 10px; }
.tile-head h2 { margin: 0; }
.hint { font-size: 12px; color: var(--muted); }
.kpi { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 2px;
  min-height: 104px; padding: 12px; }
.kpi-v { font-size: 28px; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-l { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.kpi-s { font-size: 12px; color: var(--muted); }
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 320px; }
.empty { border: 1px dashed #A19F9D; background: #fff; padding: 16px; border-radius: 2px; font-size: 13px; color: var(--ink-2);
  display: flex; flex-direction: column; gap: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--ink-2); }
.sw { display: inline-block; width: 10px; height: 10px; margin-right: 4px; vertical-align: -1px; }
.warn-list { margin: 0; padding-left: 18px; font-size: 12px; line-height: 1.5; color: var(--ink-2); display: flex; flex-direction: column; gap: 4px; }
.ok { color: var(--green); }

/* tables */
.tbl-wrap { overflow: auto; max-height: 560px; border: 1px solid var(--line-2); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th { position: sticky; top: 0; background: #fff; text-align: left; font-weight: 600; color: var(--muted);
  border-bottom: 1px solid #C8C6C4; padding: 0; white-space: nowrap; z-index: 1; }
.tbl th button { all: unset; cursor: pointer; display: block; padding: 8px; }
.tbl th button:hover { color: var(--ink); }
.tbl th.static { padding: 8px; }
.tbl td { padding: 6px 8px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tbody tr:hover td { background: #F7F7F7; }
.tbl td.cell { cursor: text; min-width: 90px; }
.tbl td.cell:focus { outline: 2px solid var(--blue); outline-offset: -2px; }
.tbl td.cell.saving { color: var(--muted); }
.tbl td.cell.bad { background: #FDE7E9; }
.tbl td.cell input, .tbl td.cell select { width: 100%; min-width: 110px; border: 1px solid var(--blue); padding: 3px 4px; font-size: 12px; }
.tbl td.del { width: 40px; text-align: center; }
.iconbtn { background: none; border: none; cursor: pointer; padding: 4px; min-width: 32px; min-height: 32px; color: var(--muted); }
.iconbtn:hover { color: var(--red); }
.flag { color: var(--red); font-weight: 600; }

/* gantt */
.gantt { min-width: 760px; }
.g-row { display: grid; grid-template-columns: 240px 1fr; gap: 12px; align-items: center; min-height: 30px; border-bottom: 1px solid var(--soft); }
.g-row.head { border-bottom: 1px solid #C8C6C4; min-height: 22px; }
.g-name { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-track { position: relative; height: 30px; }
.g-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line-2); }
.g-ticklbl { position: absolute; font-size: 11px; color: var(--muted); white-space: nowrap; top: 2px; }
.g-plan { position: absolute; top: 8px; height: 14px; background: #D2D0CE; border-radius: 1px; }
.g-prog { position: absolute; top: 8px; height: 14px; border-radius: 1px; }
.g-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--orange); }

/* forms */
.btn { border: 1px solid #8A8886; background: #fff; border-radius: 2px; padding: 6px 12px; min-height: 34px; cursor: pointer; }
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: #0E1B7A; }
.btn.danger { color: var(--red); border-color: var(--red); }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); }
.field input, .field select, .field textarea, .inp { border: 1px solid #8A8886; border-radius: 2px; padding: 6px 8px; min-height: 34px; background: #fff; font-size: 13px; }
.drop { border: 2px dashed #8A8886; border-radius: 2px; padding: 28px; text-align: center; background: #FAF9F8; color: var(--ink-2); }
.drop.over { border-color: var(--blue); background: #EFF6FC; }
.msg { padding: 8px 12px; border-radius: 2px; font-size: 13px; }
.msg.err { background: #FDE7E9; color: #8A1F2D; }
.msg.info { background: #EFF6FC; color: #0B4F8A; }
.msg.good { background: #DFF6DD; color: #0B5A0B; }
.pill { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--soft); color: var(--ink-2); }
.pill.applied { background: #DFF6DD; color: #0B5A0B; }
.pill.rejected, .pill.discarded { background: #FDE7E9; color: #8A1F2D; }
.pill.preview { background: #FFF4CE; color: #6B4E00; }

/* slicers */
.slicer h3 { margin: 0; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.slicer .hint { margin-bottom: 4px; display: block; }
.sl-item { all: unset; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 5px 4px; min-height: 24px; font-size: 13px; width: 100%; box-sizing: border-box; }
.sl-item:hover { background: var(--soft); }
.sl-box { width: 14px; height: 14px; border: 1px solid var(--muted); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.sl-item[aria-pressed="true"] .sl-box { background: var(--ink); }

/* login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login form { background: #fff; border: 1px solid var(--line); padding: 28px; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
.login h1 { margin: 0; font-size: 18px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(37,36,35,.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: #fff; width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.modal h2 { margin: 0; font-size: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 10px; }


/* management system: period bar, status chips, KPI cards, home tiles */
.pbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 10px 16px; }
.ptitle { margin: 0; font-size: 20px; font-weight: 600; }
.seg { display: inline-flex; border: 1px solid #8A8886; border-radius: 2px; overflow: hidden; }
.seg button { border: none; background: #fff; padding: 6px 12px; min-height: 34px; cursor: pointer; font-size: 13px; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: none; }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.st { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.st-on { background: #DFF6DD; color: #0B5A0B; }
.st-watch { background: #FFF4CE; color: #6B4E00; }
.st-bad { background: #FDE7E9; color: #8A1F2D; }
.cnt { display: flex; flex-wrap: wrap; gap: 4px; }
.kcard { display: flex; flex-direction: column; gap: 3px; border-left: 4px solid var(--grey); min-height: 112px; }
.kcard.k-on { border-left-color: var(--green); }
.kcard.k-watch { border-left-color: #D9B300; }
.kcard.k-bad { border-left-color: var(--red); }
.kcard-l { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.kcard-v { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kcard-s { font-size: 12px; color: var(--muted); }
.kcard .st { align-self: flex-start; }
/* home: pyramid. Apex = company, middle = production (with site maps), base = support functions */
.pyr { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.pyr-row { display: grid; gap: 12px; width: 100%; }
.pyr-row.r1 { max-width: 560px; }
.pyr-row.r2 { max-width: 1100px; grid-template-columns: 1fr 1fr; }
.pyr-row.r3 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.home-tile.apex { background: var(--ink); color: #fff; border: none; border-top: 4px solid var(--blue); min-height: 0; align-items: stretch; }
.home-tile.apex:hover { background: #2F2E2D; }
.apex-line { font-size: 26px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.apex-sub { font-size: 12px; color: #D2D0CE; }
.sbar { display: flex; height: 10px; border-radius: 1px; overflow: hidden; gap: 2px; }
.sbar .sb.on { background: #3BB143; } .sbar .sb.watch { background: #D9B300; } .sbar .sb.bad { background: #E5566D; }
.home-tile.prod { border-top-color: var(--navy); min-height: 200px; }
.prod .ht-facts { font-size: 14px; }
.ht-blurb { font-size: 12px; color: var(--muted); }
.apex .ht-name { font-size: 15px; font-weight: 600; color: #D2D0CE; }
.r3 .home-tile { min-height: 170px; }
.r3 .ht-name { font-size: 15px; }
.r3 .ht-facts { grid-template-columns: 1fr; gap: 0; }
.r3 .ht-facts dd { text-align: left; margin-bottom: 6px; }
.g-home { grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr)); }
.home-tile { text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 8px; min-height: 190px; border-top: 4px solid var(--blue); font: inherit; }
.home-tile:hover { box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.home-tile:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.home-tile.later { border-top-color: var(--grey); background: #FAF9F8; }
.ht-head { display: flex; justify-content: space-between; align-items: center; }
.ht-name { font-size: 17px; font-weight: 600; }
.ht-go { font-size: 18px; color: var(--blue); }
.ht-facts { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 13px; }
.ht-facts dt { color: var(--muted); }
.ht-facts dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.subtabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid #C8C6C4; }
.subtab { border: none; background: transparent; border-bottom: 3px solid transparent; padding: 8px 12px; min-height: 38px; cursor: pointer; font-size: 13px; color: var(--ink-2); }
.subtab:hover { background: #fff; }
.subtab[aria-current="page"] { border-bottom-color: var(--blue); font-weight: 600; color: var(--ink); }
.tbl.score td.sel, .tbl.score th.sel { background: #EFF6FC; }
.tbl.score tr.grp td { background: var(--soft); font-weight: 600; color: var(--ink); }
.tbl.score td.sub { padding-left: 22px; color: var(--muted); }
.exc { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 13px; max-height: 260px; overflow: auto; }
@media print { .seg, .subtabs, .pbar input { display: none; } }

@media (max-width: 1150px) {
  .r3 .home-tile { padding: 10px 12px 12px; }
  .r3 .ht-head { flex-wrap: wrap; gap: 4px; }
}
@media (max-width: 900px) {
  .pyr-row.r2, .pyr-row.r3 { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .main { padding: 10px; }
  .kpi-v { font-size: 24px; }
  .home-tile { min-height: 0; }
  .r3 .home-tile { min-height: 0; }
  .g-row { grid-template-columns: 140px 1fr; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab { white-space: nowrap; flex: none; }
}
@media print {
  .tabs, .pane, .topbtn { display: none; }
  body { background: #fff; }
  .tile { break-inside: avoid; }
}
