/* ============ ภารกิจคณบดี : ระบบหลังบ้าน ============ */
:root {
  --brand-900: #4C1D95; --brand-700: #7C3AED; --brand-500: #C084FC; --brand-50: #F5EEFF;
  --accent: #EC4899; --accent-50: #FDEAF4;
  --grad: linear-gradient(120deg, #7C3AED 0%, #C026D3 55%, #EC4899 100%);
  --ink: #24133D; --muted: #6E6280; --line: #EADFF5; --bg: #F8F4FD; --card: #fff;
  --danger: #DC2626; --radius: 16px;
  --shadow: 0 1px 2px rgba(76,29,149,.05), 0 6px 18px rgba(124,58,237,.08);
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.55 'Sarabun', sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand-700); }
h1, h2, h3 { font-family: 'Prompt', 'Sarabun', sans-serif; margin: 0; line-height: 1.3; }
input, select, textarea, button { font: inherit; color: inherit; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---------- Top bar ---------- */
.topbar { background: var(--grad); color: #fff; }
.topbar-inner { display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 68px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.topbar .brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; min-width: 0; }
.topbar .brand strong { display: block; font-family: 'Prompt', sans-serif; font-size: 18px; }
.topbar .brand small { display: block; font-size: 13px; opacity: .8; }
.brand-mark, .auth-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: #fff; color: var(--brand-700);
  font: 700 15px 'Prompt', sans-serif; box-shadow: inset 0 0 0 3px var(--accent); flex: none; }
.top-actions { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.top-actions form { margin: 0; }
.top-btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 999px; font: 600 15px 'Sarabun', sans-serif;
  color: #fff; text-decoration: none; cursor: pointer; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.35);
  transition: background .15s, color .15s, transform .15s; }
.top-btn:hover { background: rgba(255,255,255,.28); }
.top-btn:active { transform: translateY(1px); }
.top-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.top-btn-out { background: #fff; color: var(--brand-900); border-color: #fff; }
.top-btn-out:hover { background: var(--accent-50); color: #BE185D; }
.who { display: inline-flex; align-items: center; gap: 8px; padding: 4px 14px 4px 4px; border-radius: 999px; background: rgba(0,0,0,.16); font-weight: 500; }
.who-avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #fff; color: var(--brand-700);
  font: 700 14px 'Prompt', sans-serif; font-style: normal; }
.who-name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs-nav { display: flex; gap: 4px; overflow-x: auto; }
.tabs-nav a { padding: 10px 16px; color: rgba(255,255,255,.8); text-decoration: none; border-radius: 10px 10px 0 0; white-space: nowrap; font-weight: 500; }
.tabs-nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.tabs-nav a.active { background: var(--bg); color: var(--brand-900); }

.page { padding-top: 24px; padding-bottom: 48px; }

/* ---------- Common ---------- */
.panel { background: var(--card); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin-bottom: 20px; }
.panel.narrow { max-width: 760px; margin-left: auto; margin-right: auto; }
.page-title { font-size: 22px; margin-bottom: 16px; color: var(--brand-900); }
.sub { font-size: 18px; color: var(--brand-900); margin: 6px 0 4px; }
.alert { padding: 12px 16px; border-radius: 12px; margin-bottom: 14px; font-weight: 500; }
.alert.ok { background: var(--brand-50); color: var(--brand-900); border: 1px solid #DCC8F7; }
.alert.bad { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border-radius: 12px; border: 0;
  cursor: pointer; font-weight: 600; text-decoration: none; transition: background .15s; }
.btn-primary { background: var(--brand-700); color: #fff; }
.btn-primary:hover { background: #6D28D9; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #DB2777; }
.btn-light { background: #F1EBF9; color: var(--ink); }
.btn-light:hover { background: #E6DCF3; }
.full { width: 100%; }
.btn-sm { display: inline-block; padding: 6px 12px; border-radius: 9px; border: 1px solid var(--line); background: #fff; cursor: pointer;
  font-size: 14px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn-sm:hover { background: var(--brand-50); border-color: var(--brand-500); }
.btn-sm.danger:hover { background: #FEF2F2; border-color: var(--danger); color: var(--danger); }

.chip { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 1px 10px; border-radius: 999px;
  color: var(--type, var(--brand-700)); background: color-mix(in srgb, var(--type, var(--brand-700)) 12%, white); }
.chip-private { --type: #64748B; }
.badge-accent { background: var(--accent); color: #fff; font-size: 12px; padding: 2px 10px; border-radius: 999px; font-family: 'Sarabun', sans-serif; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--card); border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow); border-top: 3px solid var(--brand-500); }
.stat:first-child { border-top-color: var(--accent); }
.stat b { display: block; font: 700 30px/1.1 'Prompt', sans-serif; color: var(--brand-900); }
.stat span { color: var(--muted); font-size: 14px; }

/* ---------- Mission list ---------- */
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.seg { display: inline-flex; background: var(--bg); padding: 4px; border-radius: 11px; flex-wrap: wrap; }
.seg a { padding: 7px 14px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: 15px; }
.seg a.active { background: #fff; color: var(--brand-700); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.filters input[type=search] { flex: 1; min-width: 200px; }
.filters input, .filters select, .stack input, .form-grid input, .form-grid select, .form-grid textarea, .inline-form input {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-500); outline-offset: 0; border-color: transparent; }
.day-title { font-size: 16px; color: var(--brand-700); margin: 22px 0 8px; display: flex; align-items: center; gap: 8px; }
.row { display: flex; gap: 16px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-left: 5px solid var(--type);
  border-radius: 12px; margin-bottom: 8px; }
.row:hover { background: #FCFAFF; }
.row-time { width: 66px; flex: none; }
.row-time b { display: block; font-size: 16px; }
.row-time small { color: var(--muted); font-size: 13px; }
.row-info { flex: 1; min-width: 0; }
.row-tags { display: flex; gap: 6px; margin-bottom: 2px; }
.row-title { display: block; font-size: 16px; word-break: break-word; }
.row-meta { display: flex; flex-wrap: wrap; gap: 2px 14px; color: var(--muted); font-size: 14px; }
.row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.row-actions form { margin: 0; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; border: 1.5px dashed var(--line); border-radius: 12px; margin-top: 12px; }
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.pager a { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.pager a.active { background: var(--brand-700); color: #fff; border-color: var(--brand-700); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid label, .stack label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 15px; }
.form-grid label input, .form-grid label select, .form-grid label textarea, .stack label input { width: 100%; font-weight: 400; }
.form-grid em { color: var(--danger); font-style: normal; }
.span2 { grid-column: 1 / -1; }
.check { flex-direction: row !important; align-items: flex-start; gap: 10px !important; padding: 12px 14px; background: var(--bg); border-radius: 12px; cursor: pointer; }
.check input { width: 20px !important; height: 20px; margin-top: 3px; accent-color: var(--brand-700); flex: none; }
.check small { display: block; font-weight: 400; color: var(--muted); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding-top: 6px; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.photo-row { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.photo-preview { width: 160px; aspect-ratio: 4/3; border-radius: 12px; overflow: hidden; background: var(--brand-50); display: grid; place-items: center; color: var(--muted); font-size: 14px; flex: none; }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.cell-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.inline-form { display: flex; gap: 6px; margin: 0; }
.inline-form input { width: 120px; padding: 6px 10px; font-size: 14px; }
.skipped { margin-bottom: 14px; font-size: 14px; color: var(--muted); }

/* ---------- Auth ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(700px 400px at 85% 0%, rgba(255,255,255,.18), transparent 60%), var(--grad); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 22px; padding: 34px 28px; box-shadow: 0 24px 60px rgba(0,0,0,.2); }
.auth-card h1 { font-size: 22px; text-align: center; color: var(--brand-900); }
.auth-card > .muted { text-align: center; margin: 4px 0 20px; font-size: 14px; }
.auth-mark { width: 60px; height: 60px; margin: 0 auto 14px; font-size: 20px; background: var(--grad); color: #fff; }
.back { display: block; text-align: center; margin-top: 16px; font-size: 14px; color: var(--muted); }

@media (max-width: 760px) {
  .wrap { padding: 0 14px; }
  .stats { gap: 8px; }
  .stat { padding: 12px; }
  .stat b { font-size: 24px; }
  .panel { padding: 16px; }
  .form-grid, .two-col { grid-template-columns: 1fr; }
  .row { flex-wrap: wrap; gap: 6px 12px; }
  .row-actions { width: 100%; }
  .top-actions .who { display: none; }
  .form-actions .btn { flex: 1; }
}

/* ภารกิจหลายวัน */
.chip-range { --type: #0F766E; }
.date-hint { margin: -4px 0 0; }

.logo-preview img { object-fit: contain; background: #fff; }

@media (max-width: 640px) {
  .topbar-inner { justify-content: center; }
  .top-actions { width: 100%; justify-content: space-between; gap: 6px; }
  .top-btn { padding: 8px 12px; font-size: 14px; }
  .top-btn span { display: none; }
  .top-btn-out span { display: inline; }
  .who-name { max-width: 110px; }
}
