:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e2ef;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --accent: #b7791f;
  --danger: #b42318;
  --ok: #047857;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Tahoma, "Noto Sans Thai", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}
a { color: var(--brand-dark); text-decoration: none; }
.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  background: #103b3a;
  color: #fff;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { font-weight: 700; font-size: 18px; line-height: 1.3; margin: 4px 8px 18px; }
.brand small { display: block; font-weight: 400; color: #bfe3df; font-size: 12px; margin-top: 4px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #e9fffb;
  padding: 10px 11px;
  border-radius: 6px;
  margin-bottom: 4px;
}
.nav a.active, .nav a:hover { background: rgba(255,255,255,.12); }
.main { min-width: 0; }
.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 14px 22px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}
.content { padding: 22px; max-width: 1500px; }
h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: 0; }
h2 { font-size: 18px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.grid { display: grid; gap: 14px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.panel, .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 6px; }
.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; }
.btn, button {
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  padding: 9px 13px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  display: inline-flex;
  gap: 7px;
  align-items: center;
}
.btn.secondary { background: #475467; }
.btn.light { background: #edf5f4; color: var(--brand-dark); border: 1px solid #badbd7; }
.btn.danger { background: var(--danger); }
.btn.small { padding: 6px 9px; font-size: 12px; }
input, select, textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 9px 10px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
}
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-weight: 600; margin-bottom: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { border-bottom: 1px solid var(--line); padding: 10px; text-align: left; vertical-align: top; }
th { color: #334155; font-size: 12px; background: #f1f5f9; }
.num { text-align: right; white-space: nowrap; }
.status {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 8px;
  background: #e9f5f3;
  color: var(--brand-dark);
  font-size: 12px;
  white-space: nowrap;
}
.status.warn { background: #fff4d6; color: #92400e; }
.status.bad { background: #fee4e2; color: var(--danger); }
.notice {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #bae6fd;
  background: #eff8ff;
  color: #075985;
  margin-bottom: 14px;
}
.error { border-color: #fecaca; background: #fff1f2; color: var(--danger); }
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #eef8f7, #f8fafc);
  padding: 22px;
}
.login-box { width: min(480px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 26px; }
.line-items { display: grid; gap: 8px; }
.line-row { display: grid; grid-template-columns: 1.5fr 2fr 160px 44px; gap: 8px; align-items: end; }
.ledger-head { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.ledger-head div { background: #f8fafc; border: 1px solid var(--line); border-radius: 6px; padding: 10px; }
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .grid.cols-4, .grid.cols-3, .form-grid, .ledger-head { grid-template-columns: 1fr; }
  .line-row { grid-template-columns: 1fr; }
  .content { padding: 14px; }
  .topbar { align-items: flex-start; flex-direction: column; }
}

