/* ── Greenhouse brand tokens ─────────────────────────────────────────── */
:root {
  --cream:       #F8F8E8;
  --olive:       #585828;
  --olive-light: #7a7a3a;
  --sage:        #D8E0C0;
  --sage-dark:   #b8c4a0;
  --positive-bg: #E8F3E8;
  --positive-fg: #2d6a2d;
  --negative-bg: #F9EDE8;
  --negative-fg: #7a3515;
  --border:      #cdd4b8;
  --text:        #585828;
  --text-muted:  #8a8a50;
  --white:       #ffffff;
  --shadow:      0 2px 8px rgba(88,88,40,.12);
  --radius:      6px;
  --font:        'Nunito', sans-serif;
}

/* ── Reset & base ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--cream); color: var(--text); font-family: var(--font); font-size: 14px; }
button { font-family: var(--font); cursor: pointer; }
a { color: var(--olive); }

/* ── Header ──────────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: var(--olive);
  color: var(--cream);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.logo { width: 32px; height: 32px; flex-shrink: 0; }
.app-title { font-size: 16px; font-weight: 800; color: var(--cream); letter-spacing: .3px; }
.header-right { display: flex; align-items: center; gap: 20px; }
.header-control { display: flex; align-items: center; gap: 6px; }
.header-label { font-size: 11px; font-weight: 600; opacity: .7; text-transform: uppercase; letter-spacing: .5px; color: var(--cream); }
.header-value { font-size: 13px; font-weight: 600; color: var(--cream); }

.user-control { gap: 8px; }
.logout-link { font-size: 12px; color: var(--sage); text-decoration: none; opacity: .8; }
.logout-link:hover { opacity: 1; text-decoration: underline; }

/* ── Sync log ────────────────────────────────────────────────────────── */
.sync-log-wrapper { position: relative; }
.sync-log-btn {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2);
  color: var(--cream); font-size: 12px; font-weight: 600;
  padding: 5px 10px; border-radius: var(--radius);
  transition: background .15s;
}
.sync-log-btn:hover { background: rgba(255,255,255,.2); }
.chevron { transition: transform .2s; }
.sync-log-btn[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.status-dot--unknown  { background: rgba(255,255,255,.4); }
.status-dot--success  { background: #6fcf97; }
.status-dot--error    { background: #eb5757; }
.status-dot--warning  { background: #f2c94c; }

.sync-log-panel {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 340px; background: var(--white);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 8px 0; z-index: 200;
}
.sync-log-list { display: flex; flex-direction: column; }
.sync-log-entry {
  display: grid; grid-template-columns: auto 1fr auto;
  align-items: center; gap: 8px;
  padding: 8px 14px; font-size: 12px; border-bottom: 1px solid var(--sage);
}
.sync-log-entry:last-child { border-bottom: none; }
.sync-log-time { color: var(--text-muted); white-space: nowrap; }
.sync-log-desc { color: var(--text); }
.sync-log-dur  { color: var(--text-muted); white-space: nowrap; }
.sync-log-empty { padding: 14px; text-align: center; color: var(--text-muted); font-size: 12px; }

/* ── Selects ─────────────────────────────────────────────────────────── */
.gh-select {
  background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.25);
  color: var(--cream); font-family: var(--font); font-size: 13px;
  padding: 4px 8px; border-radius: var(--radius); cursor: pointer;
}
.gh-select option { background: var(--olive); color: var(--cream); }
.gh-select--sm { font-size: 12px; padding: 3px 6px; }

/* ── Tab bar ─────────────────────────────────────────────────────────── */
.tab-bar {
  display: flex; padding: 0 24px; gap: 0;
  background: var(--sage); border-bottom: 2px solid var(--sage-dark);
}
.tab-btn {
  padding: 10px 20px; background: none; border: none;
  color: var(--olive); font-size: 14px; font-weight: 600;
  border-bottom: 3px solid transparent; margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.tab-btn:hover { color: var(--olive); border-bottom-color: var(--olive-light); }
.tab-btn--active { color: var(--olive); border-bottom-color: var(--olive); }

/* ── Tab panels ──────────────────────────────────────────────────────── */
.tab-panel { padding: 20px 24px; }

/* ── Toolbar ─────────────────────────────────────────────────────────── */
.toolbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-bottom: 14px;
}

/* ── Toggle groups ───────────────────────────────────────────────────── */
.toggle-group {
  display: flex; border: 1.5px solid var(--olive); border-radius: var(--radius);
  overflow: hidden;
}
.toggle-btn {
  padding: 6px 16px; background: none; border: none;
  color: var(--olive); font-size: 13px; font-weight: 600;
  transition: background .15s, color .15s;
}
.toggle-btn + .toggle-btn { border-left: 1.5px solid var(--olive); }
.toggle-btn--active { background: var(--olive); color: var(--cream); }

/* ── Slicers ─────────────────────────────────────────────────────────── */
.slicers { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.slicer-group { display: flex; flex-direction: column; gap: 4px; }
.slicer-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }

/* ── Multiselect component ───────────────────────────────────────────── */
.multiselect { position: relative; min-width: 180px; }
.ms-trigger {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; border: 1.5px solid var(--olive); border-radius: var(--radius);
  background: var(--white); cursor: pointer; font-size: 13px; color: var(--text);
  gap: 8px;
}
.ms-trigger:focus { outline: 2px solid var(--olive); outline-offset: 1px; }
.ms-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; min-width: 100%; max-width: 300px;
  background: var(--white); border: 1.5px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); z-index: 300;
}
.ms-actions {
  display: flex; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--sage);
}
.ms-action-btn {
  font-size: 11px; font-weight: 700; color: var(--olive); background: none; border: none;
  padding: 2px 6px; border-radius: 3px;
  text-transform: uppercase; letter-spacing: .3px;
}
.ms-action-btn:hover { background: var(--sage); }
.ms-options { max-height: 220px; overflow-y: auto; padding: 4px 0; }
.ms-option {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; cursor: pointer; font-size: 13px;
  transition: background .1s;
}
.ms-option:hover { background: var(--cream); }
.ms-option input[type="checkbox"] { accent-color: var(--olive); width: 14px; height: 14px; cursor: pointer; }
.ms-option label { cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Filter group (Tab 2) ────────────────────────────────────────────── */
.filter-group { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.inline-filter { display: flex; align-items: center; gap: 6px; }
.filter-label { font-size: 12px; font-weight: 700; color: var(--text-muted); white-space: nowrap; }
.inline-filter select {
  background: var(--white); border: 1.5px solid var(--olive);
  color: var(--text); font-family: var(--font); font-size: 12px;
  padding: 4px 8px; border-radius: var(--radius); min-width: 150px; max-width: 220px;
}

/* ── KPI tile ────────────────────────────────────────────────────────── */
.kpi-row { margin-bottom: 16px; }
.kpi-tile {
  display: inline-flex; flex-direction: column; gap: 4px;
  padding: 14px 20px; background: var(--olive);
  border-radius: var(--radius); color: var(--cream);
}
.kpi-label { font-size: 11px; font-weight: 700; opacity: .75; text-transform: uppercase; letter-spacing: .4px; }
.kpi-value { font-size: 26px; font-weight: 800; }

/* ── Chart ───────────────────────────────────────────────────────────── */
.chart-wrap {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 20px; max-height: 340px;
}
.chart-wrap canvas { max-height: 300px; }

/* ── Table wrapper ───────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto; border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  max-height: 65vh; overflow-y: auto;
}

/* ── Data table ──────────────────────────────────────────────────────── */
.gh-table {
  border-collapse: collapse; width: max-content; min-width: 100%;
  font-size: 12.5px;
}
.gh-table th {
  background: var(--olive); color: var(--cream);
  padding: 8px 10px; text-align: right; font-weight: 700;
  white-space: nowrap; position: sticky; top: 0; z-index: 2;
}
.gh-table th.col-pin, .gh-table td.col-pin {
  text-align: left; position: sticky; z-index: 3; background: inherit;
}
.gh-table th.col-pin { z-index: 4; background: var(--olive); }
.col-pin-0 { left: 0; }
.col-pin-1 { left: 140px; }
.col-pin-2 { left: 260px; }
.col-pin-3 { left: 380px; }

.gh-table th.week-group { text-align: center; border-left: 2px solid rgba(255,255,255,.2); }
.gh-table th.sub-header { font-size: 11px; font-weight: 600; opacity: .85; }

.gh-table td {
  padding: 6px 10px; border-bottom: 1px solid var(--sage);
  text-align: right; white-space: nowrap;
}
.gh-table td.col-pin { text-align: left; background: var(--cream); }
.gh-table tr:hover td { background: rgba(216,224,192,.35); }
.gh-table tr:hover td.col-pin { background: rgba(216,224,192,.55); }

/* Grand total row */
.gh-table tr.row-total td {
  background: var(--sage); font-weight: 800;
  border-top: 2px solid var(--olive); border-bottom: none;
}
.gh-table tr.row-total td.col-pin { background: var(--sage); }

/* Variance colour coding */
td.var-pos { background: var(--positive-bg); color: var(--positive-fg); font-weight: 700; }
td.var-neg { background: var(--negative-bg); color: var(--negative-fg); font-weight: 700; }
td.var-zero { color: var(--text-muted); }

/* ── Tab 2 detail table ──────────────────────────────────────────────── */
.gh-table.t2-table th, .gh-table.t2-table td { text-align: right; }
.gh-table.t2-table th:first-child, .gh-table.t2-table td:first-child { text-align: left; }

/* ── Loading / empty ─────────────────────────────────────────────────── */
.loading-msg { padding: 40px; text-align: center; color: var(--text-muted); font-style: italic; }
.error-msg   { padding: 20px; color: var(--negative-fg); background: var(--negative-bg); border-radius: var(--radius); }
