/* DVESS – vocational maroon (#932D16) theme, light / dark */
:root {
  --primary: #932D16;
  --bg: #f5f1ee; --surface: #ffffff; --border: #e4dbd5;
  --text: #2a1d18; --muted: #76675f; --soft: #f8e9e4;
  --accent: #932D16; --top: #932D16;
}
:root[data-theme="dark"] {
  --bg: #17120f; --surface: #221b17; --border: #3a2f29;
  --text: #f1e9e4; --muted: #a8998f; --soft: #35211b;
  --accent: #f08f74; --top: #7a2411;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: 'IBM Plex Sans Thai', system-ui, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
input, select, button, textarea { font-family: inherit; }

/* App shell: top bar never scrolls; only .content scrolls */
.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.layout { flex: 1; display: flex; min-height: 0; }

/* Impersonation banner */
.imp-banner { flex: none; display: flex; align-items: center; gap: 14px; height: 44px; padding: 0 20px; background: #1f1a17; color: #fff; border-bottom: 3px solid #f0b429; font-size: 14px; z-index: 30; }
.imp-banner .imp-ico { font-size: 18px; }
.imp-banner .imp-text { flex: 1; min-width: 0; }
.imp-banner b { color: #f0b429; }
.imp-by { opacity: .7; }
.btn-imp-cancel { background: #f0b429; color: #1f1a17; border: 0; border-radius: 6px; padding: 7px 14px; font-weight: 600; font-size: 13px; cursor: pointer; }

/* Top bar */
.topbar { flex: none; height: 60px; display: flex; align-items: center; gap: 14px; padding: 0 20px; background: var(--top); color: #fff; z-index: 20; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.icon-btn { background: rgba(255,255,255,.14); border: 0; color: #fff; width: 38px; height: 38px; border-radius: 8px; font-size: 18px; cursor: pointer; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo { width: 36px; height: 36px; border-radius: 8px; background: #fff; color: #932D16; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.brand-text { line-height: 1.15; min-width: 0; }
.brand-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 12px; opacity: .8; }
.spacer { flex: 1; }
.theme-switch { display: flex; background: rgba(255,255,255,.12); border-radius: 20px; padding: 3px; }
.theme-switch button { border: 0; background: transparent; width: 32px; height: 28px; border-radius: 16px; cursor: pointer; font-size: 14px; }
.theme-switch button.active { background: rgba(255,255,255,.3); }
.profile { position: relative; }
.profile-btn { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 5px 8px 5px 12px; border: 0; border-radius: 30px; background: rgba(255,255,255,.12); color: #fff; }
.profile-meta { display: flex; flex-direction: column; text-align: right; line-height: 1.2; }
.profile-name { font-size: 14px; font-weight: 600; }
.profile-role { font-size: 12px; opacity: .85; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; border: 2px solid #fff; flex: none; }
.avatar.sm { width: 32px; height: 32px; font-size: 13px; border: 0; }
.profile-menu { position: absolute; right: 0; top: 54px; width: 330px; max-height: 70vh; overflow: auto; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.3); padding: 8px; }
.menu-hint { font-size: 12px; color: var(--muted); padding: 6px 10px; }
.menu-user { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; font-size: 13px; }
.menu-user:hover { background: var(--soft); }
.menu-user small { display: block; color: var(--muted); font-size: 12px; }

/* Sidebar */
.sidebar { flex: none; width: 250px; background: var(--surface); border-right: 1px solid var(--border); padding: 12px 10px; overflow: auto; transition: width .2s; display: flex; flex-direction: column; gap: 4px; }
.sidebar.collapsed { width: 68px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; font-size: 14.5px; font-weight: 500; white-space: nowrap; overflow: hidden; color: var(--text); text-decoration: none; }
.nav-item:hover { background: var(--soft); }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-ico { font-size: 20px; width: 24px; text-align: center; flex: none; }
.sidebar.collapsed .nav-label { display: none; }

/* Content */
.content { flex: 1; min-width: 0; overflow: auto; padding: 24px 28px 48px; }
.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 16px; }
.page-head > div { flex: 1; min-width: 200px; }
.page-title { font-size: 24px; font-weight: 700; margin: 0; }
.page-sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.stack { display: flex; flex-direction: column; gap: 16px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; }
.card h3 { margin: 0 0 12px; font-size: 16px; }
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.stat { display: flex; gap: 14px; align-items: center; }
.stat-ico { width: 46px; height: 46px; border-radius: 12px; background: var(--soft); display: grid; place-items: center; font-size: 24px; }
.stat-val { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 13px; color: var(--muted); }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.person-card { border: 1px solid var(--border); border-radius: 12px; padding: 16px; background: var(--bg); display: flex; flex-direction: column; gap: 8px; }

/* Buttons / forms */
.btn { border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 9px; padding: 9px 16px; font-weight: 600; font-size: 14px; cursor: pointer; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn.disabled, .btn:disabled { opacity: .35; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field.full { grid-column: 1 / -1; }
.field input, .field select, .input { padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); color: var(--text); font-size: 14px; }
.badge { padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; background: var(--soft); color: var(--accent); }
.badge.ok { background: #e1f3e8; color: #1e7a43; } .badge.wait { background: #fdf0d3; color: #8a5a00; } .badge.done { background: #e3e9f7; color: #2c4a8f; }
:root[data-theme="dark"] .badge.ok, :root[data-theme="dark"] .badge.wait, :root[data-theme="dark"] .badge.done { background: rgba(255,255,255,.1); color: var(--text); }
.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.view-toggle button { border: 0; padding: 10px 14px; font-size: 14px; cursor: pointer; background: var(--bg); color: var(--text); }
.view-toggle button.active { background: var(--primary); color: #fff; }

/* Modal (native <dialog>) with tabs */
dialog.modal { border: 0; padding: 0; border-radius: 16px; width: min(680px, 94vw); max-height: 92vh; background: var(--surface); color: var(--text); box-shadow: 0 24px 60px rgba(0,0,0,.4); }
dialog.modal::backdrop { background: rgba(0,0,0,.55); }
.modal-head { padding: 18px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal-head b { flex: 1; font-size: 17px; }
.modal-x { cursor: pointer; font-size: 20px; color: var(--muted); background: none; border: 0; }
.tabs { display: flex; gap: 4px; padding: 0 20px; border-bottom: 1px solid var(--border); overflow: auto; }
.tab { padding: 12px 14px; cursor: pointer; font-size: 14px; font-weight: 600; white-space: nowrap; border: 0; background: none; border-bottom: 3px solid transparent; color: var(--muted); }
.tab.active { border-bottom-color: var(--primary); color: var(--accent); }
.tab-panel { display: none; padding: 22px 24px; grid-template-columns: 1fr 1fr; gap: 14px; }
.tab-panel.active { display: grid; }
.modal-foot { padding: 14px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* DataTables tweaks */
table.dataTable { color: var(--text); }
.dt-container .dt-search input, .dt-container .dt-length select { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 7px; }
table.dataTable thead th { border-bottom: 2px solid var(--border) !important; color: var(--muted); }
table.dataTable tbody td { border-top: 1px solid var(--border) !important; }
table.dataTable tbody tr { background: transparent !important; }
.dt-container .dt-paging .dt-paging-button.current { background: var(--primary) !important; color: #fff !important; border-color: var(--primary) !important; }
.dt-container, .dt-container .dt-info, .dt-container .dt-paging .dt-paging-button { color: var(--text) !important; }
.swal2-popup { font-family: inherit; }

@media (max-width: 760px) {
  .brand-text, .profile-meta { display: none; }
  .content { padding: 16px; }
  .sidebar { width: 68px; } .sidebar .nav-label { display: none; }
  .tab-panel { grid-template-columns: 1fr; }
}

/* Auth pages */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px 28px 24px; box-shadow: 0 12px 40px rgba(0,0,0,.12); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.auth-sys { font-weight: 600; font-size: 14.5px; line-height: 1.25; }
.auth-sub { font-size: 12px; color: var(--muted); }
.auth-title { font-size: 22px; margin: 0 0 14px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-alert { padding: 10px 12px; border-radius: 9px; font-size: 13.5px; margin-bottom: 12px; }
.auth-alert.err { background: #fde8e6; color: #9b1c12; border: 1px solid #f5c2bd; }
.auth-alert.ok { background: #e1f3e8; color: #1e7a43; border: 1px solid #b9e0c7; }
.auth-alert.info { background: var(--soft); color: var(--text); border: 1px solid var(--border); }
:root[data-theme="dark"] .auth-alert.err { background: #3a1814; color: #f5b5ae; border-color: #6b2b24; }
:root[data-theme="dark"] .auth-alert.ok { background: #16301f; color: #9fdcb5; border-color: #2c5a3c; }
.auth-help { margin-top: 18px; font-size: 13px; color: var(--muted); }
.auth-help summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.auth-help p { margin: 8px 0; }
.auth-qr { display: grid; place-items: center; background: #fff; border-radius: 12px; padding: 12px; width: max-content; margin: 0 auto 8px; }
.auth-qr svg { width: 200px; height: 200px; }
.link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 13px; text-decoration: underline; }

.dev-badge { background: #f0b429; color: #1f1a17; border-radius: 4px; padding: 1px 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; }

/* Companies / advisors */
.req { color: #c0392b; }
.field small { font-weight: 400; opacity: .8; }
.thumb { max-width: 140px; max-height: 110px; object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 4px; }
.mentor-row { display: grid; grid-template-columns: 2fr 1.3fr 1.2fr auto; gap: 8px; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--border); font-size: 14px; }
.chk { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; color: var(--text); }
.stu-results { max-height: 190px; overflow: auto; border: 1px solid var(--border); border-radius: 9px; padding: 4px 8px; }
.kv-val { color: var(--text); font-size: 14.5px; font-weight: 500; word-break: break-word; }
.badge.err { background: #fde8e6; color: #9b1c12; }
:root[data-theme="dark"] .badge.err { background: rgba(255,255,255,.1); color: var(--text); }
.adv-pick { max-height: 300px; overflow: auto; border: 1px solid var(--border); border-radius: 9px; padding: 4px 8px; }
@media (max-width: 760px) { .mentor-row { grid-template-columns: 1fr; } }

/* author display rules (flex/grid) must not defeat the hidden attribute */
[hidden] { display: none !important; }

/* Trainee diary: attendance / daily log / weekly reflection */
.big-btn { font-size: 18px; padding: 14px 28px; border-radius: 12px; }
.rules { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.photo-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.photo-item { display: flex; gap: 12px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); }
.photo-item.ok { border-color: #2e9b5b; }
.photo-item.bad { border-color: #d33; }
.photo-thumb { width: 110px; height: 82px; object-fit: cover; border-radius: 8px; flex: none; }
.photo-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; }
.photo-name { color: var(--muted); font-size: 12px; word-break: break-all; }
.photo-err { color: #c0392b; }
:root[data-theme="dark"] .photo-err { color: #f5b5ae; }
.photo-ctrls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.photo-mini { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; margin: 2px; border: 2px solid transparent; }
.photo-mini.primary { border-color: #2e9b5b; }
.log-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--border); }
.week-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.week-btn { display: flex; gap: 8px; align-items: center; }
.week-btn.active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--soft); }
.wc { font-size: 12.5px; font-weight: 600; }
.wc.good { color: #1e7a43; } .wc.low { color: #b26a00; }
textarea.input { resize: vertical; font-family: inherit; }
@media (max-width: 760px) { .photo-thumb { width: 84px; height: 64px; } .photo-item { flex-direction: column; } }

/* Admin: update the program */
.update-log { background: #14100e; color: #e8dfd9; border-radius: 10px; padding: 12px 14px; max-height: 340px; overflow: auto; font: 12.5px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; margin: 0; }

/* password requirements checklist (public/assets/js/password-check.js) */
.pw-rules { border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; font-size: 13px; background: var(--soft); }
.pw-rules-title { font-weight: 600; margin-bottom: 6px; color: var(--text); }
.pw-rules ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.pw-rules li { display: flex; gap: 8px; align-items: flex-start; color: var(--muted); }
.pw-rules .pw-ico { width: 1.2em; flex: none; text-align: center; font-weight: 700; }
.pw-rules li.ok { color: #1e7a43; }
.pw-rules li.bad { color: #9b1c12; }
:root[data-theme="dark"] .pw-rules li.ok { color: #7fd5a0; }
:root[data-theme="dark"] .pw-rules li.bad { color: #f5b5ae; }
.pw-summary { margin-top: 8px; font-weight: 600; color: #9b1c12; }
.pw-summary.ok { color: #1e7a43; }
:root[data-theme="dark"] .pw-summary { color: #f5b5ae; }
:root[data-theme="dark"] .pw-summary.ok { color: #7fd5a0; }
.pw-note { margin-top: 6px; font-size: 12px; color: var(--muted); }

/* profile menu / page */
img.avatar { object-fit: cover; display: block; background: var(--soft); }
.profile-menu .menu-hint b { color: var(--text); font-size: 14px; }
.ptabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.ptab { border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: 9px; cursor: pointer; font: inherit; font-size: 13.5px; }
.ptab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.profile-info { display: grid; grid-template-columns: 240px 1fr; gap: 24px; align-items: start; }
.avatar-box { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.avatar-big { width: 160px; height: 160px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; color: #fff; font-size: 56px; font-weight: 700; border: 3px solid var(--border); }
.avatar-big img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.profile-dl { display: grid; grid-template-columns: 160px 1fr; gap: 8px 12px; margin: 0; }
.profile-dl dt { color: var(--muted); font-size: 13px; }
.profile-dl dd { margin: 0; }
.sig-editor { display: grid; grid-template-columns: minmax(250px, 500px) 1fr; gap: 20px; align-items: start; }
.sig-stage { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fff; }
.sig-stage canvas { display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; touch-action: none; cursor: crosshair; }
.sig-saved { display: flex; align-items: center; gap: 12px; }
.sig-saved img { border: 1px dashed var(--border); border-radius: 8px; background: #fff; }
@media (max-width: 720px) {
  .profile-info, .sig-editor { grid-template-columns: 1fr; }
  .profile-dl { grid-template-columns: 1fr; }
}
