:root {
  --navy: #062856;
  --navy-2: #031a3b;
  --gold: #d6a936;
  --gold-soft: #f4df9a;
  --ink: #111827;
  --muted: #667085;
  --line: #e6e8ee;
  --bg: #f7f8fa;
  --white: #ffffff;
  --radius: 6px;
  --admin-font-size: 14px;
  --control-height: 34px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans Thai", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
}

a {
  color: inherit;
  text-decoration: none;
}

strong,
b {
  font-weight: 600;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 600;
}

input,
select,
button {
  font: inherit;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.public-shell {
  min-height: 100vh;
  background: var(--navy-2);
  color: white;
}

.verify-home,
.result-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.verify-panel {
  width: min(680px, 100%);
  text-align: center;
}

.public-logo {
  height: 34px;
  margin-bottom: 52px;
}

.overline,
.admin-kicker {
  margin: 0 0 10px;
  color: var(--gold-soft);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
}

.verify-panel h1 {
  margin: 0;
  font-size: clamp(36px, 6vw, 52px);
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: 0;
}

.subtitle {
  margin: 16px 0 34px;
  color: rgba(255, 255, 255, .72);
  font-size: 18px;
}

.search-form {
  display: grid;
  grid-template-columns: 1fr auto;
  width: min(560px, 100%);
  margin: 34px auto 0;
  border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(255, 255, 255, .08);
  padding: 6px;
  border-radius: var(--radius);
}

.search-form input {
  min-width: 0;
  border: 0;
  background: transparent;
  color: white;
  padding: 16px 18px;
  outline: none;
  font-weight: 600;
  letter-spacing: 0;
}

.search-form button,
.print-actions button {
  border: 0;
  background: var(--gold);
  color: var(--navy-2);
  padding: 14px 24px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}

.hint {
  color: rgba(255, 255, 255, .48);
  font-size: 14px;
}

.back-link {
  position: absolute;
  top: 28px;
  left: 28px;
  color: rgba(255, 255, 255, .72);
  font-size: 14px;
}

.result-card {
  width: min(760px, 100%);
  background: rgba(255, 255, 255, .96);
  color: var(--ink);
  border-radius: var(--radius);
  padding: clamp(28px, 6vw, 58px);
  box-shadow: 0 34px 90px rgba(0, 0, 0, .28);
}

.status-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.seal {
  background: #ecfdf3;
  color: #027a48;
  border: 1px solid #abefc6;
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
}

.checked {
  color: var(--muted);
  font-size: 14px;
}

.cert-no {
  margin: 42px 0 8px;
  color: var(--gold);
  font-weight: 600;
  letter-spacing: 0;
}

.result-card h1 {
  margin: 0;
  color: var(--navy);
  font-size: 48px;
  line-height: 1.05;
  font-weight: 600;
}

.course {
  margin: 18px 0 0;
  font-size: 24px;
  color: var(--navy);
  font-weight: 600;
}

.level {
  margin: 6px 0 34px;
  color: var(--muted);
}

.details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.details div {
  background: white;
  padding: 18px;
}

.details dt {
  color: var(--muted);
  font-size: 13px;
}

.details dd {
  margin: 4px 0 0;
  font-weight: 600;
}

.admin-shell {
  background: var(--bg);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  font-size: var(--admin-font-size);
  line-height: 1.45;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card,
.form-panel,
.table-panel,
.settings-grid a {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.login-card {
  width: min(400px, 100%);
  padding: 22px;
}

.admin-logo {
  height: 24px;
  display: block;
  margin-bottom: 14px;
}

.login-card h1,
.admin-top h1,
.panel-head h2,
.tool-panel h2 {
  margin: 0;
  color: var(--navy);
  font-weight: 600;
  letter-spacing: 0;
}

.admin-top h1 {
  font-size: 21px;
  line-height: 1.25;
}

.admin-top .admin-kicker {
  margin-bottom: 2px;
}

label {
  display: grid;
  gap: 5px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

label input,
label select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: var(--control-height);
  padding: 7px 10px;
  background: white;
  color: var(--ink);
}

.primary-action,
.secondary-action {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border-radius: 6px;
  min-height: var(--control-height);
  padding: 7px 11px;
  font-size: 13px;
  line-height: 1.2;
  font-weight: 600;
}

.primary-action {
  background: var(--navy);
  color: white;
}

.primary-action:disabled,
.secondary-action:disabled,
button:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.secondary-action {
  border: 1px solid var(--line);
  color: var(--navy);
}

.login-card .primary-action {
  width: 100%;
  margin-top: 18px;
}

.admin-layout {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr);
  overflow: hidden;
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 16px;
  padding: 0 16px;
  background: white;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}

.topbar-brand {
  display: flex;
  align-items: center;
}

.topbar-brand img {
  display: block;
  height: 22px;
  width: auto;
}

.topbar-nav {
  display: flex;
  align-items: stretch;
  gap: 2px;
  min-width: 0;
  overflow-x: auto;
}

.topbar-nav a {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  color: #344054;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}

.topbar-nav a:hover {
  color: var(--navy);
}

.topbar-nav a.active {
  color: var(--navy);
  font-weight: 600;
  border-bottom-color: var(--navy);
}

.topbar-account {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-account strong {
  max-width: 160px;
  overflow: hidden;
  color: var(--navy);
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subnav {
  display: flex;
  gap: 4px;
  margin: -14px -16px 14px;
  padding: 0 16px;
  background: white;
  border-bottom: 1px solid var(--line);
}

.subnav a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 10px;
  color: #344054;
  font-size: 13px;
  font-weight: 500;
}

.subnav a:hover,
.subnav a.active {
  color: var(--navy);
  font-weight: 600;
}

.admin-main {
  min-width: 0;
  height: 100%;
  padding: 14px 16px;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

.admin-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.admin-top.compact {
  margin-bottom: 8px;
}

.admin-kicker {
  color: var(--gold);
  font-size: 10.5px;
  line-height: 1.3;
}

.metric-grid,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.metric-grid div,
.metric-grid a {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
}

.metric-grid a:hover {
  border-color: var(--navy);
}

.metric-grid span,
.settings-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric-grid strong {
  display: block;
  margin-top: 5px;
  color: var(--navy);
  font-size: 21px;
  line-height: 1;
}

.metric-grid .table-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  color: var(--navy);
  text-decoration: underline;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2,
.tool-panel h2 {
  font-size: 15px;
  line-height: 1.3;
}

.panel-head a,
.inline-actions a {
  color: var(--navy);
  font-weight: 600;
}

.panel-head a.primary-action,
.inline-actions a.primary-action {
  color: white;
}

.data-row {
  display: grid;
  grid-template-columns: 1.3fr 1fr .7fr .7fr;
  gap: 10px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  align-items: center;
  font-size: 13px;
}

.data-row:last-child {
  border-bottom: 0;
}

.table-panel > .data-row:not(.head):hover,
.table-scroll > .data-row:not(.head):hover {
  background: #fbfcfe;
}

.data-row.head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  background: #fafbfc;
}

.data-row small {
  color: var(--muted);
}

.data-row.participant {
  grid-template-columns: 58px 1.3fr .8fr 1fr .7fr;
}

.data-row.participant-readonly {
  grid-template-columns: 1.3fr .8fr 1fr .7fr;
}

.data-row.participant-edit {
  grid-template-columns: 1.25fr 1fr 1fr 1fr;
  min-width: 860px;
}

.data-row.participant-edit input,
.data-row.participant-edit select {
  width: 100%;
  min-width: 0;
}

.bulk-edit-panel .action-row {
  padding: 10px;
}

.table-scroll {
  min-width: 0;
}

.form-panel {
  padding: 12px;
  max-width: 820px;
}

.form-panel h2 {
  margin: 16px 0 5px;
  color: var(--navy);
  font-size: 15px;
  line-height: 1.35;
}

.plain-fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.permission-list {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.action-row,
.inline-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.action-row {
  justify-content: flex-end;
  margin-top: 14px;
}

.designer {
  display: grid;
  grid-template-columns: 206px 1fr;
  gap: 10px;
}

.tool-panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}

.tool-panel button {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  padding: 7px 9px;
  border-radius: 6px;
  margin-top: 8px;
  text-align: left;
}

.settings-block {
  margin-top: 14px;
}

.canvas-wrap {
  overflow: auto;
  background: #e9edf3;
  border-radius: var(--radius);
  padding: 12px;
}

.certificate-canvas {
  position: relative;
  width: 297mm;
  height: 210mm;
  max-width: 100%;
  aspect-ratio: 297 / 210;
  background: white;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .18);
}

.cert-border {
  position: absolute;
  inset: 12mm;
  border: .6mm solid var(--gold);
}

.field {
  position: absolute;
  border: 1px dashed rgba(214, 169, 54, .85);
  background: rgba(214, 169, 54, .08);
  color: var(--navy);
  text-align: center;
  font-weight: 600;
}

.name-field {
  left: 86mm;
  top: 95mm;
  width: 125mm;
  font-size: 24px;
}

.course-field {
  left: 66mm;
  top: 70mm;
  width: 165mm;
}

.date-field {
  left: 105mm;
  top: 122mm;
  width: 88mm;
}

.no-field {
  left: 22mm;
  top: 184mm;
  width: 42mm;
}

.settings-page { width: 100%; }
.settings-fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.settings-fieldset:disabled input,
.settings-fieldset:disabled select { color: #667085; background: #f8f9fb; cursor: not-allowed; }
.settings-list { background: white; border: 1px solid var(--line); border-radius: var(--radius); }
.settings-section { background: transparent; border: 0; }
.settings-section + .settings-section { border-top: 1px solid #dfe3e8; }
.settings-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 14px 8px; margin: 0; }
.settings-section-head h2 { margin: 0; color: var(--navy); font-size: 14.5px; line-height: 1.35; }
.settings-section-head p { margin: 1px 0 0; color: var(--muted); font-size: 11.5px; }
.setting-row { display: grid; grid-template-columns: 160px minmax(180px, 1fr) minmax(160px, .75fr); gap: 10px; align-items: center; min-height: 38px; padding: 5px 14px; border-top: 1px solid #edf0f3; }
.settings-section-head + .setting-row { border-top: 0; }
.setting-row > label, .setting-row > span { margin: 0; color: #344054; font-size: 12.5px; font-weight: 600; }
.setting-row input, .setting-row select { width: 100%; min-width: 0; padding: 5px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: white; }
.setting-row small { color: var(--muted); font-size: 11.5px; }
.token-list, .check-list { display: flex; flex-wrap: wrap; gap: 5px; grid-column: 2 / 4; }
.token-list b { padding: 4px 7px; border: 1px solid var(--line); border-radius: var(--radius); color: #344054; background: #fafbfc; font-size: 12px; font-weight: 600; }
.token-list button { border: 0; background: transparent; color: var(--navy); font-weight: 600; }
.check-list label { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 5px; margin: 0 10px 0 0; color: #344054; font-size: 13px; font-weight: 500; }
.check-list input { width: auto; }
.role-reserved { grid-template-columns: 160px 1fr; }
.role-definition-list { border-top: 1px solid #edf0f3; }
.role-definition-row { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 12px; padding: 8px 14px; border-bottom: 1px solid #edf0f3; }
.role-definition-head { display: flex; align-items: flex-end; gap: 6px; }
.role-definition-head label { flex: 1; margin: 0; color: #344054; font-size: 11.5px; font-weight: 600; }
.role-definition-head input { width: 100%; margin-top: 3px; padding: 5px 8px; border: 1px solid var(--line); border-radius: var(--radius); }
.role-definition-head .icon-action { flex: 0 0 30px; width: 30px; height: 30px; color: #b42318; font-size: 20px; line-height: 1; }
.role-permission-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px 10px; align-content: center; }
.role-permission-grid label { display: flex; align-items: center; gap: 5px; min-width: 0; margin: 0; color: #475467; font-size: 11px; font-weight: 500; overflow-wrap: anywhere; }
.role-permission-grid input { flex: 0 0 16px; width: 16px; min-height: 16px; height: 16px; margin: 0; padding: 0; }
.role-add { margin: 8px 14px 11px; }

.toolbar {
  display: grid;
  grid-template-columns: 1fr 190px 190px;
  gap: 8px;
  margin-bottom: 10px;
}

.toolbar input,
.toolbar select {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  min-height: var(--control-height);
  padding: 7px 10px;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.template-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.template-thumb {
  position: relative;
  margin: 8px;
  background: #fff;
  border: 1px solid #d7dce5;
  overflow: hidden;
}

.template-thumb.landscape {
  aspect-ratio: 297 / 210;
}

.template-thumb.portrait {
  width: 58%;
  aspect-ratio: 210 / 297;
  margin-inline: auto;
}

.template-thumb::before {
  content: none;
}

.template-thumb.actual-template::before {
  display: none;
}

.actual-template img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.file-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 3px 5px;
  border-radius: var(--radius);
  background: rgba(3, 26, 59, .88);
  color: white;
  font-size: 10px;
  font-weight: 600;
}

.template-thumb.alt::before {
  content: none;
}

.template-thumb .cert-border {
  inset: 7%;
  border-width: 1px;
}

.mini-logo,
.mini-title,
.mini-name,
.mini-no {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  color: var(--navy);
  text-align: center;
  white-space: nowrap;
}

.mini-logo {
  top: 13%;
  font-weight: 600;
  color: var(--gold);
}

.mini-title {
  top: 28%;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.mini-name {
  top: 51%;
  font-size: 18px;
  font-weight: 600;
}

.mini-no {
  left: 12%;
  bottom: 9%;
  transform: none;
  font-size: 10px;
  font-weight: 600;
}

.template-meta {
  padding: 0 10px 10px;
}

.template-meta strong {
  display: block;
  color: var(--navy);
}

.template-meta span,
.panel-sub {
  color: var(--muted);
  font-size: 12px;
}

.panel-sub {
  margin: 3px 0 0;
}

.project-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 10px;
  background: var(--line);
}

.project-strip div {
  background: white;
  padding: 7px 10px;
}

.project-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.project-strip strong {
  display: block;
  margin-top: 2px;
  color: var(--navy);
}

.bulk-actions a {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  background: white;
}

.selection-bar {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 36px;
  padding: 5px 12px;
  border-bottom: 1px solid #d9e2ef;
  background: #f1f5fa;
}

.selection-bar strong {
  margin-right: 5px;
  color: var(--navy);
  font-size: 13px;
}

.selection-bar a {
  padding: 5px 8px;
  border: 1px solid #d4dbe6;
  border-radius: var(--radius);
  background: white;
  color: var(--navy);
  font-size: 12px;
  font-weight: 600;
}

.selection-bar .danger-action {
  color: #b42318;
}

.project-actions-sticky {
  position: sticky;
  top: -14px;
  z-index: 4;
  background: white;
  box-shadow: 0 1px 0 var(--line);
}

.sticky-page-actions {
  position: sticky;
  top: -14px;
  z-index: 4;
  margin-top: -14px;
  padding-top: 14px;
  padding-bottom: 8px;
  background: var(--bg);
}

.preview-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 10px;
}

.print-scope { display: grid; grid-template-columns: 1.35fr 1fr 1fr 1fr; gap: 1px; margin-bottom: 10px; border: 1px solid var(--line); background: var(--line); }
.print-scope div { padding: 7px 10px; background: white; }
.print-scope span { display: block; color: var(--muted); font-size: 11px; }
.print-scope strong { display: block; margin-top: 1px; color: var(--navy); font-size: 13px; }
.print-pagination { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin: -2px 0 10px; }
.print-pagination span { color: var(--muted); font-size: 12px; }
.title-muted { color: var(--muted); font-size: .65em; font-weight: 400; }
.preview-list { padding: 6px; }
.preview-list .list-title { margin: 4px 6px 7px; color: var(--muted); font-size: 12px; font-weight: 600; }
.preview-list a { display: grid; grid-template-columns: 24px 1fr; padding: 7px; border-top: 1px solid var(--line); }
.preview-list a span { grid-row: 1 / 3; color: var(--muted); font-size: 12px; }
.preview-list a strong { color: var(--navy); font-size: 13px; }
.preview-list a small { color: var(--muted); }
.preview-list a.active { background: #f1f4f8; }

.preview-list {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px;
  align-self: start;
}

.preview-stage {
  overflow: auto;
  background: #e9edf3;
  border-radius: var(--radius);
  padding: 8px;
}

.preview-sheet {
  position: relative;
  width: min(100%, 1122px);
  aspect-ratio: 297 / 210;
  background: white;
  box-shadow: 0 16px 44px rgba(15, 23, 42, .16);
  container-type: inline-size;
}

.preview-sheet .print-border { inset: 5.7%; border-width: 2px; }
.preview-sheet .print-title { top: 23%; left: 23.6%; width: 52.8%; font-size: clamp(11px, 2.3cqw, 20pt); }
.preview-sheet .print-course { top: 34.3%; left: 19.5%; width: 61%; font-size: clamp(9px, 1.8cqw, 16pt); }
.preview-sheet .print-presented { top: 49.5%; left: 28.6%; width: 42.8%; font-size: clamp(8px, 1.35cqw, 12pt); }
.preview-sheet .print-name { top: 54.8%; left: 20.2%; width: 59.6%; font-size: clamp(15px, 3.4cqw, 30pt); }
.preview-sheet .print-date { top: 68.6%; left: 32.3%; width: 35.4%; font-size: clamp(8px, 1.45cqw, 13pt); }
.preview-sheet .print-cert-no { left: 6.7%; bottom: 7.1%; width: 18.5%; font-size: clamp(7px, 1.2cqw, 11pt); }

.print-shell {
  background: #d9dee8;
  font-family: "IBM Plex Sans Thai", sans-serif;
}

.print-actions {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line);
}

.print-actions a {
  padding: 12px 18px;
  color: var(--navy);
  font-weight: 600;
}

.print-sheet {
  position: relative;
  width: 297mm;
  height: 210mm;
  margin: 0;
  background: white;
  transform-origin: top left;
}

.print-pack {
  width: 100%;
  overflow: hidden;
}

.print-page-frame {
  margin: 18px auto;
  overflow: hidden;
  background: white;
  box-shadow: 0 16px 44px rgba(15, 23, 42, .16);
  break-after: page;
}

.print-border {
  position: absolute;
  inset: 12mm;
  border: .6mm solid var(--gold);
}

.print-title,
.print-course,
.print-presented,
.print-name,
.print-date,
.print-cert-no {
  position: absolute;
  margin: 0;
  color: var(--navy);
  text-align: center;
}

.print-title {
  top: 48mm;
  left: 70mm;
  width: 157mm;
  text-transform: uppercase;
  font-size: 20pt;
  font-weight: 600;
}

.print-course {
  top: 72mm;
  left: 58mm;
  width: 181mm;
  font-size: 16pt;
  font-weight: 600;
  line-height: 1.35;
}

.print-presented {
  top: 104mm;
  left: 85mm;
  width: 127mm;
  color: var(--gold);
  text-transform: uppercase;
  font-weight: 600;
}

.print-name {
  top: 115mm;
  left: 60mm;
  width: 177mm;
  font-size: 30pt;
  font-weight: 500;
}

.print-date {
  top: 144mm;
  left: 96mm;
  width: 105mm;
  font-size: 13pt;
}

.print-cert-no {
  left: 20mm;
  bottom: 15mm;
  width: 55mm;
  text-align: left;
  font-size: 11pt;
}

@page {
  size: A4 landscape;
  margin: 0;
}

@media print {
  body {
    background: white;
  }

  .print-actions {
    display: none;
  }

  .print-sheet {
    margin: 0;
    transform: none !important;
    box-shadow: none;
  }

  .print-pack {
    overflow: visible;
  }

  .print-page-frame {
    margin: 0;
    overflow: visible;
    box-shadow: none;
    page-break-after: always;
  }

  .print-page-frame.landscape {
    width: 297mm !important;
    height: 210mm !important;
  }

  .print-page-frame.portrait {
    width: 210mm !important;
    height: 297mm !important;
  }
}

@media (max-width: 820px) {
  .admin-shell {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: visible;
  }

  .search-form {
    grid-template-columns: 1fr;
  }

  .details,
  .template-grid,
  .preview-layout,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .metric-grid,
  .project-strip,
  .print-scope {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .print-pagination {
    justify-content: space-between;
  }

  .admin-layout {
    display: block;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    min-width: 0;
    overflow: visible;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    height: 52px;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 0 10px;
  }

  .topbar-brand {
    display: none;
  }

  .topbar-nav a {
    font-size: 13px;
    padding: 0 8px;
  }

  .topbar-account strong {
    display: none;
  }

  .subnav {
    margin: -10px -10px 10px;
    padding: 0 10px;
    overflow-x: auto;
  }

  .admin-main {
    padding: 10px;
    height: auto;
    width: 100%;
    min-width: 0;
    overflow-x: clip;
    overflow-y: visible;
  }

  .admin-top,
  .designer {
    grid-template-columns: 1fr;
    display: grid;
  }

  .table-panel {
    width: 100%;
    min-width: 0;
    overflow-x: auto;
  }

  .project-participants {
    overflow: visible;
  }

  .project-participants .table-scroll {
    width: 100%;
    overflow-x: auto;
  }

  .data-row {
    min-width: 680px;
  }

  .data-row.participant {
    min-width: 790px;
  }

  .setting-row {
    grid-template-columns: 135px minmax(180px, 1fr);
  }

  .setting-row small {
    grid-column: 2;
  }

  .token-list,
  .check-list {
    grid-column: 2;
  }

  .role-definition-row {
    grid-template-columns: 160px minmax(0, 1fr);
  }

  .role-permission-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .certificate-canvas {
    width: 100%;
  }

  .project-actions-sticky {
    top: 52px;
  }

  .project-participants .panel-head {
    align-items: start;
  }

  .project-participants .panel-head > div:first-child {
    display: none;
  }

  .project-participants .panel-head .inline-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
  }

  .project-participants .panel-head .inline-actions > * {
    min-width: 0;
    min-height: 30px;
    padding: 5px 7px;
    font-size: 0;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
  }

  .project-participants .panel-head .inline-actions > [data-mobile-label]::after {
    content: attr(data-mobile-label);
    font-size: 11px;
  }

  .project-participants .selection-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 5px;
  }

  .project-participants .selection-bar strong {
    display: none;
  }

  .project-participants .selection-bar select {
    grid-column: auto;
    min-width: 0;
    min-height: 30px;
  }

  .project-participants .selection-bar button {
    min-height: 30px;
    padding: 5px 7px;
    font-size: 11.5px;
  }

  .sticky-page-actions {
    top: 52px;
    margin-top: -10px;
    padding-top: 10px;
  }

  .designer {
    gap: 6px;
  }

  .designer .tool-panel {
    position: sticky;
    top: 52px;
    z-index: 4;
    max-height: 270px;
    overflow-y: auto;
    box-shadow: 0 1px 0 var(--line);
  }

  #field-list {
    max-height: 66px;
    overflow-y: auto;
  }

  #field-properties:not([hidden]) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
    margin-top: 8px;
  }

  #field-properties label {
    margin-top: 0;
  }

  #field-properties button {
    align-self: end;
  }

  .canvas-wrap {
    padding: 6px;
  }
}

@media (max-width: 520px) {
  .verify-home,
  .result-page {
    padding: 18px;
  }

  .public-logo {
    margin-bottom: 34px;
  }

  .verify-panel h1 {
    font-size: 38px;
  }

  .result-card h1 {
    font-size: 34px;
  }

  .subtitle {
    font-size: 16px;
  }

  .admin-top .primary-action {
    width: 100%;
  }

  .admin-top.sticky-page-actions {
    display: flex;
  }

  .admin-top.sticky-page-actions .primary-action {
    width: auto;
  }

  .setting-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .setting-row small,
  .token-list,
  .check-list {
    grid-column: 1;
  }

  .settings-section-head {
    align-items: flex-start;
  }

  .role-reserved,
  .role-definition-row {
    grid-template-columns: 1fr;
  }

  .role-permission-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

button { border: 0; cursor: pointer; }
.topbar-account .text-action { padding: 0; }
.text-action { padding: 2px 0; background: transparent; color: var(--navy); font: inherit; text-align: left; }
.notice { margin: 0 0 10px; padding: 8px 10px; border: 1px solid var(--line); background: white; color: #344054; font-size: 13px; }
.notice.success { border-color: #12b76a; background: #ecfdf3; }
.notice.error { border-color: #f04438; background: #fef3f2; color: #b42318; }
.login-card form .primary-action { border: 0; }
.empty-state { padding: 22px 14px; color: var(--muted); text-align: center; }
.status-text { font-weight: 600; color: #344054; }
.status-text.issued, .status-text.active { color: #027a48; }
.status-text.voided, .status-text.disabled { color: #b42318; }
.seal.invalid, .seal.voided { background: #fef3f2; color: #b42318; border-color: #fecdca; }
.table-link { color: var(--navy); font-weight: 600; }
.admin-top .inline-actions form { display: inline-flex; }
.inline-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.inline-form input, .inline-form select { min-width: 160px; min-height: var(--control-height); padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--radius); }
.field-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.field-grid .full { grid-column: 1/-1; }
.form-panel button { border: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
@media (max-width: 820px) {
  .topbar-account .text-action { white-space: nowrap; padding: 8px 4px; font-size: 12px; }
  .field-grid { grid-template-columns: 1fr; }
  .field-grid .full { grid-column: 1; }
}
.compact-form { max-width: none; margin-bottom: 10px; padding: 10px; }
.certificate-canvas { width: min(100%, 1122px); height: auto; background-repeat: no-repeat; touch-action: none; container-type: inline-size; }
/* Same box as the printed field: no padding or border that would shift the text; the guide is an outline. */
.draggable-field { border: 0; outline: 1px dashed rgba(214, 169, 54, .95); outline-offset: 0; padding: 0; min-height: 0; line-height: 1.2; white-space: nowrap; overflow: visible; font-weight: 400; cursor: move; user-select: none; }
.draggable-field:focus { outline: 2px solid var(--navy); }
.draggable-field.selected { outline: 2px solid rgba(6,40,86,.6); background: rgba(214, 169, 54, .16); }
.field-add { display: grid; grid-template-columns: 1fr auto; gap: 5px; margin: 10px 0 6px; }
.field-add select { min-width: 0; border: 1px solid var(--line); padding: 6px; }
#field-list { display: grid; gap: 3px; }
#field-list button.selected { border-color: var(--navy); background: #f1f4f8; }
#field-properties label { gap: 3px; margin-top: 7px; font-size: 12px; }
#field-properties input, #field-properties select { padding: 6px 7px; }
.preview-stage { display: grid; gap: 12px; }
.preview-sheet { background-repeat: no-repeat; position: relative; }
.preview-cert-field { position: absolute; overflow: hidden; color: var(--navy); line-height: 1.2; white-space: nowrap; font-weight: 400; }
.print-dynamic-field { position: absolute; overflow: hidden; color: var(--navy); line-height: 1.2; white-space: nowrap; font-weight: 400; }

.team-form h2,
.settings-section h2 {
  margin: 0 0 4px;
  color: var(--navy);
  font-size: 16px;
}

.role-legend {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

.role-legend strong {
  color: var(--navy);
  margin-right: 6px;
}

.next-cert-preview {
  margin: 0;
  color: var(--navy);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.1;
  text-align: right;
}

.next-cert-preview small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.settings-advanced {
  margin-top: 8px;
  padding: 10px 12px;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.settings-advanced summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--navy);
}

.settings-advanced[open] summary {
  margin-bottom: 12px;
}

.setup-card {
  width: min(520px, 100%);
}

.setup-copy {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.setup-users ul {
  margin: 8px 0 16px;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.setup-users li {
  display: grid;
  gap: 2px;
}

.setup-users small {
  color: var(--muted);
}

.certificate-view { display: grid; gap: 16px; }
.certificate-view .preview-sheet { margin: 0 auto; }
.certificate-meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0; }
.certificate-meta div { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.certificate-meta dt { font-size: 13px; color: var(--muted, #5b6475); }
.certificate-meta dd { margin: 4px 0 0; font-weight: 500; }
@media (max-width: 700px) { .certificate-meta { grid-template-columns: 1fr; } }

/* Certificate text: brand fonts, Poppins for Latin, IBM Plex Sans Thai for Thai. Weight comes from each field. */
.preview-cert-field,
.print-dynamic-field,
.draggable-field { font-family: "Poppins", "IBM Plex Sans Thai", sans-serif; }
.preview-cert-field.thai-text,
.print-dynamic-field.thai-text,
.draggable-field.thai-text { font-family: "IBM Plex Sans Thai", sans-serif; }

.public-certificate { margin-top: 32px; display: grid; gap: 14px; }
.public-certificate .preview-sheet { width: 100%; box-shadow: 0 10px 30px rgba(15, 23, 42, .14); }
.public-certificate-actions { display: flex; justify-content: flex-end; }
@media (max-width: 520px) { .public-certificate-actions .primary-action { width: 100%; } }

@media (max-width: 520px) {
  .back-link { position: static; display: inline-block; margin: 18px 18px 0; }
  .result-page { min-height: auto; }
}

.template-mismatch { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.template-mismatch form { margin: 0; }

.template-usage { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0 0 12px; padding: 10px 12px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); font-size: 14px; }
.template-usage p { margin: 0; }
.template-usage.unused { border-color: #f79009; background: #fffaeb; }
.template-usage select { min-width: 0; max-width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-height: var(--control-height); }
@media (max-width: 700px) { .template-usage .inline-actions { width: 100%; display: grid; } }

.template-card { display: flex; flex-direction: column; }
.template-card-link { display: block; color: inherit; }
.template-card-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 0 8px 8px; margin-top: auto; }
.danger-text { color: #b42318 !important; }
.template-remove { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.template-remove .template-thumb { margin: 0; }
.template-remove-form { display: grid; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.template-remove-form h2 { margin: 0; font-size: 16px; }
.template-remove-form label { display: grid; gap: 6px; font-size: 14px; font-weight: 500; }
.template-remove-form select { border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-height: var(--control-height); }
.usage-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.usage-list div { border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
.usage-list dt { font-size: 12px; color: var(--muted); }
.usage-list dd { margin: 2px 0 0; font-size: 20px; font-weight: 600; }
.form-help { margin: 0; font-size: 13px; color: var(--muted); }
@media (max-width: 800px) { .template-remove { grid-template-columns: 1fr; } .usage-list { grid-template-columns: 1fr; } }
.template-remove-form .danger-action { background: #b42318; color: #fff; }
.template-remove-form button:disabled { opacity: .5; cursor: not-allowed; }

/* ==========================================================================
   Control system — one size for every button, field and dropdown in the admin.
   Height 36px, text 14px, radius 6px, horizontal padding 12/14px.
   Labels 13px/600 muted; what people type is 14px/400 ink.
   ========================================================================== */
.admin-shell { --control-height: 36px; --control-border: #d0d5dd; }

.admin-shell :is(input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]):not([type=color]), select, textarea) {
  box-sizing: border-box;
  width: 100%;
  height: var(--control-height);
  min-height: var(--control-height);
  margin: 0;
  padding: 0 12px;
  border: 1px solid var(--control-border);
  border-radius: 6px;
  background-color: #fff;
  color: var(--ink);
  font: 400 14px/1.2 "IBM Plex Sans Thai", sans-serif;
}
.admin-shell textarea { height: auto; min-height: 96px; padding: 8px 12px; line-height: 1.5; resize: vertical; }
.admin-shell select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23667085' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  text-overflow: ellipsis;
}
.admin-shell :is(input, select, textarea):hover:not(:disabled) { border-color: #98a2b3; }
.admin-shell :is(input, select, textarea):focus { border-color: var(--navy); outline: none; box-shadow: 0 0 0 3px rgba(6, 40, 86, .12); }
.admin-shell input[type=file] { font: 400 14px/1.2 "IBM Plex Sans Thai", sans-serif; color: var(--ink); }
.admin-shell input[type=file]::file-selector-button { height: var(--control-height); margin-right: 10px; padding: 0 14px; border: 1px solid var(--control-border); border-radius: 6px; background: #fff; color: var(--navy); font: 600 14px/1 "IBM Plex Sans Thai", sans-serif; cursor: pointer; }
.admin-shell :is(input[type=checkbox], input[type=radio]) { width: 16px; height: 16px; min-height: 16px; margin: 0; accent-color: var(--navy); }

.admin-shell :where(button, .primary-action, .secondary-action, .danger-action, input[type=submit]):where(:not(.text-action, .icon-action, .draggable-field, .field-row)) {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--control-height);
  min-height: var(--control-height);
  margin: 0;
  padding: 0 14px;
  border: 1px solid var(--control-border);
  border-radius: 6px;
  background: #fff;
  color: var(--navy);
  font: 600 14px/1 "IBM Plex Sans Thai", sans-serif;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .12s, border-color .12s;
}
.admin-shell :where(button, .secondary-action):where(:not(.primary-action, .danger-action, .text-action, .icon-action, .draggable-field, .field-row)):hover:not(:disabled) { background: #f2f4f7; border-color: #98a2b3; }
.admin-shell .primary-action { background: var(--navy); border-color: var(--navy); color: #fff; }
.admin-shell .primary-action:hover:not(:disabled) { background: #0b3a7a; border-color: #0b3a7a; }
.admin-shell .danger-action { background: #fff; border-color: #fda29b; color: #b42318; }
.admin-shell .danger-action:hover:not(:disabled) { background: #fef3f2; }
.admin-shell .template-remove-form .danger-action { background: #b42318; border-color: #b42318; color: #fff; }
.admin-shell .danger-text { color: #b42318 !important; }
.admin-shell :is(button, .primary-action, .secondary-action, .danger-action):disabled { opacity: .45; cursor: not-allowed; }

/* Labels and the field inside them */
.admin-shell label { gap: 6px; color: #344054; font-size: 13px; font-weight: 600; }
.admin-shell label.checkbox-label,
.admin-shell .role-permission-grid label { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 14px; color: var(--ink); }

/* Places where a field sits next to buttons, not in a form column */
.admin-shell .inline-form { display: flex; gap: 8px; align-items: center; }
.admin-shell .inline-form input { width: 280px; max-width: 100%; }
.admin-shell .inline-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.admin-shell .inline-actions select,
.admin-shell .selection-bar select,
.admin-shell .template-usage select { width: auto; min-width: 200px; max-width: 360px; }
.admin-shell .selection-bar { gap: 8px; min-height: 52px; padding: 8px 12px; flex-wrap: wrap; }
.admin-shell .selection-bar a { height: var(--control-height); display: inline-flex; align-items: center; padding: 0 14px; font-size: 14px; }

/* Template editor: the field list is a list, not buttons */
.admin-shell #field-list { display: grid; gap: 6px; margin-top: 8px; }
.admin-shell #field-list .field-row { display: block; width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); font: 400 14px/1.4 "IBM Plex Sans Thai", sans-serif; text-align: left; white-space: normal; cursor: pointer; }
.admin-shell #field-list .field-row.selected { border-color: var(--navy); background: #f0f4fa; }
.admin-shell .field-add { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.admin-shell .icon-action { width: 36px; height: 36px; padding: 0; border: 1px solid #fda29b; border-radius: 6px; background: #fff; color: #b42318; font-size: 18px; line-height: 1; cursor: pointer; }

@media (max-width: 700px) {
  .admin-shell .inline-form input { width: 100%; }
  .admin-shell .inline-actions select,
  .admin-shell .selection-bar select,
  .admin-shell .template-usage select { width: 100%; max-width: none; }
}

/* Project page: add-learner row on one line, list header that never squeezes its title */
.admin-shell .compact-form .inline-form { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.2fr) minmax(0, 1fr) auto; gap: 8px; }
.admin-shell .compact-form .inline-form input { width: 100%; }
.admin-shell .panel-head > div:first-child { flex: 0 0 auto; white-space: nowrap; }
.admin-shell .panel-head .inline-actions { justify-content: flex-end; }
@media (max-width: 700px) {
  .admin-shell .compact-form .inline-form { grid-template-columns: 1fr; }
}

.admin-shell .project-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px 16px; margin: 8px 0 0; padding: 12px; border: 1px solid var(--line); border-radius: 6px; }
.admin-shell .project-picker[hidden] { display: none; }
.admin-shell .project-picker legend { padding: 0 4px; color: #344054; font-size: 13px; font-weight: 600; }
.admin-shell .project-picker .checkbox-label { margin: 0; }
.admin-shell .tool-panel > label { margin: 0 0 16px; }
.admin-shell .tool-panel h2 { margin: 0 0 8px; }

/* Phone: project list actions keep their full names, two per row, never blank boxes */
@media (max-width: 700px) {
  .admin-shell .project-participants .panel-head .inline-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .admin-shell .project-participants .panel-head .inline-actions > * { min-height: var(--control-height); height: var(--control-height); padding: 0 10px; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .admin-shell .project-participants .panel-head .inline-actions > [data-mobile-label]::after { content: none; }
  .admin-shell .project-participants .panel-head .inline-actions > select { grid-column: 1 / -1; width: 100%; max-width: none; }
}

/* Template editor layout */
.admin-shell .designer { grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.admin-shell .tool-panel { padding: 16px; }
.admin-shell .tool-panel button { margin: 0; text-align: center; }
.admin-shell .field-add { margin: 0 0 12px; align-items: stretch; }
.admin-shell #field-list .field-row { display: grid; gap: 2px; min-height: 56px; align-content: center; }
.admin-shell #field-list .field-row strong { font-size: 14px; font-weight: 600; color: var(--navy); }
.admin-shell #field-list .field-row span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.admin-shell #field-properties:not([hidden]) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.admin-shell #field-properties label { margin: 0; font-size: 13px; gap: 6px; }
.admin-shell #field-properties .checkbox-label,
.admin-shell #field-properties #center-field,
.admin-shell #field-properties #remove-field,
.admin-shell #field-properties .form-help { grid-column: 1 / -1; }
.admin-shell #field-properties #center-field,
.admin-shell #field-properties #remove-field { width: 100%; }
.admin-shell .canvas-wrap { padding: 16px; }
.admin-shell .canvas-wrap .certificate-canvas { width: 100%; max-width: none; height: auto; margin: 0 auto; }
.admin-shell .draggable-field::before { content: attr(data-label); position: absolute; left: -1px; bottom: 100%; padding: 1px 6px; border-radius: 4px 4px 0 0; background: rgba(214, 169, 54, .95); color: #fff; font: 600 10px/1.5 "IBM Plex Sans Thai", sans-serif; letter-spacing: 0; text-transform: none; white-space: nowrap; pointer-events: none; opacity: 0; }
.admin-shell .draggable-field:hover::before,
.admin-shell .draggable-field.selected::before { opacity: 1; }
.admin-shell .draggable-field.selected::before { background: var(--navy); }
.admin-shell .unsaved-note { color: #b54708; font-size: 13px; font-weight: 600; }

/* Template usage bar: status on the left, project picker and button on one line on the right */
.admin-shell .template-usage { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px 16px; padding: 12px 16px; margin-bottom: 16px; }
.admin-shell .template-usage .usage-actions { display: flex; gap: 8px; align-items: center; }
.admin-shell .template-usage .usage-actions select { width: 360px; max-width: 40vw; min-width: 0; }

@media (max-width: 900px) {
  .admin-shell .designer { grid-template-columns: 1fr; }
  .admin-shell .template-usage { grid-template-columns: 1fr; }
  .admin-shell .template-usage .usage-actions { display: grid; grid-template-columns: 1fr; }
  .admin-shell .template-usage .usage-actions select { width: 100%; max-width: none; }
}

/* API page */
.admin-shell .new-key { display: grid; gap: 8px; margin: 0 0 16px; padding: 16px; border: 1px solid #12b76a; border-radius: 6px; background: #ecfdf3; }
.admin-shell .new-key-row { display: flex; gap: 8px; }
.admin-shell .new-key-row input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.admin-shell .api-guide { margin-top: 16px; padding: 16px; background: #fff; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; line-height: 1.6; }
.admin-shell .api-guide h2 { margin: 0 0 8px; font-size: 16px; }
.admin-shell .api-guide h3 { margin: 16px 0 6px; font-size: 14px; }
.admin-shell .api-guide ol, .admin-shell .api-guide ul { margin: 0; padding-left: 20px; }
.admin-shell .api-guide code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: #f2f4f7; padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
.admin-shell .api-guide pre { margin: 0; padding: 12px; background: #0b1730; color: #e6edf7; border-radius: 6px; overflow-x: auto; }
.admin-shell .api-guide pre code { background: none; color: inherit; padding: 0; font-size: 12.5px; white-space: pre; overflow-wrap: normal; }
.admin-shell .api-endpoints { display: grid; gap: 6px; margin: 12px 0 0; }
.admin-shell .api-endpoints div { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 12px; align-items: baseline; }
.admin-shell .api-endpoints dt { color: var(--muted); font-size: 13px; }
.admin-shell .api-endpoints dd { margin: 0; }
@media (max-width: 700px) { .admin-shell .api-endpoints div { grid-template-columns: 1fr; gap: 2px; } .admin-shell .new-key-row { display: grid; } }
.admin-shell form.form-panel { max-width: none; }
.admin-shell .narrow-panel { max-width: 640px; }
.admin-shell .range-form { display: grid; grid-template-columns: 160px 160px auto; gap: 12px; align-items: end; }
.admin-shell .range-form label { margin: 0; }
.admin-shell .confirm-panel { display: grid; grid-template-columns: 240px max-content; gap: 12px; align-items: end; margin-top: 16px; }
.admin-shell .confirm-panel label { margin: 0; }
.admin-shell .confirm-panel .danger-action { background: #b42318; border-color: #b42318; color: #fff; }
.admin-shell .test-row { grid-template-columns: 140px minmax(0, 1fr) 160px 120px; }
@media (max-width: 700px) { .admin-shell .range-form, .admin-shell .confirm-panel { grid-template-columns: 1fr; } }

/* ==========================================================================
   Layout pass: field widths follow their content, one card level, one spacing scale (4/8/12/16/24).
   ========================================================================== */
/* Forms: 4-column grid. Normal field = 2 columns, short field (date, select, number) = 1, .full = 4. */
.admin-shell .field-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-flow: row dense; gap: 16px; }
.admin-shell .field-grid > label,
.admin-shell .field-grid > fieldset { grid-column: span 2; margin: 0; }
.admin-shell .field-grid > .short { grid-column: span 1; }
.admin-shell .field-grid > .full { grid-column: 1 / -1; }
.admin-shell .form-panel { padding: 16px; }
.admin-shell .form-panel .action-row { margin-top: 16px; }
@media (max-width: 900px) {
  .admin-shell .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-shell .field-grid > label, .admin-shell .field-grid > fieldset { grid-column: 1 / -1; }
  .admin-shell .field-grid > .short { grid-column: span 1; }
}
@media (max-width: 560px) {
  .admin-shell .field-grid > .short { grid-column: 1 / -1; }
}

/* Settings rows: label, value at its own width, then the hint */
.admin-shell .setting-row { grid-template-columns: 180px auto minmax(0, 1fr); gap: 12px; min-height: 52px; padding: 8px 16px; }
.admin-shell .setting-row > input:not([type=checkbox]):not([class]) { width: 480px; max-width: 100%; }
.admin-shell .input-number { width: 120px !important; }
.admin-shell .input-short { width: 160px !important; }
.admin-shell .input-medium { width: 320px !important; max-width: 100%; }
.admin-shell .setting-row > small { color: var(--muted); font-size: 13px; }
.admin-shell .setting-row > small strong { color: var(--navy); font-weight: 600; }
.admin-shell .settings-section-head { padding: 16px 16px 4px; }
@media (max-width: 700px) {
  .admin-shell .setting-row { grid-template-columns: 1fr; gap: 6px; }
  .admin-shell .input-medium, .admin-shell .setting-row > input:not([type=checkbox]):not([class]) { width: 100% !important; }
}

/* Header search: field and button on one line */
.admin-shell .admin-top .inline-form { flex-wrap: nowrap; }
.admin-shell .admin-top .inline-form input { width: 280px; }
@media (max-width: 700px) { .admin-shell .admin-top .inline-form { width: 100%; } .admin-shell .admin-top .inline-form input { flex: 1; width: auto; } }

/* File pick: no box inside the card */
.admin-shell .file-row { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.admin-shell .file-label { margin: 0; }
.admin-shell .file-label input[type=file] { display: block; margin-top: 6px; padding: 0; border: 0; background: none; min-height: 0; height: auto; }
.admin-shell .form-panel > .form-help { margin: 12px 0 0; }

/* Project: actions for ticked learners on one row, read left to right */
.admin-shell .bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: #f8fafc; }
.admin-shell .bulk-label { color: var(--muted); font-size: 13px; font-weight: 600; margin-right: 4px; }
.admin-shell .bulk-group { display: inline-flex; gap: 8px; }
.admin-shell .bulk-group select { width: 220px; min-width: 0; }
.admin-shell .bulk-end { margin-left: auto; }
.admin-shell .panel-head { padding: 12px; }
@media (max-width: 700px) {
  .admin-shell .bulk-bar { display: grid; grid-template-columns: 1fr 1fr; }
  .admin-shell .bulk-label, .admin-shell .bulk-group { grid-column: 1 / -1; }
  .admin-shell .bulk-group { display: grid; grid-template-columns: 1fr auto; }
  .admin-shell .bulk-group select { width: 100%; }
  .admin-shell .bulk-end { margin-left: 0; }
}

/* Login: readable logo */
.login-card .admin-logo { height: 32px; width: auto; }

/* Public result: details as plain rows inside the one card, no inner bordered box */
.public-shell .details { gap: 0; background: none; border: 0; border-top: 1px solid var(--line); border-radius: 0; margin-top: 24px; }
.public-shell .details div { padding: 12px 0; border-bottom: 1px solid var(--line); background: none; }
.public-shell .details div:nth-child(odd) { padding-right: 16px; }
.public-shell .public-certificate .preview-sheet { box-shadow: none; border-radius: 4px; }
.admin-shell .form-panel { max-width: none; }

/* Log: action column wide enough for the Thai labels */
.admin-shell .audit-row { grid-template-columns: 170px minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, .9fr); }
