/* Components for the dashboard and editor. Values come from design/theme.css. */

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-ui); background: var(--bg); color: var(--text); min-height: 100vh;
  -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
}

/* ---------- Sign-in ---------- */
#pin-overlay { position: fixed; inset: 0; background: var(--navy); z-index: 9999; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 18px; padding: 24px; }
#pin-overlay.hidden { display: none; }
#pin-overlay img { height: 56px; background: var(--white); padding: 8px 14px; border-radius: var(--radius-sm); margin-bottom: 6px; }
#pin-overlay h2 { color: var(--white); font-size: 19px; font-weight: 500; }
#pin-overlay input {
  font-family: var(--font-ui); font-size: 22px; text-align: center; letter-spacing: 8px; width: 220px; padding: 11px;
  border: 1px solid rgba(255,255,255,0.3); border-radius: var(--radius-sm); background: rgba(255,255,255,0.08); color: var(--white); outline: none;
}
#pin-overlay input:focus { border-color: var(--blue); background: rgba(255,255,255,0.12); }
#pin-overlay .pin-error { color: #FF8A80; font-size: 13px; min-height: 18px; }
#pin-overlay button { width: 220px; padding: 10px 0; border: none; border-radius: var(--radius-sm); background: var(--blue); color: var(--white); font: 600 15px var(--font-ui); cursor: pointer; }
#pin-overlay button:hover { filter: brightness(1.08); }

