/* ============================================================
   THEME VARIABLES (Light / Dark)
============================================================ */
:root,
[data-theme="light"] {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-alt: #f7f8fb;
  --border: #e3e7ef;
  --text: #1c2333;
  --text-muted: #6b7280;
  --text-soft: #8b93a5;
  --primary: #4f5eff;
  --primary-hover: #3d4bf0;
  --primary-soft: #eef0ff;
  --success: #16a34a;
  --success-soft: #e7f8ee;
  --danger: #e11d48;
  --danger-soft: #fde8ec;
  --warning: #d97706;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 12px rgba(16, 24, 40, .06);
  --radius: 14px;
  --sidebar-w: 250px;
  --header-h: 68px;
}

[data-theme="dark"] {
  --bg: #10131c;
  --surface: #171b28;
  --surface-alt: #1d2233;
  --border: #2a3040;
  --text: #eef1f8;
  --text-muted: #9aa2b6;
  --text-soft: #6d7488;
  --primary: #6c7bff;
  --primary-hover: #8492ff;
  --primary-soft: #232a4d;
  --success: #34d399;
  --success-soft: #103826;
  --danger: #fb7185;
  --danger-soft: #401823;
  --warning: #fbbf24;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  /*transition: background .2s ease, color .2s ease;*/
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   HEADER
============================================================ */
.app-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.header-left { display: flex; align-items: center; gap: 14px; }
.header-title { display: flex; flex-direction: column; line-height: 1.2; }
.header-title-main { font-weight: 700; font-size: 16px; }
.header-title-sub { font-size: 12px; color: var(--text-muted); }

.header-right { display: flex; align-items: center; gap: 12px; }

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease;
}
.icon-btn:hover { background: var(--surface-alt); }

.last-update-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.last-update-pill strong { color: var(--text); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-live { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }

/* ============================================================
   BODY LAYOUT (SIDEBAR + MAIN)
============================================================ */
.app-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.app-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 14px;
}

.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; border-bottom: 1px solid var(--border); }
.sidebar-brand-icon { font-size: 22px; }
.sidebar-brand-text { font-weight: 700; font-size: 14px; line-height: 1.3; }
.sidebar-brand-text span { font-weight: 400; color: var(--text-muted); font-size: 12px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-soft);
  margin: 14px 8px 4px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 14px !important;
  font-weight: 500;
}
.sidebar-link small { color: var(--text-soft); font-weight: 400; }
.sidebar-link:hover { background: var(--surface-alt); color: var(--text); }
.sidebar-link.active { background: var(--primary-soft); color: var(--primary); }
.sidebar-link.active small { color: var(--primary); opacity: .75; }
.sidebar-link-icon { font-size: 18px; }

.sidebar-note {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 10px;
  margin: 4px 8px;
  line-height: 1.5;
}
.sidebar-footer-mini { font-size: 11px; color: var(--text-soft); text-align: center; padding-top: 8px; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 39;
}

.app-main {
  flex: 1;
  min-width: 0;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ============================================================
   SUMMARY CARDS
============================================================ */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.summary-card-label { font-size: 12.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.summary-card-value { font-size: 20px; font-weight: 700; margin-top: 8px; }
.summary-card-sub { font-size: 12px; color: var(--text-soft); margin-top: 4px; }

.status-badge {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
}
.status-badge.ontrack { background: var(--success-soft); color: var(--success); }
.status-badge.behind { background: var(--danger-soft); color: var(--danger); }

/* ============================================================
   FILTER BAR
============================================================ */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  box-shadow: var(--shadow);
}
.filter-field { display: flex; flex-direction: column; gap: 6px; min-width: 160px; }
.filter-field label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.filter-field select,
.filter-field input {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 10px;
  border-radius: 9px;
  font-size: 13.5px;
  min-width: 150px;
}
.filter-actions { display: flex; gap: 10px; margin-left: auto; flex-wrap: wrap; }

.btn {
  border: none;
  padding: 10px 16px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  transition: filter .15s ease, background .15s ease;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { filter: brightness(1.05); }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover { background: var(--primary-soft); }

/* ============================================================
   PANELS (Chart + Progress)
============================================================ */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px 22px;
  box-shadow: var(--shadow);
}
.panel-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 6px; }
.panel-header h2 { font-size: 15.5px; margin: 0; }
.panel-subtitle { font-size: 12.5px; color: var(--text-muted); }

.chart-wrapper { position: relative; width: 100%; }

.group-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.group-card {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.group-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.group-card-name { font-weight: 700; font-size: 14px; }
.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.progress-fill { height: 100%; border-radius: 999px; background: var(--primary); transition: width .3s ease; }
.progress-fill.ontrack { background: var(--success); }
.progress-fill.behind { background: var(--danger); }

.group-card-stats { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-muted); }
.group-card-stats b { color: var(--text); }
.group-card-percentage { font-size: 13px; font-weight: 700; }

/* ============================================================
   FOOTER
============================================================ */
.app-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 14px 22px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
}

/* ============================================================
   MODAL
============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 20, .55);
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; font-size: 15.5px; }
.modal-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; }
.modal-body p { margin: 0 0 6px; font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.modal-body label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.modal-body input {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 14px;
}
.modal-error { color: var(--danger); font-size: 12.5px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border); }

/* ============================================================
   TOAST
============================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 80;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================
   RESPONSIVE
============================================================ */
@media (max-width: 1024px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .app-sidebar {
    position: fixed;
    left: 0;
    top: var(--header-h);
    bottom: 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: var(--shadow);
  }
  .app-sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; top: var(--header-h); }
  .filter-actions { margin-left: 0; width: 100%; }
  .filter-actions .btn { flex: 1; }
}

@media (max-width: 640px) {
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .app-main { padding: 14px; gap: 14px; }
  .header-title-sub { display: none; }
  .last-update-pill { display: none; }
  .filter-field { min-width: 100%; }
  .group-card-grid { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .summary-grid { grid-template-columns: 1fr; }
}
/* ============================================================
   HAMBURGER
============================================================ */
.hide-lg {
  display: block; 
}

/* Hidden on large screens and up */
@media screen and (min-width: 1024px) {
  .hide-lg {
    display: none;
  }
}
.hide {
	display: none;
}