:root {
  --bg: #dddcf0;
  --card: #ffffff;
  --ink: #2c2c34;
  --ink-2: #5d5d69;
  --muted: #9b9ba8;
  --line: #ececf2;
  --field: #f1f1f5;
  --green: #9fd35f;
  --green-2: #c6e79a;
  --green-deep: #6fae2a;
  --green-pale: #eef7e2;
  --grad: linear-gradient(90deg, #9fd35f 0%, #c6e79a 100%);
  --red: #e0526b;
  --amber: #e9a23b;
  --blue: #6b8de3;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(40, 40, 80, .04), 0 6px 20px rgba(40, 40, 80, .05);
  --font: "Prompt", "Poppins", "Leelawadee UI", "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--green-deep); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- cards ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; min-width: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-h h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card-h .sub { font-size: 12px; color: var(--muted); font-weight: 400; }

/* ---------- controls ---------- */
.field { width: 100%; background: var(--field); border: 1px solid transparent; border-radius: 10px; padding: 9px 14px; outline: none; transition: border-color .15s, background .15s; }
.field:focus { background: #fff; border-color: var(--green); }
select.field { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%239fd35f' d='M12 21.6 2.4 10.2A5.4 5.4 0 0 1 12 4.3a5.4 5.4 0 0 1 9.6 5.9Z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; cursor: pointer; }
label.lbl { display: block; font-size: 12px; color: var(--ink-2); margin: 0 0 5px 2px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 999px; padding: 8px 18px; cursor: pointer; font-weight: 500; font-size: 13px; background: var(--field); color: var(--ink-2); transition: transform .08s, filter .15s, background .15s; white-space: nowrap; }
.btn:hover { filter: brightness(.97); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--grad); color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.08); }
.btn.ghost { background: transparent; color: var(--ink-2); }
.btn.danger { background: #fdecef; color: var(--red); }
.btn.sm { padding: 5px 12px; font-size: 12px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.spin svg.i { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { width: 32px; height: 32px; border-radius: 50%; border: 0; background: transparent; display: inline-grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { background: var(--field); }
.icon-btn.danger:hover { background: #fdecef; color: var(--red); }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.pill { display: inline-block; font-size: 11px; line-height: 1; padding: 5px 10px; border-radius: 999px; background: var(--field); color: var(--ink-2); white-space: nowrap; }
.pill.green { background: var(--green-2); color: #3f6b12; }
.pill.pale { background: var(--green-pale); color: #4d7d1c; }
.pill.red { background: #fdecef; color: var(--red); }
.pill.blue { background: #e9eefc; color: #3f5fb5; }
.pill.amber { background: #fdf2e0; color: #a86b12; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { accent-color: var(--green-deep); width: 16px; height: 16px; }
.dept-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 12px; max-height: 220px; overflow: auto;
  border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: 12.5px; }
.dept-picks .check { align-items: flex-start; }
.dept-picks .check input { margin-top: 1px; flex: none; }
.dept-picks input:disabled + span { opacity: .45; }
.form-grid [hidden] { display: none !important; }
.seg { display: inline-flex; background: var(--field); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 5px 12px; font-size: 12px; cursor: pointer; color: var(--ink-2); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); font-weight: 500; }

/* ---------- login ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 18px; width: min(860px, 100%); }
.hero { padding: 30px; display: flex; flex-direction: column; justify-content: space-between; gap: 22px; position: relative; overflow: hidden; }
.hero h1 { font-size: 24px; margin: 6px 0 4px; line-height: 1.3; }
.hero .co { font-size: 12px; color: var(--muted); letter-spacing: .02em; }
.hero-art { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mini { background: var(--field); border-radius: 12px; padding: 12px 14px; }
.mini b { display: block; font-size: 20px; }
.mini span { font-size: 11px; color: var(--muted); }
.bar { height: 7px; border-radius: 99px; background: #ececf0; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--grad); }
.login-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.login-card form { padding: 30px 32px 22px; display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.login-logo { display: block; width: 150px; max-width: 60%; height: auto; margin: 4px auto 14px; }
.login-card .field { border-radius: 999px; padding: 10px 18px; }
.pw-wrap { position: relative; }
.pw-wrap .icon-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.login-card .btn.primary { padding: 11px; font-size: 15px; margin-top: 4px; }
.login-card form[hidden] { display: none; }
.otp-note { text-align: center; font-size: 13px; color: var(--ink-2); line-height: 1.6; }
.login-card .field.otp-in { text-align: center; font-size: 22px; letter-spacing: .45em; padding: 10px 18px 10px calc(18px + .45em); font-variant-numeric: tabular-nums; }
.otp-links { display: flex; justify-content: space-between; gap: 8px; }
.login-foot { background: var(--green-pale); text-align: center; padding: 18px 16px 20px; font-size: 12px; color: var(--ink-2); margin-top: auto; }
.login-foot svg { width: 30px; height: 30px; stroke: var(--green); display: block; margin: 0 auto 6px; }
.err { color: var(--red); font-size: 12px; min-height: 18px; text-align: center; }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 18px; padding: 18px; min-height: 100%; }
.side { position: sticky; top: 18px; align-self: start; display: flex; flex-direction: column; gap: 4px; padding: 18px 12px; max-height: calc(100vh - 36px); }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 16px; }
.brand-logo { width: 38px; height: 38px; border-radius: 12px; background: var(--grad); display: grid; place-items: center; color: #fff; }
.brand b { display: block; font-size: 14px; line-height: 1.2; }
.brand small { font-size: 11px; color: var(--muted); }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--ink-2); font-size: 13.5px; }
.nav a:hover { background: var(--field); }
.nav a.on { background: var(--grad); color: #fff; font-weight: 500; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; display: flex; align-items: center; gap: 10px; }
.side-foot .who { min-width: 0; flex: 1; }
.side-foot .who b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-foot .who span { font-size: 11px; color: var(--muted); }
.main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.topbar h2 { margin: 0; font-size: 20px; font-weight: 600; }
.topbar .crumb { font-size: 12px; color: var(--ink-2); opacity: .8; }
.topbar .tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.av { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--green-pale); color: var(--green-deep); font-weight: 600; flex: none; font-size: 14px; }
.av.lg { width: 96px; height: 96px; font-size: 32px; }

/* ---------- grids ---------- */
.grid { display: grid; gap: 18px; }
.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { display: flex; align-items: center; gap: 14px; }
.kpi .ic { width: 46px; height: 46px; border-radius: 50%; background: var(--grad); display: grid; place-items: center; color: #fff; flex: none; }
.kpi b { display: block; font-size: 22px; line-height: 1.2; }
.kpi span { font-size: 12px; color: var(--muted); }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-1-1 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-1-2 { grid-template-columns: minmax(280px, 1fr) minmax(0, 2.2fr); align-items: start; }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
/* dashboard: chart with calendar / latest / no-training under it on the left, department hours on the right */
.stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; container-type: inline-size; }
.dash-sub { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
@container (min-width: 620px) {
  .dash-sub { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-sub > :last-child { grid-column: 1 / -1; }
}
@container (min-width: 980px) {
  .dash-sub { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash-sub > :last-child { grid-column: auto; }
}
/* Side by side: the department card takes the left column's height and scrolls inside */
@media screen and (min-width: 1021px) {
  .dept-card { contain: size; display: flex; flex-direction: column; }
  .dept-card .plist { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -8px; padding: 4px 8px; }
}

/* progress list (dept) */
.plist { display: flex; flex-direction: column; gap: 12px; }
.plist .row { display: grid; grid-template-columns: minmax(0, 1fr) 70px; gap: 4px 10px; align-items: center; font-size: 12.5px; }
.plist .row .bar { grid-column: 1 / -1; }
.plist .row .v { text-align: right; color: var(--ink-2); }
.plist button.row { border: 0; background: none; font: inherit; color: inherit; text-align: left; padding: 4px 6px; margin: -4px -6px; border-radius: 10px; cursor: pointer; }
.plist button.row:hover { background: #fafafc; }
.plist button.row:hover > span:first-child { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
.pill-btn { border: 0; cursor: pointer; display: inline-flex; align-items: center; gap: 2px; font: inherit; font-size: 11px; }
.pill-btn svg.i { width: 12px; height: 12px; }
.link-btn { border: 0; background: none; font: inherit; font-size: 12px; color: var(--ink-2); padding: 8px 0 0; cursor: pointer; text-align: left; }
.link-btn:hover { text-decoration: underline; }
.elist.people { max-height: min(62vh, 560px); }

/* list rows */
.list { display: flex; flex-direction: column; }
.list .li { display: flex; align-items: center; gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--line); min-width: 0; }
.list .li:last-child { border-bottom: 0; }
.list .li .t { flex: 1; min-width: 0; }
.list .li .t b { font-weight: 500; font-size: 13px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .li .t span { font-size: 11.5px; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex: none; }

/* search list (employees) */
.searchbox { position: relative; margin-bottom: 8px; }
.searchbox .field { padding-right: 38px; background: transparent; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding-left: 4px; }
.searchbox .field:focus { border-color: var(--green); }
.searchbox svg { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); color: var(--ink-2); }
.elist { display: flex; flex-direction: column; max-height: calc(100vh - 290px); overflow: auto; margin: 0 -20px; }
.elist a { display: flex; align-items: center; gap: 10px; padding: 8px 20px; color: var(--ink-2); font-size: 13px; border-bottom: 1px solid var(--line); }
.elist a:hover { background: #fafafc; }
.elist a.on { background: var(--grad); color: #fff; }
.elist a.on .muted { color: rgba(255,255,255,.85); }
.elist a .av { width: 30px; height: 30px; font-size: 12px; }
.elist a.on .av { background: rgba(255,255,255,.35); color: #fff; }
.elist .grp { padding: 10px 20px 4px; font-size: 11px; color: var(--muted); letter-spacing: .03em; background: #fafafc; position: sticky; top: 0; }

/* profile card */
.profile { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 18px; align-items: center; }
.profile h2 { margin: 0; font-size: 19px; }
.profile .meta { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12.5px; color: var(--ink-2); margin-top: 4px; }
.profile .meta span { display: inline-flex; align-items: center; gap: 5px; }
.profile .meta svg { width: 14px; height: 14px; color: var(--green-deep); }
.heart { width: 52px; height: 52px; border-radius: 50%; background: var(--grad); display: grid; place-items: center; color: #fff; border: 0; cursor: pointer; box-shadow: 0 4px 12px rgba(111,174,42,.3); }
.heart svg { width: 22px; height: 22px; }
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.stat { background: var(--field); border-radius: 12px; padding: 10px 12px; }
.stat b { display: block; font-size: 18px; }
.stat span { font-size: 11px; color: var(--muted); }

/* tables */
.tbl-wrap { overflow: auto; margin: 0 -20px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th { text-align: left; font-weight: 500; color: var(--muted); font-size: 11.5px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; background: #fff; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th:first-child, .tbl td:first-child { padding-left: 20px; }
.tbl th:last-child, .tbl td:last-child { padding-right: 20px; }
.tbl tr:hover td { background: #fbfbfd; }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl .topic { font-weight: 500; color: var(--ink); min-width: 220px; }
.tbl .acts { white-space: nowrap; text-align: right; }
.tbl tr.yr td { background: #fafafc; font-size: 11.5px; color: var(--ink-2); font-weight: 600; padding-top: 7px; padding-bottom: 7px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; font-size: 13px; }

/* schedule strip */
.strip { display: flex; align-items: center; gap: 6px; }
.strip .days { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; gap: 4px; }
.strip .d { font-size: 11px; color: var(--muted); cursor: pointer; border-radius: 10px; padding: 4px 0 6px; }
.strip .d b { display: block; font-size: 18px; color: var(--ink-2); font-weight: 400; }
.strip .d.today b { color: var(--red); }
.strip .d.sel { background: var(--green-pale); }
.strip .d i { display: block; width: 7px; height: 7px; border-radius: 50%; margin: 3px auto 0; background: transparent; }
.strip .d.has i { background: var(--green); }

/* upload */
.drop { border: 1.5px dashed #d4d4de; border-radius: 12px; padding: 30px 16px; text-align: center; color: var(--muted); font-size: 12.5px; transition: background .15s, border-color .15s; }
.drop.over { background: var(--green-pale); border-color: var(--green); }
.drop .up { width: 64px; height: 64px; border-radius: 50%; background: #e4e4ea; display: grid; place-items: center; margin: 0 auto 12px; color: #fff; }
.drop .up svg { width: 28px; height: 28px; stroke-width: 2.2; }
.prog { display: flex; align-items: center; gap: 14px; }
.prog .ic { width: 42px; height: 42px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; flex: none; }
.prog .t { flex: 1; font-size: 11.5px; color: var(--muted); }
.prog .bar { margin-top: 6px; height: 9px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(44, 44, 70, .35); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .15s; }
.modal { width: min(640px, 100%); max-height: calc(100vh - 32px); overflow: auto; }
.modal.wide { width: min(880px, 100%); }
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
@keyframes fade { from { opacity: 0; } }

/* toast */
.toast { position: fixed; right: 18px; bottom: 18px; background: var(--ink); color: #fff; border-radius: 12px; padding: 11px 16px; font-size: 13px; z-index: 60; box-shadow: var(--shadow); display: flex; align-items: center; gap: 10px; animation: fade .2s; max-width: calc(100vw - 36px); }
.toast.ok::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.toast.bad::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }

/* pick list (bulk add) */
.picklist { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.picklist label { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-bottom: 1px solid var(--line); font-size: 13px; cursor: pointer; }
.picklist label:hover { background: #fafafc; }
.picklist .grp { padding: 7px 12px; font-size: 11.5px; background: #fafafc; color: var(--ink-2); display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; }

.notice { background: #fdf2e0; color: #8a5a10; border-radius: 12px; padding: 12px 16px; font-size: 13px; display: flex; gap: 10px; align-items: center; }

/* bottom nav (mobile) */
.bnav { display: none; }

@media (max-width: 1280px) and (min-width: 821px) {
  .shell { grid-template-columns: 68px minmax(0, 1fr); }
  .side { padding: 14px 10px; align-items: center; }
  .brand { padding: 2px 0 14px; }
  .brand > div:last-child, .nav a span, .side-foot .who, .side-foot .av { display: none; }
  .nav a { justify-content: center; padding: 11px; }
  .side-foot { justify-content: center; }
}
@media (max-width: 1020px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-2-1, .g-1-2, .g-3 { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .elist { max-height: 340px; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); padding: 12px 16px 90px; }
  .side { display: none; }
  .login-grid { grid-template-columns: minmax(0, 1fr); }
  .hero { display: none; }
  .g-1-1, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .profile { grid-template-columns: auto minmax(0, 1fr); }
  .profile .heart { display: none; }
  .av.lg { width: 64px; height: 64px; font-size: 22px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bnav { display: flex; position: fixed; left: 12px; right: 12px; bottom: 12px; background: #fff; border-radius: 16px; box-shadow: var(--shadow); justify-content: space-around; padding: 8px; z-index: 40; }
  .bnav a { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: var(--ink-2); }
  .bnav a.on { background: var(--grad); color: #fff; }
  .hide-sm { display: none; }
}

@media print {
  body { background: #fff; }
  .side, .bnav, .topbar .tools, .no-print, .acts { display: none !important; }
  .shell { display: block; padding: 0; }
  .card { box-shadow: none; padding: 8px 0; }
  .tbl-wrap { overflow: visible; margin: 0; }
  .tbl th { position: static; }
}

/* photos */
.av { overflow: hidden; }
.av img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 18%; display: block; }
.photo-wrap { position: relative; }
.photo-acts { position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); display: flex; gap: 2px; background: #fff; border-radius: 999px; box-shadow: var(--shadow); padding: 1px; }
.photo-acts .icon-btn { width: 26px; height: 26px; }
.photo-acts svg.i { width: 14px; height: 14px; }
.av.lg:has(img) { width: 108px; height: 140px; border-radius: 14px; cursor: zoom-in; }
.av.lg img { object-position: 50% 15%; }
.photo-big { display: block; max-width: 100%; max-height: calc(100vh - 140px); margin: 0 auto; border-radius: 12px; }
@media (max-width: 820px) { .av.lg:has(img) { width: 72px; height: 94px; } }
