:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #17202a;
  --muted: #5d6a79;
  --line: #dde3ec;
  --primary: #1a4d8f;
  --primary-ink: #ffffff;
  --ok: #197a4b;
  --warn: #b45d00;
  --danger: #b82937;
  --info: #1b6ca8;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Sarabun", "Noto Sans Thai", "Segoe UI", Tahoma, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #eef2f7; padding: 1px 6px; border-radius: 4px; font-size: .92em; }

.topbar {
  background: #102a43;
  color: #fff;
  padding: 10px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .brand { color: #fff; font-weight: 700; font-size: 1.15rem; text-decoration: none; }
.mainnav { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.mainnav a { color: #d9e4f1; padding: 6px 12px; border-radius: 6px; font-weight: 500; text-decoration: none; }
.mainnav a:hover, .mainnav a.active { background: #244b70; color: #fff; }
.userbox { display: flex; align-items: center; gap: 10px; font-size: .92rem; }
.userbox .link { background: none; border: 1px solid #486581; color: #d9e4f1; padding: 4px 9px; border-radius: 5px; cursor: pointer; }
.bell { position: relative; color: #fff; text-decoration: none; font-size: 1.15rem; }
.bell .count { background: #e12d39; color: #fff; border-radius: 99px; padding: 1px 6px; font-size: .72rem; position: relative; top: -6px; }

.container { max-width: 1280px; margin: 18px auto; padding: 0 14px; }
.container.narrow { max-width: 460px; margin-top: 60px; }
.foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 24px 10px; }

.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.page-head h1 { margin: 0 0 4px; font-size: 1.5rem; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 2px rgba(16,42,67,.04); }
.card h2 { margin: 0 0 12px; font-size: 1.15rem; }
.card h3 { margin: 14px 0 8px; font-size: 1rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 7px; border: 1px solid #bcc8d6;
  background: #fff; color: var(--ink); font-size: .95rem; font-family: inherit;
  font-weight: 600; cursor: pointer; text-decoration: none; min-height: 38px;
}
.btn:hover { background: #f0f4f8; text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: #143d73; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.sm { padding: 5px 10px; font-size: .86rem; min-height: 32px; }
.btn.big { padding: 10px 18px; font-size: 1rem; }
.btn.block { width: 100%; }
.inline { display: inline; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: #e6ecf3; color: #243b53; vertical-align: middle; }
.st-draft { background: #fff3c4; color: #7c4700; }
.st-assigned { background: #e3f0ff; color: #12467b; }
.st-in_progress { background: #d8f3dc; color: #14532d; }
.st-review { background: #ede9fe; color: #5b21b6; }
.st-closed { background: #e5e7eb; color: #374151; }
.pr-high { background: #ffe8cc; color: #9c4221; }
.pr-urgent { background: #ffd8d8; color: #9b1c1c; }
.flag-blocked { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.flag-decision { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.flag-overdue { background: #991b1b; color: #fff; }
.act-note { background: #e0f2fe; color: #075985; }
.act-new_task { background: #dcfce7; color: #166534; }
.act-follow_existing { background: #ede9fe; color: #5b21b6; }
.code { font-family: ui-monospace, Consolas, monospace; font-weight: 700; color: #1a4d8f; }
.lbl { display: inline-block; background: #edf2f7; color: #334e68; padding: 1px 6px; border-radius: 4px; font-size: .78rem; margin-right: 4px; }
.rel { color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.tiny { font-size: .8rem; }
.text-danger { color: var(--danger); }
.req { color: var(--danger); }
.hint { color: var(--muted); font-size: .86rem; margin: 6px 0; }
.empty { color: var(--muted); margin: 6px 0; }
.count { background: #e6ecf3; padding: 1px 8px; border-radius: 99px; font-size: .85rem; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; border: 1px solid transparent; }
.flash-success { background: #e6f7ed; border-color: #9ae6b4; color: #14532d; }
.flash-error { background: #fde8e8; border-color: #f8b4b4; color: #7f1d1d; }
.flash-info { background: #e6f2ff; border-color: #90cdf4; color: #1e3a8a; }
.flash ul { margin: 0; padding-left: 18px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--primary); border-radius: 8px; padding: 10px 12px; text-decoration: none; color: var(--ink); }
.stat b { display: block; font-size: 1.55rem; line-height: 1.1; }
.stat span { font-size: .86rem; color: var(--muted); }
.stat.warn, .q-warn { border-left-color: var(--warn); }
.stat.danger, .q-danger { border-left-color: var(--danger); }
.stat.ok, .q-ok { border-left-color: var(--ok); }
.stat.info, .q-info { border-left-color: var(--info); }

.qlist { display: flex; flex-direction: column; gap: 8px; }
.qrow { display: grid; grid-template-columns: 160px 1.4fr 1.3fr auto; gap: 12px; align-items: start; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfe; }
.q-who strong { display: block; }
.q-who small { color: var(--muted); }
.q-dates { margin-top: 3px; }
.q-last .ask { margin-top: 3px; color: #102a43; }
.q-act.wide { min-width: 240px; }

.decision-box { border-left: 4px solid var(--warn); background: #fffdf7; }
.drow { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.drow:first-of-type { border-top: none; }
.d-q { flex: 1 1 360px; }
.d-question { font-weight: 600; margin-bottom: 3px; }
.d-form { display: flex; gap: 6px; min-width: 320px; }
.d-form input { flex: 1; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters label { flex: 1 1 150px; margin: 0; font-size: .86rem; }
.filter-actions { display: flex; gap: 6px; }

label { display: block; margin-bottom: 10px; font-weight: 600; font-size: .92rem; }
input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #bcc8d6; border-radius: 6px;
  font: inherit; font-weight: 400; background: #fff; margin-top: 3px;
}
input[type=range] { width: 100%; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.taskrow { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 10px; position: relative; background: #fbfcfe; }
.taskrow legend { font-weight: 700; padding: 0 6px; }
.taskrow .rm { position: absolute; top: 6px; right: 8px; }

.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .94rem; }
.tbl th, .tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { background: #f0f4f8; font-weight: 700; white-space: nowrap; }
.exec-tbl tr.group-start td { border-top: 2px solid #9fb3c8; }
.person-cell { background: #f8fafc; min-width: 150px; }
.mini-bar, .progress { height: 7px; background: #e2e8f0; border-radius: 99px; overflow: hidden; margin: 4px 0; position: relative; }
.mini-bar span, .progress div { display: block; height: 100%; background: var(--ok); }
.progress { height: 18px; }
.progress span { position: absolute; inset: 0; text-align: center; font-size: .75rem; font-weight: 700; line-height: 18px; }

.cols { display: grid; grid-template-columns: 1.6fr 1fr; gap: 14px; align-items: start; }
.meeting-cols { display: grid; grid-template-columns: 1fr 1.25fr; gap: 14px; align-items: start; }
.rawtext { white-space: pre-wrap; background: #f8fafc; border: 1px solid var(--line); border-radius: 6px; padding: 12px; max-height: 440px; overflow: auto; font-family: inherit; font-size: .93rem; margin: 0 0 10px; }
.selbar { background: #fff3c4; padding: 6px 10px; border-radius: 6px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.mitem { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; background: #fbfcfe; }
.mitem.active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(26,77,143,.15); }
.mitem-meta, .mitem-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.linked { background: #f0f4f8; border-radius: 6px; padding: 6px 8px; margin-top: 6px; }
.linked-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 3px 0; }
.action-panel { border: 2px solid var(--primary); }
blockquote { margin: 6px 0; padding: 8px 12px; background: #f0f4f8; border-left: 3px solid var(--primary); border-radius: 4px; }
.inline-details { display: inline-block; }
.inline-details[open] { display: block; width: 100%; margin-top: 8px; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 6px; }

.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 14px; }
.step { text-align: center; padding: 6px; border-radius: 6px; background: #e6ecf3; color: var(--muted); font-size: .86rem; font-weight: 600; }
.step.done { background: #d8f3dc; color: #14532d; }
.step.current { background: var(--primary); color: #fff; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; margin-bottom: 10px; }
.info-grid > div { background: #f8fafc; padding: 6px 8px; border-radius: 6px; }
.info-grid .lbl { display: block; margin-bottom: 2px; background: none; padding: 0; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 10px; margin: 8px 0 0; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; }

.timeline, .files, .notifs, .audit { list-style: none; padding: 0; margin: 0; }
.timeline li, .files li, .notifs li, .audit li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.tl-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; }
.thumb { display: block; max-width: 180px; max-height: 120px; border-radius: 6px; border: 1px solid var(--line); margin-bottom: 4px; }
.decision { padding: 8px 0; border-bottom: 1px solid var(--line); }
.decision .answer { background: #ecfdf5; padding: 6px 8px; border-radius: 6px; margin-top: 4px; }
.notifs li.unread { background: #f0f7ff; padding: 8px; border-radius: 6px; font-weight: 600; }

.my-card .my-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.my-title { font-size: 1.1rem; font-weight: 700; }
.my-due { text-align: right; }
.my-update summary { cursor: pointer; font-weight: 600; color: var(--primary); padding: 6px 0; }

.dlg { border: none; border-radius: 10px; padding: 0; max-width: 520px; width: 94vw; box-shadow: 0 12px 32px rgba(0,0,0,.25); }
.dlg::backdrop { background: rgba(16,42,67,.45); }
.dlg-body { padding: 18px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

.login-card h1 { margin-top: 0; }
.demo-box { margin-top: 14px; background: #f8fafc; padding: 8px 12px; border-radius: 6px; font-size: .9rem; }
.visually-hidden { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

@media (max-width: 820px) {
  .cols, .meeting-cols, .grid2, .grid3, .qrow { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .d-form { min-width: 100%; }
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tr { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; padding: 6px; background: #fff; }
  .tbl td { border: none; padding: 4px 6px; }
  .tbl td[data-th]::before { content: attr(data-th) ": "; font-weight: 700; color: var(--muted); }
  .person-cell { background: #eef2f7; border-radius: 6px; }
}

