/* ============================================================
   Eval Tool — Design System
   Health at Work / Health at Home
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@400;500;600;700;800&family=Noto+Sans+Thai:wght@400;500;600;700;800&display=swap');

:root {
  /* Brand */
  --primary: #3FD19E;
  --primary-dark: #2AB885;
  --primary-deep: #1E9E72;
  --primary-light: #E8FAF4;
  --primary-mid: #C0F0DC;

  /* Ink */
  --text: #14271F;
  --text-muted: #5A7A6E;
  --text-light: #8FA89F;

  /* Surfaces */
  --bg: #F5FAF8;
  --surface: #FFFFFF;
  --border: #E2F0EA;
  --border-strong: #CFE7DD;

  /* Semantic */
  --danger: #E84C4C;
  --danger-light: #FEF2F2;
  --warn: #F08C2E;
  --warn-light: #FFF6EA;
  --info: #4B7BEC;
  --info-light: #EEF3FE;

  /* Accent palette for teams / charts */
  --team-design: #3FD19E;
  --team-eng: #6366F1;
  --team-product: #F08C2E;

  /* Effects */
  --shadow-sm: 0 1px 2px rgba(20, 39, 31, 0.04);
  --shadow-md: 0 6px 24px rgba(20, 39, 31, 0.07);
  --shadow-lg: 0 24px 60px rgba(20, 39, 31, 0.10);
  --shadow-brand: 0 8px 22px rgba(63, 209, 158, 0.20);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  --font: "Sarabun", "Noto Sans Thai", system-ui, -apple-system, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, monospace;

  --sidebar-w: 232px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

/* ── App shell ──────────────────────────────────── */
.app {
  display: flex;
  min-height: 100vh;
}
.main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  height: 100vh;
}
.content {
  max-width: 920px;
  margin: 0 auto;
  padding: 34px 40px 80px;
}
.content.wide { max-width: 1100px; }
.content.narrow { max-width: 760px; }

/* ── Sidebar ────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(150deg, var(--primary), var(--primary-dark));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 17px;
  box-shadow: 0 4px 12px rgba(63,209,158,0.32);
  flex-shrink: 0;
}
.sidebar-logo .name { font-size: 14.5px; font-weight: 800; letter-spacing: -0.3px; }
.sidebar-logo .sub { font-size: 11px; color: var(--text-light); margin-top: -1px; }

.sidebar-nav {
  flex: 1;
  padding: 12px 12px;
  overflow-y: auto;
}
.nav-section-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.6px;
  text-transform: uppercase; color: var(--text-light);
  padding: 14px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  margin-bottom: 2px;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active {
  background: var(--primary-light);
  color: var(--primary-deep);
  font-weight: 600;
}
.nav-item .nav-ic {
  width: 18px; text-align: center; font-size: 15px; opacity: 0.85; flex-shrink: 0;
}
.nav-item .nav-badge {
  margin-left: auto;
  font-size: 11px; font-weight: 700;
  background: var(--primary); color: #fff;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
}

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px;
  border-top: 1px solid var(--border);
}
.sidebar-user .u-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .u-role { font-size: 11px; color: var(--text-light); }

/* ── Avatar ─────────────────────────────────────── */
.avatar {
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; flex-shrink: 0;
  width: 36px; height: 36px; font-size: 14px;
}
.avatar.dark { background: var(--primary-dark); }
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }
.avatar.lg { width: 46px; height: 46px; font-size: 18px; }
.avatar.muted { background: var(--border-strong); color: var(--text-muted); }

/* ── Page header ────────────────────────────────── */
.page-head { margin-bottom: 26px; }
.page-title { font-size: 23px; font-weight: 800; letter-spacing: -0.6px; }
.page-sub { font-size: 14px; color: var(--text-muted); margin-top: 4px; }

.head-row {
  display: flex; align-items: center; gap: 14px;
}
.back-btn {
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 17px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color 0.15s, color 0.15s;
}
.back-btn:hover { border-color: var(--border-strong); color: var(--text); }

/* ── Badge / Status ─────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
}
.badge .b-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge.not_started { background: #F1F5F3; color: #8FA89F; }
.badge.draft { background: var(--warn-light); color: var(--warn); }
.badge.submitted { background: var(--primary-light); color: var(--primary-deep); }
.badge.overdue { background: var(--danger-light); color: var(--danger); }
.badge.pending { background: var(--info-light); color: var(--info); }
.badge.active { background: var(--primary-light); color: var(--primary-deep); }
.badge.resigned { background: #EEEAEC; color: #94858C; }

/* ── Buttons ────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  font-family: var(--font);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: transform 0.14s, box-shadow 0.14s, background 0.14s, border-color 0.14s;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--shadow-brand); transform: translateY(-1px); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary-deep); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.95); }
.btn-sm { padding: 7px 13px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn:disabled, .btn.is-disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none !important; transform: none !important; }
.submit-hint { font-size: 12.5px; color: var(--warn); display: flex; align-items: center; gap: 6px; }
.submit-hint.ok { color: var(--primary-deep); }

/* ── Cards ──────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px 24px; }

/* ── KPI cards (admin dashboard) ─────────────────── */
.kpi { padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.kpi .k-num { font-size: 30px; font-weight: 800; line-height: 1.05; letter-spacing: -0.5px; color: var(--text); }
.kpi .k-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }

