* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f8f8f6;
  color: #1a1a1a;
}

/* === APP LAYOUT WITH SIDEBAR === */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px; min-width: 240px; background: #1a2332; color: #ccc;
  display: flex; flex-direction: column; transition: width 0.2s;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar.collapsed { width: 0; min-width: 0; overflow: hidden; }
.sidebar-expand {
  display: none; position: fixed; top: 12px; left: 8px; z-index: 100;
  background: #1a2332; color: #ccc; border: none; border-radius: 6px;
  padding: 6px 10px; cursor: pointer; font-size: 14px;
}
.sidebar-expand:hover { background: #2a3442; color: #fff; }
.sidebar.collapsed ~ .main-content .sidebar-expand { display: block; }
.sidebar-header {
  padding: 16px; display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid #2a3442;
}
.sidebar-logo { font-size: 15px; font-weight: 600; color: #fff; }
.sidebar-toggle {
  background: none; border: none; color: #667; cursor: pointer; font-size: 16px;
  padding: 4px 8px; border-radius: 4px;
}
.sidebar-toggle:hover { background: #2a3442; color: #fff; }

.sidebar-nav { flex: 1; padding: 8px 0; }
.nav-group { margin-bottom: 2px; }
.nav-group-header {
  padding: 8px 16px; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; color: #8899aa; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
}
.nav-group-header:hover { color: #fff; background: #222d3d; }
.nav-group-header.open .nav-arrow { transform: rotate(90deg); }
.nav-arrow { font-size: 10px; transition: transform 0.15s; }
.nav-group-items { padding-left: 0; }
.nav-item {
  display: block; padding: 6px 16px 6px 28px; font-size: 13px; color: #99aabb;
  text-decoration: none; border-left: 2px solid transparent;
}
.nav-item:hover { background: #222d3d; color: #fff; }
.nav-item.active { color: #fff; background: #2a3a4a; border-left-color: #4a9eff; }

.sidebar-admin {
  border-top: 1px solid #2a3442; padding: 8px 0;
}
.sidebar-admin-label {
  padding: 8px 16px 4px; font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; color: #556;
}
.sidebar-admin .nav-item { padding-left: 16px; }

.sidebar-user {
  border-top: 1px solid #2a3442; padding: 12px 16px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: #889;
}

.main-content { flex: 1; overflow-x: auto; background: #f8f8f6; }

/* === LAYOUT === */
.page-wrapper { max-width: 1400px; margin: 0 auto; padding: 20px; }

.top-bar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; flex-wrap: wrap; gap: 8px;
}
.dashboard-title { font-size: 18px; font-weight: 500; }
.last-updated { font-size: 12px; color: #aaa; margin-top: 4px; }

.controls {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.toggle-label {
  font-size: 12px; color: #888; cursor: pointer;
  display: flex; align-items: center; gap: 5px;
}
.btn-recalculate {
  font-size: 12px; padding: 6px 14px; border: 1px solid #d0d0d0;
  background: #fff; border-radius: 6px; cursor: pointer; color: #555;
}
.btn-recalculate:hover { background: #f5f5f3; color: #1a1a1a; }

/* === TABLE === */
.table-container {
  overflow-x: auto; border: 1px solid #e2e2e2; border-radius: 8px;
}
.kpi-grid {
  width: 100%; border-collapse: collapse; font-size: 12px; min-width: 900px;
}

/* Header */
.kpi-grid thead tr { background: #1a3a4a; }
.kpi-grid thead th {
  color: #fff; font-weight: 400; padding: 10px 8px;
  text-align: center; white-space: nowrap; font-size: 12px;
}
.th-kpi {
  min-width: 160px; text-align: left; padding-left: 14px;
  position: sticky; left: 0; z-index: 2; background: #1a3a4a;
}
.th-quarter { font-weight: 600 !important; background: #2a3e55; }
.th-ytd { font-weight: 600 !important; background: #4a3a28; }

/* KPI label column */
.td-kpi {
  padding: 10px 14px; font-weight: 500; color: #1a1a1a;
  position: sticky; left: 0; z-index: 1; background: #fff;
  border-bottom: 1px solid #d8d8d6; font-size: 12px; white-space: nowrap;
}
tr:nth-child(even) .td-kpi { background: #fcfcfb; }

/* Data cells */
.cell {
  text-align: center; border-bottom: 1px solid #d8d8d6;
  border-left: 1px solid #ddd; font-size: 12px;
  white-space: nowrap; vertical-align: middle;
}
.cell-inner { padding: 6px 8px 4px; }
.cell-inner.no-yoy { padding: 8px 8px; }
.cell-value { line-height: 1.3; }

/* Cell backgrounds — monthly */
.cell-data { background: #eef4ea; }
tr:nth-child(even) .cell-data { background: #e9f0e5; }
/* Cell backgrounds — quarterly (distinct blue-gray tint) */
.cell-quarter { background: #e3eaf2; font-weight: 600; border-left: 2px solid #c0cdd8 !important; }
tr:nth-child(even) .cell-quarter { background: #dce4ed; }
/* Cell backgrounds — YTD (distinct warm amber tint) */
.cell-ytd { background: #f5ecd8; font-weight: 600; border-left: 2px solid #d8c9a8 !important; }
tr:nth-child(even) .cell-ytd { background: #f0e6d0; }
/* Cell backgrounds — future */
.cell-future { background: #fce8d8; }
tr:nth-child(even) .cell-future { background: #f9e3d2; }
.cell-future-quarter { background: #e8e0ee; border-left: 2px solid #c0cdd8 !important; }
.cell-future-ytd { background: #f0e6d0; border-left: 2px solid #d8c9a8 !important; }

/* Section dividers */
.section-divider td {
  padding: 8px 14px; font-size: 11px; font-weight: 600; color: #777;
  background: #f0efed; border-top: 2px solid #d0d0ce;
  border-bottom: 1px solid #d8d8d6;
  text-transform: uppercase; letter-spacing: 0.5px;
}

/* YoY badges */
.yoy-badge {
  display: inline-block; font-size: 9px; font-weight: 500;
  padding: 1px 4px; border-radius: 3px; margin-top: 3px; line-height: 1;
  opacity: 0.85;
}
.yoy-up { background: #EAF3DE; color: #27500A; }
.yoy-down { background: #FCEBEB; color: #A32D2D; }
.yoy-flat { background: #f0f0ee; color: #aaa; }

/* === TAB BAR === */
.tab-bar { display: flex; gap: 2px; margin-bottom: 12px; flex-wrap: wrap; }
.tab {
  padding: 8px 16px; font-size: 12px; text-decoration: none;
  border-radius: 8px 8px 0 0; cursor: pointer;
}
.tab-active {
  background: #fff; border: 1px solid #d0d0d0;
  border-bottom: 2px solid #1a3a4a; font-weight: 500; color: #1a1a1a;
}
.tab-inactive {
  background: #f5f5f3; border: 1px solid #e8e8e8; color: #888;
}
.tab-inactive:hover { background: #ededeb; color: #555; }

/* === LOGIN === */
.login-container {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; background: #f8f8f6;
}
.login-card {
  background: #fff; border: 1px solid #e2e2e2; border-radius: 12px;
  padding: 40px; width: 360px; text-align: center;
}
.login-card h1 { font-size: 20px; font-weight: 500; margin-bottom: 8px; }
.login-subtitle { font-size: 13px; color: #888; margin-bottom: 24px; }
.login-card input {
  width: 100%; padding: 10px 14px; margin-bottom: 12px;
  border: 1px solid #d0d0d0; border-radius: 6px; font-size: 14px;
}
.login-card button {
  width: 100%; padding: 10px; background: #1a3a4a; color: #fff;
  border: none; border-radius: 6px; font-size: 14px; cursor: pointer;
}
.login-card button:hover { background: #153040; }
.login-error {
  background: #FCEBEB; color: #A32D2D; padding: 8px 12px;
  border-radius: 6px; font-size: 12px; margin-bottom: 16px;
}

/* === ADMIN === */
.admin-table {
  width: 100%; border-collapse: collapse; font-size: 12px;
  margin-top: 16px;
}
.admin-table th, .admin-table td {
  padding: 8px 12px; border: 1px solid #e2e2e2; text-align: left;
}
.admin-table th { background: #f5f5f3; font-weight: 500; }
.status-success { color: #27500A; }
.status-error { color: #A32D2D; }
.status-running { color: #886600; }

/* KPI tooltip */
.kpi-tip-wrap {
  position: relative; display: inline-block; margin-left: 5px; vertical-align: middle;
}
.kpi-tip-icon {
  color: #bbb; font-size: 11px; cursor: default;
}
.kpi-tip-text {
  display: none; position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(100% + 8px); background: #1a2332; color: #fff; font-size: 11px;
  font-weight: 400; padding: 6px 10px; border-radius: 5px; white-space: nowrap;
  z-index: 20; pointer-events: none; line-height: 1.4;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.kpi-tip-text::after {
  content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: #1a2332;
}
.kpi-tip-wrap:hover .kpi-tip-text { display: block; }
.kpi-tip-wrap:hover .kpi-tip-icon { color: #666; }

/* Hidden columns */
.col-hidden { display: none; }

/* Filter pills (used by tabs with filter_groups) */
.filter-pills {
  display: inline-flex;
  gap: 3px;
  padding: 2px;
  background: #fff;
  border: 1px solid #e2e2e2;
  border-radius: 6px;
}
.filter-pill {
  background: transparent;
  border: none;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  color: #555;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.12s, color 0.12s;
}
.filter-pill:hover {
  background: #e2e6ea;
  color: #1a1a1a;
}
.filter-pill.active {
  background: #1a2332;
  color: #fff;
}
.filter-pill.active:hover {
  background: #2a3548;
}

/* Reorder modal drag-and-drop hover state */
.reorder-item:hover {
  background: #f0f4f8 !important;
  border-color: #c0c8d0 !important;
}
