:root {
  --ink: #1e293b; --muted: #64748b; --line: #e2e8f0; --bg: #f8fafc; --card: #fff;
  --blue: #2563eb; --blue-l: #eff6ff; --green: #059669; --green-l: #ecfdf5; --red: #dc2626; --red-l: #fef2f2;
  --amber: #b45309; --amber-l: #fffbeb; --violet: #7c3aed; --violet-l: #f5f3ff;
  --r: 10px;
  font-family: "Leelawadee UI", "Noto Sans Thai", "Sarabun", system-ui, sans-serif;
  color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); font-size: 15px; line-height: 1.5; }
a { color: var(--blue); }
[hidden] { display: none !important; }

.top { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: #1f2a44; color: #fff; flex-wrap: wrap; position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 17px; white-space: nowrap; }
.brand .sub { font-weight: 400; font-size: 12px; opacity: .7; margin-left: 4px; }
nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
nav a { color: #cbd5e1; text-decoration: none; padding: 6px 12px; border-radius: 8px; font-size: 14px; }
nav a.on, nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.who { font-size: 13px; display: flex; gap: 10px; align-items: center; }
.who button { background: transparent; border: 1px solid rgba(255,255,255,.3); color: #fff; padding: 4px 10px; border-radius: 6px; cursor: pointer; font: inherit; font-size: 13px; }
.mode-bar { background: #fef3c7; color: #92400e; text-align: center; padding: 6px; font-size: 14px; font-weight: 600; }

main { max-width: 1080px; margin: 0 auto; padding: 22px 16px 60px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 10px; }
.lead { color: var(--muted); margin: 0 0 18px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: 13px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin-bottom: 14px; }
.step { display: inline-flex; width: 26px; height: 26px; border-radius: 50%; background: var(--blue); color: #fff; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; margin-right: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 720px) {
  .grid2 { grid-template-columns: 1fr; } .top { padding: 8px 12px; gap: 8px; } main { padding: 16px 12px 60px; }
  .brand .sub { display: none; } .who { margin-left: auto; } .who > span { display: none; }
  nav { order: 3; flex-basis: 100%; flex-wrap: nowrap; overflow-x: auto; } nav a { white-space: nowrap; }
}

label.f { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input[type=text], input[type=password], input[type=tel], input[type=number], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }
textarea { min-height: 120px; font-family: Consolas, monospace; font-size: 13px; }
.big-input { font-size: 22px !important; padding: 14px 16px !important; font-family: Consolas, monospace !important; letter-spacing: 1px; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px; border-radius: 8px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.green { background: var(--green); color: #fff; }
.btn.ghost { background: #fff; border-color: #cbd5e1; color: var(--ink); }
.btn.ghost:hover { background: #f1f5f9; }
.btn.danger { background: #fff; border-color: #fca5a5; color: var(--red); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; align-items: center; }

.drop { display: block; border: 2px dashed #93c5fd; background: var(--blue-l); border-radius: var(--r); padding: 28px; text-align: center; cursor: pointer; }
.drop.over { background: #dbeafe; }
.drop strong { display: block; font-size: 16px; margin-bottom: 4px; }

.note { border-radius: 8px; padding: 10px 14px; margin: 10px 0; font-size: 14px; }
.note.bad { background: var(--red-l); color: #991b1b; border: 1px solid #fecaca; }
.note.warn { background: var(--amber-l); color: #92400e; border: 1px solid #fde68a; }
.note.info { background: var(--blue-l); color: #1e40af; border: 1px solid #bfdbfe; }
.note.good { background: var(--green-l); color: #065f46; border: 1px solid #a7f3d0; }
.note ul { margin: 4px 0 0; padding-left: 20px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #f8fafc; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f8fafc; }
.tbl-wrap { overflow-x: auto; }
.mono { font-family: Consolas, monospace; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.pill.info { background: var(--blue-l); color: #1d4ed8; }
.pill.warn { background: var(--amber-l); color: var(--amber); }
.pill.bad { background: var(--red-l); color: var(--red); }
.pill.good { background: var(--green-l); color: var(--green); }
.age.over { color: var(--red); font-weight: 700; }

dl.kv { display: grid; grid-template-columns: 130px 1fr; gap: 4px 12px; margin: 0; font-size: 14px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }

.progress { display: flex; gap: 3px; margin: 12px 0; }
.progress div { flex: 1; text-align: center; font-size: 11px; padding-top: 18px; position: relative; color: var(--muted); }
.progress div::before { content: ''; position: absolute; top: 4px; left: 0; right: 0; height: 6px; border-radius: 3px; background: var(--line); }
.progress div.done::before { background: var(--green); }
.progress div.now { color: var(--ink); font-weight: 700; }
.progress div.now::before { background: var(--blue); }

.timeline { list-style: none; padding: 0; margin: 0; font-size: 13.5px; }
.timeline li { padding: 6px 0 6px 16px; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ''; position: absolute; left: -5px; top: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }
.timeline time { color: var(--muted); font-size: 12px; margin-right: 6px; }

.copybox { white-space: pre-wrap; background: #f1f5f9; border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-size: 13.5px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #1e293b; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 20; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 90vw; }
.toast.bad { background: var(--red); }
dialog { border: none; border-radius: 12px; padding: 0; max-width: 760px; width: calc(100% - 24px); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15,23,42,.45); }
#dlgBody { padding: 20px; max-height: 85vh; overflow: auto; }
.login { max-width: 380px; margin: 8vh auto 0; }
.login .card { padding: 26px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.filters > * { width: auto; flex: 1 1 180px; }
.stat-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.stat { flex: 1 1 140px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; }
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 12.5px; color: var(--muted); }
