/* TAWAN Corporate Theme 2030 — Provisional Token Hook Stylesheet (exact brand hex pending DEC-08 verification) */
:root {
  --cpm-bg: #f3f5f8;
  --cpm-surface: #ffffff;
  --cpm-surface-subtle: #f8fafc;
  --cpm-sidebar: #132235;
  --cpm-sidebar-hover: #1d334e;
  --cpm-sidebar-active: #27476d;
  --cpm-ink: #16202c;
  --cpm-muted: #526171;
  --cpm-border: #d9e1ec;
  --cpm-accent: #1e4b7a;
  --cpm-accent-hover: #163a5f;
  --cpm-ok-bg: #e6f6ec;
  --cpm-ok-ink: #11633c;
  --cpm-info-bg: #e8f1fb;
  --cpm-info-ink: #184e88;
  --cpm-warn-bg: #fff4e3;
  --cpm-warn-ink: #945600;
  --cpm-err-bg: #fdecec;
  --cpm-err-ink: #b42318;
  --cpm-closed-bg: #eaeef4;
  --cpm-closed-ink: #2c3a4b;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--cpm-bg);
  color: var(--cpm-ink);
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans Thai", Tahoma, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* AppShell Layout */
.app-layout {
  display: grid;
  grid-template-columns: 265px 1fr;
  min-height: 100vh;
}
.app-sidebar {
  background: var(--cpm-sidebar);
  color: #e6edf5;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #0e1a29;
}
.brand-box {
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.brand-code {
  display: block;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: #8ab4e1;
  font-weight: 700;
}
.brand-title {
  display: block;
  font-size: 18px;
  color: #ffffff;
  margin: 3px 0;
}
.brand-sub {
  display: block;
  font-size: 12px;
  color: #9fb3c8;
}
.brand-sub code {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: none;
}

.side-nav {
  padding: 10px 10px 24px;
  overflow-y: auto;
}
.nav-group { margin-bottom: 14px; }
.nav-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #88a0b9;
  padding: 6px 10px 4px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  color: #dbe4ee;
  text-decoration: none;
  font-size: 13.5px;
  margin-bottom: 2px;
  transition: background 0.12s ease;
}
.nav-link:hover { background: var(--cpm-sidebar-hover); color: #ffffff; }
.nav-link.is-active {
  background: var(--cpm-sidebar-active);
  color: #ffffff;
  font-weight: 600;
}
.nav-pid {
  display: inline-block;
  min-width: 32px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.12);
  color: #a7c8eb;
}
.nav-link.is-active .nav-pid {
  background: #ffffff;
  color: var(--cpm-sidebar);
}

/* Main Content Area */
.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar {
  background: var(--cpm-surface);
  border-bottom: 1px solid var(--cpm-border);
  padding: 14px 24px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.page-id-pill {
  background: var(--cpm-accent);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 8px;
}
.topbar-title {
  font-size: 19px;
  margin: 0;
}
.topbar-sub {
  font-size: 12px;
  color: var(--cpm-muted);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--cpm-surface-subtle);
  border: 1px solid var(--cpm-border);
  padding: 6px 12px;
  border-radius: 10px;
}
.user-chip strong { display: block; font-size: 13px; }
.user-chip small { display: block; font-size: 11.5px; color: var(--cpm-muted); }

/* Role Switcher Bar */
.role-switcher-bar {
  background: #eef3f9;
  border-bottom: 1px solid var(--cpm-border);
  padding: 8px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.switcher-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--cpm-accent);
}
.switcher-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip-btn {
  border: 1px solid #c3d1e2;
  background: #ffffff;
  color: var(--cpm-ink);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.chip-btn:hover { background: #e3ecf7; }
.chip-btn.chip-active {
  background: var(--cpm-accent);
  color: #ffffff;
  border-color: var(--cpm-accent);
}

.content-area {
  padding: 20px 24px 40px;
  max-width: 1400px;
  width: 100%;
}

/* Panels, Cards & Grid */
.panel, .notice {
  background: var(--cpm-surface);
  border: 1px solid var(--cpm-border);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 18px;
}
.notice-err { border-color: #f3b8bf; background: var(--cpm-err-bg); color: var(--cpm-err-ink); }
.notice-warn { border-color: #f4d39b; background: var(--cpm-warn-bg); color: var(--cpm-warn-ink); }
.panel-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-head h2 { font-size: 16.5px; margin: 0; }
h3 { font-size: 14.5px; margin: 0 0 10px; }
p { margin: 4px 0 0; color: var(--cpm-muted); }

.stats-grid, .cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 12px;
}
.stat-item, .cards article {
  background: var(--cpm-surface-subtle);
  border: 1px solid var(--cpm-border);
  border-radius: 10px;
  padding: 14px 16px;
}
.stat-item span, .stat-item small, .cards span, .cards small {
  display: block;
  color: var(--cpm-muted);
  font-size: 12.5px;
}
.stat-item strong, .cards strong {
  display: block;
  font-size: clamp(20px, 2vw, 27px);
  font-variant-numeric: tabular-nums;
  margin: 6px 0 4px;
  color: var(--cpm-ink);
}

.tables-two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 18px;
  margin-top: 16px;
}

/* Tables */
.table-scroll { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
th, td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--cpm-border);
  vertical-align: middle;
}
th {
  background: var(--cpm-surface-subtle);
  color: var(--cpm-muted);
  font-weight: 600;
  white-space: nowrap;
}
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Status Badges */
.status-badge, .tag-draft {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.tag-draft { background: var(--cpm-warn-bg); color: var(--cpm-warn-ink); }
.tag-info { background: var(--cpm-info-bg); color: var(--cpm-info-ink); }
.tag-ok { background: var(--cpm-ok-bg); color: var(--cpm-ok-ink); }
.tag-err { background: var(--cpm-err-bg); color: var(--cpm-err-ink); }
.tag-closed { background: var(--cpm-closed-bg); color: var(--cpm-closed-ink); }
.tag-muted { background: #eceff3; color: #526171; }

/* Forms & Buttons */
.inline-form { display: inline-block; margin: 0; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--cpm-ink);
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #c5d0de;
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  background: #fff;
  color: var(--cpm-ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--cpm-accent);
  border-color: var(--cpm-accent);
}
.btn, .link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: inherit;
}
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-primary { background: var(--cpm-accent); color: #fff; }
.btn-primary:hover { background: var(--cpm-accent-hover); }
.btn-success { background: #157347; color: #fff; }
.btn-danger { background: #b42318; color: #fff; }
.btn-outline, .link-btn {
  background: var(--cpm-surface-subtle);
  color: var(--cpm-ink);
  border-color: var(--cpm-border);
}
.btn-outline:hover, .link-btn:hover { background: #e8eef5; }

.flash-banner {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
}
.flash-success { background: var(--cpm-ok-bg); color: var(--cpm-ok-ink); border: 1px solid #b7e4c7; }
.flash-error { background: var(--cpm-err-bg); color: var(--cpm-err-ink); border: 1px solid #f5c2c7; }

.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-12 { margin-bottom: 12px; }
.flex-gap { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

code {
  background: var(--cpm-surface-subtle);
  border: 1px solid var(--cpm-border);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 0.9em;
}



/* ---------- ปุ่มเมนู / ตัวครอบเมนูสำหรับแท็บเล็ต ---------- */
.nav-toggle { display: none; }
.nav-overlay { display: none; }
body { -webkit-text-size-adjust: 100%; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }

/* แท็บเล็ต (แนวตั้ง/แนวนอนขนาดเล็ก) และมือถือ: เมนูข้างเลื่อนออกมา */
@media (max-width: 1100px) {
  .app-layout { grid-template-columns: 1fr; }
  .app-sidebar {
    position: fixed; z-index: 50; inset: 0 auto 0 0; width: 280px; max-width: 85vw;
    transform: translateX(-100%); transition: transform .22s ease; overflow-y: auto;
  }
  .app-layout.nav-open .app-sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .nav-overlay { position: fixed; inset: 0; z-index: 40; background: rgba(10,20,34,.5); }
  .app-layout.nav-open .nav-overlay { display: block; }
  .nav-toggle {
    display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px;
    margin-right: 8px; font-size: 22px; border: 1px solid var(--cpm-border); border-radius: 10px;
    background: var(--cpm-surface); color: var(--cpm-ink); cursor: pointer;
  }
  .topbar { padding-left: 12px; padding-right: 12px; }
  .content-area { padding-left: 14px; padding-right: 14px; }
  .tables-two-col { grid-template-columns: 1fr !important; }
  .table-scroll { -webkit-overflow-scrolling: touch; }
}

/* อุปกรณ์สัมผัส: ปุ่มและช่องกรอกใหญ่พอแตะ (≥ 44px) และกันการซูมอัตโนมัติบน iPad */
@media (pointer: coarse) {
  input[type="text"], input[type="email"], input[type="password"], input[type="date"],
  input[type="time"], input[type="number"], select, textarea { min-height: 46px; font-size: 16px; }
  .btn, .link-btn { min-height: 44px; padding: 10px 16px; font-size: 14px; }
  .btn-sm { min-height: 40px; padding: 8px 14px; font-size: 13px; }
  .nav-link { min-height: 46px; }
  .chip-btn { min-height: 40px; }
}

/* ---------- หน้าเข้าสู่ระบบ ---------- */
.auth-body {
  min-height: 100vh; min-height: 100dvh;
  background: radial-gradient(1200px 600px at 15% -10%, #27476d 0%, rgba(39,71,109,0) 60%),
              radial-gradient(900px 500px at 100% 110%, #1b3a5c 0%, rgba(27,58,92,0) 55%), #132235;
}
.auth-wrap { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card {
  width: 100%; max-width: 440px; background: #fff; border-radius: 20px; padding: 36px 32px 28px;
  box-shadow: 0 24px 60px rgba(4, 12, 24, .45);
}
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand img { border-radius: 16px; box-shadow: 0 6px 18px rgba(19,34,53,.35); }
.auth-brand h1 { font-size: 22px; margin: 14px 0 4px; color: var(--cpm-sidebar); }
.auth-brand p { margin: 0; color: var(--cpm-muted); font-size: 14px; }
.auth-form label { display: block; font-weight: 600; margin: 16px 0 6px; font-size: 14px; }
.auth-form input[type="email"], .auth-form input[type="password"], .auth-form input[type="text"] {
  width: 100%; min-height: 50px; padding: 12px 14px; font-size: 16px; border: 1.5px solid var(--cpm-border);
  border-radius: 12px; background: #f8fafc; color: var(--cpm-ink);
}
.auth-form input:focus { outline: none; border-color: var(--cpm-accent); background: #fff; box-shadow: 0 0 0 4px rgba(30,75,122,.16); }
.auth-pass { position: relative; }
.auth-pass input { padding-right: 76px !important; }
.auth-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%); min-width: 60px; min-height: 40px;
  border: 0; background: transparent; color: var(--cpm-accent); font-weight: 700; font-size: 14px; cursor: pointer; border-radius: 8px;
}
.auth-toggle:hover { background: #e8eef5; }
.auth-submit {
  width: 100%; margin-top: 24px; min-height: 52px; border: 0; border-radius: 12px; background: var(--cpm-accent);
  color: #fff; font-size: 17px; font-weight: 700; cursor: pointer; transition: background .15s;
}
.auth-submit:hover { background: var(--cpm-accent-hover); }
.auth-submit:focus-visible { outline: 3px solid #8ab4e1; outline-offset: 2px; }
.auth-flash { margin-bottom: 8px; padding: 12px 14px; border-radius: 12px; font-size: 14px; }
.auth-flash-error { background: var(--cpm-err-bg); color: var(--cpm-err-ink); }
.auth-flash-success { background: var(--cpm-ok-bg); color: var(--cpm-ok-ink); }
.auth-foot { margin: 20px 0 0; color: #7f95ad; font-size: 12.5px; text-align: center; }
.auth-demo { margin-top: 22px; padding-top: 16px; border-top: 1px dashed var(--cpm-border); }
.auth-demo p { margin: 0 0 8px; color: var(--cpm-muted); font-size: 13px; }
.auth-demo-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.auth-demo-list button {
  width: 100%; text-align: left; padding: 8px 10px; min-height: 44px; border: 1px solid var(--cpm-border);
  border-radius: 10px; background: #fff; cursor: pointer; font-size: 13px; font-weight: 600;
}
.auth-demo-list button small { display: block; font-weight: 400; color: var(--cpm-muted); }
@media (max-width: 480px) { .auth-card { padding: 28px 20px 22px; border-radius: 16px; } .auth-demo-list { grid-template-columns: 1fr; } }

/* ---------- ผู้ใช้และสิทธิ์ (คลิก/ลากวาง/สลับ) ---------- */
.rb-tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.rb-tab { min-height: 44px; padding: 10px 18px; border: 1px solid var(--cpm-border); border-radius: 999px; background: var(--cpm-surface); color: var(--cpm-ink); font-size: 14px; font-weight: 600; cursor: pointer; }
.rb-tab.is-active { background: var(--cpm-accent); border-color: var(--cpm-accent); color: #fff; }
.rb-pane { background: var(--cpm-surface); border: 1px solid var(--cpm-border); border-radius: 14px; padding: 16px; }
.rb-pane[hidden] { display: none; }
.rb-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.rb-bar-sub { justify-content: space-between; }
.rb-help { margin: 0; color: var(--cpm-muted); flex: 1 1 280px; font-size: 13.5px; }
.rb-modes { display: inline-flex; border: 1px solid var(--cpm-border); border-radius: 10px; overflow: hidden; }
.rb-mode { min-height: 44px; padding: 8px 16px; border: 0; background: #fff; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--cpm-muted); }
.rb-mode.is-active { background: var(--cpm-sidebar-active); color: #fff; }
.rb-add { position: relative; }
.rb-add summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; }
.rb-add summary::-webkit-details-marker { display: none; }
.rb-add-form { position: absolute; right: 0; top: 52px; z-index: 20; width: min(360px, 92vw); background: #fff; border: 1px solid var(--cpm-border); border-radius: 14px; padding: 16px; box-shadow: 0 16px 40px rgba(15,30,50,.2); display: grid; gap: 10px; }
.rb-add-form label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; }
.rb-selected { display: flex; gap: 10px; align-items: center; justify-content: space-between; background: var(--cpm-info-bg); color: var(--cpm-info-ink); border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; font-weight: 600; }
.rb-selected[hidden] { display: none; }

.rb-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; align-items: start; }
.rb-col { min-width: 0; background: #f3f6fa; border: 2px solid transparent; border-radius: 14px; padding: 10px; min-height: 140px; transition: border-color .12s, background .12s; }
.rb-col.is-spare { opacity: .85; }
.rb-spare { margin-top: 14px; border: 1px dashed var(--cpm-border); border-radius: 12px; padding: 10px 12px; }
.rb-spare summary { cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--cpm-muted); min-height: 36px; display: flex; align-items: center; gap: 8px; }
.rb-spare summary span { background: #e8eef5; border-radius: 999px; padding: 1px 10px; font-size: 12px; }
.rb-spare .rb-board { margin-top: 10px; }
.rb-col.is-over { border-color: var(--cpm-accent); background: #e6eefa; }
.rb-col-head { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; padding: 4px 4px 10px; }
.rb-col-head strong { display: block; font-size: 14.5px; }
.rb-col-head small { display: block; color: var(--cpm-muted); font-size: 12px; line-height: 1.35; margin-top: 2px; }
.rb-count { background: var(--cpm-sidebar); color: #fff; border-radius: 999px; min-width: 26px; height: 26px; display: inline-grid; place-items: center; font-size: 12.5px; font-weight: 700; flex: none; }
.rb-drop-btn { display: none; flex: none; min-height: 36px; padding: 4px 10px; border: 1.5px dashed var(--cpm-accent); border-radius: 8px; background: #fff; color: var(--cpm-accent); font-weight: 700; cursor: pointer; font-size: 13px; }
.has-selection .rb-drop-btn { display: inline-block; }
.rb-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; min-height: 48px; }
.rb-card { min-width: 0; display: flex; gap: 8px; align-items: center; background: #fff; border: 1px solid var(--cpm-border); border-radius: 12px; padding: 10px 10px 10px 8px; cursor: grab; user-select: none; -webkit-user-select: none; box-shadow: 0 1px 2px rgba(15,30,50,.06); }
.rb-card:hover { border-color: #b9c8dc; }
.rb-card:focus-visible { outline: 3px solid #8ab4e1; }
.rb-card.is-selected { border-color: var(--cpm-accent); box-shadow: 0 0 0 3px rgba(30,75,122,.22); }
.rb-card.is-dragging { opacity: .45; }
.rb-card.is-off { opacity: .6; background: #f1f3f6; }
.rb-grip { color: #9aa9bb; letter-spacing: -2px; font-size: 16px; flex: none; }
.rb-card-body { min-width: 0; flex: 1; }
.rb-card-body strong { display: block; font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; }
.rb-card-body small { display: block; color: var(--cpm-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rb-switch { position: relative; flex: none; display: inline-block; width: 46px; height: 28px; cursor: pointer; }
.rb-switch input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.rb-switch span { position: absolute; inset: 0; background: #c3ccd8; border-radius: 999px; transition: background .15s; pointer-events: none; }
.rb-switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.rb-switch input:checked + span { background: #157347; }
.rb-switch input:checked + span::after { transform: translateX(18px); }
.rb-switch input:focus-visible + span { outline: 3px solid #8ab4e1; outline-offset: 2px; }

.rb-roles { display: flex; gap: 8px; flex-wrap: wrap; }
.rb-chip { display: grid; text-align: left; gap: 0; min-height: 52px; padding: 8px 16px; border: 1.5px solid var(--cpm-border); border-radius: 12px; background: #fff; cursor: pointer; font-size: 14px; font-weight: 700; color: var(--cpm-ink); }
.rb-chip small { font-weight: 500; color: var(--cpm-muted); font-size: 12px; }
.rb-chip.is-spare { opacity: .72; }
.rb-chip.is-active { background: var(--cpm-accent); border-color: var(--cpm-accent); color: #fff; opacity: 1; }
.rb-chip.is-active small { color: #cfe0f3; }
.rb-copy { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; font-weight: 600; }
.rb-copy select { width: auto; min-width: 180px; }
.rb-matrix { width: 100%; border-collapse: separate; border-spacing: 0; }
.rb-matrix th, .rb-matrix td { padding: 6px 8px; border-bottom: 1px solid var(--cpm-border); text-align: center; }
.rb-matrix thead th { background: var(--cpm-surface-subtle); font-size: 13px; position: sticky; top: 0; }
.rb-th-act { cursor: pointer; white-space: nowrap; }
.rb-th-act:hover { background: #e8eef5; }
.rb-matrix tbody th { text-align: left; font-weight: 600; font-size: 13.5px; white-space: nowrap; background: #fff; }
.rb-empty { color: #c8d1dc; }
.rb-rowtools { width: 1%; white-space: nowrap; }
.rb-rowbtn { min-height: 34px; padding: 4px 10px; border: 1px solid var(--cpm-border); border-radius: 8px; background: #fff; color: var(--cpm-accent); font-size: 12.5px; font-weight: 700; cursor: pointer; }
.rb-cell { position: relative; width: 48px; height: 40px; border: 1.5px solid #c3ccd8; border-radius: 10px; background: #fff; color: #fff; font-size: 18px; font-weight: 800; cursor: pointer; transition: background .12s, border-color .12s, transform .06s; }
.rb-cell:active { transform: scale(.94); }
.rb-cell.is-on { background: #157347; border-color: #157347; }
.rb-cell.is-locked { cursor: not-allowed; }
.rb-cell.is-locked:not(.is-on) { background: #f1f3f6; border-style: dashed; }
.rb-cell i { position: absolute; right: -4px; bottom: -6px; font-style: normal; font-size: 11px; }
.rb-cell:focus-visible { outline: 3px solid #8ab4e1; outline-offset: 2px; }
.rb-legend { margin: 12px 0 0; color: var(--cpm-muted); font-size: 12.5px; }
.rb-dot { display: inline-block; width: 12px; height: 12px; border-radius: 4px; border: 1.5px solid #c3ccd8; vertical-align: -1px; margin: 0 2px 0 8px; }
.rb-dot.is-on { background: #157347; border-color: #157347; }
.rb-toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 80; background: #132235; color: #fff; padding: 12px 20px; border-radius: 12px; font-size: 14px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.3); max-width: 90vw; }
.rb-toast.is-bad { background: #b42318; }
.rb-toast[hidden] { display: none; }
@media (max-width: 700px) { .rb-board { grid-template-columns: minmax(0, 1fr); } .rb-matrix th, .rb-matrix td { padding: 4px; } .rb-cell { width: 42px; } }

/* checkbox ขนาดปกติในเมทริกซ์สิทธิ์ (พื้นที่แตะ 40px ผ่านช่องว่างของเซลล์) */
.rb-matrix td { padding: 0; }
.rb-cell, .rb-na { display: inline-block; vertical-align: middle; width: 20px; height: 20px; border-radius: 4px; font-size: 14px; line-height: 17px; font-weight: 700; padding: 0; margin: 10px 14px; }
.rb-cell { border: 1.5px solid #8a97a8; background: #fff; color: #fff; }
.rb-cell.is-on { background: #1e4b7a; border-color: #1e4b7a; }
.rb-cell.is-locked { opacity: .55; cursor: not-allowed; background-image: none; }
.rb-cell.is-locked:not(.is-on) { background: #eef1f5; border-style: solid; }
.rb-na { border: 1.5px solid #dde3ea; background: #f3f5f8; cursor: not-allowed; }
.rb-matrix tbody tr:hover { background: #f6f9fc; }
.rb-matrix tbody tr:hover th { background: #f6f9fc; }
.rb-th-act { min-width: 78px; }
@media (max-width: 700px) { .rb-cell, .rb-na { margin: 10px 8px; } }
.rb-dot.is-na { background: #f3f5f8; border-color: #dde3ea; }
.rb-cell i { display: none; }
.rb-dot.is-on { background: #1e4b7a; border-color: #1e4b7a; }

/* ช่องวันที่ dd/mm/YYYY */
.df-wrap { position: relative; display: inline-flex; align-items: center; width: 100%; }
.df-wrap .df-text { width: 100%; padding-right: 44px; }
.df-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; cursor: pointer; font-size: 18px; min-width: 36px; min-height: 36px; border-radius: 8px; }
.df-btn:hover { background: #eef3f9; }
.df-native { position: absolute; right: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; }

/* ตารางบันทึกผลิตแบบใบรายงานกระดาษ */
.eg-table { border-collapse: collapse; width: 100%; }
.eg-table th, .eg-table td { border: 1px solid var(--cpm-border, #d9e0e8); padding: 4px 6px; text-align: center; }
.eg-table th { background: #f3f6fa; font-size: 13px; white-space: nowrap; }
.eg-table th.eg-row { text-align: left; background: #f8fafc; }
.eg-table .cell-in { width: 100%; min-width: 64px; max-width: 96px; min-height: 36px; text-align: right; }
.eg-table .eg-off { background: #e9edf2; }
.eg-table tfoot td, .eg-table tfoot th { background: #f3f6fa; font-weight: 700; }
.eg-sec { margin: 16px 0 8px; font-size: 15px; font-weight: 700; }
.eg-extra { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 12px; }
.eg-2col { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .eg-2col { grid-template-columns: minmax(0, 1fr); } }

/* ช่องแสดงผลอย่างเดียว (ดึงจากบัญชีที่ล็อกอิน) */
.ro-field { min-height: 40px; display: flex; align-items: center; padding: 6px 12px; border: 1px solid var(--cpm-border, #d9e0e8); border-radius: 8px; background: #f3f6fa; color: #1b2a3b; }

a.rb-tab { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
a.rb-tab small { opacity: .75; font-weight: 500; }

/* แยกสีกะเช้า (เหลืองอำพัน) / กะดึก (น้ำเงินคราม) ในใบบันทึกผลิต */
.shift-box { border: 1px solid var(--cpm-border, #d9e0e8); border-radius: 12px; padding: 12px; margin: 16px 0; border-left-width: 6px; }
.shift-day { border-color: #e2b44a; background: #fffaf0; }
.shift-night { border-color: #6f7fd8; background: #f4f6ff; }
.shift-day legend, .shift-day .shift-title { color: #8a5a00; }
.shift-night legend, .shift-night .shift-title { color: #2f3f9e; }
.shift-day .eg-table th, .shift-day .eg-table tfoot td { background: #fdf0cf; }
.shift-night .eg-table th, .shift-night .eg-table tfoot td { background: #e3e7fb; }
.shift-day .eg-table .eg-off, .shift-night .eg-table .eg-off { background: #e9edf2; }
.shift-day .eg-table td, .shift-night .eg-table td { background-clip: padding-box; }
.shift-day legend::before, .shift-night legend::before { display: inline-block; margin-right: 6px; }
.shift-day legend::before { content: "☀"; }
.shift-night legend::before { content: "☾"; }
tr.shift-row-day th.eg-row { background: #fdf0cf; color: #8a5a00; }
tr.shift-row-night th.eg-row { background: #e3e7fb; color: #2f3f9e; }
form.shift-day, form.shift-night { margin: 0; }
