:root {
  --bg: #f4f7f4;
  --panel: #ffffff;
  --panel-border: #e2e9e0;
  --text: #16201a;
  --text-muted: #667169;

  /* Màu thương hiệu Siêu Tốc — lấy trực tiếp từ logo */
  --brand-dark: #0a804a;
  --brand-light: #97c354;

  --accent: var(--brand-dark);
  --accent-soft: #e7f3ea;
  --green: var(--brand-dark);
  --red: #dc2626;
  --amber: #c8811a;
  --shadow: 0 1px 2px rgba(16, 40, 24, 0.05), 0 1px 3px rgba(16, 40, 24, 0.07);
  --radius: 14px;
  --sidebar-w: 280px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10130f;
    --panel: #191d17;
    --panel-border: #2a3126;
    --text: #f1f4ee;
    --text-muted: #9aa79b;
    --accent: var(--brand-light);
    --accent-soft: #223420;
    --amber: #e0a842;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.25);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }

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

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  min-width: 220px;
  max-width: 480px;
  background: var(--panel);
  border-right: 1px solid var(--panel-border);
  padding: 20px 18px 32px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-resizer {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  width: 8px;
  height: 100vh;
  margin-left: -4px;
  cursor: col-resize;
  z-index: 20;
  background: transparent;
}
.sidebar-resizer:hover,
.sidebar-resizer.active {
  background: var(--accent);
  opacity: 0.35;
}
@media (max-width: 760px) {
  .sidebar-resizer { display: none; }
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-dark);
  border-radius: 10px;
  flex: 0 0 38px;
}
.brand-mark img { width: 22px; height: 22px; display: block; }
.brand-title { font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand-sub { font-size: 12px; color: var(--text-muted); }

.sidebar-section {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--panel-border);
}
.sidebar-section:last-child { border-bottom: none; }

