/* Checkrace Flex — shared styles (Checkrace red CI) */
:root {
  --red: #E93735; --red-dark: #C42A28; --red-soft: #FDECEC;
  --ink: #14213D; --ink-2: #3D4A63; --muted: #6B7590; --line: #E4E7EE;
  --bg: #F6F7F9; --card: #FFFFFF; --ok: #1F9D55; --ok-soft: #E6F6EC; --warn: #D97706; --warn-soft: #FEF3E2; --bad: #C42A28;
  --radius: 14px; --shadow: 0 1px 2px rgba(20,33,61,.06), 0 8px 24px -12px rgba(20,33,61,.18);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: 'Sarabun', 'Kanit', system-ui, sans-serif; font-size: 16px; line-height: 1.6; color: var(--ink); background: var(--bg); }
h1, h2, h3, h4, .kanit { font-family: 'Kanit', 'Sarabun', sans-serif; font-weight: 600; line-height: 1.25; margin: 0 0 .4em; }
h1 { font-size: 2rem; } h2 { font-size: 1.4rem; } h3 { font-size: 1.1rem; }
p { margin: 0 0 .8em; }
a { color: var(--red-dark); }
.mono { font-family: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace; }
.muted { color: var(--muted); } .small { font-size: .875rem; } .tiny { font-size: .78rem; }
.svg { width: 1.1em; height: 1.1em; vertical-align: -.2em; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* layout */
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.nav { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.nav .wrap { display: flex; align-items: center; gap: 18px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-family: 'Kanit'; font-weight: 600; font-size: 1.15rem; }
.brand .mark { width: 34px; height: 34px; border-radius: 9px; background: var(--red); color: #fff; display: grid; place-items: center; font-weight: 700; letter-spacing: -.02em; }
.brand .tag { font-size: .7rem; font-weight: 500; background: var(--red-soft); color: var(--red-dark); padding: 2px 8px; border-radius: 999px; }
.nav-links { margin-left: auto; display: flex; gap: 4px; }
.nav-links a { text-decoration: none; color: var(--ink-2); padding: 8px 12px; border-radius: 8px; font-size: .95rem; }
.nav-links a:hover, .nav-links a.on { background: var(--bg); color: var(--ink); }
.hero { padding: 56px 0 36px; }
.hero h1 { font-size: 2.4rem; letter-spacing: -.01em; }
.hero .lead { font-size: 1.15rem; color: var(--ink-2); max-width: 720px; }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; font-family: 'Kanit'; font-size: .8rem; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--red-dark); margin-bottom: 10px; }
section { padding: 28px 0; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 860px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } .hero h1 { font-size: 1.8rem; } .nav-links { display: none; } }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card h3 { display: flex; align-items: center; gap: 8px; }
.card .ic { width: 38px; height: 38px; border-radius: 10px; background: var(--red-soft); color: var(--red-dark); display: grid; place-items: center; margin-bottom: 12px; }
.card .ic .svg { width: 20px; height: 20px; }
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi .v { font-family: 'Kanit'; font-size: 1.7rem; font-weight: 600; color: var(--ink); }
.kpi .l { font-size: .85rem; color: var(--muted); }

