/* =====================================================================
   SGC Holiday Bonus & Gift Cards — styled after the Excel workbooks
   ===================================================================== */
:root {
  color-scheme: light;
  --navy: #1F3864;
  --xl-blue: #4472C4;
  --xl-blue-mid: #5B9BD5;
  --xl-blue-pale: #BDD7EE;
  --xl-blue-light: #DDEBF7;
  --xl-orange: #FFC000;
  --xl-orange-soft: #FFE699;
  --xl-orange-ink: #3F3F76;
  --xl-extra: #FFEB9C;
  --xl-extra-ink: #9C5700;
  --badge: #ED7D31;
  --band: #EDEDED;
  --grid: #D0D7E5;
  --ink: #1d1d1f;
  --dim: #666b75;
  --ok: #2E7D32;
  --ok-bg: #E2EFDA;
  --bad: #C00000;
  --bad-bg: #FCE4E4;
  --warn: #B45309;
  --bg: #F4F6FA;
  --card: #ffffff;
  --font: Calibri, Carlito, "Segoe UI", Arial, sans-serif;
  --tot-h: 0px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 15px; color: var(--ink); background: var(--bg); }
a { color: #1f5fbf; }
h1 { font-size: 26px; margin: 0 0 2px; font-weight: 700; }
h2 { font-size: 20px; margin: 0 0 10px; }
h3 { font-size: 17px; margin: 0 0 10px; }
.dim { color: var(--dim); }
.small { font-size: 13px; }
.tiny { font-size: 11px; }
.mono { font-variant-numeric: tabular-nums; }
.warn { color: var(--warn); font-weight: 700; }
.n { text-align: right; font-variant-numeric: tabular-nums; }
.r { text-align: right; }

/* ---------- app bar ---------- */
.appbar { display: flex; align-items: center; gap: 18px; background: var(--navy); color: #fff; padding: 0 18px; min-height: 52px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; padding: 8px 0; }
.brand-mark { background: var(--badge); color: #fff; font-weight: 700; padding: 3px 8px; border-radius: 3px; letter-spacing: .5px; }
.brand-text { font-size: 17px; font-weight: 700; white-space: nowrap; }
.mainnav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.mainnav a { color: #d6e0f5; text-decoration: none; padding: 15px 11px 13px; border-bottom: 3px solid transparent; font-size: 15px; }
.mainnav a:hover { color: #fff; }
.mainnav a.on { color: #fff; border-bottom-color: var(--xl-orange); font-weight: 700; }
.appbar-right { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.appbar-right .who em { color: #aebbd6; font-style: normal; }
.appbar-right .logout { color: #d6e0f5; }
.yearpick select { font: inherit; font-weight: 700; background: #2b4a85; color: #fff; border: 1px solid #4a6aa8; border-radius: 4px; padding: 4px 6px; }

.campbar { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; padding: 7px 18px; background: #fff; border-bottom: 1px solid var(--grid); font-size: 14px; }
.campbar.status-locked { background: #FFF4E5; }
.campbar.status-closed { background: #EEE; }

.page { padding: 18px; max-width: 1680px; margin: 0 auto; }
.foot { text-align: center; color: var(--dim); font-size: 12px; padding: 24px; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--grid); border-radius: 6px; padding: 18px; margin-bottom: 16px; }
.card.empty { text-align: center; padding: 40px 18px; }

/* ---------- buttons, forms ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 700; font-size: 14px; background: var(--xl-blue); color: #fff; border: 1px solid #2f5597; padding: 7px 14px; border-radius: 4px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #2f5597; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { padding: 3px 10px; font-size: 13px; }
.btn-ghost { background: #fff; color: var(--xl-blue); border-color: var(--xl-blue-pale); }
.btn-ghost:hover { background: var(--xl-blue-light); }
.btn-go { background: var(--ok); border-color: #1b5e20; }
.btn-go:hover { background: #1b5e20; }
.btn-warn { background: var(--badge); border-color: #c55a11; }
.btn-danger { background: var(--bad); border-color: #8b0000; }
.btn-ms { background: #fff; color: #333; border: 1px solid #8c8c8c; font-size: 16px; padding: 10px 18px; }
.btn-ms:hover { background: #f3f3f3; }
form.inline { display: inline; margin: 0; }
label { display: block; font-size: 13px; color: var(--dim); margin-bottom: 10px; }
label > input, label > select, label > textarea { display: block; margin-top: 3px; width: 100%; }
input, select, textarea { font: inherit; font-size: 15px; padding: 6px 8px; border: 1px solid #b8c2d3; border-radius: 4px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--xl-blue-mid); outline-offset: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
fieldset { border: 1px solid var(--grid); border-radius: 6px; padding: 10px 14px; margin: 0 0 12px; }
legend { font-weight: 700; padding: 0 6px; }
.help { font-size: 13px; color: var(--dim); margin: -4px 0 10px; }
.check { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: 14px; }
.check input { width: auto; margin: 0; }

.flash { padding: 10px 14px; border-radius: 4px; margin-bottom: 12px; font-weight: 700; }
.flash-ok { background: var(--ok-bg); color: #1b5e20; border: 1px solid #a9d08e; }
.flash-err { background: var(--bad-bg); color: var(--bad); border: 1px solid #f4b0b0; }
.flash-warn { background: #FFF4E5; color: var(--warn); border: 1px solid #f6c48b; }

/* ---------- status pills ---------- */
.pill { display: inline-block; padding: 1px 9px; border-radius: 10px; font-size: 12px; font-weight: 700; background: #e7e7e7; color: #444; white-space: nowrap; }
.pill-setup, .pill-draft { background: #ECECEC; color: #555; }
.pill-open, .pill-distributed { background: var(--xl-blue-light); color: #1f4e9c; }
.pill-returned { background: #FCE4D6; color: #c55a11; }
.pill-submitted { background: var(--xl-orange-soft); color: #7a5600; }
.pill-verified { background: var(--ok-bg); color: #1b5e20; }
.pill-locked { background: #FCE4D6; color: #c55a11; }
.pill-closed { background: #ddd; color: #333; }

/* ---------- Excel-style tables ---------- */
.tablewrap { overflow-x: auto; background: #fff; border: 1px solid var(--grid); }
table.xl { border-collapse: collapse; font-size: 14px; width: 100%; }
table.xl th, table.xl td { border: 1px solid var(--grid); padding: 3px 7px; white-space: nowrap; }
table.xl thead th { background: var(--xl-blue); color: #fff; font-weight: 700; text-align: left; border-color: #3a65b0; }
table.xl thead th.n { text-align: right; }
table.xl tbody tr:nth-child(even) td { background: var(--band); }
table.xl tfoot th, table.xl tfoot td { background: var(--xl-blue); color: #fff; font-weight: 700; border-color: #3a65b0; }
table.xl-list td a { text-decoration: none; }
table.xl-list td.tbd { color: var(--warn); font-weight: 700; }

/* worksheet */
.xl-sheet thead th { position: sticky; top: var(--tot-h); z-index: 2; }
@media (min-width: 901px) { .sheet .tablewrap { overflow: visible; } }
.xl-sheet td.in, .xl-sheet tbody tr:nth-child(even) td.in { background: var(--xl-orange); color: var(--xl-orange-ink); border: 1px solid #7f7f7f; padding: 0; }
.xl-sheet td.in-no, .xl-sheet tbody tr:nth-child(even) td.in-no { background: #FFD966; }
.xl-sheet td.in-tbd, .xl-sheet tbody tr:nth-child(even) td.in-tbd { background: #FFF2CC; }
.xl-sheet td.in select, .xl-sheet td.in input { width: 100%; min-width: 72px; border: 0; border-radius: 0; background: transparent; color: var(--xl-orange-ink); font-weight: 700; padding: 4px 6px; font-size: 14px; }
.xl-sheet td.in input.money-in { min-width: 100px; text-align: right; }
.xl-sheet td.in:not(:has(select, input)) { padding: 3px 7px; font-weight: 700; }
.xl-sheet td.total { font-weight: 700; }
.xl-sheet td.bill { color: #333; min-width: 38px; }
.xl-sheet td.warn-cell { background: #FCE4D6 !important; }
.xl-sheet td.more { padding: 0 2px; text-align: center; }
.xl-sheet tr.saving td { opacity: .55; }
.xl-sheet tr.flash-row td { animation: flashrow 1.1s ease-out; }
@keyframes flashrow { from { background: #C6EFCE; } }
.xl-sheet tfoot th { text-align: right; }
.dots { border: 0; background: transparent; font-size: 18px; line-height: 1; cursor: pointer; color: #555; padding: 2px 6px; border-radius: 3px; }
.dots:hover { background: var(--xl-blue-light); }
.tag { display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase; padding: 0 5px; border-radius: 3px; margin-left: 3px; vertical-align: 1px; }
.tag-new { background: #E2EFDA; color: #375623; }
.tag-ovr { background: #FCE4D6; color: #c55a11; }
.tag-note { background: var(--xl-blue-light); color: #1f4e9c; cursor: help; }

.sheet { margin-bottom: 18px; }
.sheet-title { padding: 8px 2px 6px; }
.sheethead { display: flex; align-items: center; gap: 18px; margin-bottom: 12px; flex-wrap: wrap; }
.badge-dept { background: var(--badge); color: #fff; font-size: 30px; padding: 10px 26px; min-width: 200px; text-align: center; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.sheetmeta { flex: 1; min-width: 240px; display: grid; gap: 3px; }
.sheetactions { display: flex; gap: 8px; flex-wrap: wrap; }
.note-line { color: #c55a11; font-weight: 700; }
.readonly-banner { background: #FFF4E5; border: 1px solid #f6c48b; color: #7a4100; padding: 8px 14px; border-radius: 4px; margin-bottom: 10px; font-weight: 700; }

.filterbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 12px 0 6px; }
.filterbar input[type=search] { min-width: 260px; }
.seg { display: inline-flex; border: 1px solid var(--xl-blue-pale); border-radius: 4px; overflow: hidden; background: #fff; }
.seg button { font: inherit; font-size: 13px; border: 0; background: #fff; padding: 6px 11px; cursor: pointer; color: var(--xl-blue); border-right: 1px solid var(--xl-blue-pale); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--xl-blue); color: #fff; font-weight: 700; }
.seg .cnt { background: var(--xl-orange); color: #333; border-radius: 8px; padding: 0 6px; font-size: 11px; font-weight: 700; }
.saved-ind { font-size: 13px; color: var(--ok); font-weight: 700; min-width: 80px; }
.saved-ind.err { color: var(--bad); }

/* ---------- TOTALS PANEL (always visible) ---------- */
#totals-wrap { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 4px 0 8px; margin-top: -4px; }
#totals-wrap .totals { margin-bottom: 0; }
.totals { position: sticky; top: 0; z-index: 5; display: flex; gap: 14px; align-items: stretch; flex-wrap: wrap; background: #fff; border: 1px solid var(--grid); border-radius: 6px; padding: 10px 12px; margin-bottom: 10px; box-shadow: 0 2px 6px rgba(31,56,100,.08); }
.tb { display: flex; flex-direction: column; justify-content: center; }
.tb-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--dim); margin-bottom: 3px; }
.tb-foot { font-size: 12px; margin-top: 3px; }
table.xl-mini { width: auto; font-size: 13px; }
table.xl-mini th, table.xl-mini td { padding: 1px 9px; text-align: center; }
table.xl-mini thead th { background: var(--xl-blue-mid); border-color: #fff; text-align: center; }
table.xl-mini tbody th { background: var(--xl-blue-mid); color: #fff; }
table.xl-mini tbody td, table.xl-mini tbody tr:nth-child(even) td { background: var(--xl-blue-light); border-color: #fff; }
table.xl-mini td.extra, table.xl-mini tbody tr:nth-child(even) td.extra { background: var(--xl-extra); color: var(--xl-extra-ink); padding: 0; }
table.xl-mini td.extra input { width: 52px; border: 0; background: transparent; text-align: center; color: var(--xl-extra-ink); font-weight: 700; padding: 1px 2px; font-size: 13px; }
table.xl-mini tfoot th, table.xl-mini tfoot td { background: var(--xl-blue); padding: 1px 9px; text-align: center; }
table.xl-mini tr.sub td, table.xl-mini tbody tr.sub:nth-child(even) td { background: #fff; color: var(--dim); font-size: 12px; }
table.xl-sum { width: auto; font-size: 15px; }
table.xl-sum th { background: var(--xl-blue-mid); color: #fff; text-align: right; padding: 3px 12px; border-color: #fff; font-weight: 700; }
table.xl-sum th small { font-weight: 400; opacity: .85; }
table.xl-sum td { background: var(--xl-blue-light); text-align: right; padding: 3px 12px; min-width: 130px; border-color: #fff; font-variant-numeric: tabular-nums; }
table.xl-sum tr.grand th { background: var(--navy); font-size: 17px; }
table.xl-sum tr.grand td { background: var(--xl-blue-pale); font-size: 22px; font-weight: 700; color: var(--navy); }
.tb-bonus { min-width: 170px; border-left: 3px solid var(--xl-blue-pale); padding-left: 12px; }
.kv { display: flex; justify-content: space-between; gap: 14px; font-size: 15px; }
.kv b { font-variant-numeric: tabular-nums; }
.kv.dim { color: var(--dim); font-size: 13px; }
.tb-status { min-width: 110px; border-left: 3px solid var(--xl-blue-pale); padding-left: 12px; }
.st { font-size: 14px; }
.st b { display: inline-block; min-width: 34px; text-align: right; margin-right: 4px; font-size: 16px; }
.st-yes b { color: var(--ok); } .st-no b { color: var(--bad); } .st-tbd b { color: var(--warn); }

/* dashboard progress strip */
.progress-strip { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; }
.ps { background: #fff; border: 1px solid var(--grid); border-radius: 6px; padding: 6px 14px; display: flex; gap: 8px; align-items: baseline; }
.ps b { font-size: 20px; }
.ps span { font-size: 13px; color: var(--dim); }
.ps-verified b { color: var(--ok); } .ps-submitted b { color: #7a5600; } .ps-returned b { color: #c55a11; } .ps-warn b { color: var(--bad); } .ps-new b { color: #375623; }

/* ---------- dialogs ---------- */
dialog.dlg { border: 0; border-radius: 8px; padding: 20px 22px; width: min(540px, 94vw); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog.dlg::backdrop { background: rgba(20,30,50,.45); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* ---------- admin ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--xl-blue); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a { padding: 7px 14px; text-decoration: none; color: var(--xl-blue); border: 1px solid transparent; border-bottom: 0; border-radius: 4px 4px 0 0; }
.tabs a.on { background: var(--xl-blue); color: #fff; font-weight: 700; }
table.matrix td, table.matrix th { text-align: center; }
table.matrix td:first-child, table.matrix th:first-child { text-align: left; white-space: normal; }
table.matrix .grp td { background: var(--xl-blue-light) !important; font-weight: 700; text-align: left; }
table.matrix input[type=checkbox] { width: 18px; height: 18px; }
.audit-details { font-size: 12px; color: var(--dim); white-space: normal; max-width: 520px; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.toolbar { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar label { margin: 0; }
table.xl td.wrap { white-space: normal; }
.issues { max-height: 220px; overflow: auto; font-size: 13px; background: #FFF9EC; border: 1px solid #f6c48b; padding: 8px 12px; border-radius: 4px; }
.kpis { display: flex; gap: 12px; flex-wrap: wrap; margin: 10px 0; }
.kpi { background: var(--xl-blue-light); border-radius: 6px; padding: 8px 16px; }
.kpi b { display: block; font-size: 24px; color: var(--navy); }
.kpi span { font-size: 13px; color: var(--dim); }

/* ---------- login ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(160deg, var(--navy), #2f5597); }
.login-card { background: #fff; padding: 36px 40px; border-radius: 10px; width: min(420px, 92vw); text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.login-card h1 { font-size: 24px; }
.login-badge { display: inline-block; background: var(--badge); color: #fff; font-weight: 700; font-size: 22px; padding: 6px 16px; margin-bottom: 12px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .totals, #totals-wrap { position: static; }
  .xl-sheet thead th { top: 0; }
  .grid3, .grid4 { grid-template-columns: 1fr 1fr; }
  .badge-dept { font-size: 22px; min-width: 0; padding: 8px 16px; }
  .brand-text { display: none; }
}
@media (max-width: 560px) {
  .page { padding: 12px; }
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
  .filterbar input[type=search] { min-width: 0; width: 100%; }
}

/* ---------- print (Save as PDF) ---------- */
@media print {
  @page { size: landscape; margin: 10mm; }
  body { background: #fff; font-size: 11px; }
  .appbar, .campbar, .filterbar, .sheetactions, .foot, .dots, .readonly-banner, .no-print, .tabs, .toolbar { display: none !important; }
  .page { padding: 0; max-width: none; }
  .totals, #totals-wrap { position: static; box-shadow: none; }
  .xl-sheet thead th { position: static; }
  table.xl { font-size: 10px; }
  .tablewrap { overflow: visible; border: 0; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .xl-sheet td.in select, .xl-sheet td.in input { appearance: none; -webkit-appearance: none; }
  .page-break { page-break-before: always; }
}
