@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700&display=swap');

:root {
  --sidebar-width: 220px;
  --sidebar-bg: #1a1f36;
  --sidebar-accent: #6366f1;
  --sidebar-accent-hover: #818cf8;
  --bg: #f0f2f8;
  --card-bg: #ffffff;
  --text-primary: #111827;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Kanit', 'Segoe UI', sans-serif;
  background: var(--bg);
  margin: 0;
  padding: 0;
  font-weight: 400;
}

/* ===================== SIDEBAR ===================== */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  z-index: 1000;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.sidebar-brand {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}
.sidebar-brand .brand-icon { font-size: 24px; margin-bottom: 4px; }
.sidebar-brand .brand-title {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  margin: 0;
  letter-spacing: 0.01em;
}
.sidebar-brand .brand-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  margin-top: 2px;
}

.sidebar-nav { flex: 1; padding: 8px 0 20px; }

.sidebar-section {
  padding: 14px 18px 5px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.28);
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px 9px 18px;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-size: 13.5px;
  margin: 1px 8px;
  border-radius: 8px;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.sidebar-item:hover {
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.92);
  text-decoration: none;
}
.sidebar-item.active {
  background: var(--sidebar-accent);
  color: #fff;
  font-weight: 500;
}
.sidebar-item .s-icon {
  font-size: 15px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

/* ===================== MAIN LAYOUT ===================== */
.main-wrap {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

.page-content { padding: 20px 24px 32px; }

/* ===================== SUB TABS ===================== */
.sub-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.sub-tab {
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-family: 'Kanit', sans-serif;
  border: 1px solid var(--border);
  background: #fff;
  color: #374151;
  text-decoration: none;
  transition: all 0.15s;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.sub-tab:hover { background: #f1f5f9; border-color: #cbd5e1; color: #374151; text-decoration: none; }
.sub-tab.active { background: var(--sidebar-accent); color: #fff; border-color: var(--sidebar-accent); }

/* ===================== CARDS ===================== */
.card {
  border-radius: var(--radius) !important;
  border: none !important;
  box-shadow: var(--shadow-sm) !important;
  background: var(--card-bg);
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid transparent;
  transition: transform 0.18s, box-shadow 0.18s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card.green  { border-left-color: #10b981; }
.stat-card.blue   { border-left-color: #6366f1; }
.stat-card.red    { border-left-color: #ef4444; }
.stat-card.amber  { border-left-color: #f59e0b; }
.stat-card.cyan   { border-left-color: #06b6d4; }

.stat-label {
  font-size: 11.5px;
  color: #9ca3af;
  margin-bottom: 5px;
  font-weight: 400;
  letter-spacing: 0.01em;
}
.stat-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

/* ===================== FILTER CARD ===================== */
.filter-card { padding: 16px 20px; margin-bottom: 16px; }
.filter-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 5px;
  display: block;
}

/* ===================== FORM CONTROLS ===================== */
.form-select, .form-control {
  border-radius: 8px !important;
  border: 1px solid #e2e8f0 !important;
  font-family: 'Kanit', sans-serif !important;
  font-size: 13px !important;
  color: var(--text-primary) !important;
  background-color: #fff !important;
  transition: border-color 0.15s, box-shadow 0.15s !important;
}
.form-select:focus, .form-control:focus {
  border-color: var(--sidebar-accent) !important;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12) !important;
  outline: none !important;
}
.form-select-sm, .form-control-sm {
  padding: 6px 10px !important;
  font-size: 13px !important;
}

/* ===================== BUTTONS ===================== */
.btn-clear {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #e5e7eb;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-family: 'Kanit', sans-serif;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-clear:hover { background: #e5e7eb; }

.btn-export {
  background: #10b981;
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-family: 'Kanit', sans-serif;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-export:hover { background: #059669; }

.btn { font-family: 'Kanit', sans-serif !important; }

/* ===================== TABLE ===================== */
.table {
  font-family: 'Kanit', sans-serif;
  font-size: 13.5px;
}
.table thead th {
  background: #f8fafc;
  font-weight: 600;
  font-size: 12.5px;
  color: #374151;
  border-bottom: 2px solid #e5e7eb !important;
  padding: 10px 12px !important;
  letter-spacing: 0.01em;
}
.table tbody td {
  padding: 9px 12px !important;
  border-color: #f3f4f6 !important;
  vertical-align: middle;
}
.table-hover tbody tr:hover { background: #f5f7ff !important; }
.table-sm tbody td, .table-sm thead th { padding: 7px 10px !important; }

/* ===================== CHART TAB ===================== */
.chart-tab {
  cursor: pointer;
  padding: 6px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-family: 'Kanit', sans-serif;
  border: 1px solid var(--border);
  background: #fff;
  color: #374151;
  transition: all 0.15s;
}
.chart-tab.active { background: var(--sidebar-accent); color: #fff; border-color: var(--sidebar-accent); }
.chart-tab:hover:not(.active) { background: #f1f5f9; border-color: #cbd5e1; }

/* ===================== MISC ===================== */
.clicked-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--sidebar-accent);
}
.section-header {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}
.badge.bg-warning { font-family: 'Kanit', sans-serif; }

/* Chart card hover */
.chart-card { cursor: pointer; transition: box-shadow 0.2s, transform 0.2s; }
.chart-card:hover { box-shadow: 0 6px 24px rgba(99,102,241,0.12) !important; transform: translateY(-2px); }

.chart-title { font-size: 14px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.chart-subtitle { font-size: 11.5px; color: #9ca3af; margin-bottom: 10px; }

/* Loading/Error */
.loading-msg { font-size: 13px; color: var(--text-muted); }
.error-msg { font-size: 13px; color: #ef4444; }

/* Badge pending */
.badge-pending {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-family: 'Kanit', sans-serif;
}

.row-pending   { background-color: #fffbeb !important; }
.row-confirmed { background-color: #ecfdf5 !important; }
.row-confirmed td { color: #065f46 !important; }

/* Responsive */
@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }
  .sidebar { transform: translateX(-220px); }
  .main-wrap { margin-left: 0; }
}
