:root {
  --bg: #f4f6f8; --card: #fff; --ink: #1c2530; --muted: #6b7785;
  --line: #e2e7ec; --brand: #2563eb; --ok: #16a34a; --warn: #d97706; --danger: #dc2626;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Noto Sans Thai", "Sarabun", -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.55;
}
body.center { display: flex; align-items: center; justify-content: center; min-height: 100vh; }

header {
  background: #fff; border-bottom: 1px solid var(--line); padding: 12px 20px;
  display: flex; align-items: center; gap: 24px; position: sticky; top: 0; z-index: 5;
}
.brand { font-size: 20px; font-weight: 700; color: var(--brand); text-decoration: none; letter-spacing: .5px; }
nav { display: flex; gap: 18px; }
nav a, a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
main { max-width: 1180px; margin: 20px auto 60px; padding: 0 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 16px; }
.card h2, .card h3 { margin: 0 0 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { text-align: center; color: var(--muted); font-size: 13px; }
.stat .num { display: block; font-size: 26px; font-weight: 700; color: var(--ink); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.inline { display: inline-flex; gap: 8px; align-items: center; margin: 0; }
button, .btnlink {
  background: var(--brand); color: #fff; border: 0; border-radius: 7px;
  padding: 9px 14px; font-size: 14px; cursor: pointer; font-family: inherit;
}
button:hover, .btnlink:hover { filter: brightness(1.08); text-decoration: none; }
button.secondary { background: #eef2f7; color: var(--ink); border: 1px solid var(--line); }
button.danger { background: var(--danger); }
button:disabled { opacity: .45; cursor: not-allowed; }
.btnlink { display: inline-block; background: #eef2f7; color: var(--ink); border: 1px solid var(--line); }
.btnlink.primary { background: var(--brand); color: #fff; }

input, select { font-family: inherit; font-size: 14px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); width: 100%; }
input[type=file] { padding: 6px; }
.toolbar input, .toolbar select { width: auto; min-width: 150px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-bottom: 8px; }
.grid label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.grid .full { grid-column: 1 / -1; }

table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .3px; }
td.r, th.r { text-align: right; } td.b { font-weight: 700; }
tbody tr:hover { background: #fafbfc; }
tr.attn { background: #fffbeb; }
tfoot td { font-weight: 600; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 600; background: #eef2f7; }
.tag.gift { background: #dcfce7; color: #15803d; }
.tag.winner { background: #dbeafe; color: #1d4ed8; }
.tag.unknown { background: #fee2e2; color: #b91c1c; }
.tag.exp { background: #fef3c7; color: #92400e; }
.tag.inc { background: #e0e7ff; color: #4338ca; }
.tag.oth { background: #f1f5f9; color: #64748b; }

td.acts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
td.acts input { width: 175px; }
td.acts button { padding: 7px 10px; font-size: 13px; }
td input { padding: 6px 8px; font-size: 13.5px; }
h4 { margin: 22px 0 6px; }

.ok { color: var(--ok); } .warn { color: var(--warn); } .muted { color: var(--muted); }
.center { text-align: center; }
.flash { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; }
.flash.error { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.flash.warnbox { background: #fffbeb; border-color: #fde68a; color: #92400e; }

.login { width: 340px; text-align: center; display: flex; flex-direction: column; gap: 12px; }
.login h1 { margin: 0; color: var(--brand); }
.login p { margin: 0; }

dl.meta { display: grid; grid-template-columns: 200px 1fr; gap: 6px 14px; margin: 16px 0; font-size: 14px; }
dl.meta dt { color: var(--muted); } dl.meta dd { margin: 0; }
.steps { margin: 8px 0; padding-left: 20px; } .steps li { margin-bottom: 8px; }
code, code.copy { background: #eef2f7; padding: 3px 7px; border-radius: 5px; font-size: 13px; word-break: break-all; }
pre.raw { background: #f8fafc; border: 1px solid var(--line); border-radius: 7px; padding: 12px;
  max-height: 380px; overflow: auto; white-space: pre-wrap; font-size: 12.5px; }
summary { cursor: pointer; font-weight: 600; }

@media (max-width: 640px) {
  dl.meta { grid-template-columns: 1fr; }
  table { display: block; overflow-x: auto; }
}
