/* =========================================================================
   TCEX 2026 Executive Voting — shared styles
   Royal purple theme (สีม่วง) consistent with the current TMA website.
   ========================================================================= */
:root {
  --p-950: #1d0b38;
  --p-900: #2a1050;
  --p-800: #3a1868;
  --p-700: #4f2390;   /* primary */
  --p-600: #5f2fa8;
  --p-500: #7848c4;
  --p-300: #b9a0e6;
  --p-200: #d9cbf3;
  --p-100: #ece4fa;
  --p-50:  #f7f3fd;
  --gold: #c8a24b;
  --gold-light: #ecd593;

  --bg: #f3f0f8;
  --surface: #ffffff;
  --text: #1f1633;
  --muted: #6b6380;
  --faint: #9a94a8;
  --border: #e3ddef;
  --border-strong: #cfc6e2;

  --green: #15803d;  --green-500: #22a454; --green-bg: #e7f6ec;
  --blue: #1d4ed8;   --blue-500: #2f6ae6;  --blue-bg: #e8effd;
  --grey: #8a849a;   --grey-bg: #f0eef4;
  --amber: #b45309;  --amber-500: #f59e0b; --amber-bg: #fff5e3;
  --red: #b91c1c;    --red-bg: #fdecec;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(31, 22, 51, .06);
  --shadow: 0 2px 6px rgba(31, 22, 51, .06), 0 8px 24px rgba(31, 22, 51, .06);
  --shadow-lg: 0 20px 60px rgba(29, 11, 56, .28);
  --font: 'Inter', 'Noto Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5;
  color: var(--text); background: var(--bg);
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; color: var(--p-800); }
p { margin: 0; }
a { color: var(--p-600); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
svg.ico { width: 1.1em; height: 1.1em; flex: none; vertical-align: -0.15em; }
svg:not([width]):not([class]) { max-width: 100%; }
:focus-visible { outline: 3px solid var(--p-300); outline-offset: 2px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 9px 18px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: var(--p-700); color: #fff;
  font-weight: 600; font-size: 14.5px; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--p-800); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { background: var(--p-200); color: #fff; cursor: not-allowed; transform: none; }
.btn-outline { background: #fff; color: var(--p-700); border-color: var(--border-strong); }
.btn-outline:hover { background: var(--p-50); border-color: var(--p-300); }
.btn-outline:disabled { background: #fff; color: var(--faint); border-color: var(--border); }
.btn-ghost { background: transparent; color: var(--p-700); }
.btn-ghost:hover { background: var(--p-50); }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #991b1b; }
.btn-danger-outline { background: #fff; color: var(--red); border-color: #f1c4c4; }
.btn-danger-outline:hover { background: var(--red-bg); }
.btn-success { background: var(--green); }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 13.5px; }
.btn-xs { min-height: 28px; padding: 3px 9px; font-size: 12.5px; border-radius: 6px; }
.btn-lg { min-height: 50px; padding: 12px 28px; font-size: 16px; }
.btn-block { width: 100%; }
.btn .ico { width: 16px; height: 16px; flex: none; }
.link-btn { background: none; border: 0; padding: 0; color: var(--p-600); cursor: pointer; font-weight: 500; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.link-btn:hover { text-decoration: underline; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label, .label { font-weight: 600; font-size: 14px; color: var(--text); }
.req { color: var(--red); }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: #fff; transition: border-color .15s, box-shadow .15s;
}
textarea.input { min-height: 110px; resize: vertical; line-height: 1.5; }
.input:focus { outline: none; border-color: var(--p-500); box-shadow: 0 0 0 3px var(--p-100); }
.input.invalid { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-bg); }
.input-icon { position: relative; }
.input-icon > .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--faint); pointer-events: none; }
.input-icon .input { padding-left: 40px; }
.input-icon .toggle-pw { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 6px; }
.hint { font-size: 12.5px; color: var(--muted); }
.counter { font-size: 12px; color: var(--faint); text-align: right; }
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--p-700); }
.form-error { background: var(--red-bg); color: var(--red); border: 1px solid #f3c9c9; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 14px; }

/* ---------- App header (purple bar) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(90deg, var(--p-900), var(--p-700));
  color: #fff; box-shadow: 0 2px 10px rgba(29, 11, 56, .25);
}
.topbar-inner { max-width: 1160px; margin: 0 auto; padding: 0 20px; height: 64px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; min-width: 0; }
.brand img { height: 34px; width: auto; }
.brand-text { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; line-height: 1.25; text-transform: uppercase; }
.topbar-spacer { flex: 1; }
.welcome { text-align: right; font-size: 12px; line-height: 1.3; opacity: .92; }
.welcome strong { display: block; font-size: 13.5px; font-weight: 600; opacity: 1; }
.topnav { display: flex; align-items: center; gap: 4px; }
.topnav a, .topnav button {
  display: inline-flex; align-items: center; gap: 6px; color: #fff; text-decoration: none; background: none;
  border: 1px solid transparent; padding: 7px 10px; border-radius: 8px; font-size: 13.5px; cursor: pointer;
}
.topnav a:hover, .topnav button:hover { background: rgba(255, 255, 255, .12); }
.topnav .ico { width: 16px; height: 16px; }
.lang-toggle { border: 1px solid rgba(255, 255, 255, .35) !important; font-weight: 600; font-size: 12.5px !important; }

/* ---------- Page layout ---------- */
.page { max-width: 1160px; margin: 0 auto; padding: 28px 20px 64px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 28px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.page-title { font-size: 26px; font-weight: 700; }
.page-sub { color: var(--muted); margin-top: 6px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--p-500); margin-bottom: 6px; }

/* ---------- Status pills ---------- */
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.status .dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.status .dot svg { width: 13px; height: 13px; }
.status.completed { color: var(--green); }
.status.completed .dot { background: var(--green-500); color: #fff; }
.status.in_progress { color: var(--blue); }
.status.in_progress .dot { background: var(--blue-500); color: #fff; }
.status.not_started { color: var(--grey); }
.status.not_started .dot { background: #d6d2de; color: #fff; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.pill.completed { background: var(--green-bg); color: var(--green); }
.pill.in_progress { background: var(--blue-bg); color: var(--blue); }
.pill.not_started { background: var(--grey-bg); color: var(--grey); }
.pill.warn { background: var(--amber-bg); color: var(--amber); }
.pill.danger { background: var(--red-bg); color: var(--red); }
.pill.purple { background: var(--p-100); color: var(--p-700); }

/* ---------- Banners / alerts ---------- */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius-sm); font-size: 14px; border: 1px solid; }
.alert .ico { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.alert-info { background: var(--p-50); border-color: var(--p-200); color: var(--p-800); }
.alert-warn { background: var(--amber-bg); border-color: #f6d9a6; color: #7c3f06; }
.alert-danger { background: var(--red-bg); border-color: #f3c9c9; color: var(--red); }
.alert-success { background: var(--green-bg); border-color: #b9e4c7; color: var(--green); }

/* ---------- Stepper ---------- */
.stepper { display: flex; align-items: center; gap: 10px; margin: 18px 0 26px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; font-weight: 500; }
.step-num { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; border: 1.5px solid var(--border-strong); background: #fff; color: var(--muted); flex: none; }
.step.active { color: var(--p-700); font-weight: 700; }
.step.active .step-num { background: var(--p-700); border-color: var(--p-700); color: #fff; }
.step.done { color: var(--text); }
.step.done .step-num { background: var(--green-500); border-color: var(--green-500); color: #fff; }
.step.done .step-num svg { width: 15px; height: 15px; }
.step-line { flex: 1; min-width: 24px; max-width: 90px; height: 2px; background: var(--border); }
.step-line.done { background: var(--green-500); }

/* ---------- Organization rows ---------- */
.org-list { display: grid; gap: 10px; }
.org-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 16px; min-height: 60px;
  border: 1px solid var(--border); border-radius: 10px; background: #fff; transition: border-color .15s, background .15s, box-shadow .15s;
}
.org-row.selectable { cursor: pointer; }
.org-row.selectable:hover { border-color: var(--p-300); }
.org-row.selected { border-color: var(--p-500); background: var(--p-50); box-shadow: inset 3px 0 0 var(--p-600); }
.org-row.disabled { opacity: .55; }
.org-row.disabled.selectable { cursor: not-allowed; }
.org-row input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--p-700); flex: none; cursor: inherit; }
.org-icon { width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; background: var(--p-50); color: var(--p-500); flex: none; }
.org-icon svg { width: 22px; height: 22px; }
.org-name { flex: 1; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.factsheet-link { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--p-600); background: none; border: 0; cursor: pointer; padding: 6px 8px; border-radius: 6px; white-space: nowrap; font-weight: 500; }
.factsheet-link:hover { background: var(--p-100); }
.factsheet-link svg { width: 18px; height: 18px; }
.factsheet-link.none { color: var(--faint); cursor: default; }
.factsheet-link.none:hover { background: none; }
.rank-badge { width: 30px; height: 30px; border-radius: 7px; background: var(--p-800); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }

/* ---------- Rating ---------- */
.rating-row .factsheet-link { margin-left: -8px; }
.rating-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 18px 20px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.rating-row.rated { border-color: var(--p-200); }
.rating-org { display: flex; align-items: center; gap: 12px; min-width: 0; }
.rating-org .names { min-width: 0; }
.rating-org .org-name { display: block; }
.scale { display: grid; gap: 6px; justify-items: stretch; }
.scale-buttons { display: flex; gap: 8px; }
.scale-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 1.5px solid var(--border-strong); background: #fff;
  font-weight: 700; font-size: 15px; color: var(--text); cursor: pointer; transition: all .12s; flex: none;
}
.scale-btn:hover:not(:disabled) { border-color: var(--p-500); color: var(--p-700); background: var(--p-50); }
.scale-btn.on, .scale-btn.on:hover:not(:disabled) { background: var(--p-700); border-color: var(--p-700); color: #fff; box-shadow: 0 4px 12px rgba(79, 35, 144, .35); }
.scale-btn:disabled { cursor: not-allowed; opacity: .6; }
.scale-ends { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); }
.scale-current { font-size: 13px; font-weight: 600; color: var(--p-700); min-height: 20px; text-align: center; }
.scale-current.unrated { color: var(--faint); font-weight: 500; }

.scale-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.scale-table th { text-align: left; font-weight: 700; color: var(--p-800); padding: 6px 10px; border-bottom: 1px solid var(--p-200); }
.scale-table td { padding: 5px 10px; border-bottom: 1px solid var(--p-100); }
.scale-table td:first-child, .scale-table th:first-child { width: 64px; text-align: center; font-weight: 700; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; background: var(--p-50); padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fcfbfe; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .center { text-align: center; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(29, 11, 56, .55); backdrop-filter: blur(2px);
  display: grid; place-items: center; padding: 20px; animation: fade .15s ease-out;
}
.modal { background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); width: min(560px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; animation: pop .18s ease-out; }
.modal.wide { width: min(860px, 100%); }
.modal.xl { width: min(1100px, 100%); height: calc(100vh - 40px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 19px; }
.modal-body { padding: 22px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.icon-btn { width: 36px; height: 36px; border-radius: 8px; border: 0; background: none; display: grid; place-items: center; cursor: pointer; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--p-50); color: var(--p-700); }
.icon-btn svg { width: 20px; height: 20px; }
.modal.xl .modal-body { flex: 1; padding: 0; overflow: hidden; display: flex; }
.pdf-frame { width: 100%; height: 100%; flex: 1; border: 0; background: #525659; display: block; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- Toast ---------- */
.toasts { position: fixed; z-index: 200; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; width: min(440px, calc(100% - 32px)); }
.toast { background: var(--p-950); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 14px; display: flex; gap: 10px; align-items: center; animation: pop .18s ease-out; }
.toast.error { background: var(--red); }
.toast.success { background: #14532d; }
.toast svg { width: 18px; height: 18px; flex: none; }

/* ---------- Misc ---------- */
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 16px; }
.mt-0 { margin-top: 0 !important; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.divider { height: 1px; background: var(--border); margin: 24px 0; border: 0; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--p-100); border-top-color: var(--p-600); border-radius: 50%; animation: spin .8s linear infinite; }
.loading { display: grid; place-items: center; padding: 80px 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.kbd { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: var(--p-50); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; }

@media (max-width: 760px) {
  .topbar-inner { height: 58px; padding: 0 14px; gap: 10px; }
  .brand img { height: 28px; }
  .brand-text { font-size: 10px; }
  .welcome { display: none; }
  .topnav .label-text { display: none; }
  .page { padding: 18px 16px 48px; }
  .card-pad { padding: 18px; }
  .page-title { font-size: 21px; }
  .rating-row { grid-template-columns: 1fr; gap: 12px; padding: 16px; }
  .scale-buttons { justify-content: space-between; gap: 4px; }
  .scale-btn { width: 38px; height: 38px; font-size: 14px; }
  .org-row { padding: 10px 12px; gap: 10px; }
  .org-icon { display: none; }
  .factsheet-link .label-text { display: none; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal { width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; }
  .modal.xl { height: 92vh; }
  .step-label { display: none; }
  .step.active .step-label { display: inline; }
}
@media (max-width: 380px) {
  .scale-btn { width: 34px; height: 34px; font-size: 13px; }
}
@media print {
  .topbar, .no-print, .toasts { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ccc; }
}
