:root {
  --primary: #6d5bff;
  --primary-dark: #5643f0;
  --primary-light: #ede9ff;
  --pink: #ff5ca8;
  --cyan: #17c3d6;
  --bg: #f4f3fb;
  --card: #ffffff;
  --text: #201c3a;
  --muted: #767293;
  --border: #e8e5f7;
  --green: #16a34a;
  --orange: #ea580c;
  --red: #ef4444;

  /* legacy aliases used elsewhere in the codebase */
  --blue: var(--primary);
  --blue-dark: var(--primary-dark);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Roboto", "Noto Sans Thai", "Segoe UI", "Sarabun", sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 8% 8%, rgba(109, 91, 255, 0.10), transparent 32%),
    radial-gradient(circle at 92% 18%, rgba(255, 92, 168, 0.10), transparent 32%),
    radial-gradient(circle at 50% 100%, rgba(23, 195, 214, 0.08), transparent 40%);
  background-attachment: fixed;
  color: var(--text);
}

.topbar {
  background: linear-gradient(120deg, var(--primary) 0%, #8a4fff 45%, var(--pink) 100%);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 28px;
  box-shadow: 0 6px 24px rgba(109, 91, 255, 0.28);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-title h1 {
  font-size: 1.45rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.icon-clip { font-size: 1.6rem; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15)); }

.topbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
}

.btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn:active { transform: translateY(0); }

