:root {
  --navy: #12296b;
  --blue: #2f6fed;
  --blue-bg: #eaf1fb;
  --green: #1fa971;
  --green-bg: #e8f7f0;
  --gray-bg: #eef0f5;
  --purple: #6b4fd6;
  --purple-bg: #f1eefb;
  --red: #d64545;
  --amber: #d68a1f;
  --text: #1c2333;
  --muted: #6b7280;
  --border: #e1e5ee;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #f5f7fb;
  color: var(--text);
}

.topbar {
  background: var(--navy);
  color: white;
  padding: 18px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.topbar-title h1 { margin: 0; font-size: 20px; }
.topbar-title span { font-size: 13px; opacity: 0.75; }

.topbar-brand { display: flex; align-items: center; gap: 12px; }
.topbar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 10px;
  background: white;
  color: var(--blue);
}

.hero-block { margin-bottom: 20px; }
.hero-block h2 { margin: 0 0 4px; font-size: 26px; font-weight: 800; color: var(--navy); }
.hero-block p { margin: 0; font-size: 14px; color: var(--muted); }

.tabs { display: flex; gap: 8px; }
.tab-btn {
  background: rgba(255,255,255,0.1);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.tab-btn.active { background: white; color: var(--navy); font-weight: 600; }

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

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 20px;
}
.card-title { font-weight: 700; margin-bottom: 12px; font-size: 15px; }

.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }

.card-title-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-title-row .card-title { margin-bottom: 0; }

