:root {
  --brand: #0f766e;
  --brand-2: #14b8a6;
  --ink: #1e293b;
  --muted: #64748b;
  --bg: #f4f6f8;
  --side: #0f1f2e;
  --radius: 14px;
}
* { font-family: "Noto Sans Thai", system-ui, sans-serif; }
body { background: var(--bg); color: var(--ink); }

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

/* ---------- Sidebar ---------- */
.sidebar {
  width: 250px; background-color: var(--side) !important; color: #fff;
  --bs-offcanvas-width: 260px; --bs-offcanvas-bg: var(--side); --bs-offcanvas-color: #fff;
  display: flex; flex-direction: column; flex-shrink: 0;
}
@media (min-width: 992px) {
  .sidebar { position: sticky; top: 0; height: 100vh; }
}
.brand { display: flex; align-items: center; gap: .75rem; padding: 1.25rem 1.25rem 1rem; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
  display: grid; place-items: center; font-size: 1.3rem;
}
.brand-name { font-weight: 700; font-size: 1.05rem; line-height: 1.2; }
.brand-sub { font-size: .78rem; opacity: .6; }
.sidebar .nav { padding: .5rem .75rem; gap: 2px; flex-grow: 1; overflow-y: auto; }
.sidebar .nav-link {
  color: rgba(255,255,255,.72); border-radius: 10px; padding: .6rem .85rem;
  display: flex; align-items: center; gap: .75rem; font-size: .95rem;
}
.sidebar .nav-link i { font-size: 1.1rem; width: 1.2rem; text-align: center; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar .nav-link.active { background: var(--brand); color: #fff; }
.sidebar-user {
  display: flex; align-items: center; gap: .65rem; padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.08); font-size: .9rem;
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,.15);
  display: grid; place-items: center; font-weight: 600; flex-shrink: 0;
}

/* ---------- Content ---------- */
.content { flex-grow: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: .75rem; padding: 1rem 1.5rem;
  background: #fff; border-bottom: 1px solid #e5e7eb; position: sticky; top: 0; z-index: 10;
}
.page-title { font-size: 1.25rem; font-weight: 700; margin: 0; }
.page { padding: 1.5rem; max-width: 1400px; }
@media (max-width: 576px) { .page { padding: 1rem; } .topbar { padding: .75rem 1rem; } }

.card { border: 0; border-radius: var(--radius); box-shadow: 0 1px 3px rgba(15,23,42,.06); }
.card-header { background: #fff; border-bottom: 1px solid #eef0f3; font-weight: 600; border-radius: var(--radius) var(--radius) 0 0 !important; }

/* ---------- KPI cards ---------- */
.card.kpi { flex-direction: row; text-align: left; }
.kpi { padding: 1.1rem 1.2rem; display: flex; gap: 1rem; align-items: center; height: 100%; }
.kpi-icon {
  width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center;
  font-size: 1.35rem; flex-shrink: 0;
}
.kpi-label { color: var(--muted); font-size: .85rem; }
.kpi-value { font-size: 1.45rem; font-weight: 700; line-height: 1.2; }
.kpi-sub { font-size: .8rem; color: var(--muted); }
.t-green  { background: #dcfce7; color: #15803d; }
.t-blue   { background: #dbeafe; color: #1d4ed8; }
.t-red    { background: #fee2e2; color: #b91c1c; }
.t-amber  { background: #fef3c7; color: #b45309; }
.t-violet { background: #ede9fe; color: #6d28d9; }
.t-teal   { background: #ccfbf1; color: #0f766e; }

.quick a {
  display: flex; flex-direction: column; align-items: center; gap: .35rem;
  padding: .9rem .5rem; border-radius: 12px; background: #fff; text-decoration: none;
  color: var(--ink); font-size: .88rem; box-shadow: 0 1px 3px rgba(15,23,42,.06); height: 100%;
}
.quick a i { font-size: 1.5rem; color: var(--brand); }
.quick a:hover { background: #f0fdfa; }

/* ---------- Tables ---------- */
.table { margin: 0; }
.table thead th { font-size: .82rem; color: var(--muted); font-weight: 600; background: #f8fafc; white-space: nowrap; }
.table td { vertical-align: middle; }
.table tfoot td { font-weight: 700; background: #f8fafc; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

.btn-brand { background: var(--brand); color: #fff; border: 0; }
.btn-brand:hover { background: #115e59; color: #fff; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 1rem;
  background: radial-gradient(circle at 20% 20%, #134e4a 0, var(--side) 55%);
}
.login-card { width: 100%; max-width: 400px; padding: 2rem; }
.login-card .brand-mark { width: 56px; height: 56px; font-size: 1.7rem; color: #fff; margin: 0 auto 1rem; }

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .page { padding: 0; }
  .card { box-shadow: none; }
}
