:root {
  --ktam-primary: #0d3b66;
  --ktam-accent: #1976d2;
  --ktam-bg: #f4f6f9;
  --sidebar-w: 250px;
}

html { font-size: 14px; }
@media (min-width: 768px) { html { font-size: 15px; } }

body {
  background: var(--ktam-bg);
  font-family: 'Segoe UI', 'Leelawadee UI', Tahoma, sans-serif;
  margin: 0;
}

/* ===== Layout ===== */
.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--ktam-primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.15);
}
.brand-logo {
  width: 38px; height: 38px;
  background: #fff; color: var(--ktam-primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.3rem;
}
.brand-name { font-weight: 700; font-size: .95rem; }
.brand-sub { font-size: .75rem; opacity: .7; }

.sidebar-nav { flex: 1; padding: 12px 8px; }
.sidebar-nav .nav-item {
  display: flex; align-items: center; gap: 10px;
  color: rgba(255,255,255,.85);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 4px;
  font-size: .92rem;
}
.sidebar-nav .nav-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-nav .nav-item.active { background: var(--ktam-accent); color: #fff; font-weight: 600; }
.nav-icon { font-size: 1.05rem; }

.sidebar-footer {
  padding: 12px 16px;
  font-size: .72rem;
  opacity: .6;
  border-top: 1px solid rgba(255,255,255,.15);
}

.main-content { flex: 1; padding: 24px 28px; min-width: 0; }

/* ===== Cards / stats ===== */
.page-title { font-weight: 700; color: var(--ktam-primary); margin-bottom: 4px; }
.page-sub { color: #6c757d; font-size: .88rem; margin-bottom: 20px; }

.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  height: 100%;
}
.stat-label { font-size: .8rem; color: #6c757d; margin-bottom: 4px; }
.stat-value { font-size: 1.7rem; font-weight: 700; color: var(--ktam-primary); }
.stat-value.text-success { color: #198754 !important; }
.stat-value.text-danger { color: #dc3545 !important; }

.panel {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  margin-bottom: 20px;
}
.panel-title { font-weight: 700; color: var(--ktam-primary); font-size: 1rem; margin-bottom: 14px; }

/* ===== Tables ===== */
.table-sm td, .table-sm th { font-size: .85rem; vertical-align: middle; }
.badge-method {
  font-family: Consolas, monospace;
  font-size: .7rem;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 700;
}
.badge-get { background: #e3f2fd; color: #1565c0; }
.badge-post { background: #e8f5e9; color: #2e7d32; }
.badge-put { background: #fff3e0; color: #ef6c00; }
.badge-delete { background: #ffebee; color: #c62828; }

.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.status-dot.on { background: #22c55e; }
.status-dot.off { background: #adb5bd; }

.code-block {
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 14px;
  font-family: Consolas, monospace;
  font-size: .8rem;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 420px;
  overflow: auto;
}

.tier-badge { font-size: .68rem; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.tier-front { background: #e0f2fe; color: #0369a1; }
.tier-back { background: #ede9fe; color: #6d28d9; }

.form-switch .form-check-input { cursor: pointer; }
.chart-canvas { width: 100%; height: 240px; }

@media (max-width: 768px) {
  .app-wrapper { flex-direction: column; }
  .sidebar { width: 100%; min-width: 100%; height: auto; position: static; }
  .main-content { padding: 16px; }
}
