/* CodeForge Connect — one stylesheet for the LINE pages, the back office and documents.
   Same tokens as codeforge.co.th: black/white/grey with one blue. */

:root {
  --bg: #ffffff;
  --bg-subtle: #f7f7f8;
  --fg: #111111;
  --muted: #555555;
  --faint: #8a8a8a;
  --line: #e6e6e6;
  --line-strong: #cfcfcf;
  --accent: #0062cc;
  --accent-soft: #e8f2ff;
  --green: #12804a; --green-soft: #e7f6ee;
  --amber: #a15c00; --amber-soft: #fff4e0;
  --red: #c62828; --red-soft: #fdecec;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 20px rgba(0,0,0,.05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg-subtle); color: var(--fg);
  font: 16px/1.65 "Anuphan", "Geist", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.3; margin: 0; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
img { max-width: 100%; }
.icon { width: 20px; height: 20px; flex: none; }
.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: .875rem; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 20px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grid2 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ── cards & lists ─────────────────────────────────────── */
.card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card-tight { padding: 0; overflow: hidden; }
.card h2 + *, .card h3 + * { margin-top: 10px; }
.section-title { font-size: .8rem; font-weight: 600; color: var(--faint); letter-spacing: .04em; margin: 22px 4px 8px; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--line); }
.list a.item, .list .item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; color: inherit; }
.list a.item:hover { background: var(--bg-subtle); text-decoration: none; }
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; }
.item .sub { color: var(--muted); font-size: .875rem; display: block; }
.chev { color: var(--faint); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: .95rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 500; }
.empty { text-align: center; color: var(--muted); padding: 28px 16px; }

/* ── buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--bg); color: var(--fg); font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none !important; transition: opacity .15s, background .15s;
}
.btn:hover { background: var(--bg-subtle); }
.btn-primary { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.btn-primary:hover { background: var(--fg); opacity: .85; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent); opacity: .9; }
.btn-danger { color: var(--red); border-color: #efc4c4; }
.btn-line { background: #06c755; border-color: #06c755; color: #fff; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: .875rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-busy { opacity: .55; pointer-events: none; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }

/* ── forms ─────────────────────────────────────────────── */
.field { display: block; }
.field > span { display: block; font-weight: 600; font-size: .925rem; margin-bottom: 6px; }
.field > span small { font-weight: 400; color: var(--faint); }
.req { color: var(--accent); }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=password],
input[type=date], input[type=datetime-local], input[type=url], input[type=search], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--bg); color: var(--fg); font: inherit; font-size: 16px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=file] { font: inherit; font-size: .9rem; max-width: 100%; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .95rem; }
.check input { margin-top: 5px; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.field-error { color: var(--red); font-size: .85rem; margin-top: 4px; }
.hint { color: var(--muted); font-size: .85rem; margin-top: 4px; }
.upload { display: block; border: 1.5px dashed var(--line-strong); border-radius: 12px; padding: 14px; text-align: center; color: var(--muted); cursor: pointer; background: var(--bg); }
.upload:hover { border-color: var(--accent); }
.upload input { display: block; margin: 8px auto 0; }
.choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(52px, 1fr)); gap: 8px; }
.choice label { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; }
.choice span { display: block; text-align: center; padding: 10px 6px; border: 1px solid var(--line-strong); border-radius: 10px; font-weight: 600; cursor: pointer; background: var(--bg); }
.choice input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.choice input:focus-visible + span { outline: 2px solid var(--accent); }

