:root {
  --brand: #0ea5e9;
  --brand-dark: #0369a1;
  --bg: #f8fafc;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Thai", "Sarabun", sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand-dark); }
.container { max-width: 880px; margin: 0 auto; padding: 24px; }
.wide { max-width: 1200px; }
h1 { margin: 0 0 4px; font-size: 28px; }
h2 { margin: 24px 0 8px; font-size: 20px; }
p.sub { color: var(--muted); margin: 0 0 24px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
label { display: block; font-size: 14px; font-weight: 500; margin: 10px 0 4px; }
input, textarea, select { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 15px; font-family: inherit; background: #fff; }
input:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(14,165,233,0.15); }
textarea { resize: vertical; min-height: 80px; }
button { background: var(--brand); color: #fff; border: 0; padding: 10px 16px; border-radius: 8px; font-size: 15px; font-weight: 500; cursor: pointer; }
button:hover { background: var(--brand-dark); }
button.ghost { background: transparent; color: var(--brand-dark); border: 1px solid var(--border); }
button.ghost:hover { background: #f1f5f9; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 200px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.pill.green { background: #dcfce7; color: #166534; }
.pill.gray  { background: #f1f5f9; color: #475569; }
.pill.blue  { background: #dbeafe; color: #1e40af; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { background: #f8fafc; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border); gap: 12px; }
.topbar .logo { font-weight: 700; font-size: 18px; display: inline-flex; align-items: center; gap: 10px; }
.topbar .logo-img { height: 28px; width: auto; display: block; }
.topbar .logo-sub { font-size: 12px; color: var(--muted); font-weight: 500; letter-spacing: 0.3px; text-transform: uppercase; }
.login-logo-img { width: 220px; height: auto; display: block; margin: 0 auto 8px; }
.topbar nav a { margin-left: 16px; text-decoration: none; font-size: 14px; color: var(--muted); }
.topbar nav a:hover { color: var(--ink); }

/* Chat */
.chat { max-height: 60vh; overflow-y: auto; padding: 8px; margin-bottom: 16px; }
.msg { margin: 10px 0; display: flex; gap: 10px; }
.msg.ai { justify-content: flex-start; }
.msg.user { justify-content: flex-end; }
.bubble { padding: 12px 16px; border-radius: 16px; max-width: 78%; line-height: 1.5; font-size: 15px; }
.msg.ai .bubble  { background: #eff6ff; color: #1e3a8a; border-bottom-left-radius: 4px; }
.msg.user .bubble { background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.progress { height: 6px; background: #e2e8f0; border-radius: 999px; margin-bottom: 16px; overflow: hidden; }
.progress > div { height: 100%; background: var(--brand); transition: width 0.3s; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.empty { color: var(--muted); font-style: italic; text-align: center; padding: 32px; }

/* Division grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.div-card {
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  padding: 20px; cursor: pointer; text-decoration: none; color: inherit;
  display: flex; flex-direction: column; gap: 8px;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  border-top: 4px solid var(--brand);
}
.div-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(15,23,42,0.08); }
.div-card .icon { font-size: 32px; }
.div-card .name { font-size: 18px; font-weight: 600; }
.div-card .meta { color: var(--muted); font-size: 13px; }
.div-card.add {
  border-top-color: var(--muted);
  border-style: dashed;
  align-items: center; justify-content: center; text-align: center;
  color: var(--muted);
}
.div-card.add:hover { color: var(--brand); border-top-color: var(--brand); }
.breadcrumb { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--ink); }

/* Example page */
.ex-q {
  background: #f8fafc;
  border-left: 4px solid var(--brand);
  padding: 14px 18px;
  border-radius: 8px;
  margin: 16px 0 10px;
  font-weight: 600;
  font-size: 16px;
}
.ex-bad, .ex-good {
  padding: 12px 16px;
  border-radius: 10px;
  margin: 8px 0;
  font-size: 14.5px;
  line-height: 1.6;
}
.ex-bad { background: #fef2f2; border: 1px solid #fecaca; }
.ex-good { background: #f0fdf4; border: 1px solid #bbf7d0; }
.ex-tip  { background: #fffbeb; border: 1px solid #fde68a; padding: 10px 14px; border-radius: 8px; font-size: 14px; margin: 8px 0 4px; }
.ex-label { display:inline-block; font-weight: 600; margin-right: 6px; }
.ex-section { border-top: 2px dashed var(--border); margin: 32px 0 12px; padding-top: 16px; }
.ex-section h2 { margin: 0 0 4px; }

/* Language switcher (mounted by i18n.js) */
.lang-switcher { display: inline-flex; gap: 4px; margin-left: 12px; vertical-align: middle; }
.lang-btn {
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  cursor: pointer; min-width: 32px; line-height: 1;
}
.lang-btn:hover { color: var(--ink); background: #f1f5f9; }
.lang-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.lang-btn.active:hover { background: var(--brand-dark); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,0.55); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
  padding: 20px;
}
.modal {
  background: #fff; border-radius: 14px; padding: 24px;
  max-width: 520px; width: 100%; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal h2 { margin-top: 0; }

/* Row-action buttons (Interview / Review) */
.row-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 7px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 600;
  text-decoration: none; white-space: nowrap;
  transition: background 0.12s, box-shadow 0.12s;
}
.row-btn.primary { background: var(--brand); color: #fff; }
.row-btn.primary:hover { background: var(--brand-dark); box-shadow: 0 2px 6px rgba(14,165,233,0.3); }
.row-btn.ghost { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.row-btn.ghost:hover { background: #dcfce7; }

/* Calendar */
.cal-controls { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.cal-controls button { padding: 6px 10px; font-size: 13px; }
.cal-label { font-weight: 600; min-width: 130px; text-align: center; color: var(--ink); }
.cal-scope-group { display: inline-flex; gap: 2px; background: #f1f5f9; padding: 2px; border-radius: 8px; }
.cal-scope-group button { background: transparent; color: var(--muted); border: 0; padding: 6px 12px; border-radius: 6px; font-size: 12px; cursor: pointer; font-weight: 500; }
.cal-scope-group button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 12px; }
.cal-head { font-weight: 600; font-size: 12px; color: var(--muted); text-align: center; padding: 8px 0; text-transform: uppercase; letter-spacing: 0.5px; }
.cal-day {
  border: 1px solid var(--border); border-radius: 8px;
  min-height: 64px; padding: 6px; position: relative; background: #fff;
  cursor: pointer; transition: border-color 0.1s, background 0.1s;
  display: flex; flex-direction: column; gap: 3px;
}
.cal-day:hover { border-color: var(--brand); }
.cal-day.other-month { background: #f8fafc; color: #cbd5e1; cursor: default; }
.cal-day.other-month:hover { border-color: var(--border); }
.cal-day.today { border-color: var(--brand); border-width: 2px; }
.cal-day.has-activity { background: #eff6ff; }
.cal-day.selected { outline: 2px solid var(--brand); outline-offset: 1px; }
.cal-day .date { font-weight: 600; font-size: 14px; }
.cal-day .dots { display: flex; flex-wrap: wrap; gap: 3px; margin-top: auto; }
.cal-day .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); }
.cal-day .dot.started { background: #fbbf24; }
.cal-day .count { font-size: 11px; color: var(--brand-dark); font-weight: 600; }
.cal-legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.cal-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.cal-legend .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.cal-legend .dot.done { background: var(--brand); }
.cal-legend .dot.started { background: #fbbf24; }
.cal-selected-panel { margin-top: 12px; padding: 12px; background: #f8fafc; border-radius: 8px; border: 1px solid var(--border); }
.cal-selected-panel h3 { margin: 0 0 8px; font-size: 15px; }
.cal-person-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.cal-person-row:last-child { border-bottom: 0; }
.cal-person-row .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* Schedule picker */
.schedule-picker { display: grid; gap: 12px; margin: 16px 0; }
.schedule-option {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  border: 2px solid var(--border); border-radius: 10px; cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.schedule-option:hover { border-color: var(--brand); background: #f0f9ff; }
.schedule-option.selected { border-color: var(--brand); background: #eff6ff; }
.schedule-option input[type="radio"] { width: 18px; height: 18px; margin: 0; flex-shrink: 0; }
.schedule-option .label { font-weight: 600; font-size: 15px; }
