/* SPO KPI Data Upload — demo styles
   Neutral, clean, Amazon-internal-tool feel. No framework. */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #16191f;
  --ink-soft: #545b64;
  --line: #e2e6ea;
  --brand: #146eb4;       /* Amazon blue */
  --brand-dark: #0f5a94;
  --accent: #ff9900;      /* Amazon orange */
  --ok: #1a8754;
  --ok-bg: #e6f4ec;
  --warn: #b8860b;
  --warn-bg: #fbf3dc;
  --err: #c72c41;
  --err-bg: #fbe7ea;
  --lock: #6c47b8;
  --lock-bg: #efe9fa;
  --changed-bg: #fff3d6;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Amazon Ember", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; }
.muted { color: var(--ink-soft); }
.small { font-size: 12px; }
.pad { padding: 10px 12px; }
.nowrap { white-space: nowrap; }
.row-gap { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }

/* ---- Demo banner ---- */
#demo-banner {
  background: repeating-linear-gradient(45deg, #fff4e0, #fff4e0 12px, #ffedcc 12px, #ffedcc 24px);
  color: #7a4b00;
  border-bottom: 1px solid #f0d9a8;
  padding: 7px 16px;
  font-size: 12.5px;
  text-align: center;
}

/* ---- Header ---- */
#app-header {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 10px 20px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-left { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.logo {
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  padding: 8px 10px;
  border-radius: 8px;
  letter-spacing: .3px;
  font-size: 13px;
}
.app-title { font-weight: 700; font-size: 15px; }
.app-subtitle { color: var(--ink-soft); font-size: 12px; display: flex; align-items: center; gap: 8px; margin-top: 2px; }
#period-switcher { border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font-size: 12px; background: var(--bg); }
.period-chip { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 20px; letter-spacing: .4px; }
.chip-open { background: var(--ok-bg); color: var(--ok); }
.chip-closed { background: #eef1f4; color: var(--ink-soft); }

.header-spacer { flex: 1 1 auto; }
.header-right { display: flex; align-items: center; gap: 14px; flex: 0 0 auto; margin-left: auto; }

/* ---- Left side navigation ---- */
#app-layout { display: flex; align-items: flex-start; }
#side-nav {
  flex: 0 0 232px; width: 232px; background: var(--surface); border-right: 1px solid var(--line);
  min-height: calc(100vh - 53px); position: sticky; top: 53px; padding: 14px 12px; transition: width .18s ease, padding .18s ease;
}
#side-nav.collapsed { flex-basis: 54px; width: 54px; padding: 14px 8px; }
#side-nav-toggle { border: 1px solid var(--line); background: var(--bg); color: var(--ink-soft); border-radius: 7px; width: 32px; height: 30px; cursor: pointer; font-size: 15px; margin-bottom: 12px; }
#side-nav-toggle:hover { color: var(--ink); }
.side-nav-group { margin-bottom: 18px; }
.side-nav-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-soft); margin: 0 6px 6px; }
.nav-btn { border: none; background: transparent; color: var(--ink-soft); padding: 8px 14px; border-radius: 7px; cursor: pointer; font-size: 13.5px; font-weight: 600; }
.nav-btn:hover { background: var(--bg); color: var(--ink); }
.nav-btn.active { background: var(--brand); color: #fff; }
.side-btn { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; margin-bottom: 2px; }
.nav-ico { width: 18px; text-align: center; flex: 0 0 auto; font-size: 14px; }
/* collapsed: icons only */
#side-nav.collapsed .side-nav-label, #side-nav.collapsed .side-btn span:not(.nav-ico),
#side-nav.collapsed .model-switch, #side-nav.collapsed .model-hint { display: none; }
#side-nav.collapsed .side-btn { justify-content: center; padding: 8px 0; }

/* model switch */
.model-switch { display: flex; gap: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.model-btn { flex: 1 1 0; border: none; background: transparent; color: var(--ink-soft); padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 700; }
.model-btn:hover { color: var(--ink); }
.model-btn.active { background: var(--brand); color: #fff; }
.model-hint { margin: 7px 4px 0; line-height: 1.35; }
body.model-true_score .model-btn[data-model="true_score"].active { background: #6b3fa0; }
#app-content { flex: 1 1 auto; min-width: 0; }
@media (max-width: 820px) {
  #side-nav { position: fixed; z-index: 25; left: 0; box-shadow: var(--shadow); }
  #side-nav.collapsed { transform: none; }
}
.admin-toggle { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-soft); cursor: pointer; user-select: none; }
.admin-toggle input { cursor: pointer; }
.user-chip { background: var(--bg); border: 1px solid var(--line); padding: 6px 12px; border-radius: 20px; font-size: 12.5px; font-weight: 600; }
body.admin-mode .user-chip { background: var(--lock-bg); border-color: #d6c8f2; color: var(--lock); }

/* ---- Layout ---- */
#app-content { padding: 22px 28px 60px; }
.view-inner { max-width: 1120px; margin: 0 auto; }
.view-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.view-head h1 { margin-right: 4px; }
.section-h { margin: 22px 0 8px; }

/* ---- Period toolbar (home) ---- */
.period-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.period-heading { display: flex; align-items: center; gap: 12px; }
.period-admin-btns { gap: 8px; }
body.admin-mode .period-admin-btns { display: flex; }
.banner-readonly, .banner-info, .banner-warn {
  border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px;
}
.banner-readonly { background: #eef1f4; border: 1px solid var(--line); color: var(--ink-soft); }
.banner-info { background: #eaf3fb; border: 1px solid #cadff2; color: var(--brand-dark); }
.banner-warn { background: var(--warn-bg); border: 1px solid #ecd9a3; color: var(--warn); }

/* ---- Report cards ---- */
.card-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
@media (max-width: 820px) { .card-grid { grid-template-columns: 1fr; } }
.report-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px;
}
.report-card.ready { border-color: #bfe3cd; }
.report-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.report-card-title { font-size: 16px; font-weight: 700; }
.report-card-badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.progress { height: 8px; background: var(--bg); border-radius: 6px; overflow: hidden; margin: 8px 0 4px; }
.progress-fill { height: 100%; background: var(--ok); transition: width .3s; }
.card-actions { display: flex; gap: 8px; margin-top: 12px; align-items: center; flex-wrap: wrap; }

/* Badges + chips */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.badge-ready { background: var(--ok); color: #fff; }
.badge-progress { background: #eef1f4; color: var(--ink-soft); }
.badge-locked { background: var(--lock-bg); color: var(--lock); }
.badge-corr { background: var(--warn-bg); color: var(--warn); }
.chip { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.chip-idle { background: #eef1f4; color: var(--ink-soft); }
.chip-corr { background: var(--warn-bg); color: var(--warn); }
.chip-locked { background: var(--lock-bg); color: var(--lock); }

/* ---- Buttons ---- */
.btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 8px 14px; border-radius: 7px; cursor: pointer; font-size: 13px; font-weight: 600; }
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: var(--surface); }
.btn-warn { background: var(--warn); color: #fff; border-color: var(--warn); }
.btn-warn:hover { filter: brightness(.95); }
.btn-ghost { background: transparent; }
.btn-small { padding: 5px 10px; font-size: 12px; }
.btn-tiny { padding: 3px 8px; font-size: 11px; border-radius: 6px; }
.btn.disabled { background: #b7c7d4; border-color: #b7c7d4; cursor: not-allowed; pointer-events: auto; }
.icon-btn { border: none; background: transparent; font-size: 18px; cursor: pointer; color: var(--ink-soft); line-height: 1; }
.icon-btn-sm { border: none; background: transparent; cursor: pointer; color: #b0b8bf; font-size: 12px; }
.icon-btn-sm:hover { color: var(--err); }

/* ---- Metric list (modal) ---- */
.metric-list { max-height: 60vh; overflow: auto; }
.metric-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 4px; border-top: 1px solid var(--line); cursor: pointer; }
.metric-row:hover { background: #fafbfc; }
.metric-row-main { min-width: 0; }
.metric-name { font-weight: 600; font-size: 13.5px; }
.metric-row-side { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

/* ---- Upload / data-entry grid ---- */
.upload-head { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.upload-titles { flex: 1 1 auto; }
.upload-titles h1 { font-size: 19px; }
.upload-head-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.paste-hint { margin: 10px 0; }

.grid-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); max-height: 55vh; }
table.entry-grid { border-collapse: collapse; width: 100%; font-size: 12.5px; }
table.entry-grid th, table.entry-grid td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 0; text-align: left; }
table.entry-grid thead th { position: sticky; top: 0; background: #f7f9fb; z-index: 1; padding: 6px 8px; vertical-align: top; }
table.entry-grid thead th span { display: block; }
.col-type { font-size: 10px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .3px; font-weight: 400; }
td.rownum, th.rownum { text-align: center; color: #9aa4ad; font-variant-numeric: tabular-nums; padding: 4px 6px; width: 34px; }
.cell-input { width: 100%; min-width: 90px; border: none; padding: 6px 8px; font: inherit; background: transparent; }
.cell-input:focus { outline: 2px solid var(--brand); outline-offset: -2px; background: #fff; }
td.cell-error { background: var(--err-bg); }
td.cell-error .cell-input { color: var(--err); font-weight: 600; }
td.cell-warn { background: var(--warn-bg); }
td.cell-changed { box-shadow: inset 3px 0 0 var(--accent); background: var(--changed-bg); }

.validation-summary { margin: 14px 0; border-radius: 8px; padding: 12px 14px; border: 1px solid var(--line); }
.validation-summary.ok { background: var(--ok-bg); border-color: #bfe3cd; }
.validation-summary.has-errors { background: var(--err-bg); border-color: #f0c2ca; }
.val-line { font-weight: 700; }
.val-list { margin: 8px 0 0; padding-left: 20px; font-size: 12.5px; }
.val-errors li { color: var(--err); }
.val-warns li { color: var(--warn); }

.upload-footer { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.footer-right { display: flex; gap: 10px; }

/* ---- Consolidated view ---- */
.consol-overview { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.consol-chip { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; min-width: 120px; }
.consol-chip.ready { border-color: #bfe3cd; background: var(--ok-bg); }
.consol-chip-name { font-weight: 700; font-size: 13px; }
.consol-chip-stat { color: var(--ink-soft); font-size: 12px; margin-top: 2px; }
.consol-report { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden; }
.consol-report > summary { display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; font-weight: 600; }
.consol-report-title { font-size: 15px; flex: 1 1 auto; }
table.consol-table { border-collapse: collapse; width: 100%; font-size: 12px; }
table.consol-table th, table.consol-table td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 5px 8px; text-align: left; white-space: nowrap; }
table.consol-table thead th { background: #f7f9fb; font-size: 10.5px; text-transform: uppercase; letter-spacing: .3px; color: var(--ink-soft); }
table.consol-table td.id-cell { font-weight: 700; }
table.consol-table td.cell-missing, td.cell-missing { color: #b0b8bf; }

/* ---- Changelog ---- */
.log-controls { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.text-input { padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px; background: var(--surface); font-family: inherit; }
.table-scroll { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; }
table.log-table { border-collapse: collapse; width: 100%; font-size: 13px; }
table.log-table th, table.log-table td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.log-table th { background: #f7f9fb; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-soft); position: sticky; top: 0; }
.log-chip { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 20px; text-transform: uppercase; letter-spacing: .3px; white-space: nowrap; }
.log-submit, .log-resubmit, .log-report_ready { background: var(--ok-bg); color: var(--ok); }
.log-correction { background: var(--warn-bg); color: var(--warn); }
.log-lock { background: var(--lock-bg); color: var(--lock); }
.log-unlock, .log-create_period, .log-create_report { background: #e7f0f7; color: var(--brand-dark); }
.log-close_period { background: #eef1f4; color: var(--ink-soft); }
.log-validation_fail { background: var(--err-bg); color: var(--err); }

/* ---- Action report ---- */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
@media (max-width: 820px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.kpi-big { font-size: 28px; font-weight: 800; line-height: 1; }
.kpi-label { color: var(--ink-soft); font-size: 12px; margin-top: 6px; }
.kpi-sub { margin-top: 2px; }
table.ar-table { border-collapse: collapse; width: 100%; font-size: 13px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.ar-table th, table.ar-table td { padding: 9px 14px; border-bottom: 1px solid var(--line); text-align: left; }
table.ar-table th { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-soft); background: #f7f9fb; }
table.ar-table tr:last-child td { border-bottom: none; }

/* ---- Wizard / forms ---- */
.form-field { display: block; margin: 12px 0; }
.form-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 4px; }
.form-field .text-input, .form-field select { width: 100%; }
.metric-check-list { max-height: 46vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; margin: 10px 0; }
.metric-check { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.metric-check:last-child { border-bottom: none; }
.metric-check span:nth-child(2) { font-weight: 600; flex: 0 0 auto; }
.metric-check .small { margin-left: auto; text-align: right; }
.added-metrics { margin: 8px 0; }
.added-metric { font-size: 12px; color: var(--brand-dark); background: #eaf3fb; border-radius: 6px; padding: 4px 8px; margin-top: 4px; }
.review-list { margin: 8px 0; padding-left: 20px; }
.reason-area { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 8px; font-family: inherit; font-size: 13px; resize: vertical; }

/* ---- Modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(20,25,31,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal-box { background: var(--surface); border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,.25); width: 100%; max-width: 520px; padding: 18px 20px; max-height: 88vh; overflow: auto; }
.modal-box.modal-wide { max-width: 720px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.modal-head h2 { margin: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* ---- Toast ---- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.25); font-size: 13.5px; opacity: 0; transition: opacity .25s, transform .25s; z-index: 60; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-success { background: var(--ok); }
.toast-error { background: var(--err); }
.toast-warn { background: var(--warn); }

/* Admin-only elements hidden unless admin-mode on body */
.admin-only { display: none; }
body.admin-mode .admin-only { display: inline-flex; }

@media print {
  #demo-banner, #app-header, .log-controls, .no-print, .card-actions { display: none !important; }
  #app-content { max-width: none; }
  .report-card, .kpi, .consol-report, .table-scroll { box-shadow: none; }
}

/* ============================================================= */
/* Refinement round 2: richer home, auto-lock, consolidated++    */
/* ============================================================= */

/* auto-lock chip in the period toolbar */
.autolock-chip { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; background: #fff4e0; color: #7a4b00; border: 1px solid #f0d9a8; }

/* closed-period banner with an action button on the right */
.banner-flex { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---- Report card: metric status strip + pending chips ---- */
.metric-strip { display: flex; flex-wrap: wrap; gap: 4px; margin: 10px 0 4px; }
.metric-pip { width: 16px; height: 16px; border-radius: 4px; border: none; cursor: pointer; padding: 0; position: relative; }
.metric-pip:hover { outline: 2px solid var(--brand); outline-offset: 1px; }
.pip-idle { background: #d7dde2; }
.pip-done { background: var(--ok); }
.pip-corr { background: var(--accent); }
.pip-locked::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(45deg, transparent, transparent 3px, rgba(0,0,0,.22) 3px, rgba(0,0,0,.22) 5px); border-radius: 4px; }

.pending-wrap { margin-top: 8px; }
.pending-title { font-size: 11px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .3px; margin-bottom: 5px; }
.pending-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pending-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid #f0c2ca; background: #fdf1f3; color: var(--ink); border-radius: 20px; padding: 3px 10px; cursor: pointer; font-size: 12px; }
.pending-chip:hover { border-color: var(--err); }
.pending-metric { font-weight: 600; }
.pending-owner { color: var(--ink-soft); font-size: 11px; }
.all-in-note { margin-top: 8px; font-size: 12.5px; color: var(--ok); font-weight: 600; }

/* ---- Consolidated gradient chips ---- */
.consol-chip { min-width: 150px; }
.consol-chip-stat { font-weight: 800; font-size: 15px; }
.consol-chip-sub { font-size: 11px; margin-top: 1px; }
.consol-chip-bar { height: 6px; background: var(--bg); border-radius: 6px; overflow: hidden; margin-top: 8px; }
.consol-chip-bar-fill { height: 100%; transition: width .3s; }

/* ---- Maximized modal (Excel-online feel) ---- */
.modal-box.modal-max { max-width: 96vw; width: 96vw; height: 90vh; display: flex; flex-direction: column; padding: 14px 16px; }
.max-modal { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.max-modal .modal-head { flex: 0 0 auto; }
.max-modal .modal-head h2 { font-size: 17px; }
.consol-scroll-full { flex: 1 1 auto; overflow: auto; border: 1px solid var(--line); border-radius: 8px; min-height: 0; }

/* full consolidated table: sticky header row(s) + sticky id column */
table.consol-table-full { font-size: 12px; }
table.consol-table-full thead th { position: sticky; top: 0; z-index: 3; }
table.consol-table-full thead tr.consol-subhead th { top: 42px; z-index: 3; background: #eef3f7; font-weight: 400; font-size: 10.5px; color: var(--ink-soft); text-transform: none; letter-spacing: 0; }
.consol-col-name { display: block; font-weight: 700; }
.consol-col-owner { display: block; font-size: 10px; color: var(--ink-soft); font-weight: 400; }
.sticky-id { position: sticky; left: 0; z-index: 2; background: #f7f9fb; }
table.consol-table-full tbody td.sticky-id { background: var(--surface); z-index: 1; }
table.consol-table-full tbody tr:hover td { background: #f3f8fd; }
table.consol-table-full tbody tr:hover td.sticky-id { background: #e9f2fb; }

/* ---- Report Setup ---- */
.setup-report { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; }
.setup-report > summary { display: flex; align-items: center; gap: 12px; padding: 10px 14px; cursor: pointer; font-weight: 600; }
.setup-report > summary .consol-report-title { flex: 1 1 auto; }
.setup-metric { border-top: 1px solid var(--line); padding: 10px 14px; }
.setup-metric-head { display: flex; align-items: center; gap: 10px; }
.setup-metric-head .metric-name { flex: 1 1 auto; }
.setup-cols { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.setup-col { display: grid; grid-template-columns: 64px 180px 1fr; align-items: center; gap: 10px; font-size: 12.5px; }
.col-badge { font-size: 10px; font-weight: 700; text-transform: uppercase; text-align: center; padding: 2px 6px; border-radius: 5px; }
.col-site { background: #e7f0f7; color: var(--brand-dark); }
.col-login { background: #efe9fa; color: var(--lock); }
.col-score { background: var(--ok-bg); color: var(--ok); }
.col-number { background: #fbf3dc; color: var(--warn); }
.setup-col-key { font-weight: 600; }

/* column definition editor rows */
.coldef-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.coldef-row { display: grid; grid-template-columns: 1fr 120px auto auto 1.4fr; align-items: center; gap: 8px; }
.coldef-req { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-soft); }
.coldef-logic { line-height: 1.2; }

/* changelog chips for new actions */
.log-auto_lock { background: #fff4e0; color: #7a4b00; }
.log-edit_report { background: #e7f0f7; color: var(--brand-dark); }

/* ============================================================= */
/* Refinement round 3: shrink-to-fit columns, rule builder, admin */
/* ============================================================= */

/* Shrink all table columns to content width.
   width:auto (NOT min-width:100%) so the table sizes to its content and
   does not stretch narrow columns to fill the container. */
table.entry-grid, table.consol-table, table.consol-table-full, table.log-table, table.ar-table {
  width: auto;
  table-layout: auto;
}
table.entry-grid th, table.entry-grid td,
table.consol-table th, table.consol-table td,
table.consol-table-full th, table.consol-table-full td,
table.log-table th, table.log-table td,
table.ar-table th, table.ar-table td {
  white-space: nowrap;
  width: 1%;            /* collapse each column to its content width */
}
/* Let the entry grid cell input shrink to a reasonable min-width */
.cell-input { min-width: 70px; width: 100%; }

/* Admin panel styles */
.admin-list { margin: 8px 0; }
.admin-list-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px; border-bottom: 1px solid var(--line); font-size: 13px; }
.admin-list-row:last-child { border-bottom: none; }

/* Validation rule builder in report setup */
.coldef-row-v { margin-bottom: 8px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.coldef-rules { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 5px; padding-left: 4px; }
.rule-check { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-soft); cursor: pointer; }
.rule-check input { cursor: pointer; }
.regex-fields { display: flex; gap: 6px; margin-top: 4px; }
.coldef-regex { font-size: 12px; padding: 4px 8px; min-width: 120px; }

/* scope checkbox */
.scope-check { display: flex; align-items: center; gap: 8px; margin: 14px 0 4px; padding: 10px 12px; background: var(--warn-bg); border: 1px solid #ecd9a3; border-radius: 8px; cursor: pointer; font-size: 13px; }
.scope-check input { cursor: pointer; }

/* ============================================================= */
/* Refinement round 4: Excel-like grid (selection, resize, nav)  */
/* ============================================================= */

/* The table is focusable (tabindex) so it can catch keyboard actions during a
   multi-cell selection; hide the default focus outline (cells show focus). */
table.entry-grid:focus { outline: none; }

/* Cells are the selectable unit. Give them position for the focus ring
   and a subtle default so selection highlight reads clearly. */
table.entry-grid td.cell { position: relative; cursor: cell; }

/* Range selection highlight + active (focus) cell outline. */
table.entry-grid td.cell.cell-selected { background: #e8f1fd; }
table.entry-grid td.cell.cell-selected.cell-error { background: #fbe3df; }
table.entry-grid td.cell.cell-selected.cell-warn { background: #f7edcf; }
table.entry-grid td.cell.cell-focus { box-shadow: inset 0 0 0 2px var(--brand); z-index: 2; }
table.entry-grid td.cell.cell-selected .cell-input,
table.entry-grid td.cell.cell-focus .cell-input { background: transparent; }

/* Row-number cells act as whole-row selectors. */
td.rownum.rowsel { cursor: pointer; user-select: none; }
td.rownum.rowsel:hover { background: #eef3f7; color: var(--ink); }

/* Column header resize grip: a thin grab strip on the right edge. */
th.colhead { position: relative; }
.col-resize-grip {
  position: absolute; top: 0; right: -3px; width: 7px; height: 100%;
  cursor: col-resize; z-index: 3; display: block;
}
.col-resize-grip:hover { background: linear-gradient(to right, transparent, var(--brand)); }

/* When any column has a manual width, switch to fixed layout so the widths
   are honored (overrides the round-3 shrink-to-fit auto layout). */
table.entry-grid.fixed-layout { table-layout: fixed; width: auto; }
table.entry-grid.fixed-layout th,
table.entry-grid.fixed-layout td { width: auto; overflow: hidden; }
table.entry-grid.fixed-layout .cell-input { min-width: 0; }

/* ============================================================= */
/* Refinement round 5: audit panel + error navigator            */
/* ============================================================= */

/* What's-being-audited panel */
.audit-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 10px 0; }
.audit-panel > summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--ink); }
.audit-body { margin-top: 8px; }
.audit-h { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; color: var(--ink-soft); margin: 10px 0 4px; }
.audit-list { margin: 0 0 4px; padding-left: 18px; font-size: 12.5px; }
.audit-list li { margin: 2px 0; }
table.audit-cols { border-collapse: collapse; font-size: 12.5px; margin-top: 2px; }
table.audit-cols td { padding: 3px 10px 3px 0; vertical-align: top; }
.audit-col-key { font-weight: 600; white-space: nowrap; }
.audit-col-type { color: var(--ink-soft); font-size: 10.5px; text-transform: uppercase; letter-spacing: .3px; white-space: nowrap; }

/* Error navigator bar */
.error-nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 10px 0; }
.error-nav.clean { border-color: #bfe3cd; background: var(--ok-bg); }
.error-nav-status { display: flex; gap: 8px; align-items: center; }
.en-count { font-size: 12.5px; font-weight: 700; padding: 2px 8px; border-radius: 12px; }
.en-err { color: var(--err); background: var(--err-bg); }
.en-warn { color: #8a6d00; background: var(--warn-bg); }
.en-ok { color: var(--ok); }
.error-nav-controls { display: flex; align-items: center; gap: 6px; }
.error-nav-pos { margin-left: 4px; }
.error-nav-toggle { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; cursor: pointer; }
.error-nav-toggle input { cursor: pointer; }

/* ============================================================= */
/* Round 6: side-nav views (historical), owner-grant admin row   */
/* ============================================================= */
.hist-period { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 12px; overflow: hidden; }
.hist-period > summary { display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; font-weight: 600; }
.hist-report-row { display: flex; align-items: center; gap: 14px; padding: 9px 16px; border-top: 1px solid var(--line); }
.hist-report-name { font-weight: 600; flex: 1 1 auto; }
.grant-row { flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.grant-row .text-input { min-width: 120px; }
.grant-row select.text-input { min-width: 220px; }

/* ---- Login gate + auth chrome (real build) ---- */
.hidden { display: none !important; }
.gate {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f1b28, #16344f);
}
.gate-card {
  background: #fff; border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.3);
  padding: 34px 38px; width: 400px; max-width: 92vw; text-align: center;
}
.gate-card .logo {
  display: inline-block; background: var(--brand); color: #fff; font-weight: 700;
  padding: 8px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 16px;
}
.gate-card .logo .accent { color: var(--accent); }
.gate-card h1 { font-size: 20px; margin: 0 0 4px; }
.gate-card p { color: var(--ink-soft); margin: 0 0 20px; }
.spinner {
  width: 20px; height: 20px; border: 3px solid var(--line); border-top-color: var(--brand);
  border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
/* signed-in user chip + sign out in the header */
.signout-btn { margin-left: 6px; }

/* ---- View-as-user preview banner ---- */
.preview-banner {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: var(--lock); color: #fff; padding: 8px 14px; border-radius: 20px;
  font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,.25); z-index: 70;
}
.preview-banner .btn { background: rgba(255,255,255,.16); border-color: transparent; color: #fff; }
.preview-banner .btn:hover { background: rgba(255,255,255,.28); color: #fff; }