.btn-guide { background: #22c55e; color: white; box-shadow: 0 3px 10px rgba(34, 197, 94, 0.35); }
.btn-add { background: white; color: var(--primary-dark); box-shadow: 0 3px 10px rgba(0,0,0,0.12); }
.btn-sort { background: rgba(255,255,255,0.18); color: white; backdrop-filter: blur(4px); }
.btn-cancel { background: #eeecf9; color: var(--text); }
.btn-drive {
  background: linear-gradient(120deg, #ffc93c, #ff9f43);
  color: #4a2b00;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  box-shadow: 0 3px 10px rgba(255, 159, 67, 0.4);
}

.container {
  max-width: 1200px;
  margin: 28px auto;
  padding: 0 24px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--card);
  border-radius: 18px;
  padding: 20px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 20px rgba(109, 91, 255, 0.08);
  border: 1px solid var(--border);
  transition: transform 0.15s, box-shadow 0.15s;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(109, 91, 255, 0.14);
}

.stat-label { color: var(--muted); font-size: 0.88rem; font-weight: 500; }
.stat-value { font-size: 2rem; font-weight: 800; margin-top: 4px; }
.stat-total { color: var(--primary); }
.stat-pending { color: var(--orange); }
.stat-done { color: var(--green); }

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.icon-blue { background: linear-gradient(135deg, #e0dbff, #cfc6ff); }
.icon-orange { background: linear-gradient(135deg, #ffe4cc, #ffd2a8); }
.icon-green { background: linear-gradient(135deg, #d3f5df, #b7edc9); }

.filter-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.assignee-filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  font-size: 0.88rem;
  color: var(--muted);
}

.assignee-filter-row select {
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 0.88rem;
  font-family: inherit;
  color: var(--text);
  background: white;
}

.tab {
  border: 1px solid var(--border);
  background: white;
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  transition: transform 0.12s, background 0.12s, box-shadow 0.12s;
}

.tab:hover { border-color: var(--primary); color: var(--primary-dark); }

.tab.active {
  background: linear-gradient(120deg, var(--primary), var(--pink));
  border-color: transparent;
  color: white;
  box-shadow: 0 4px 14px rgba(109, 91, 255, 0.35);
}

.tab.drag-over {
  background: var(--primary-light);
  border-color: var(--primary);
  outline: 2px dashed var(--primary);
  transform: scale(1.06);
}

.status-msg {
  min-height: 20px;
  font-size: 0.85rem;
  color: var(--muted);
}

.task-card[draggable="true"] {
  cursor: grab;
}

.task-card.dragging {
  opacity: 0.4;
}

.task-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

.task-card {
  background: var(--card);
  border-radius: 18px;
  padding: 18px 20px;
  box-shadow: 0 4px 18px rgba(109, 91, 255, 0.08);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  display: flex;
  flex-direction: column;
  gap: 9px;
  transition: transform 0.15s, box-shadow 0.15s;
}

.task-card:hover {
  box-shadow: 0 10px 30px rgba(109, 91, 255, 0.16);
}

.task-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.task-title { font-weight: 700; font-size: 1.03rem; }

.status-badge {
  font-size: 0.72rem;
  padding: 4px 11px;
  border-radius: 999px;
  white-space: nowrap;
  font-weight: 700;
}

.status-select {
  border: none;
  cursor: pointer;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 22px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%23000' opacity='0.5' d='M2 4l4 4 4-4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  background-size: 9px;
}

.status-ยังไม่ได้ทำ { background: #ffe1e6; color: #d6336c; }
.status-กำลังทำ { background: #fff3bf; color: #b7791f; }
.status-กำลังเทสต์ { background: #e5dbff; color: #7048e8; }
.status-กำลังตรวจงาน { background: #d0ebff; color: #1971c2; }
.status-ทำเสร็จแล้ว { background: #d3f9d8; color: #2b8a3e; }

.task-card:has(.status-ยังไม่ได้ทำ) { border-left-color: #d6336c; }
.task-card:has(.status-กำลังทำ) { border-left-color: #b7791f; }
.task-card:has(.status-กำลังเทสต์) { border-left-color: #7048e8; }
.task-card:has(.status-กำลังตรวจงาน) { border-left-color: #1971c2; }
.task-card:has(.status-ทำเสร็จแล้ว) { border-left-color: #2b8a3e; }

.task-desc {
  font-size: 0.87rem;
  color: var(--muted);
  flex-grow: 1;
}

.task-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.task-meta-line { display: flex; align-items: center; gap: 5px; }

.task-actions { display: flex; gap: 10px; }

.icon-btn {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1rem;
  border-radius: 8px;
  padding: 4px;
  transition: background 0.12s, transform 0.12s;
}

.icon-btn:hover { background: var(--primary-light); transform: scale(1.08); }

.icon-edit { color: var(--primary); }
.icon-delete { color: var(--red); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(32, 28, 58, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-backdrop.hidden { display: none; }

.modal {
  background: white;
  border-radius: 20px;
  padding: 26px;
  width: 420px;
  max-width: 92vw;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(32, 28, 58, 0.3);
  animation: modal-pop 0.18s ease-out;
}

@keyframes modal-pop {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal h2 { margin-top: 0; }

.modal form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal label {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
  gap: 4px;
}

.modal input,
.modal textarea,
.modal select {
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.modal input:focus,
.modal textarea:focus,
.modal select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.task-card-clickable {
  cursor: pointer;
}

.task-card-clickable:hover {
  transform: translateY(-3px);
}

.task-open-hint {
  font-size: 0.75rem;
  color: var(--primary-dark);
  font-weight: 600;
  white-space: nowrap;
}

.update-task-info {
  background: var(--primary-light);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.update-task-name {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  margin: 0;
}

.guide-modal {
  text-align: center;
  width: 420px;
}

.guide-icon {
  font-size: 2.4rem;
  display: block;
}

.guide-title {
  margin: 8px 0 4px;
  background: linear-gradient(120deg, var(--primary), var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.guide-content {
  text-align: left;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.6;
  margin: 14px 0 4px;
}

.guide-content p { margin: 10px 0; }
.guide-content b { color: var(--text); }

.guide-ok-btn {
  width: 100%;
  margin-top: 10px;
  background: linear-gradient(120deg, var(--primary), var(--pink));
  color: white;
}

.task-file-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.icon-file {
  align-self: flex-start;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  transition: transform 0.12s, box-shadow 0.12s;
}

.icon-file:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(109, 91, 255, 0.25); }

.icon-submission {
  background: #dcfce7;
  color: #15803d;
}

.submission-info {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #15803d;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.82rem;
  margin: 0;
}

.submission-info a { color: #15803d; font-weight: 600; }

.file-preview-modal {
  width: 720px;
  max-width: 94vw;
  height: 80vh;
  display: flex;
  flex-direction: column;
}

.file-frame {
  flex-grow: 1;
  width: 100%;
  border: none;
  border-radius: 12px;
  margin-top: 12px;
}

.role-badge {
  font-size: 0.7rem;
  background: rgba(255,255,255,0.22);
  padding: 3px 11px;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 8px;
  font-weight: 600;
  backdrop-filter: blur(4px);
}

.btn-update {
  font-size: 0.8rem;
}

.landing {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, #8a4fff 45%, var(--pink) 100%);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.landing::before,
.landing::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(10px);
  opacity: 0.35;
}

.landing::before {
  width: 340px;
  height: 340px;
  background: var(--cyan);
  top: -80px;
  left: -80px;
}

.landing::after {
  width: 420px;
  height: 420px;
  background: #ffc93c;
  bottom: -120px;
  right: -100px;
}

.landing-card {
  background: white;
  border-radius: 24px;
  padding: 44px;
  max-width: 560px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 70px rgba(32, 28, 58, 0.35);
  position: relative;
  z-index: 1;
}

.landing-icon { font-size: 2.8rem; display: block; }

.landing-card h1 {
  margin: 14px 0 4px;
  font-weight: 800;
  background: linear-gradient(120deg, var(--primary), var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.landing-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 30px;
}

.role-card {
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 26px 18px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s, background 0.18s;
}

.role-owner:hover {
  background: linear-gradient(160deg, #fff, var(--primary-light));
  border-color: var(--primary);
}

.role-staff:hover {
  background: linear-gradient(160deg, #fff, #fff0f8);
  border-color: var(--pink);
}

.role-card:hover {
  transform: translateY(-5px) scale(1.02);
  box-shadow: 0 14px 30px rgba(109, 91, 255, 0.2);
}

.role-emoji {
  font-size: 2.2rem;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.12));
}
.role-title { font-weight: 700; font-size: 1.05rem; }
.role-desc { font-size: 0.8rem; color: var(--muted); }

@media (max-width: 480px) {
  .landing-links { grid-template-columns: 1fr; }
}

/* ---------- Employee picker (staff-select.html) ---------- */

.picker-intro {
  text-align: center;
  margin-bottom: 28px;
}

.picker-intro h2 {
  margin: 0 0 6px;
  font-size: 1.6rem;
  background: linear-gradient(120deg, var(--primary), var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.picker-intro .subtitle { color: var(--muted); margin: 0; }

.employee-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.employee-card {
  position: relative;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 18px;
  padding: 26px 18px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.employee-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: var(--surface-2, #f3f1fb);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.12s, background 0.12s, color 0.12s;
}

.employee-card:hover .employee-delete { opacity: 1; }

.employee-delete:hover {
  background: var(--rose-tint, #ffe1e6);
  color: var(--red);
}

.employee-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 12px 28px rgba(109, 91, 255, 0.18);
  border-color: var(--primary);
}

.employee-emoji { font-size: 2.1rem; }
.employee-name { font-weight: 700; font-size: 1rem; }
.employee-position { font-size: 0.76rem; color: var(--primary-dark); background: var(--primary-light); padding: 2px 9px; border-radius: 999px; }
.employee-stat { font-size: 0.78rem; color: var(--muted); }

/* ---------- Employee management (owner.html modal) ---------- */

.lede-small {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.6;
  margin: 12px 0 16px;
}

.employee-form {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.employee-form input {
  flex: 1 1 120px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
}

.employee-form button { flex-shrink: 0; }

.employee-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
}

.employee-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-2, #f3f1fb);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.92rem;
}

.employee-list-empty {
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
  padding: 12px 0;
}

.emoji-picker {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.employee-form .emoji-picker {
  flex-basis: 100%;
  margin: 2px 0 4px;
}

.emoji-option {
  border: 1.5px solid var(--border);
  background: var(--card);
  border-radius: 10px;
  font-size: 1.2rem;
  padding: 8px 0;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.1s, background 0.1s;
}

.emoji-option:hover { transform: scale(1.08); }

.emoji-option.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}
