/* =========================================================
   CRS Check – styles. Skins are pure CSS variables on <html data-skin>.
   Changing a skin never changes behaviour.
   ========================================================= */
:root, [data-skin="modern"] {
  --primary: #183451; --primary-deep: #10283f; --primary-ink: #fff;
  --accent: #a9501c; --accent-soft: #d4af83; --red: #df0011; --green: #2f7252;
  --bg: #f6f4ef; --paper: #fff; --surface-2: #f5f8fa; --ink: #172433; --muted: #687584; --line: #dfe3e6;
  --input-bg: #fff; --input-line: #cbd4dc; --focus: rgba(24, 52, 81, .12);
  --header-bg: #183451; --header-ink: #fff; --header-muted: #c9d3dd;
  --hero-bg: radial-gradient(1200px 600px at 85% 10%, #2b5379 0%, transparent 60%), radial-gradient(800px 500px at 0% 100%, rgba(169,80,28,.35) 0%, transparent 60%), linear-gradient(135deg, #10283f, #183451 55%, #0a1926);
  --notice-bg: #fff4e9; --notice-ink: #8d451a;
  --th-bg: #f8f9fa; --row-hover: #f5f8fa; --chip-bg: #eef2f5; --chip-ink: #33475b;
  --shadow: 0 20px 50px rgba(16, 40, 63, .12); --radius: 10px; --btn-radius: 7px;
  --font: "Segoe UI", "Noto Sans Thai", "Noto Sans JP", "Hiragino Sans", Arial, sans-serif;
  --font-head: Manrope, "Segoe UI", "Noto Sans Thai", "Noto Sans JP", Arial, sans-serif;
  color-scheme: light;
}
[data-skin="colorful"] {
  --primary: #5b2a86; --primary-deep: #43196a; --primary-ink: #fff;
  --accent: #e4572e; --accent-soft: #ffc857; --green: #138a72;
  --bg: #fff8f0; --paper: #fff; --surface-2: #fdf1ff; --ink: #24133a; --muted: #6d5c80; --line: #eadcf2;
  --input-bg: #fff; --input-line: #d9c6e8; --focus: rgba(91, 42, 134, .16);
  --header-bg: linear-gradient(90deg, #5b2a86, #a23b72 55%, #e4572e); --header-ink: #fff; --header-muted: #f6dff0;
  --hero-bg: radial-gradient(900px 500px at 90% 0%, #ffc85766 0%, transparent 55%), radial-gradient(700px 500px at 0% 100%, #17bebb55 0%, transparent 60%), linear-gradient(135deg, #43196a, #a23b72 60%, #e4572e);
  --notice-bg: #fff1e6; --notice-ink: #9a3412;
  --th-bg: #fbf3ff; --row-hover: #fff6e8; --chip-bg: #f3e8ff; --chip-ink: #5b2a86;
  --shadow: 0 20px 50px rgba(91, 42, 134, .16); --radius: 16px; --btn-radius: 999px;
}
[data-skin="msn"] {
  --primary: #2b5797; --primary-deep: #1d3f73; --primary-ink: #fff;
  --accent: #3a9b2e; --accent-soft: #bfe3ff; --green: #2f8a2a;
  --bg: #dfeaf7; --paper: #fdfeff; --surface-2: #eef5fd; --ink: #0d2240; --muted: #4f6584; --line: #a9c3e3;
  --input-bg: #fff; --input-line: #7f9dc5; --focus: rgba(43, 87, 151, .2);
  --header-bg: linear-gradient(180deg, #4f8fd9 0%, #2b5797 55%, #234a83 100%); --header-ink: #fff; --header-muted: #dbe9fb;
  --hero-bg: linear-gradient(180deg, #6fa8e8 0%, #2b5797 45%, #163a6b 100%);
  --notice-bg: #fffbd6; --notice-ink: #6b5200;
  --th-bg: linear-gradient(180deg, #f6faff, #dbe8f8); --row-hover: #eaf3ff; --chip-bg: #e2eefc; --chip-ink: #1d3f73;
  --shadow: 0 6px 18px rgba(29, 63, 115, .25); --radius: 6px; --btn-radius: 4px;
  --font: Tahoma, "Segoe UI", "Noto Sans Thai", "Noto Sans JP", Verdana, sans-serif;
  --font-head: Tahoma, "Segoe UI", "Noto Sans Thai", "Noto Sans JP", Verdana, sans-serif;
}
[data-skin="dark"] {
  --primary: #5b9bd5; --primary-deep: #79b0e2; --primary-ink: #08121c;
  --accent: #e9a15f; --accent-soft: #d4af83; --red: #ff6b6b; --green: #5fc38f;
  --bg: #0d141c; --paper: #151f2a; --surface-2: #1b2734; --ink: #e6edf3; --muted: #9aa8b6; --line: #2a3846;
  --input-bg: #0f1822; --input-line: #3a4a5b; --focus: rgba(91, 155, 213, .25);
  --header-bg: #0a1017; --header-ink: #e6edf3; --header-muted: #9aa8b6;
  --hero-bg: radial-gradient(1000px 600px at 85% 10%, #1d3550 0%, transparent 60%), linear-gradient(135deg, #070c12, #0d141c 60%, #111c27);
  --notice-bg: #2c1f12; --notice-ink: #f5c08a;
  --th-bg: #1b2734; --row-hover: #1d2b39; --chip-bg: #223244; --chip-ink: #cfe0f1;
  --shadow: 0 20px 50px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { color: var(--ink); background: var(--bg); font-family: var(--font); font-size: 15px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .6; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.ico { display: inline-flex; line-height: 0; flex: none; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.stack { display: grid; gap: 14px; } .stack.tight { gap: 8px; }
.stack label, .modal label { display: grid; gap: 6px; font-size: 13px; font-weight: 700; }
.stack label.check-choice { display: flex; font-weight: 400; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0; }
legend { font-size: 13px; font-weight: 700; padding: 0 4px; }
code { background: var(--chip-bg); padding: 1px 6px; border-radius: 4px; }

input, select, textarea { background: var(--input-bg); border: 1px solid var(--input-line); border-radius: 6px; padding: 9px 11px; min-height: 42px; outline: none; width: 100%; color: var(--ink); }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; accent-color: var(--primary); flex: none; }
input[type=file] { padding: 8px; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
textarea { resize: vertical; min-height: 90px; }
select option { background: var(--paper); color: var(--ink); }

.brand-logo { object-fit: contain; width: 164px; height: auto; display: block; }
.primary { background: var(--primary); color: var(--primary-ink); border: 0; border-radius: var(--btn-radius); display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 20px; font-weight: 700; transition: background .2s, transform .2s; }
.primary:hover:not(:disabled) { background: var(--primary-deep); transform: translateY(-1px); }
.primary.wide { width: 100%; }
.secondary { color: var(--primary); background: var(--paper); border: 1px solid var(--line); border-radius: var(--btn-radius); display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; font-weight: 700; white-space: nowrap; }
.secondary:hover:not(:disabled) { border-color: var(--primary); }
.icon-btn { background: transparent; border: 1px solid transparent; color: inherit; border-radius: 8px; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.icon-btn:hover:not(:disabled) { background: var(--surface-2); }
.icon-btn.sm { width: 30px; height: 30px; }
.link-btn { background: none; border: 0; color: var(--primary); padding: 0; font-weight: 700; font-size: 12px; }
.step-label, .eyebrow { letter-spacing: .16em; color: var(--accent); font: 700 11px/1 var(--font); text-transform: uppercase; }
.inline-notice { color: var(--notice-ink); background: var(--notice-bg); border-left: 3px solid var(--accent); border-radius: 3px; margin: 12px 0; padding: 11px 13px; font-size: 13px; }
.chip { display: inline-block; background: var(--chip-bg); color: var(--chip-ink); border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 600; margin: 2px 4px 2px 0; white-space: nowrap; }
.chip.ok { background: #e5f3ec; color: #1f6143; } .chip.off { background: #f1e3e3; color: #8f261f; }
[data-skin="dark"] .chip.ok { background: #183a2a; color: #8fe0b5; } [data-skin="dark"] .chip.off { background: #3a1d1d; color: #ffb4b4; }

/* ---------- preferences (language + skin) ---------- */
.prefs { display: flex; align-items: center; gap: 8px; }
.lang-wrap { position: relative; display: flex; align-items: center; }
.lang-wrap .ico { position: absolute; left: 9px; pointer-events: none; color: var(--muted); }
.lang-select { min-height: 36px; padding: 6px 28px 6px 30px; width: auto; border-radius: var(--btn-radius); font-size: 13px; font-weight: 600; }
.skin-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 12px; border-radius: var(--btn-radius); border: 1px solid var(--line); background: var(--paper); color: var(--ink); font-size: 13px; font-weight: 600; }
.prefs.on-dark .lang-select, .prefs.on-dark .skin-btn { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.28); color: var(--header-ink); }
.prefs.on-dark .lang-wrap .ico { color: var(--header-muted); }
.prefs.on-dark .lang-select option { color: #172433; background: #fff; }

/* ---------- toast & modal ---------- */
.toast { position: fixed; z-index: 200; right: 24px; bottom: 24px; max-width: min(460px, calc(100vw - 32px)); background: var(--primary); color: var(--primary-ink); box-shadow: var(--shadow); border-radius: 8px; display: flex; align-items: center; gap: 10px; padding: 14px 17px; font-weight: 600; }
.toast.error { background: #8f261f; color: #fff; }
.help-overlay { position: fixed; inset: 0; z-index: 120; background: rgba(5, 10, 17, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--paper); color: var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); width: min(520px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; border: 1px solid var(--line); }
.modal.wide { width: min(720px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font: 800 19px/1.25 var(--font-head); }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.modal textarea { min-height: 260px; font-family: var(--font); line-height: 1.55; }

/* ---------- lobby ---------- */
.hero-lobby { min-height: 100vh; position: relative; color: #fff; overflow: hidden; display: flex; flex-direction: column; }
.hero-bg { position: absolute; inset: 0; background: var(--hero-bg); z-index: 0; }
.hero-bg::after { content: ""; position: absolute; width: 520px; height: 520px; right: -140px; top: -160px; border: 1px solid rgba(212,175,131,.25); border-radius: 50%; }
.hero-nav, .hero-layout { position: relative; z-index: 1; }
.hero-nav { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 22px max(16px, 5vw); flex-wrap: wrap; }
.hero-nav .brand-logo { width: 160px; }
.hero-nav-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hero-new { background: var(--accent); color: #fff; border: 0; border-radius: var(--btn-radius); display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; font-weight: 700; }
.hero-layout { flex: 1; display: grid; grid-template-columns: 1.1fr .9fr; align-items: center; gap: 5vw; padding: 3vh max(16px, 6vw) 8vh; }
.hero-copy h1 { font: 800 clamp(44px, 6vw, 86px)/1 var(--font-head); letter-spacing: -.04em; margin: 18px 0 8px; }
.hero-copy h2 { font: 600 clamp(20px, 2.2vw, 30px)/1.2 var(--font-head); color: var(--accent-soft); margin: 0 0 18px; }
.hero-copy p { color: #d6dee6; max-width: 560px; font-size: 17px; line-height: 1.65; margin: 0 0 28px; }
.hero-copy .eyebrow { color: var(--accent-soft); }
.security-note { display: flex; align-items: center; gap: 10px; color: #dbe2e9; font-size: 14px; }
.login-card { width: 100%; max-width: 480px; justify-self: end; background: var(--paper); color: var(--ink); border-radius: calc(var(--radius) + 4px); padding: 30px; box-shadow: 0 30px 80px rgba(0,0,0,.35); border: 1px solid var(--line); }
.login-card h2 { margin: 10px 0 6px; font: 800 28px/1.2 var(--font-head); letter-spacing: -.02em; }
.login-card > div > p { color: var(--muted); margin: 0 0 20px; }
.role-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.role-tabs.three { grid-template-columns: repeat(3, 1fr); }
.role-tabs button { border: 1px solid var(--line); background: var(--paper); text-align: left; border-radius: 9px; padding: 13px 14px; font-weight: 700; color: var(--ink); }
.role-tabs button span { display: block; color: var(--muted); font-weight: 400; font-size: 12px; margin-top: 3px; }
.role-tabs button.active { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); background: var(--surface-2); }
.login-fields { display: grid; gap: 14px; margin: 6px 0 16px; }
.login-fields label, .passcode-card label { display: grid; gap: 7px; font-size: 13px; font-weight: 700; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 44px; }
.password-wrap button { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); padding: 4px; }
.forgot { justify-self: end; background: none; border: 0; padding: 0; color: var(--accent); font-weight: 700; font-size: 13px; }
.hero-form-mobile { display: none; width: 100%; margin-top: 12px; background: none; border: 1px dashed var(--line); border-radius: var(--btn-radius); padding: 11px; color: var(--primary); font-weight: 700; align-items: center; justify-content: center; gap: 6px; }

/* ---------- distributor form ---------- */
.form-page { min-height: 100vh; background: var(--bg); }
.form-page > header { background: var(--paper); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 72px; padding: 10px max(16px, calc(50vw - 525px)); flex-wrap: wrap; }
.form-page > header .brand-logo { width: 135px; }
.form-head-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.secure-pill { color: var(--green); display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; }
.back { background: none; border: 0; color: var(--primary); font-weight: 700; }
.form-heading { max-width: 1050px; margin: 44px auto 22px; padding: 0 16px; display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.form-heading h1 { font: 800 40px/1 var(--font-head); letter-spacing: -.035em; margin: 9px 0 11px; }
.form-heading p { color: var(--muted); margin: 0; }
.required-note { color: var(--muted); font-size: 12px; white-space: nowrap; }
em { color: var(--red); font-style: normal; margin-left: 3px; }
.crs-form { max-width: 1050px; margin: 0 auto 70px; padding: 0 16px; display: grid; gap: 16px; }
.crs-form > section { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px 30px; }
.crs-form h2 { color: var(--primary); font: 700 17px var(--font-head); margin: 0 0 22px; padding-bottom: 13px; border-bottom: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 24px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field.wide { grid-column: 1 / -1; }
.field > label { font-size: 13px; font-weight: 700; }
.field small { color: var(--muted); font-size: 11px; }
.stacked-fields { display: grid; gap: 26px; }
.radio-row { display: flex; gap: 28px; flex-wrap: wrap; }
.radio-column { display: grid; gap: 10px; }
.radio-row label, .radio-column label, .check-choice { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 400; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 16px; }
.other-input { margin-top: 10px; max-width: 360px; }
.file-list { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.submit-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 24px; }
.submit-bar p { margin: 0; color: var(--muted); font-size: 13px; }
.form-page.compact { display: flex; flex-direction: column; }
.passcode-card { background: var(--paper); border: 1px solid var(--line); border-radius: calc(var(--radius) + 4px); box-shadow: var(--shadow); width: min(440px, calc(100% - 32px)); margin: 8vh auto; padding: 32px; text-align: center; }
.passcode-card h1 { font: 800 32px/1.1 var(--font-head); margin: 10px 0; }
.passcode-card p { color: var(--muted); }
.passcode-card form { display: grid; gap: 14px; text-align: left; margin-top: 16px; }
.lock-mark { width: 56px; height: 56px; border-radius: 50%; background: var(--surface-2); color: var(--primary); display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.thanks { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; background: var(--bg); }
.thanks-prefs { position: absolute; top: 16px; right: 16px; }
.thanks section { background: var(--paper); border: 1px solid var(--line); border-radius: calc(var(--radius) + 4px); padding: 36px; width: min(520px, 100%); text-align: center; display: grid; gap: 12px; justify-items: center; box-shadow: var(--shadow); }
.thanks h1 { font: 800 30px/1.1 var(--font-head); margin: 6px 0 0; }
.thanks p { color: var(--muted); margin: 0; }
.success-mark { color: var(--green); }
.reference { background: var(--surface-2); border-radius: 8px; padding: 10px 16px; }
.text-button { background: none; border: 0; color: var(--primary); font-weight: 700; }

/* ---------- dashboard ---------- */
.dashboard { min-height: 100vh; background: var(--bg); }
.dash-header { background: var(--header-bg); color: var(--header-ink); display: flex; align-items: center; gap: 20px; padding: 12px max(16px, 3vw); position: sticky; top: 0; z-index: 30; flex-wrap: wrap; }
.dash-header .brand-logo { width: 130px; }
.dash-header nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.dash-header nav button { background: none; border: 0; color: var(--header-muted); padding: 9px 13px; border-radius: 6px; font-weight: 700; }
.dash-header nav button.nav-active, .dash-header nav button:hover { color: var(--header-ink); background: rgba(255,255,255,.12); }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.header-actions .secondary { background: rgba(255,255,255,.1); color: var(--header-ink); border-color: rgba(255,255,255,.28); }
.header-actions .icon-btn { color: var(--header-ink); }
.header-actions .icon-btn:hover { background: rgba(255,255,255,.12); }
.user-badge { display: flex; align-items: center; gap: 9px; }
.user-badge > span { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; text-transform: uppercase; }
.user-badge strong { display: block; font-size: 13px; } .user-badge small { color: var(--header-muted); font-size: 11px; text-transform: capitalize; }
.dashboard-content { max-width: 1440px; margin: 0 auto; padding: 28px max(16px, 3vw) 60px; }
.page-title { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; }
.page-title h1 { font: 800 34px/1.05 var(--font-head); letter-spacing: -.03em; margin: 8px 0; }
.page-title p { color: var(--muted); margin: 0; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.metrics button { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; text-align: left; color: var(--ink); }
.metrics button span { display: block; color: var(--muted); font-size: 13px; font-weight: 600; }
.metrics button strong { font: 800 28px/1.2 var(--font-head); color: var(--primary); }
.metrics button.active { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
[data-skin="colorful"] .metrics button:nth-child(1) { background: linear-gradient(135deg, #fff, #f3e8ff); }
[data-skin="colorful"] .metrics button:nth-child(2) { background: linear-gradient(135deg, #fff, #fff1d6); }
[data-skin="colorful"] .metrics button:nth-child(3) { background: linear-gradient(135deg, #fff, #ffe4ec); }
[data-skin="colorful"] .metrics button:nth-child(4) { background: linear-gradient(135deg, #fff, #dcfbf3); }
.bg-refresh { color: var(--muted); font-size: 13px; margin: 6px 0; }
.deleted-toggle { margin: 4px 0 12px; }
.table-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table-tools { display: grid; grid-template-columns: minmax(220px, 1fr) auto auto; align-items: end; gap: 12px; padding: 16px; border-bottom: 1px solid var(--line); }
.search { position: relative; display: flex; align-items: center; }
.search .ico { position: absolute; left: 11px; color: var(--muted); }
.search input { padding-left: 38px; }
.filter-row { display: flex; gap: 10px; flex-wrap: wrap; }
.status-filter { display: grid; gap: 4px; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.status-filter select { min-width: 150px; max-width: 210px; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--ink); }
.export-row { display: flex; gap: 8px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { background: var(--th-bg); text-align: left; font-size: 12px; color: var(--muted); padding: 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:last-child { padding: 10px 14px; }
.sort-header { background: none; border: 0; padding: 11px 14px; font-weight: 700; color: inherit; width: 100%; text-align: left; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: top; }
td small { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; }
.sub-table tbody tr { cursor: pointer; }
.sub-table tbody tr:hover { background: var(--row-hover); }
td.empty { text-align: center; color: var(--muted); padding: 40px; cursor: default; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.mini { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); background: var(--paper); color: var(--primary); border-radius: var(--btn-radius); padding: 5px 9px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.mini:hover { border-color: var(--primary); }
.mini.danger { color: #b42318; } [data-skin="dark"] .mini.danger { color: #ff8a80; }
.table-footer { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; font-size: 13px; color: var(--muted); }
.table-footer button { border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 6px; padding: 6px 12px; }
.table-footer span { margin-left: auto; font-size: 12px; }

.status { display: inline-block; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 700; background: #eef2f5; color: #33475b; }
.status.pending-1st-approval { background: #fff0d9; color: #8a4b08; }
.status.pending-2nd-approval { background: #e3edfb; color: #1d4f91; }
.status.complete { background: #e5f3ec; color: #1f6143; }
.status.green { background: #e2f4ea; color: #1b6b43; } .status.blue { background: #e1ecfb; color: #174f9c; }
.status.red { background: #fde4e1; color: #a1251a; } .status.yellow { background: #fff5bd; color: #7a5b00; } .status.gray { background: #eceff2; color: #44515e; }
[data-skin="dark"] .status { background: #263545; color: #d6e2ee; }
[data-skin="dark"] .status.pending-1st-approval { background: #3d2c12; color: #ffcf8a; }
[data-skin="dark"] .status.pending-2nd-approval, [data-skin="dark"] .status.blue { background: #16304f; color: #9cc6ff; }
[data-skin="dark"] .status.complete, [data-skin="dark"] .status.green { background: #153526; color: #8fe0b5; }
[data-skin="dark"] .status.red { background: #3d1a17; color: #ffa59b; } [data-skin="dark"] .status.yellow { background: #3a3110; color: #ffe37a; }
.first-result { margin-top: 6px; }
.waiting { font-size: 12px; font-weight: 700; }
.waiting.caution { color: #8a6d00; } .waiting.warning { color: #b45309; } .waiting.danger { color: #b42318; } .waiting.finished { color: var(--green); }
[data-skin="dark"] .waiting.caution { color: #f0d060; } [data-skin="dark"] .waiting.warning { color: #ffb070; } [data-skin="dark"] .waiting.danger { color: #ff8a80; }

/* ---------- drawer ---------- */
.drawer-scrim { position: fixed; inset: 0; background: rgba(5, 10, 17, .45); z-index: 60; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--paper); color: var(--ink); z-index: 70; display: flex; flex-direction: column; box-shadow: -20px 0 50px rgba(0,0,0,.2); border-left: 1px solid var(--line); }
.drawer-head { display: flex; justify-content: space-between; gap: 12px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font: 800 22px/1.2 var(--font-head); margin: 8px 0; word-break: break-word; }
.drawer-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.drawer-body { flex: 1; overflow: auto; padding: 18px 22px; display: grid; gap: 16px; align-content: start; }
.drawer-body h3 { font: 700 14px var(--font-head); margin: 0 0 10px; color: var(--primary); }
.summary-card { background: var(--surface-2); border-radius: 8px; padding: 14px 16px; display: grid; gap: 3px; }
.summary-card span, .summary-card small { color: var(--muted); font-size: 12px; }
.attachment-links { display: grid; gap: 6px; }
.attachment-links a { font-weight: 600; font-size: 13px; word-break: break-all; }
.detail-list > div { display: grid; grid-template-columns: 42% 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.detail-list span { color: var(--muted); } .detail-list strong { font-weight: 600; word-break: break-word; }
.audit > div { display: flex; gap: 12px; margin-bottom: 10px; }
.audit i { font-style: normal; width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: var(--primary-ink); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 12px; flex: none; }
.audit p { margin: 0; display: grid; gap: 2px; font-size: 13px; } .audit small { color: var(--muted); }
.approval-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; background: var(--surface-2); }
.approval-box label { display: grid; gap: 6px; font-size: 13px; font-weight: 700; }
.decision-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.decision-grid button { border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 8px; padding: 10px; text-align: left; font-size: 13px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.decision-grid button.selected { border-color: var(--primary); box-shadow: inset 0 0 0 2px var(--primary); }
.drawer-foot { display: flex; gap: 8px; flex-wrap: wrap; padding: 14px 22px; border-top: 1px solid var(--line); }
.drawer-foot button { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--paper); color: var(--primary); border-radius: var(--btn-radius); padding: 9px 12px; font-weight: 700; font-size: 13px; }
.drawer-foot button.delete { color: #b42318; margin-left: auto; } [data-skin="dark"] .drawer-foot button.delete { color: #ff8a80; }

/* ---------- admin ---------- */
.admin-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.admin-tabs button { display: inline-flex; align-items: center; gap: 4px; background: var(--paper); border: 1px solid var(--line); color: var(--ink); border-radius: var(--btn-radius); padding: 9px 14px; font-weight: 700; }
.admin-tabs button.active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.admin-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.admin-card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.admin-card-head h2 { margin: 0; font: 800 20px var(--font-head); }
.admin-table td { cursor: default; }
tr.is-off td, li.is-off .setting-main { opacity: .6; }
.cat-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.cat-chips button { border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 600; }
.cat-chips button.active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.setting-list { list-style: none; margin: 0; padding: 0; }
.setting-list li { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.setting-list li.empty { color: var(--muted); justify-content: center; padding: 24px; }
.order-btns { display: flex; flex-direction: column; }
.setting-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.setting-main small { color: var(--muted); font-size: 12px; word-break: break-word; }

/* MSN-like bevels */
[data-skin="msn"] .table-card, [data-skin="msn"] .admin-card, [data-skin="msn"] .crs-form > section, [data-skin="msn"] .login-card, [data-skin="msn"] .metrics button, [data-skin="msn"] .modal { border: 1px solid #7f9dc5; box-shadow: inset 0 1px 0 #fff, 0 2px 6px rgba(29,63,115,.18); }
[data-skin="msn"] .primary { background: linear-gradient(180deg, #5fa0e8, #2b5797); box-shadow: inset 0 1px 0 rgba(255,255,255,.5); border: 1px solid #1d3f73; }
[data-skin="msn"] .primary:hover:not(:disabled) { background: linear-gradient(180deg, #74b1f2, #3463a8); }
[data-skin="msn"] .secondary, [data-skin="msn"] .mini, [data-skin="msn"] .admin-tabs button { background: linear-gradient(180deg, #ffffff, #e3edf9); border-color: #7f9dc5; }
[data-skin="msn"] .admin-tabs button.active { background: linear-gradient(180deg, #5fa0e8, #2b5797); color: #fff; }
[data-skin="msn"] .crs-form h2, [data-skin="msn"] .drawer-body h3 { color: #1d3f73; }
[data-skin="msn"] .user-badge > span { background: linear-gradient(180deg, #7ad36b, #2f8a2a); }
[data-skin="colorful"] .primary { background: linear-gradient(90deg, #5b2a86, #a23b72); }
[data-skin="colorful"] .primary:hover:not(:disabled) { background: linear-gradient(90deg, #43196a, #e4572e); }
[data-skin="dark"] .brand-logo { filter: none; }
[data-skin="dark"] .form-page > header { background: var(--paper); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .table-tools { grid-template-columns: 1fr; align-items: stretch; }
  .hero-layout { grid-template-columns: 1fr; }
  .login-card { justify-self: stretch; max-width: 560px; }
}
@media (max-width: 760px) {
  body { font-size: 14px; }
  .hero-nav .brand-logo { width: 130px; }
  .hero-new { display: none; }
  .hero-form-mobile { display: inline-flex; }
  .hero-copy p, .security-note { display: none; }
  .hero-copy h1 { font-size: 44px; margin-top: 10px; }
  .hero-layout { padding-top: 0; gap: 18px; }
  .login-card { padding: 20px; }
  .role-tabs.three { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .role-tabs button { padding: 10px 8px; font-size: 13px; }
  .role-tabs button span { font-size: 11px; }
  .form-heading { flex-direction: column; align-items: flex-start; margin-top: 24px; }
  .form-heading h1 { font-size: 32px; }
  .crs-form > section { padding: 18px 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .submit-bar { flex-direction: column; align-items: stretch; }
  .dash-header { gap: 10px; }
  .dash-header nav { order: 3; flex-basis: 100%; }
  .header-actions { margin-left: auto; }
  .hide-sm, .user-badge div { display: none; }
  .page-title h1 { font-size: 26px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .status-filter { flex: 1 1 140px; } .status-filter select { max-width: none; min-width: 0; }
  .export-row .secondary { flex: 1; justify-content: center; }
  /* tables become cards */
  .sub-table thead, .admin-table thead { display: none; }
  .sub-table tr, .admin-table tr { display: block; border-bottom: 1px solid var(--line); padding: 10px 12px; }
  .sub-table td, .admin-table td { display: grid; grid-template-columns: 38% 1fr; gap: 8px; border: 0; padding: 4px 0; }
  .sub-table td::before, .admin-table td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; }
  .sub-table td.row-actions, .admin-table td.row-actions { display: flex; padding-top: 8px; }
  .sub-table td.row-actions::before, .admin-table td.row-actions::before, td.empty::before { content: none; }
  td.empty { display: block !important; }
  .table-footer span { margin-left: 0; }
  .drawer-foot button.delete { margin-left: 0; }
  .detail-list > div { grid-template-columns: 1fr; gap: 2px; }
  .decision-grid { grid-template-columns: 1fr; }
  .setting-list li { flex-wrap: wrap; }
  .setting-list .row-actions { width: 100%; padding-left: 42px; }
  .skin-btn span:not(.ico) { display: none; }
  .two-col { grid-template-columns: 1fr; }
  .toast { left: 16px; right: 16px; bottom: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* fixes after visual review */
[data-skin="msn"] .header-actions .secondary { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.4); color: #fff; }
@media (max-width: 760px) {
  .sub-table td > small, .sub-table td > .status + small { grid-column: 2; margin-top: 0; }
  .sub-table td:nth-child(2) > small { display: none; }
}
