* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: #0B0F14; height: 100%; }
body {
  color: #E8EDF2;
  font-family: 'Noto Sans Thai', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #232B36; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }
input::placeholder { color: #55606E; }
button, input { font-family: inherit; outline: none; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulseDot { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } }

.screen { animation: fadeIn 0.35s ease; }

.app-shell { display: flex; min-height: 100vh; background: #0B0F14; color: #E8EDF2; }

/* ---- Sidebar ---- */
.sidebar {
  width: 236px; flex-shrink: 0; background: #0D1117; border-right: 1px solid #1C232D;
  padding: 20px 12px; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 22px 8px; }
.sidebar-logo {
  width: 32px; height: 32px; border-radius: 8px; background: #16A34A22;
  display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0;
}
.sidebar-title { font-size: 14px; font-weight: 800; letter-spacing: 0.1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-sub { font-size: 10.5px; color: #5B6472; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  cursor: pointer; color: #C7D0DB; font-weight: 500;
}
.nav-item:hover { background: #12171F; }
.nav-item.active { font-weight: 700; }
.nav-icon { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }
.nav-label { flex: 1; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Main ---- */
.main { flex: 1; padding: 32px 40px 60px 40px; overflow-y: auto; height: 100vh; min-width: 0; }
.page-header { margin-bottom: 26px; }
.page-header.with-action, .page-header.with-search { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; gap: 20px; flex-wrap: wrap; }
.page-title { font-size: 23px; font-weight: 800; }
.page-sub { font-size: 13.5px; color: #8A97A8; margin-top: 4px; }

.card {
  background: #12171F; border: 1px solid #1E2530; border-radius: 14px; padding: 20px;
}
[data-card] { transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease; }
[data-card]:hover { border-color: #38475A; transform: translateY(-2px); box-shadow: 0 10px 30px rgba(0,0,0,0.4); }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.search-input {
  background: #12171F; border: 1px solid #232B36; border-radius: 9px; padding: 10px 14px;
  color: #E8EDF2; font-size: 13.5px; width: 260px;
}

.chip-row { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.chip {
  padding: 8px 16px; border-radius: 20px; font-size: 13px; font-weight: 600; cursor: pointer;
  background: transparent; color: #8A97A8; border: 1px solid #232B36; white-space: nowrap;
}
.chip.active { border-width: 1px; }
.chip-square {
  padding: 7px 14px; border-radius: 8px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  background: transparent; color: #8A97A8; border: 1px solid #232B36;
}

.table-wrap { background: #12171F; border: 1px solid #1E2530; border-radius: 14px; overflow: hidden; }
.table-head {
  display: grid; gap: 10px; padding: 13px 20px; font-size: 11.5px; color: #7C8794;
  text-transform: uppercase; letter-spacing: 0.4px; border-bottom: 1px solid #1E2530;
}
.table-row { display: grid; gap: 10px; padding: 14px 20px; font-size: 13.5px; border-bottom: 1px solid #171C24; align-items: center; }
.table-empty { padding: 40px; text-align: center; color: #5B6472; font-size: 13.5px; }
.text-right { text-align: right; }
.tabular { font-variant-numeric: tabular-nums; }

.btn {
  border: none; border-radius: 10px; padding: 11px 22px; font-size: 13.5px; font-weight: 700;
  cursor: pointer; white-space: nowrap; transition: filter .15s ease, transform .15s ease;
}
.btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-ghost {
  background: #12171F; color: #E8EDF2; border: 1px solid #2A3442; font-weight: 600;
}
.btn-ghost:hover { border-color: #3A4756; }

.toggle-track { width: 42px; height: 24px; border-radius: 12px; position: relative; cursor: pointer; transition: background .15s; flex-shrink: 0; }
.toggle-thumb { width: 18px; height: 18px; border-radius: 50%; background: #fff; position: absolute; top: 3px; transition: left .15s; }

.theme-swatch { width: 34px; height: 34px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; }

.pill-option {
  padding: 9px 18px; border-radius: 8px; font-size: 13.5px; font-weight: 600; cursor: pointer;
  background: #0D1117; color: #8A97A8; border: 1px solid #232B36;
}

.donut { border-radius: 50%; flex-shrink: 0; }

.settings-section { background: #12171F; border: 1px solid #1E2530; border-radius: 14px; padding: 22px; }
.settings-title { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.settings-desc { font-size: 12.5px; color: #8A97A8; margin-bottom: 16px; }
.notif-row { display: flex; align-items: center; justify-content: space-between; padding: 13px 0; border-bottom: 1px solid #171C24; }
.notif-row:last-child { border-bottom: none; }

.bar-chart { display: flex; align-items: flex-end; gap: 10px; height: 120px; }
.bar-chart-tall { height: 130px; }
.bar-col { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.bar-fill { width: 100%; border-radius: 3px 3px 0 0; transition: height .6s ease; }
.bar-labels { display: flex; gap: 10px; margin-top: 8px; }
.bar-label { flex: 1; text-align: center; font-size: 10.5px; color: #5B6472; }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn {
  width: 28px; height: 28px; border-radius: 7px; background: #161B22; border: 1px solid #232B36;
  color: #8A97A8; cursor: pointer; font-size: 13px; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { border-color: #3A4756; color: #E8EDF2; }

#modal-root { display: none; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5, 8, 12, 0.65); display: flex;
  align-items: center; justify-content: center; z-index: 1000; padding: 20px;
}
.modal-card {
  width: 100%; max-width: 440px; background: #12171F; border: 1px solid #232B36; border-radius: 16px;
  padding: 26px; max-height: 90vh; overflow-y: auto;
}
.modal-title { font-size: 16px; font-weight: 800; margin-bottom: 4px; }
.modal-subtitle { font-size: 12px; color: #8A97A8; margin-bottom: 18px; }
.form-grid { display: flex; flex-direction: column; gap: 12px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: #8A97A8; }
.form-field input, .form-field select {
  background: #0D1117; border: 1px solid #232B36; border-radius: 9px; padding: 10px 12px;
  color: #E8EDF2; font-size: 13.5px;
}
.form-field select:disabled { opacity: 0.6; cursor: not-allowed; }
.form-hint { font-size: 11px; color: #5B6472; margin-top: -6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

@media print {
  @page { margin: 0.5cm; }
  figure, table { break-inside: avoid; }
  .sidebar { display: none; }
  .main { height: auto; overflow: visible; }
}