/* ── badges & alerts ───────────────────────────────────── */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge-blue { background: var(--accent-soft); color: var(--accent); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-gray { background: #eeeeee; color: #555; }
.alert { border-radius: 12px; padding: 12px 14px; font-size: .95rem; border: 1px solid transparent; }
.alert-success { background: var(--green-soft); color: #0c5a34; border-color: #c7ead8; }
.alert-error { background: var(--red-soft); color: #8e1c1c; border-color: #f3c9c9; }
.alert-warning { background: var(--amber-soft); color: #6d3e00; border-color: #f4dcb0; }
.alert-info { background: var(--accent-soft); color: #00478f; border-color: #c9defa; }
.flash { margin-bottom: 14px; }

/* ── LINE (LIFF) layout ────────────────────────────────── */
.liff { max-width: 560px; margin: 0 auto; min-height: 100vh; padding-bottom: 40px; }
.liff-top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; height: 56px; padding: 0 12px; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.liff-top h1 { font-size: 1.05rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.liff-top .back { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 999px; color: var(--fg); }
.liff-top .back:hover { background: var(--bg-subtle); }
.liff-main { padding: 16px; }
.hello { display: flex; align-items: center; gap: 12px; }
.hello img, .avatar { width: 48px; height: 48px; border-radius: 999px; object-fit: cover; background: var(--line); flex: none; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; aspect-ratio: 1 / .92; padding: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); color: var(--fg); font-size: .875rem; font-weight: 600; text-align: center; line-height: 1.3; position: relative; }
.tile:hover { border-color: var(--accent); text-decoration: none; }
.tile .icon { width: 26px; height: 26px; color: var(--accent); }
.tile .dot { position: absolute; top: 8px; right: 8px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--red); color: #fff; font-size: .72rem; display: grid; place-items: center; }
.todo { display: flex; gap: 12px; align-items: center; padding: 14px 16px; background: var(--bg); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 12px; color: inherit; }
.todo:hover { text-decoration: none; border-color: var(--accent); }
.todo.warn { border-left-color: #e08a00; }
.todo .grow { flex: 1; min-width: 0; }
.amount-big { font-size: 2rem; font-weight: 700; letter-spacing: -.01em; }
.qr-box { display: grid; place-items: center; padding: 16px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.qr-box canvas, .qr-box img { width: 220px; height: 220px; image-rendering: pixelated; }
.pp-head { display: flex; align-items: center; gap: 8px; font-weight: 700; color: #113566; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding-left: 34px; min-height: 26px; }
.steps li + li { margin-top: 8px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 999px; background: var(--fg); color: #fff; font-size: .8rem; display: grid; place-items: center; font-weight: 700; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 26px; }
.timeline li::before { content: ""; position: absolute; left: 7px; top: 22px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; left: 1px; top: 7px; width: 14px; height: 14px; border-radius: 999px; background: var(--bg); border: 3px solid var(--line-strong); }
.timeline li.by-customer::after { border-color: var(--accent); }
.stages { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.stages div { text-align: center; font-size: .72rem; color: var(--faint); }
.stages div::before { content: ""; display: block; height: 6px; border-radius: 999px; background: var(--line); margin-bottom: 6px; }
.stages div.done { color: var(--fg); font-weight: 600; }
.stages div.done::before { background: var(--accent); }
.bubble { max-width: 88%; padding: 10px 14px; border-radius: 16px; background: var(--bg); border: 1px solid var(--line); }
.bubble.mine { margin-left: auto; background: var(--accent-soft); border-color: #cfe2fb; }
.bubble .meta { font-size: .75rem; color: var(--faint); margin-top: 4px; }
.days { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x mandatory; }
.days label { flex: none; scroll-snap-align: start; position: relative; }
.days input { position: absolute; opacity: 0; }
.days span { display: block; width: 64px; padding: 8px 4px; text-align: center; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--bg); font-size: .8rem; cursor: pointer; line-height: 1.3; }
.days span b { display: block; font-size: 1.2rem; }
.days input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.choice input:disabled + span { opacity: .35; text-decoration: line-through; cursor: not-allowed; }

/* ── back office layout ────────────────────────────────── */
.admin { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--bg); border-right: 1px solid var(--line); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; padding: 4px 8px 16px; }
.brand svg { width: 28px; height: 28px; }
.brand small { display: block; font-weight: 500; color: var(--faint); font-size: .72rem; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--muted); font-size: .95rem; position: relative; }
.nav a:hover { background: var(--bg-subtle); color: var(--fg); text-decoration: none; }
.nav a.active { background: var(--bg-subtle); color: var(--fg); font-weight: 600; }
.nav a.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--accent); }
.nav-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 10px; background: none; color: var(--muted); font: inherit; font-size: .95rem; text-align: left; cursor: pointer; line-height: 1.3; }
.nav-btn:hover { background: var(--bg-subtle); color: var(--fg); }
.nav .count { margin-left: auto; background: var(--red); color: #fff; border-radius: 999px; font-size: .72rem; padding: 0 7px; font-weight: 700; }
.nav-group { font-size: .72rem; font-weight: 600; color: var(--faint); letter-spacing: .05em; margin: 16px 10px 4px; }
.main { min-width: 0; padding: 24px 32px 60px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 1.5rem; }
.crumb { font-size: .85rem; color: var(--faint); margin-bottom: 4px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; color: inherit; display: block; }
a.stat:hover { border-color: var(--accent); text-decoration: none; }
.stat b { display: block; font-size: 1.6rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .875rem; }
.stat.hot b { color: var(--red); }
table.table { width: 100%; border-collapse: collapse; background: var(--bg); font-size: .925rem; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--bg-subtle); white-space: nowrap; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fbfbfc; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs a { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-size: .9rem; background: var(--bg); }
.tabs a.on { border-color: var(--fg); color: var(--fg); font-weight: 600; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.lines td input, .lines td select { min-height: 40px; padding: 6px 10px; }
.lines .del { color: var(--faint); background: none; border: 0; cursor: pointer; font-size: 1.2rem; }
.slip-thumb { width: 88px; height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-subtle); display: grid; place-items: center; font-size: .8rem; color: var(--muted); }
@media (max-width: 960px) {
  .admin { grid-template-columns: 1fr; }
  .side { position: static; height: auto; display: flex; flex-wrap: wrap; gap: 4px; }
  .side .nav-group, .side .brand small { display: none; }
  .nav { display: contents; }
  .two-col { grid-template-columns: 1fr; }
  .main { padding: 16px; }
}

/* ── standalone pages (login, errors) ──────────────────── */
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.center .card { width: min(420px, 100%); }

/* ── printable documents ───────────────────────────────── */
.doc-bar { max-width: 210mm; margin: 16px auto; padding: 0 12px; display: flex; gap: 8px; justify-content: space-between; }
.doc { width: 210mm; max-width: 100%; min-height: 297mm; margin: 0 auto 24px; background: #fff; padding: 16mm 15mm; box-shadow: var(--shadow); font-size: 14px; line-height: 1.55; }
.doc-head { display: flex; justify-content: space-between; gap: 24px; border-bottom: 2px solid var(--fg); padding-bottom: 12px; }
.doc-head h1 { font-size: 22px; text-align: right; }
.doc-head .co b { font-size: 16px; }
.doc-parties { display: grid; grid-template-columns: 1fr 240px; gap: 24px; margin: 16px 0; }
.doc table { width: 100%; border-collapse: collapse; }
.doc th { background: #f2f2f2; font-weight: 600; text-align: left; padding: 8px; font-size: 13px; }
.doc td { padding: 8px; border-bottom: 1px solid #e5e5e5; vertical-align: top; }
.doc .totals { width: 280px; margin-left: auto; margin-top: 8px; }
.doc .totals td { border: 0; padding: 4px 8px; }
.doc .totals tr.grand td { font-weight: 700; font-size: 16px; border-top: 2px solid var(--fg); }
.doc .sign { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 48px; text-align: center; }
.doc .sign div { border-top: 1px solid #999; padding-top: 6px; }
.doc .stamp { display: inline-block; border: 2px solid var(--green); color: var(--green); padding: 4px 14px; border-radius: 8px; font-weight: 700; transform: rotate(-6deg); }
@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  .doc-bar { display: none; }
  .doc { box-shadow: none; margin: 0; width: auto; min-height: auto; }
}
