@import url('https://assets.greenhouse.ca/fonts/chapeau.css');
:root {
  --gh-olive: #585828;
  --gh-cream: #F8F8E8;
  --gh-olive-muted: #809060;
  --gh-sage: #D8E0C0;
  --gh-sky: #D8F0F8;
  --gh-font: 'Chapeau', 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Status ramp - reserved meaning, never reused for chart series. */
  --status-critical: #A3402A;
  --status-warning: #8F681C;
  --status-good: #5E8038;
  --status-excellent: #3E6B2E;

  /* Categorical chart-series palette (validated via the dataviz skill's palette
     validator against this page's cream surface - all six checks pass; a contrast
     WARN on 4 of the 8 steps means every chart using them ships visible direct
     labels/legend, never color-alone identification). Fixed hue order, never cycled
     or reassigned per filter. */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--gh-cream);
  color: var(--gh-olive);
  font-family: var(--gh-font);
}

h1, h2, h3 { font-weight: 700; margin: 0; }
a { color: var(--gh-olive); }

.card {
  background: #fff;
  border: 1px solid var(--gh-sage);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(88, 88, 40, 0.08);
}

/* Login page */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 340px; text-align: center; }
.login-card h1 { font-size: 1.4rem; margin-bottom: 8px; }
.login-card p.subtitle { color: var(--gh-olive-muted); margin: 0 0 20px; }

.btn-primary {
  display: inline-block;
  width: 100%;
  padding: 12px;
  background: var(--gh-olive);
  color: var(--gh-cream);
  border: none;
  border-radius: 8px;
  font-family: var(--gh-font);
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
}
.btn-primary:hover { background: var(--gh-olive-muted); }

.auth-disabled-banner {
  background: var(--status-warning);
  color: #fff;
  text-align: center;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 700;
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.error-banner {
  background: #F4E3D3;
  border: 1px solid #D9A97A;
  color: #7A4A1E;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

/* App shell */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--gh-olive);
  color: var(--gh-cream);
  flex-wrap: wrap;
  gap: 8px;
}
.app-header h1 { font-size: 1.2rem; color: var(--gh-cream); }
.app-header .meta { font-size: 0.8rem; color: var(--gh-sage); }
.app-header .user { display: flex; align-items: center; gap: 14px; font-size: 0.85rem; }
.app-header a.logout { color: var(--gh-cream); text-decoration: underline; }

.sync-toggle {
  background: none;
  border: 1px solid var(--gh-cream);
  color: var(--gh-cream);
  border-radius: 8px;
  padding: 8px 14px;
  font-family: var(--gh-font);
  cursor: pointer;
}

main { padding: 24px 28px; max-width: 1200px; margin: 0 auto; }

.sync-panel { margin-bottom: 16px; display: none; }
.sync-panel.open { display: block; }
.sync-panel table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.sync-panel th, .sync-panel td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--gh-sage); }
.status-success { color: var(--status-excellent); font-weight: 700; }
.status-error { color: var(--status-critical); font-weight: 700; }

/* Tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 2px solid var(--gh-sage); }
.tab-btn {
  background: none;
  border: none;
  padding: 10px 18px;
  font-family: var(--gh-font);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gh-olive-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}
.tab-btn.active { color: var(--gh-olive); border-bottom-color: var(--gh-olive); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Filter toolbar */
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.btn-clear-filters {
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-family: var(--gh-font);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--gh-olive-muted);
  background: none;
  cursor: pointer;
  margin-left: auto;
}
.btn-clear-filters:hover { color: var(--gh-olive); text-decoration: underline; }
/* Multiselect filter dropdown */
.multiselect { position: relative; }
.ms-trigger {
  padding: 9px 14px;
  border: 1px solid var(--gh-sage);
  border-radius: 8px;
  font-family: var(--gh-font);
  font-size: 0.9rem;
  color: var(--gh-olive);
  background: #fff;
  cursor: pointer;
  min-width: 130px;
  text-align: left;
  white-space: nowrap;
}
.ms-trigger.has-selection { border-color: var(--gh-olive); font-weight: 700; }
.ms-panel {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  width: 240px;
  max-height: 320px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--gh-sage);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(88, 88, 40, 0.18);
  padding: 8px;
}
.multiselect.open .ms-panel { display: block; }
.ms-search {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 10px;
  border: 1px solid var(--gh-sage);
  border-radius: 6px;
  font-family: var(--gh-font);
  font-size: 0.85rem;
  margin-bottom: 6px;
}
.ms-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  font-size: 0.85rem;
  cursor: pointer;
  border-radius: 4px;
}
.ms-option:hover { background: var(--gh-sky); }
.ms-option span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-select-all {
  font-weight: 700;
  border-bottom: 1px solid var(--gh-sage);
  padding-bottom: 8px;
  margin-bottom: 4px;
}
.ms-options-list { display: flex; flex-direction: column; }
.ms-empty { padding: 10px 4px; color: var(--gh-olive-muted); font-size: 0.85rem; }

/* KPI grid */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi-card .kpi-label { font-size: 0.8rem; color: var(--gh-olive-muted); margin-bottom: 6px; }
.kpi-card .kpi-value { font-size: 1.8rem; font-weight: 700; line-height: 1.1; }

.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.chart-row .card h3 { font-size: 0.95rem; margin-bottom: 10px; }
.chart-row .chart-wrap { height: 260px; }

@media (max-width: 860px) {
  .chart-row { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

/* YoY page */
.yoy-hero { display: flex; gap: 20px; align-items: flex-start; margin-bottom: 20px; flex-wrap: wrap; }
.yoy-hero .card { flex: 1; min-width: 220px; }
.yoy-pct { font-size: 2.2rem; font-weight: 700; }
.yoy-pct.positive { color: var(--status-excellent); }
.yoy-pct.negative { color: var(--status-critical); }
.metric-picker { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.metric-picker button {
  background: #fff;
  border: 1px solid var(--gh-sage);
  color: var(--gh-olive);
  border-radius: 999px;
  padding: 8px 16px;
  font-family: var(--gh-font);
  font-size: 0.85rem;
  cursor: pointer;
}
.metric-picker button.active { background: var(--gh-olive); color: var(--gh-cream); border-color: var(--gh-olive); }
.trend-wrap { height: 320px; }

/* Detail table */
.table-scroll { overflow-x: auto; border-radius: 10px; border: 1px solid var(--gh-sage); }
table.detail { border-collapse: collapse; width: 100%; background: #fff; font-size: 0.88rem; }
table.detail th, table.detail td { padding: 10px 14px; border-bottom: 1px solid var(--gh-sage); text-align: left; white-space: nowrap; }
table.detail th { background: var(--gh-sage); color: var(--gh-olive); position: sticky; top: 0; }
table.detail td.num, table.detail th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.detail th.sortable { cursor: pointer; user-select: none; }
table.detail th.sortable:hover { background: #CCD6AC; }
table.detail tbody tr:hover { background: var(--gh-sky); }

/* Sync tab */
.sync-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 20px; }
.sync-slot { display: flex; flex-direction: column; gap: 6px; }
.sync-slot label { font-weight: 700; font-size: 0.9rem; }
.sync-slot input[type="file"] {
  border: 1px dashed var(--gh-sage);
  border-radius: 8px;
  padding: 12px;
  font-family: var(--gh-font);
  font-size: 0.82rem;
  background: #fff;
}
.sync-slot .filename { font-size: 0.78rem; color: var(--gh-olive-muted); }
.sync-result { margin-top: 16px; padding: 12px 16px; border-radius: 8px; font-size: 0.9rem; display: none; }
.sync-result.success { display: block; background: #EAF2E1; color: var(--status-excellent); }
.sync-result.error { display: block; background: #F4E3D3; color: var(--status-critical); }

.empty-state { text-align: center; padding: 40px; color: var(--gh-olive-muted); }