.icon-badge-sm {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 8px;
}
.icon-badge-sm.blue { background: #d3e4fb; color: var(--blue); }
.icon-badge-sm.green { background: #cdf0e0; color: var(--green); }
.icon-badge-sm.purple { background: #e0d6f7; color: var(--purple); }
.icon-badge-sm.amber { background: #fef3e2; color: var(--amber); }
.icon-badge-sm.navy { background: var(--gray-bg); color: var(--navy); }
.card-head .card-title { margin-bottom: 0; }

.hours-pill {
  background: var(--blue-bg);
  color: var(--blue);
  font-weight: 700;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 20px;
  white-space: nowrap;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.details-grid label, .filters-grid label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: var(--muted);
  gap: 4px;
}
input, select, textarea {
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  color: var(--text);
}
.status-badge-wrap { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.week-range-hint { font-size: 11px; color: var(--blue); font-weight: 600; }
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  width: fit-content;
}
.badge.draft { background: #fef3e2; color: var(--amber); }
.badge.submitted { background: var(--green-bg); color: var(--green); }
.badge.zone-green { background: var(--green-bg); color: var(--green); }
.badge.zone-yellow { background: #fef3e2; color: var(--amber); }
.badge.zone-red { background: #fbe7e7; color: var(--red); }
.badge.zone-none { background: var(--gray-bg); color: var(--muted); }

.balance-badge-row { margin-bottom: 10px; }

.quadrant-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
@media (max-width: 800px) {
  .quadrant-grid { grid-template-columns: 1fr; }
  .details-grid, .filters-grid { grid-template-columns: 1fr 1fr; }
}

.quadrant-box {
  border-radius: 12px;
  border-top: 4px solid transparent;
  padding: 16px;
  min-height: 140px;
}
.quadrant-box.blue { background: var(--blue-bg); border-top-color: var(--blue); }
.quadrant-box.green { background: var(--green-bg); border-top-color: var(--green); }
.quadrant-box.gray { background: var(--gray-bg); border-top-color: var(--muted); }
.quadrant-box.purple { background: var(--purple-bg); border-top-color: var(--purple); }
.quadrant-box.amber { background: #fef3e2; border-top-color: var(--amber); }

.admin-box { margin-bottom: 20px; }

.help-tile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 900px) { .help-tile-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .help-tile-grid { grid-template-columns: 1fr; } }
.help-tile-card { border-radius: 10px; border-top: 4px solid transparent; padding: 14px; }
.help-tile-card .quadrant-icon-badge { margin-bottom: 10px; }
.help-tile-card h4 { margin: 0 0 6px; font-size: 14px; }
.help-tile-card p { margin: 0; font-size: 12px; color: var(--text); line-height: 1.5; }
.help-tile-card.blue { background: var(--blue-bg); border-top-color: var(--blue); }
.help-tile-card.green { background: var(--green-bg); border-top-color: var(--green); }
.help-tile-card.gray { background: var(--gray-bg); border-top-color: var(--muted); }
.help-tile-card.purple { background: var(--purple-bg); border-top-color: var(--purple); }
.help-tile-card.amber { background: #fef3e2; border-top-color: var(--amber); }
.help-tile-card.blue .quadrant-icon-badge { background: #d3e4fb; color: var(--blue); }
.help-tile-card.green .quadrant-icon-badge { background: #cdf0e0; color: var(--green); }
.help-tile-card.gray .quadrant-icon-badge { background: #dfe2ea; color: var(--muted); }
.help-tile-card.purple .quadrant-icon-badge { background: #e0d6f7; color: var(--purple); }
.help-tile-card.amber .quadrant-icon-badge { background: var(--amber); color: white; }

.help-intro { font-size: 13px; color: var(--muted); margin: 0 0 16px; }
.help-role-card { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
.help-role-card:last-child { margin-bottom: 0; }
.help-role-card h4 { margin: 0 0 10px; font-size: 14px; color: var(--navy); }
.help-row { font-size: 13px; line-height: 1.6; margin-bottom: 6px; }
.help-row:last-child { margin-bottom: 0; }
.help-row strong { color: var(--navy); }
.quadrant-box label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; margin-top: 10px; }
.quadrant-box textarea { width: 100%; }

.quadrant-side-fields { display: flex; gap: 8px; flex-shrink: 0; }
.mini-field, .admin-hours-label { margin-top: 0; width: 90px; flex-shrink: 0; }
.mini-field input, .mini-field select, .admin-hours-label input { width: 100%; text-align: center; }

.quadrant-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.quadrant-head h3 { margin: 0; font-size: 15px; }
.quadrant-head-main { display: flex; align-items: flex-start; gap: 12px; }

.quadrant-icon-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 10px;
}
.quadrant-box.blue .quadrant-icon-badge { background: #d3e4fb; color: var(--blue); }
.quadrant-box.green .quadrant-icon-badge { background: #cdf0e0; color: var(--green); }
.quadrant-box.gray .quadrant-icon-badge { background: #dfe2ea; color: var(--muted); }
.quadrant-box.purple .quadrant-icon-badge { background: #e0d6f7; color: var(--purple); }
.quadrant-box.amber .quadrant-icon-badge { background: var(--amber); color: white; }

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  color: white;
  font-size: 10px;
  font-style: italic;
  font-weight: 700;
  font-family: Georgia, serif;
  cursor: help;
  vertical-align: middle;
  position: relative;
}
.info-icon::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  background: var(--navy);
  color: white;
  font-size: 12px;
  font-style: normal;
  font-weight: 400;
  line-height: 1.4;
  padding: 8px 10px;
  border-radius: 6px;
  white-space: normal;
  z-index: 20;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease;
  pointer-events: none;
}
.info-icon:hover::after { opacity: 1; visibility: visible; }
.quadrant-head .subtitle { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); margin-bottom: 2px; }
.quadrant-head .desc { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.empty-hint { font-size: 12px; color: var(--muted); font-style: italic; padding: 8px 0; }

.narrative-text { font-size: 13px; color: var(--text); line-height: 1.6; margin: 0 0 16px; padding: 12px 14px; background: var(--blue-bg); border-radius: 8px; }

.summary-list { display: flex; flex-direction: column; gap: 10px; }
.summary-row { display: flex; align-items: center; gap: 12px; }
.summary-row-label { width: 220px; flex-shrink: 0; font-size: 13px; font-weight: 600; }
.summary-bar-wrap { flex: 1; height: 14px; background: var(--gray-bg); border-radius: 6px; overflow: hidden; }
.summary-bar-fill { height: 100%; background: var(--blue); }
.summary-row-value { width: 110px; flex-shrink: 0; text-align: right; font-size: 12px; color: var(--muted); white-space: nowrap; }

.footer-actions { display: flex; justify-content: space-between; align-items: center; }
.footer-actions-right { display: flex; gap: 10px; }

.btn { border: none; padding: 10px 18px; border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-primary { background: var(--blue); color: white; }
.btn-secondary { background: var(--navy); color: white; }
.btn-ghost { background: white; border: 1px solid var(--border); color: var(--text); }
.btn-warning { background: var(--amber); color: white; }
.btn-danger { background: var(--red); color: white; }
.row-actions { display: flex; gap: 6px; }
.row-actions .btn { padding: 6px 12px; font-size: 12px; }
.btn:hover { opacity: 0.9; }

.filters-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  align-items: end;
}
.checkbox-label { flex-direction: row !important; align-items: center; gap: 6px !important; }
.checkbox-label input { width: auto; }
.filters-actions { display: flex; align-items: flex-end; gap: 8px; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
@media (max-width: 900px) { .stats-row { grid-template-columns: repeat(2, 1fr); } .filters-grid { grid-template-columns: 1fr 1fr; } }
.stat-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.stat-card .stat-value { font-size: 24px; font-weight: 800; color: var(--navy); }
.stat-card .stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

.balance-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
@media (max-width: 800px) { .balance-row { grid-template-columns: 1fr; } }
.balance-card { background: white; border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.balance-title { font-size: 13px; font-weight: 700; margin-bottom: 10px; }
.stacked-bar { display: flex; height: 22px; border-radius: 6px; overflow: hidden; background: var(--border); }
.stacked-bar .seg-a { background: var(--blue); }
.stacked-bar .seg-b { background: var(--purple); }
.stacked-bar .seg-green { background: var(--green); }
.stacked-bar .seg-yellow { background: var(--amber); }
.stacked-bar .seg-red { background: var(--red); }
.stacked-legend { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }
.value-legend { display: flex; gap: 10px; flex-wrap: wrap; }

.dashboard-quadrant-stats { font-size: 12px; color: var(--text); }
.dashboard-quadrant-stats div { margin-bottom: 3px; }
.dashboard-quadrant-stats .dq-value { font-weight: 700; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tr:hover td { background: #fafbfd; }

.excel-table { border: 1px solid var(--border); max-height: 70vh; }
.excel-table th, .excel-table td { border: 1px solid var(--border); }
.excel-table thead th {
  position: sticky; top: 0;
  background: #f3f5fa;
  cursor: pointer;
  user-select: none;
}
.excel-table thead th:hover { background: #e9ecf5; }
.excel-table thead th.sorted-asc::after { content: ' ▲'; font-size: 9px; }
.excel-table thead th.sorted-desc::after { content: ' ▼'; font-size: 9px; }
.excel-table tbody tr:nth-child(even) td { background: #fafbfd; }
.excel-table tbody tr:hover td { background: #eef2fb; }
.excel-table td.wrap-cell { white-space: normal; max-width: 280px; font-size: 12px; color: var(--muted); }
.excel-table td.wrap-cell.blockers { color: var(--red); }

.summary-points { margin: 0; padding-left: 16px; }
.summary-points li { margin-bottom: 4px; }
.summary-points li:last-child { margin-bottom: 0; }
.summary-label { font-weight: 700; color: var(--navy); }
