/* Tender pages: colours (light / dark) and shared pieces. ui.css (touch sizes, dialogs) loads after this. */
:root {
  --bg: #f6f7f9; --card: #fff; --text: #1d2330; --muted: #5d6675; --line: #dde1e7; --accent: #1f5fbf; --chip: #e8eefa;
  --ok: #1a7f56; --okbg: #e3f5ec; --warn: #9a5b00; --warnbg: #fdf1dc; --bad: #b42318; --badbg: #fde8e6; --lock: #6a4fc0; --lockbg: #efeafb;
  --g-open: #1f9d6b; --g-wait: #d9822b; --g-done: #3b6fd8; --g-draft: #7b8494; --g-off: #a0a7b2;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171c; --card: #1d2128; --text: #e6e9ee; --muted: #9aa3b0; --line: #2e343d; --accent: #6fa3ff; --chip: #23314a;
    --ok: #4cc38a; --okbg: #17352a; --warn: #f2b45c; --warnbg: #3a2c14; --bad: #ff7b6e; --badbg: #3d1d1a; --lock: #b4a2f0; --lockbg: #2c2545; color-scheme: dark; }
}
:root[data-theme="dark"] {
  --bg: #14171c; --card: #1d2128; --text: #e6e9ee; --muted: #9aa3b0; --line: #2e343d; --accent: #6fa3ff; --chip: #23314a;
  --ok: #4cc38a; --okbg: #17352a; --warn: #f2b45c; --warnbg: #3a2c14; --bad: #ff7b6e; --badbg: #3d1d1a; --lock: #b4a2f0; --lockbg: #2c2545; color-scheme: dark; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15.5px/1.55 "Sarabun", "Leelawadee UI", Tahoma, "Noto Sans Thai", system-ui, sans-serif; }
/* Windows PCs are the main screens: wider pages from 1000px; phones keep the single column */
@media (min-width: 1000px) { body { font-size: 16px; } main { max-width: 1240px !important; } }
main { max-width: 760px; margin: 0 auto; padding-block: 16px 64px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
main.wide { max-width: 1100px; }
h1 { font-size: 1.4rem; margin: 0; text-wrap: balance; }
h2 { font-size: .82rem; letter-spacing: .04em; color: var(--muted); margin: 20px 0 8px; font-weight: 600; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }
.row { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.btn { display: inline-flex; justify-content: center; align-items: center; gap: 6px; min-height: 44px; padding: 8px 16px; border-radius: 12px;
  border: 1px solid transparent; background: var(--accent); color: #fff; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; }
.btn.full { width: 100%; min-height: 50px; font-size: 1.02rem; }
.btn.ghost { background: var(--card); color: var(--accent); border-color: var(--line); }
.btn.danger { background: var(--bad); }
.btn.ghost.danger { background: var(--card); color: var(--bad); }
.btn:disabled { opacity: .5; }
.pill { display: inline-flex; align-items: center; min-height: 36px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--accent); font: inherit; font-weight: 600; font-size: .88rem; cursor: pointer; text-decoration: none; }
.st { display: inline-flex; align-items: center; gap: 4px; font-size: .8rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.st.open { background: var(--okbg); color: var(--ok); } .st.wait { background: var(--warnbg); color: var(--warn); }
.st.done { background: var(--chip); color: var(--accent); } .st.draft { background: var(--line); color: var(--muted); }
.st.off { background: var(--line); color: var(--muted); text-decoration: line-through; } .st.lock { background: var(--lockbg); color: var(--lock); }
label { display: block; font-size: .85rem; font-weight: 600; margin: 10px 0 4px; }
input:not([type=checkbox]):not([type=radio]), select, textarea { width: 100%; font: inherit; font-size: 1rem; padding: 9px 12px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); min-height: 44px; }
textarea { min-height: 72px; resize: vertical; }
input.good { border-color: var(--ok); } input.badf { border-color: var(--bad); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.note { font-size: .8rem; margin-top: 4px; color: var(--muted); }
.note.ok { color: var(--ok); } .note.bad { color: var(--bad); }
.lockbox { background: var(--lockbg); color: var(--lock); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.okbox { background: var(--okbg); color: var(--ok); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.warnbox { background: var(--warnbg); color: var(--warn); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.badbox { background: var(--badbg); color: var(--bad); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.empty { color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: 12px; padding: 16px; text-align: center; }
.offline { display: none; background: var(--warnbg); color: var(--warn); text-align: center; font-size: .85rem; padding: 6px; }
body.is-offline .offline { display: block; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.bar { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 8px; padding: max(8px, env(safe-area-inset-top, 0px)) 12px 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.bar .ttl { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 900; background: #1d2330; color: #fff;
  padding: 10px 16px; border-radius: 12px; font-size: .92rem; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: calc(100% - 32px); }
@media print { .bar, .noprint, .offline { display: none !important; } body { background: #fff; color: #000; } }