/* ── Stat cards (team progress) ──────────────────── */
.stat-card { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.stat-card .s-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.stat-card .s-pct { font-size: 26px; font-weight: 800; line-height: 1; letter-spacing: -0.5px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 15px; font-weight: 700; }
.card-head .sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Cycle banner ───────────────────────────────── */
.cycle-banner {
  position: relative; overflow: hidden;
  background: linear-gradient(150deg, var(--primary), var(--primary-dark) 70%, var(--primary-deep));
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  color: #fff;
  display: flex; align-items: center; justify-content: space-between;
}
.cycle-banner .ring {
  position: absolute; border-radius: 50%;
  background: rgba(255,255,255,0.10);
  right: -30px; top: -40px; width: 180px; height: 180px;
  pointer-events: none;
}
.cycle-banner .ring.two { right: 60px; bottom: -90px; top: auto; width: 130px; height: 130px; background: rgba(255,255,255,0.07); }
.cycle-banner .cb-main { position: relative; }
.cycle-banner .cb-label { font-size: 12px; color: rgba(255,255,255,0.78); font-weight: 500; margin-bottom: 4px; }
.cycle-banner .cb-title { font-size: 24px; font-weight: 800; letter-spacing: -0.5px; }
.cycle-banner .cb-deadline { font-size: 13px; color: rgba(255,255,255,0.85); margin-top: 4px; }
.cycle-banner .cb-count { position: relative; text-align: right; }
.cycle-banner .cb-count .n { font-size: 44px; font-weight: 800; line-height: 1; }
.cycle-banner .cb-count .u { font-size: 13px; color: rgba(255,255,255,0.82); }

/* ── Progress bar ───────────────────────────────── */
.progress {
  display: flex; align-items: center; gap: 10px;
}
.progress .track {
  flex: 1; height: 6px; border-radius: 3px;
  background: var(--border); overflow: hidden;
}
.progress .fill {
  height: 100%; border-radius: 3px;
  background: var(--primary);
  transition: width 0.6s ease;
}
.progress .label { font-size: 12px; color: var(--text-muted); min-width: 38px; text-align: right; white-space: nowrap; }

/* ── Assignment row ─────────────────────────────── */
.assign-card {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  width: 100%; text-align: left; font-family: var(--font);
}
.assign-card:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.assign-card .ac-icon {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  background: var(--primary-light); color: var(--primary-deep);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.assign-card .ac-title { font-size: 14.5px; font-weight: 600; }
.assign-card .ac-sub { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.assign-card .ac-chev { font-size: 19px; color: var(--text-light); }

/* ── Score buttons (1–4) ────────────────────────── */
.score-row { display: flex; gap: 8px; }
.score-btn {
  width: 46px; height: 46px; border-radius: 11px;
  border: 1.5px solid var(--border);
  background: transparent; color: var(--text-muted);
  font-size: 17px; font-weight: 700; cursor: pointer;
  font-family: var(--font);
  transition: all 0.14s;
  display: flex; align-items: center; justify-content: center;
}
.score-btn:hover { border-color: var(--primary-mid); background: var(--primary-light); }
.score-btn.selected { border-color: var(--primary); background: var(--primary); color: #fff; box-shadow: var(--shadow-brand); }

/* ── Rating dots (1–5) ──────────────────────────── */
.rating-row { display: flex; gap: 9px; }
.rating-dot {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1.5px solid var(--border);
  background: transparent; color: var(--text-light);
  font-size: 14px; font-weight: 700; cursor: pointer;
  font-family: var(--font);
  transition: all 0.14s;
  display: flex; align-items: center; justify-content: center;
}
.rating-dot:hover { border-color: var(--primary-mid); }
.rating-dot.selected { border-color: var(--primary-dark); background: var(--primary-dark); color: #fff; }

/* ── Form fields ────────────────────────────────── */
.field { margin-bottom: 20px; }
.field-label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 7px; }
.field-label .opt { font-weight: 400; color: var(--text-light); font-size: 12px; }
.field-hint { font-size: 12px; color: var(--text-muted); margin-top: -2px; margin-bottom: 8px; line-height: 1.5; }
.input, .textarea, .select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 14px; color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder, .textarea::placeholder { color: var(--text-light); }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(63,209,158,0.16);
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
.field.error .input, .field.error .textarea { border-color: var(--danger); }
.field.error .field-error { color: var(--danger); font-size: 12px; margin-top: 6px; display: block; }
.field.filled .input, .field.filled .textarea { border-color: var(--primary-mid); background: #FCFFFE; }

/* ── Tabs ───────────────────────────────────────── */
.tabs {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}
.tab {
  padding: 9px 18px; border: none; cursor: pointer;
  background: transparent; color: var(--text-muted);
  font-family: var(--font); font-size: 13px; font-weight: 500;
  transition: all 0.15s;
}
.tab.active { background: var(--primary); color: #fff; font-weight: 700; }

/* ── Table ──────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl thead th {
  text-align: left; padding: 11px 16px;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.tbl tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: var(--bg); }

/* ── Modal ──────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20,39,31,0.42);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fade 0.18s ease;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 26px 28px;
  max-width: 380px; width: 100%;
  box-shadow: var(--shadow-lg);
  animation: pop 0.2s ease;
}
.modal .m-icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; margin-bottom: 14px;
}
.modal .m-icon.warn { background: var(--warn-light); color: var(--warn); }
.modal .m-icon.danger { background: var(--danger-light); color: var(--danger); }
.modal .m-icon.brand { background: var(--primary-light); color: var(--primary-deep); }
.modal h3 { font-size: 18px; font-weight: 800; margin-bottom: 8px; }
.modal p { font-size: 14px; color: var(--text-muted); line-height: 1.6; margin-bottom: 22px; }
.modal .m-actions { display: flex; gap: 10px; }
.modal .m-actions .btn { flex: 1; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ── Empty state ────────────────────────────────── */
.empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-muted);
}
.empty .e-icon {
  width: 64px; height: 64px; border-radius: 18px;
  background: var(--primary-light); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 30px; margin-bottom: 16px;
}
.empty h3 { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty p { font-size: 13.5px; max-width: 320px; margin: 0 auto; line-height: 1.6; }

/* ── Misc helpers ───────────────────────────────── */
.section-label {
  display: flex; align-items: center; gap: 9px;
  font-size: 13px; font-weight: 700; color: var(--primary-deep);
  margin-bottom: 14px;
}
.section-label .bar { width: 4px; height: 16px; border-radius: 2px; background: var(--primary); }
.stack { display: flex; flex-direction: column; }
.gap-6 { gap: 6px; } .gap-10 { gap: 10px; } .gap-14 { gap: 14px; } .gap-20 { gap: 20px; }
.row { display: flex; align-items: center; }
.between { justify-content: space-between; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; } .mt-32 { margin-top: 32px; }
.mb-14 { margin-bottom: 14px; } .mb-24 { margin-bottom: 24px; }
.muted { color: var(--text-muted); }
.light { color: var(--text-light); }
.fw-700 { font-weight: 700; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.grid { display: grid; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }

.hint-legend {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--text-muted);
}
.hint-legend .swatch { width: 12px; height: 12px; border-radius: 3px; }

/* ── Toast (auto-save) ──────────────────────────── */
.autosave {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-light);
}
.autosave .as-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }

/* ── Result switch (Skill Matrix / Performance Review) ── */
.result-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); margin-bottom: 24px; }
.result-switch a { padding: 9px 18px; font-size: 13px; font-weight: 500; color: var(--text-muted); }
.result-switch a.active { background: var(--primary); color: #fff; font-weight: 700; }

/* ── Locked result card ─────────────────────────── */
.locked-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 20px; border-radius: var(--radius);
  background: var(--bg); border: 1px dashed var(--border-strong);
}
.locked-card .lc-ic {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  background: var(--surface); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; font-size: 17px; color: var(--text-light);
}

/* ── Mobile chrome (hidden on desktop) ──────────── */
.mobile-topbar { display: none; }
.nav-overlay { display: none; }
.hamburger {
  width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.hamburger span { display: block; width: 17px; height: 2px; border-radius: 2px; background: var(--text); }
.mt-logo { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 800; letter-spacing: -0.3px; }
.mt-mark { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(150deg, var(--primary), var(--primary-dark));
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 14px; }

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 900px) {
  .content.wide { max-width: 100%; }
  .kpi-row { grid-template-columns: repeat(2, 1fr) !important; }
}

@media (max-width: 760px) {
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 60;
    transform: translateX(-100%);
    transition: transform 0.26s cubic-bezier(0.4,0,0.2,1);
    box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  .nav-overlay {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(20,39,31,0.4); opacity: 0; pointer-events: none;
    transition: opacity 0.22s ease;
  }
  body.nav-open .nav-overlay { opacity: 1; pointer-events: auto; }

  .mobile-topbar {
    display: flex; align-items: center; gap: 14px;
    position: sticky; top: 0; z-index: 40;
    padding: 11px 16px;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
  }
  .mobile-topbar .avatar { margin-left: auto; }

  .content, .content.wide, .content.narrow { padding: 22px 16px 64px; max-width: 100%; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .page-title { font-size: 20px; }
  .page-head.row.between, .head-row { flex-wrap: wrap; }

  .cycle-banner { padding: 20px; flex-wrap: wrap; gap: 12px; }
  .cycle-banner .cb-count { text-align: left; }
  .cycle-banner .cb-count .n { font-size: 34px; }

  .tabs { width: 100%; }
  .tab { flex: 1; padding: 9px 8px; font-size: 12px; }

  .modal { max-width: 100%; }
}

@media (max-width: 420px) {
  .kpi-row { grid-template-columns: 1fr !important; }
}