/* ---------- Banner ---------- */
.banner { background: var(--navy); padding: 22px var(--gutter); display: flex; align-items: center; gap: 22px; }
.banner img { height: 42px; background: var(--white); padding: 5px 8px; border-radius: 5px; }
.banner-text { flex: 1; min-width: 0; }
.banner h1 { color: var(--white); font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.banner .subtitle { color: var(--banner-text); font-size: 13px; margin-top: 2px; }
.view-badge, .banner .sync-status { font-size: 12px; color: var(--banner-text); display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.view-badge::before, .banner .sync-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--banner-text); opacity: .7; }
.banner .sync-status[data-state="ok"]::before { background: #5FD38A; opacity: 1; }
.banner .sync-status[data-state="busy"]::before { background: #F6C35B; opacity: 1; }
.banner .sync-status[data-state="error"] { color: #FFB4AB; }
.banner .sync-status[data-state="error"]::before { background: #FF8A80; opacity: 1; }

/* ---------- OKR cycle strip ---------- */
.cycle-strip { background: var(--white); border-bottom: 1px solid var(--line); padding: 14px var(--gutter); }
.cycle-info { display: flex; align-items: baseline; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.cycle-label { font-size: 13px; font-weight: 600; color: var(--navy); }
.cycle-progress-text { font-size: 13px; color: var(--text-mid); }
.cycle-progress-text strong { font-weight: 700; color: var(--navy); }
.cycle-meta { margin-left: auto; font-size: 13px; color: var(--text-mid); }
.cycle-bar { height: 6px; background: var(--navy-tint); border-radius: 3px; overflow: hidden; }
.cycle-bar-fill { height: 100%; background: var(--blue); border-radius: 3px; transition: width .4s ease; }

/* ---------- Tabs ---------- */
.tab-bar { background: var(--white); border-bottom: 1px solid var(--line-strong); padding: 0 var(--gutter); display: flex; gap: 32px; overflow-x: auto; }
.tab-btn { padding: 14px 0 12px; font: 600 14px var(--font-ui); border: none; background: none; cursor: pointer; color: var(--text-light); border-bottom: 3px solid transparent; white-space: nowrap; transition: color .15s, border-color .15s; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--navy); border-bottom-color: var(--blue); }

/* ---------- Page body ---------- */
.container { max-width: var(--content-max); margin: 0 auto; padding: 28px 24px 60px; }
.tab-content { display: none; }
.tab-content.active { display: block; }
.loading { text-align: center; padding: 60px; color: var(--text-light); }
.section-label { font-size: 16px; font-weight: 700; color: var(--navy); margin: 32px 0 12px; }
.section-label:first-child { margin-top: 0; }

/* Shared card surface */
.targets-table, .bu-section, .cal-card, .cal-next-card {
  background: var(--white); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow);
}

/* ---------- Traffic-light figures ---------- */
.metric {
  display: inline-block; min-width: 58px; height: 26px; line-height: 26px; padding: 0 8px; border-radius: var(--radius-sm);
  text-align: center; font-size: 13px; font-weight: 600;
}
.metric.tl-green { background: var(--green-bg); color: var(--green); }
.metric.tl-amber { background: var(--amber-bg); color: var(--amber); }
.metric.tl-red   { background: var(--red-bg);   color: var(--red); }
.metric.tl-grey  { background: none; color: var(--grey); font-weight: 500; }

/* ---------- Annual targets ---------- */
.targets-table { width: 100%; border-collapse: separate; border-spacing: 0; overflow: hidden; margin-bottom: 24px; }
.targets-table th { background: var(--navy-tint); padding: 11px 16px; font-size: 12px; font-weight: 600; color: var(--navy); text-align: left; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.targets-table td { padding: 14px 16px; font-size: 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.targets-table tr:last-child td { border-bottom: none; }
.targets-table .goal-cell { font-weight: 700; color: var(--navy); white-space: nowrap; width: 170px; font-size: 15px; }
.targets-table .goal-cell img { height: 24px; max-width: 80px; object-fit: contain; vertical-align: middle; margin-right: 10px; }
.targets-table .target-cell { color: var(--text); min-width: 200px; font-size: 18px; font-weight: 600; line-height: 1.35; }
.targets-table .e1-cell { width: 70px; text-align: center; font-size: 16px; font-weight: 600; color: var(--navy); }
.targets-table .m-cell { min-width: 180px; }
.targets-table .m-target { display: inline-block; vertical-align: middle; min-width: 92px; margin-right: 6px; font-size: 18px; font-weight: 600; color: var(--text); line-height: 1.3; }
.targets-table .m-row { display: inline-flex; vertical-align: middle; align-items: center; gap: 8px; margin: 4px 0; }
.targets-table .m-lbl { font-size: 12px; font-weight: 500; color: var(--text-light); }
.targets-table .m-ytd { font-size: 14px; color: var(--navy); min-width: 46px; }
.targets-table .m-ytd:empty::after, .targets-table .e1-cell:empty::after { content: "–"; color: #C8CCD2; font-weight: 400; }
.targets-table [contenteditable="true"], .ytd-asof [contenteditable="true"] { background: var(--surface-alt); border: 1px dashed var(--line-strong); border-radius: 4px; padding: 3px 8px; cursor: text; outline: none; }
.targets-table [contenteditable="true"]:focus, .ytd-asof [contenteditable="true"]:focus { border: 1px solid var(--blue); background: var(--white); box-shadow: 0 0 0 3px var(--accent-soft); }
.ytd-asof { font-size: 13px; color: var(--text-mid); margin: -4px 0 12px; }
.ytd-asof strong { color: var(--navy); }

/* ---------- OKRs ---------- */
.bu-section { margin-bottom: 20px; overflow: hidden; }
.bu-header { display: flex; align-items: center; gap: 16px; padding: 12px 24px 12px 20px; border-left: 4px solid var(--biz); background: var(--biz-bg); }
.bu-section[data-bu="n2"]       { --biz: var(--navy);        --biz-bg: var(--navy-tint); }
.bu-section[data-bu="bioteam"]  { --biz: var(--bt-teal);     --biz-bg: var(--bt-teal-bg); }
.bu-section[data-bu="bismarck"] { --biz: var(--bis-purple);  --biz-bg: var(--bis-purple-bg); }
.bu-section[data-bu="stac"]     { --biz: var(--stac-orange); --biz-bg: var(--stac-orange-bg); }
.bu-section[data-bu^="nag"]     { --biz: var(--nag-blue);    --biz-bg: var(--nag-blue-bg); }
.bu-header img { max-width: 130px; object-fit: contain; mix-blend-mode: multiply; }  /* white logo backgrounds take the header tint */
.bu-header .bu-name { font-size: 17px; font-weight: 700; color: var(--biz); }
.bu-header .col-labels { margin-left: auto; display: flex; }
.bu-header .col-label { width: 88px; text-align: center; font-size: 12px; font-weight: 600; color: var(--text-mid); }
.obj-block { border-top: 1px solid var(--line); padding-bottom: 6px; }
.objective { padding: 14px 24px 6px; font-size: 14px; font-weight: 600; color: var(--text); }
.kr-row { display: flex; align-items: center; padding: 6px 24px; gap: 12px; }
.kr-label { font-size: 11px; font-weight: 600; color: var(--text-light); flex-shrink: 0; width: 20px; }
.kr-desc { flex: 1; font-size: 14px; color: var(--text-mid); line-height: 1.45; }
.kr-owner { font-size: 13px; font-weight: 600; color: var(--navy); white-space: nowrap; min-width: 70px; text-align: right; }
.metric-cell { width: 88px; text-align: center; flex-shrink: 0; }
.legend { text-align: center; padding: 16px; font-size: 12px; color: var(--text-light); display: flex; justify-content: center; align-items: center; gap: 20px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; }
.legend-dot.green { background: var(--green); }
.legend-dot.amber { background: var(--amber); }
.legend-dot.red { background: var(--red); }
.legend-dot.grey { background: var(--grey); }
.legend .view-badge { color: var(--text-light); }
.legend .view-badge::before { background: var(--grey); }

/* ---------- OKR calendar ---------- */
.cal-next { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.cal-next-card { flex: 1 1 260px; padding: 16px 20px; border-left: 4px solid var(--blue); }
.cal-next-card.later { border-left-color: #BFD4F2; }
.cal-next-when { font-size: 12px; font-weight: 600; color: var(--text-light); }
.cal-next-date { font-size: 20px; font-weight: 700; color: var(--navy); margin: 4px 0 2px; }
.cal-next-what { font-size: 14px; color: var(--text-mid); }
.cal-card { margin-bottom: 28px; overflow-x: auto; }
.cal-tl { min-width: 780px; padding: 30px 20px 14px; }
.cal-row, .cal-axis { display: grid; grid-template-columns: 190px 1fr; align-items: center; }
.cal-row { height: 52px; border-bottom: 1px solid var(--line); }
.cal-row:last-of-type { border-bottom: none; }
.cal-row-label { font-size: 14px; font-weight: 700; color: var(--navy); line-height: 1.25; }
.cal-row-label small { display: block; font-size: 12px; font-weight: 500; color: var(--text-mid); }
.cal-row.current .cal-row-label::before { content: "● "; color: var(--blue); }
.cal-track { position: relative; height: 100%; }
.cal-grid { position: absolute; top: 0; bottom: 0; width: 1px; background: #F0F2F5; }
.cal-grid.year { background: var(--line-strong); }
.cal-bar { position: absolute; top: 50%; height: 14px; margin-top: -7px; border-radius: 4px; display: flex; overflow: hidden; }
.cal-bar .wk13 { flex: 13; } .cal-bar .wkco { flex: 1; opacity: .45; border-left: 2px solid var(--white); }
.cal-bar.past .wk13, .cal-bar.past .wkco { background: #C4C9D0; }
.cal-bar.current .wk13, .cal-bar.current .wkco { background: var(--blue); }
.cal-bar.upcoming .wk13, .cal-bar.upcoming .wkco { background: #9DBCE8; }
.cal-mark { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--navy); border: 2px solid var(--white); box-sizing: content-box; cursor: default; z-index: 2; }
.cal-mark.close { border-radius: 2px; transform: rotate(45deg); background: var(--white); border: 2.5px solid var(--navy); width: 9px; height: 9px; margin: -6px 0 0 -6px; }
.cal-mark::after { content: ""; position: absolute; inset: -8px; }
.cal-today { position: absolute; top: -6px; bottom: 0; width: 2px; margin-left: -1px; background: var(--red); z-index: 3; }
.cal-today span { position: absolute; top: -16px; left: 4px; font-size: 11px; font-weight: 700; color: var(--red); white-space: nowrap; }
.cal-axis { height: 28px; }
.cal-axis .cal-track span { position: absolute; top: 8px; font-size: 11px; color: var(--text-light); transform: translateX(-50%); white-space: nowrap; }
.cal-axis .cal-track span.yr { font-weight: 700; color: var(--text-mid); }
.cal-legend { display: flex; gap: 22px; flex-wrap: wrap; padding: 12px 20px 16px 210px; font-size: 12px; color: var(--text-mid); border-top: 1px solid var(--line); }
.cal-legend i { display: inline-block; vertical-align: middle; margin-right: 6px; }
.cal-legend .lg-bar { width: 26px; height: 10px; border-radius: 3px; background: var(--blue); }
.cal-legend .lg-co { width: 10px; height: 10px; border-radius: 2px; background: var(--blue); opacity: .45; }
.cal-legend .lg-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--navy); }
.cal-legend .lg-dia { width: 8px; height: 8px; border: 2px solid var(--navy); border-radius: 1px; transform: rotate(45deg); }
.cal-legend .lg-today { width: 2px; height: 14px; background: var(--red); }
.cal-tip { position: fixed; pointer-events: none; background: var(--navy); color: var(--white); font-size: 12px; line-height: 1.4; padding: 7px 10px; border-radius: var(--radius-sm); z-index: 50; display: none; max-width: 260px; box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.cal-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.cal-table th { background: var(--navy-tint); padding: 11px 14px; font-size: 12px; font-weight: 600; color: var(--navy); text-align: left; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.cal-table th small { display: block; font-weight: 500; color: var(--text-mid); }
.cal-table td { padding: 12px 14px; font-size: 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.cal-table tr:last-child td { border-bottom: none; }
.cal-table td:first-child { font-weight: 700; color: var(--navy); }
.cal-table tr.current td { background: #F1F6FD; }
.cal-table tr.past td { color: var(--text-light); }
.cal-table tr.past td:first-child { color: var(--text-mid); }
.cal-status { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 20px; background: var(--grey-bg); color: var(--text-mid); }
.cal-status.current { background: var(--blue); color: var(--white); }
.cal-status.upcoming { background: var(--blue-soft); color: var(--navy); }
.cal-note { font-size: 14px; color: var(--text-mid); line-height: 1.6; max-width: 860px; }
.cal-note strong { color: var(--navy); }

/* ---------- Narrow screens ---------- */
@media (max-width: 760px) {
  .banner { gap: 14px; padding-block: 16px; }
  .banner img { height: 34px; }
  .banner h1 { font-size: 19px; }
  .cycle-meta { margin-left: 0; flex-basis: 100%; }
  .tab-bar { gap: 22px; }
  .container { padding: 20px 16px 48px; }
  .tab-content { overflow-x: auto; }
  .bu-header { padding-inline: 14px 16px; }
  .bu-header .col-labels { display: none; }
  .objective { padding-inline: 16px; }
  .kr-row { flex-wrap: wrap; padding-inline: 16px; }
  .kr-desc { flex-basis: calc(100% - 40px); }
  .kr-owner { text-align: left; min-width: 0; margin-left: 32px; margin-right: auto; }
  .metric-cell { width: auto; }
  .targets-table .goal-cell { width: auto; white-space: normal; }
}