/* steps / tiers */
.steps { counter-reset: s; display: grid; gap: 14px; }
.step { display: grid; grid-template-columns: 44px 1fr; gap: 14px; align-items: start; }
.step::before { counter-increment: s; content: counter(s); width: 40px; height: 40px; border-radius: 50%; background: var(--ink); color: #fff; font-family: 'Kanit'; font-weight: 600; display: grid; place-items: center; }
.tier { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.tier .pct { font-family: 'Kanit'; font-size: 1.5rem; font-weight: 600; }
.tier.ok { border-color: #BFE7CD; background: var(--ok-soft); } .tier.ok .pct { color: var(--ok); }
.tier.mid { border-color: #F8D9A8; background: var(--warn-soft); } .tier.mid .pct { color: var(--warn); }
.tier.no { border-color: #F5C2C1; background: var(--red-soft); } .tier.no .pct { color: var(--bad); }
.tier.now { outline: 2px solid var(--ink); outline-offset: 2px; }

/* forms */
label { display: block; font-size: .85rem; font-weight: 500; color: var(--ink-2); margin-bottom: 4px; }
input, select, textarea { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(233,55,53,.25); border-color: var(--red); }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1; min-width: 160px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-family: 'Kanit'; font-weight: 500; font-size: .95rem; padding: 10px 18px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; text-decoration: none; transition: .15s; white-space: nowrap; }
.btn.primary { background: var(--red); color: #fff; } .btn.primary:hover { background: var(--red-dark); }
.btn.dark { background: var(--ink); color: #fff; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); } .btn.ghost:hover { background: var(--bg); }
.btn.sm { padding: 6px 12px; font-size: .85rem; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; font-weight: 500; padding: 2px 9px; border-radius: 999px; background: var(--bg); color: var(--ink-2); border: 1px solid var(--line); }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.bad { background: var(--red-soft); color: var(--bad); border-color: transparent; }
.chip.ink { background: var(--ink); color: #fff; border-color: transparent; }
.alert { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: #fff; display: flex; gap: 10px; align-items: flex-start; }
.alert.ok { background: var(--ok-soft); border-color: #BFE7CD; color: #14532D; }
.alert.warn { background: var(--warn-soft); border-color: #F8D9A8; color: #7C3E00; }
.alert.bad { background: var(--red-soft); border-color: #F5C2C1; color: #7F1D1D; }
.code-box { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 1.6rem; font-weight: 600; letter-spacing: .08em; background: var(--ink); color: #fff; padding: 16px 20px; border-radius: 12px; text-align: center; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-family: 'Kanit'; font-weight: 500; font-size: .8rem; color: var(--muted); background: var(--bg); position: sticky; top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl { overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; max-height: 70vh; }
tr:hover td { background: #FAFBFC; }

/* terms */
.terms h2 { font-size: 1.15rem; margin-top: 1.6em; padding-top: .6em; border-top: 1px solid var(--line); }
.terms ul { padding-left: 1.3em; } .terms li { margin-bottom: .35em; }
.terms strong { color: var(--ink); }

/* docs */
pre { background: #0F172A; color: #E2E8F0; padding: 14px 16px; border-radius: 10px; overflow: auto; font-size: .82rem; line-height: 1.5; }
code { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: .85em; background: var(--bg); padding: 1px 5px; border-radius: 4px; }
pre code { background: none; padding: 0; }
.diagram { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; align-items: stretch; }
.box { border: 1.5px solid var(--ink); border-radius: 12px; padding: 14px; background: #fff; }
.box h4 { margin: 0 0 6px; font-size: .95rem; }
.box ul { margin: 0; padding-left: 1.1em; font-size: .85rem; color: var(--ink-2); }
.box.red { border-color: var(--red); } .box.red h4 { color: var(--red-dark); }
.arrow { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .8rem; text-align: center; }
.toc a { display: block; padding: 4px 0; color: var(--ink-2); text-decoration: none; font-size: .9rem; }
.toc a:hover { color: var(--red-dark); }
footer { padding: 36px 0; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); margin-top: 40px; }

/* admin */
.admin { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 60px); }
.side { background: var(--ink); color: #fff; padding: 16px 10px; }
.side a { display: flex; align-items: center; gap: 10px; color: #CBD5E1; text-decoration: none; padding: 9px 12px; border-radius: 8px; font-size: .92rem; }
.side a:hover { background: rgba(255,255,255,.08); color: #fff; }
.side a.on { background: var(--red); color: #fff; }
.main { padding: 24px; min-width: 0; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }
.modal-bg { position: fixed; inset: 0; background: rgba(20,33,61,.45); display: none; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal-bg.open { display: flex; }
.modal { background: #fff; border-radius: 16px; width: min(720px, 100%); max-height: 90vh; overflow: auto; padding: 24px; }
.modal h3 { margin-bottom: 14px; }
@media (max-width: 860px) { .admin { grid-template-columns: 1fr; } .side { display: flex; overflow: auto; gap: 4px; padding: 8px; } .side a { white-space: nowrap; } }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: .9rem; opacity: 0; transition: .2s; pointer-events: none; z-index: 60; }
.toast.show { opacity: 1; }