.sidebar-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.sidebar-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.quick-range {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.chip {
  border: 1px solid var(--panel-border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 999px;
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.month-year-row {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.month-year-row .select { padding: 8px 8px; font-size: 13px; }

.date-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}
.date-row input[type="date"] {
  flex: 1;
  min-width: 0;
  padding: 8px 8px;
  border-radius: 9px;
  border: 1px solid var(--panel-border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}
.date-sep { color: var(--text-muted); font-size: 12px; }

.select {
  width: 100%;
  padding: 9px 10px;
  border-radius: 9px;
  border: 1px solid var(--panel-border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
}

.employee-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 260px;
  overflow-y: auto;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  padding: 5px 4px;
  border-radius: 7px;
  cursor: pointer;
  user-select: none;
}
.checkbox-row:hover { background: var(--accent-soft); }
.checkbox-row input { accent-color: var(--accent); width: 15px; height: 15px; }
.check-all { font-weight: 600; }

.btn {
  border: none;
  border-radius: 9px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: scale(0.98); }
.btn-block { width: 100%; }
.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { opacity: 0.92; }
.btn-primary:disabled { opacity: 0.6; cursor: progress; }

/* ---------- Topbar / main ---------- */
.main {
  flex: 1;
  min-width: 0;
  padding: 22px 28px 60px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}
.topbar h1 {
  font-size: 21px;
  font-weight: 800;
  margin: 0;
  flex: 1;
}
.topbar-status {
  font-size: 12.5px;
  color: var(--text-muted);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.icon-btn {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  width: 36px; height: 36px;
  border-radius: 9px;
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.only-mobile { display: none; }

.error-banner {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 18px;
  font-size: 13.5px;
}
@media (prefers-color-scheme: dark) {
  .error-banner { background: #3a1616; color: #fca5a5; border-color: #5c2323; }
}

/* ---------- Metric cards ---------- */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 26px;
}
.metric-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-top: 3px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}
.metric-card:hover { box-shadow: 0 2px 4px rgba(16, 40, 24, 0.09), 0 4px 10px rgba(16, 40, 24, 0.1); }
.metric-card:active { transform: scale(0.98); }
.metric-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Nhấp nháy nhẹ khi vừa cuộn tới đúng mục, để người dùng biết đã "nhảy" đến
   đúng chỗ, nhất là với Trụ 3/4 nằm khá xa phía dưới trang. */
.panel.jump-flash { animation: jumpFlash 1s ease; }
@keyframes jumpFlash {
  0% { box-shadow: 0 0 0 3px var(--accent); }
  100% { box-shadow: var(--shadow); }
}
.metric-card.accent-green { border-top-color: var(--accent); }
.metric-card.accent-gold { border-top-color: var(--amber); }
.metric-card.accent-red { border-top-color: var(--red); }
.metric-card.accent-amber { border-top-color: var(--amber); }
.metric-label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
}
.metric-value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.metric-sub { font-size: 12px; color: var(--amber); margin-top: 4px; font-weight: 600; }
.accent-green .metric-value { color: var(--accent); }
.accent-gold .metric-value { color: var(--amber); }
.accent-red .metric-value { color: var(--red); }
.accent-amber .metric-value { color: var(--amber); }

/* ---------- Panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 20px 22px 8px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
}
.panel h2 {
  font-size: 15.5px;
  margin: 0 0 14px;
  font-weight: 700;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.col { min-width: 0; }

.chart-box { position: relative; height: 260px; margin-bottom: 12px; }
.chart-box.tall { height: 300px; }
.chart-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 0 20px;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 380px;
  margin-bottom: 18px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
thead th {
  position: sticky;
  top: 0;
  text-align: left;
  padding: 8px 10px;
  color: var(--text-muted);
  font-weight: 600;
  background: var(--panel);
  border-bottom: 1px solid var(--panel-border);
  white-space: nowrap;
  z-index: 1;
}
tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--panel-border);
  white-space: nowrap;
}
tbody tr:hover { background: var(--accent-soft); }
.table-empty {
  padding: 14px 4px;
  color: var(--text-muted);
  font-size: 13px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 4px 0 16px;
}
.pager-btn {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 13px;
  border-radius: 8px;
  cursor: pointer;
}
.pager-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.pager-btn:disabled { opacity: 0.4; cursor: default; }
.pager-info {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 600;
  min-width: 70px;
  text-align: center;
}

.status-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
}
.status-pending { background: #fbead0; color: #92400e; }
.status-success { background: #dff1e2; color: #0a804a; }
.status-cancel { background: #fee2e2; color: #991b1b; }
.status-unassigned { background: #e5e7eb; color: #374151; }
@media (prefers-color-scheme: dark) {
  .status-pending { background: #4a3a15; color: #f0c477; }
  .status-success { background: #16301f; color: #97c354; }
  .status-cancel { background: #431a1a; color: #fca5a5; }
  .status-unassigned { background: #2b2f3a; color: #d1d5db; }
}

.footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  margin-top: 8px;
  padding: 18px 0 4px;
}
.footer-logo { opacity: 0.85; }

/* ---------- Nút lên đầu trang ---------- */
.back-to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(16, 40, 24, 0.18), 0 6px 16px rgba(16, 40, 24, 0.16);
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}
.back-to-top.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.back-to-top:hover { opacity: 0.92; }
.back-to-top:active { transform: scale(0.94); }
.back-to-top:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 760px) {
  .back-to-top { right: 16px; bottom: 16px; width: 40px; height: 40px; font-size: 16px; }
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .only-mobile { display: flex; }
  .sidebar {
    position: fixed;
    z-index: 40;
    left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 0 0 0 rgba(0,0,0,0);
  }
  .sidebar.open { transform: translateX(0); box-shadow: 20px 0 40px rgba(0,0,0,0.25); }
  .sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 30;
  }
  .sidebar-backdrop.show { display: block; }
  .main { padding: 16px 14px 40px; }
  .metrics { grid-template-columns: 1fr 1fr; }
}
