:root {
  --bg: #f6f3ec; --card: #fff; --ink: #1d2320; --muted: #6b716c; --line: #e3ddd0;
  --brand: #1f5c3f; --brand-2: #174631; --gold: #d9b24a; --gold-soft: #fbf3dc;
  --ok: #15803d; --err: #b91c1c; --warn: #a16207; --radius: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 'Sarabun', system-ui, sans-serif; }
a { color: var(--brand); }
h1 { font-size: 1.55rem; margin: .2rem 0 .8rem; line-height: 1.3; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
code { background: #f1ede3; padding: 0 .3em; border-radius: 4px; font-size: .92em; word-break: break-all; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.main { padding-top: 18px; padding-bottom: 40px; min-height: 70vh; }
.muted { color: var(--muted); }
.tiny { font-size: .85rem; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.okc { color: var(--ok); } .errc { color: var(--err); }

/* header */
.top { background: linear-gradient(90deg, var(--brand-2), var(--brand)); color: #fff; border-bottom: 3px solid var(--gold); }
.top-in { display: flex; align-items: center; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.brand { display: flex; gap: 10px; align-items: center; color: #fff; text-decoration: none; }
.brand img { background: #fff; border-radius: 50%; padding: 2px; }
.brand span { display: flex; flex-direction: column; line-height: 1.2; }
.brand small { opacity: .85; font-size: .78rem; }
.nav { display: flex; gap: 4px; align-items: center; margin-left: auto; flex-wrap: wrap; }
.nav a { color: #fff; text-decoration: none; padding: 6px 11px; border-radius: 8px; font-size: .95rem; }
.nav a:hover { background: rgba(255,255,255,.12); }
.nav a.on { background: rgba(255,255,255,.18); }
.nav a.cta { background: var(--gold); color: #2b2205; font-weight: 600; }
.who { display: flex; align-items: center; gap: 6px; margin-left: 8px; padding-left: 10px; border-left: 1px solid rgba(255,255,255,.3); font-size: .9rem; }
.who form { margin: 0; }
.who .link { color: #fff; opacity: .8; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 1px solid rgba(255,255,255,.4); color: #fff; font-size: 1.3rem; border-radius: 8px; padding: 2px 10px; }
@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .nav { display: none; width: 100%; flex-direction: column; align-items: stretch; padding-bottom: 10px; }
  .nav-open .nav { display: flex; }
  .who { margin: 6px 0 0; border: 0; padding: 0 11px; }
}
.foot { color: var(--muted); font-size: .8rem; padding: 18px 16px 30px; text-align: center; }

/* cards & layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; box-shadow: 0 1px 2px rgba(40,30,0,.04); }
.card.empty { text-align: center; color: var(--muted); padding: 30px; }
.card.notice { display: block; background: var(--gold-soft); border-color: #ecd99a; text-decoration: none; color: #5b4708; }
.narrow { max-width: 640px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }
.head-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.head-row h1 { margin-bottom: 0; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.row-btns form { margin: 0; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: .95rem; padding: 8px 15px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); text-decoration: none; cursor: pointer; min-height: 40px; }
.btn:hover { border-color: #cfc6b3; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.sm { padding: 3px 10px; min-height: 30px; font-size: .85rem; }
.btn.block { width: 100%; margin-top: 10px; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer; text-decoration: underline; }
.link.danger { color: var(--err); }

/* alerts & badges */
.alert { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; border: 1px solid; }
.alert.ok { background: #ecfdf3; border-color: #a7e3bd; color: #14532d; }
.alert.err { background: #fef2f2; border-color: #f5b5b5; color: #7f1d1d; }
.alert.warn { background: #fffbeb; border-color: #f3d58b; color: #713f12; }
.badge { display: inline-block; font-size: .78rem; padding: 1px 9px; border-radius: 99px; font-weight: 600; white-space: nowrap; vertical-align: middle; }
.st-pending { background: #fef3c7; color: #92400e; }
.st-approved { background: #dcfce7; color: #166534; }
.st-rejected { background: #fee2e2; color: #991b1b; }
.st-cancelled { background: #eee; color: #666; text-decoration: line-through; }
.kind { display: inline-block; font-size: .85rem; font-weight: 600; color: var(--k); background: color-mix(in srgb, var(--k) 10%, white); padding: 1px 9px; border-radius: 99px; white-space: nowrap; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin: 6px 0 16px; }
@media (max-width: 900px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 480px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { --k: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; border-top: 4px solid var(--k); }
.stat.ok { --k: var(--ok); }
.stat span { display: block; font-size: .85rem; color: var(--muted); }
.stat b { font-size: 1.9rem; line-height: 1.2; color: var(--k); font-variant-numeric: tabular-nums; }
.kh { color: var(--k); }
.kh small { color: var(--muted); font-weight: 400; font-size: .85rem; margin-left: 4px; }
ul.away { list-style: none; margin: 0; padding: 0; }
ul.away li { padding: 8px 0; border-top: 1px solid #f0ece2; }
ul.away li:first-child { border-top: 0; }
ul.away a { text-decoration: none; color: var(--ink); }
ul.away .sub { font-size: .88rem; color: var(--muted); }
ul.mini { list-style: none; padding: 0; margin: 0; }
ul.mini li { padding: 5px 0; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
ul.mini a { text-decoration: none; }
.sumtext { width: 100%; font: .85rem/1.45 'Sarabun', sans-serif; border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: #fbfaf6; resize: vertical; }
.datenav { display: flex; gap: 6px; align-items: center; }
.datenav input { min-height: 40px; }

/* forms */
.form label { display: block; margin-bottom: 10px; font-weight: 500; font-size: .95rem; }
.form label.inline { display: flex; gap: 8px; align-items: baseline; font-weight: 400; }
input, select, textarea { font: inherit; color: inherit; }
.form input:not([type=checkbox]):not([type=radio]):not([type=file]), .form select, .form textarea, .filters input, .filters select {
  display: block; width: 100%; margin-top: 3px; padding: 8px 11px; border: 1px solid #d6cfbf; border-radius: 9px; background: #fff; min-height: 42px; }
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px 4px; margin: 0 0 14px; min-width: 0; }
fieldset.card { padding: 14px 18px 8px; }
legend { font-weight: 700; padding: 0 6px; color: var(--brand-2); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr .7fr; gap: 0 14px; }
@media (max-width: 600px) { .row2, .row3 { grid-template-columns: 1fr; } }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters > * { width: auto !important; flex: 0 1 auto; margin: 0 !important; }
.filters input[type=search] { min-width: 200px; }
.filters label { display: flex; gap: 6px; align-items: center; margin: 0; }
.who-line { background: #f7f4ec; border-radius: 9px; padding: 8px 12px; }
.kinds { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
@media (max-width: 600px) { .kinds { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kindopt input { position: absolute; opacity: 0; }
.kindopt span { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 6px; border: 2px solid var(--line); border-radius: var(--radius); cursor: pointer; font-weight: 600; text-align: center; background: #fff; }
.kindopt i { font-style: normal; font-size: 1.6rem; }
.kindopt input:checked + span { border-color: var(--k); background: color-mix(in srgb, var(--k) 9%, white); color: var(--k); }
.kindopt input:focus-visible + span { outline: 2px solid var(--k); }
.checklist { max-height: 240px; overflow: auto; border: 1px solid var(--line); border-radius: 9px; padding: 6px 10px; margin: 6px 0; columns: 2 260px; }
.checklist label { font-weight: 400; margin: 0; padding: 3px 0; break-inside: avoid; display: flex; gap: 6px; align-items: baseline; }
.filter { margin-top: 0 !important; }
.support { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 18px; }
@media (max-width: 700px) { .support { grid-template-columns: 1fr; } }
.support label { font-weight: 400; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.support input.sm { width: 110px !important; display: inline-block !important; min-height: 34px !important; margin: 0 !important; padding: 4px 8px !important; }
.support input.md { width: 160px !important; display: inline-block !important; min-height: 34px !important; margin: 0 !important; padding: 4px 8px !important; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 99px; cursor: pointer; font-weight: 500; }
.seg input:checked + span { background: var(--brand); color: #fff; border-color: var(--brand); }
.box { background: #f7f4ec; border-radius: 9px; padding: 10px 12px; margin: 6px 0 10px; }
.sel { user-select: all; }
.sticky-save { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 14px 0 6px; }

/* tables */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .93rem; }
.tbl th, .tbl td { padding: 7px 8px; border-bottom: 1px solid #efeadf; text-align: left; vertical-align: top; }
.tbl th { font-weight: 600; color: var(--muted); font-size: .85rem; background: #faf8f3; }
.tbl.compact td, .tbl.compact th { padding: 4px 6px; }
.tbl td.clip { max-width: 320px; }
.tbl tr.inactive td { opacity: .5; }
.tbl .num { text-align: center; font-variant-numeric: tabular-nums; }
.tbl .b { font-weight: 700; }
.tbl .small { font-size: .85rem; }
.rep th { text-align: center; border: 1px solid #e6e0d2; }
.rep td { border-left: 1px solid #f2eee5; }
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
@media (max-width: 520px) { .dl { grid-template-columns: 1fr; } .dl dd { margin-bottom: 6px; } }
.olist { margin: 0; padding-left: 1.3em; }

.login { max-width: 400px; margin: 30px auto; text-align: center; }
.login .form { text-align: left; margin-top: 12px; }

@media print {
  .top, .foot, .noprint, .filters { display: none !important; }
  body { background: #fff; font-size: 12pt; }
  .card { border: 0; box-shadow: none; padding: 0; }
  .wrap { max-width: none; }
  .tbl th, .tbl td { border: 1px solid #999; padding: 3px 5px; }
}
