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

:root {
  --forest: #0d3329;
  --forest-2: #174b3d;
  --mint: #bfe3c3;
  --mint-soft: #e9f4e8;
  --sun: #f4b942;
  --coral: #e36e4f;
  --ink: #18312a;
  --muted: #71827c;
  --canvas: #f4f1e9;
  --paper: #fffdf8;
  --line: #dedfd7;
  --danger: #b54232;
  --danger-soft: #fff0eb;
  --shadow-sm: 0 4px 16px rgba(13, 51, 41, .06);
  --shadow-lg: 0 22px 60px rgba(13, 51, 41, .16);
  --radius-lg: 24px;
  --radius-md: 16px;
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 8% 5%, rgba(244,185,66,.14), transparent 24rem),
    radial-gradient(circle at 92% 22%, rgba(191,227,195,.32), transparent 26rem),
    var(--canvas);
  color: var(--ink);
  font-family: 'IBM Plex Sans Thai', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid rgba(244,185,66,.45);
  outline-offset: 2px;
}
#app { min-height: 100vh; }

.loading { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 14px; color: var(--muted); }
.spinner { width: 38px; height: 38px; border: 3px solid #d8ddd5; border-top-color: var(--forest); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Login */
.login {
  position: relative;
  min-height: 100svh;
  max-width: 1120px;
  margin: auto;
  padding: 26px 20px 36px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}
.login::before {
  content: '';
  position: absolute;
  width: 260px;
  height: 260px;
  right: -115px;
  top: 80px;
  border: 46px solid rgba(13,51,41,.06);
  border-radius: 50%;
  pointer-events: none;
}
.brand-mark { display: flex; align-items: center; gap: 11px; font-weight: 700; letter-spacing: -.01em; }
.mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 13px 13px 13px 4px;
  background: var(--forest);
  color: var(--sun);
  font: 800 20px Manrope, sans-serif;
  box-shadow: 0 7px 18px rgba(13,51,41,.2);
}
.login-copy { align-self: center; max-width: 520px; padding: 44px 0 22px; position: relative; z-index: 1; }
.eyebrow { color: var(--forest-2); font: 800 10px/1 Manrope, sans-serif; letter-spacing: .18em; text-transform: uppercase; }
.login h1 { margin: 14px 0 16px; font-size: clamp(42px, 13vw, 74px); line-height: .98; letter-spacing: -.055em; font-weight: 700; }
.login h1 em { color: var(--coral); font-style: normal; position: relative; }
.login h1 em::after { content: ''; position: absolute; height: 7px; left: 2px; right: 0; bottom: -2px; background: var(--sun); opacity: .65; border-radius: 10px; z-index: -1; }
.login-copy p { color: var(--muted); margin: 0; font-size: 16px; line-height: 1.75; max-width: 450px; }
.login-card {
  position: relative;
  z-index: 1;
  background: rgba(255,253,248,.92);
  border: 1px solid rgba(255,255,255,.9);
  border-radius: 28px;
  padding: 22px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
}
label { display: block; margin-bottom: 7px; color: #304a42; font-size: 13px; font-weight: 700; }
.field { margin-bottom: 16px; }
select, input, textarea {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 15px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color .18s, box-shadow .18s, transform .18s;
}
textarea { min-height: auto; resize: vertical; }
input::placeholder, textarea::placeholder { color: #9ca8a3; }
select:focus, input:focus, textarea:focus { border-color: #6e957e; box-shadow: 0 0 0 4px rgba(191,227,195,.45); }
.primary {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 14px;
  padding: 13px 18px;
  background: var(--forest);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 9px 20px rgba(13,51,41,.18);
  transition: transform .18s, background .18s, box-shadow .18s;
}
.primary:hover { background: var(--forest-2); box-shadow: 0 12px 24px rgba(13,51,41,.22); }
.primary:active, .secondary:active, .task-action:active { transform: translateY(1px) scale(.995); }
.hint { margin: 13px 0 0; color: var(--muted); text-align: center; font-size: 11px; }

/* App shell */
.shell { width: 100%; max-width: 840px; min-height: 100vh; margin: auto; padding-bottom: 64px; }
.topbar {
  position: relative;
  overflow: hidden;
  padding: max(22px, env(safe-area-inset-top)) 20px 26px;
  background: linear-gradient(145deg, #092b22, #174c3d);
  color: #fff;
  border-radius: 0 0 32px 32px;
  box-shadow: 0 18px 40px rgba(13,51,41,.17);
}
.topbar::before { content: ''; position: absolute; width: 210px; height: 210px; right: -80px; top: 35px; border: 38px solid rgba(255,255,255,.05); border-radius: 50%; }
.topbar::after { content: ''; position: absolute; width: 120px; height: 120px; right: 48px; top: 88px; border: 1px solid rgba(255,255,255,.09); border-radius: 50%; }
.topline, .profile, .header-meta { position: relative; z-index: 1; }
.topline { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.topbar .mark { background: var(--sun); color: var(--forest); box-shadow: none; }
.ghost { min-height: 38px; border: 1px solid rgba(255,255,255,.16); border-radius: 999px; padding: 8px 13px; background: rgba(255,255,255,.07); color: #fff; font-size: 12px; font-weight: 600; }
.ghost:hover { background: rgba(255,255,255,.14); }
.profile { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-top: 34px; }
.profile h1 { margin: 7px 0 0; font-size: clamp(28px, 8vw, 38px); line-height: 1.15; letter-spacing: -.035em; }
.brand-pill { flex: 0 0 auto; padding: 7px 11px; border: 1px solid rgba(255,255,255,.15); border-radius: 999px; background: var(--sun); color: var(--forest); font: 800 11px Manrope, sans-serif; box-shadow: 0 6px 15px rgba(0,0,0,.13); }
.header-meta { display: flex; align-items: stretch; justify-content: space-between; gap: 9px; margin-top: 16px; }
.shift { display: inline-flex; align-items: center; gap: 7px; padding: 8px 11px; border-radius: 12px; background: rgba(255,255,255,.08); color: #bcd0c8; font-size: 12px; }
.shift::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 4px rgba(191,227,195,.12); }
.shift strong { color: #fff; }
.live-clock { display: flex; align-items: center; gap: 8px; padding: 7px 11px; border: 1px solid rgba(255,255,255,.11); border-radius: 12px; background: rgba(5,28,21,.22); }
.clock-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--sun); box-shadow: 0 0 0 4px rgba(244,185,66,.12); animation: clockPulse 2s ease-in-out infinite; }
.live-clock div { display: grid; min-width: 62px; }
.clock-time { color: #fff; font: 800 13px/1.2 Manrope, sans-serif; letter-spacing: .03em; font-variant-numeric: tabular-nums; }
.clock-date { margin-top: 2px; color: #aec6bc; font-size: 9px; line-height: 1.2; white-space: nowrap; }
@keyframes clockPulse { 50% { opacity: .45; transform: scale(.86); } }
.content { padding: 24px 18px; }
.date-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; margin-bottom: 17px; }
.date-row h2 { margin: 0; font-size: 19px; line-height: 1.35; letter-spacing: -.02em; }
.progress { flex: 0 0 auto; padding: 7px 10px; border: 1px solid #d9ddd5; border-radius: 999px; background: rgba(255,255,255,.6); color: var(--forest-2); font: 800 11px Manrope, sans-serif; }

/* Task cards */
.task-list { display: grid; gap: 12px; }
.task {
  position: relative;
  overflow: hidden;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
.task::after { content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; background: #d8ddd7; }
.task:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(13,51,41,.09); }
.task.done { background: linear-gradient(135deg, #f4faef, #edf7ed); border-color: #c7dcc5; }
.task.done::after { background: #4e925f; }
.task-head { display: flex; align-items: flex-start; gap: 13px; }
.num { flex: 0 0 38px; height: 38px; display: grid; place-items: center; border-radius: 13px; background: #eceee8; color: #5f6d68; font: 800 12px Manrope, sans-serif; }
.done .num { background: var(--forest); color: var(--sun); box-shadow: 0 6px 14px rgba(13,51,41,.17); }
.task-title { flex: 1; min-width: 0; padding-top: 1px; font-size: 15px; font-weight: 600; line-height: 1.52; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 4px 8px; border-radius: 999px; background: #edf0eb; color: #5c6e67; font-size: 10px; font-weight: 700; line-height: 1.25; }
.badge.late { background: var(--danger-soft); color: var(--danger); }
.badge.late::before { content: '!'; width: 15px; height: 15px; display: grid; place-items: center; margin-right: 4px; border-radius: 50%; background: var(--danger); color: #fff; font: 800 9px Manrope; }
.badge.success { background: #dcefd9; color: #29613a; }
.badge.success::before { content: '✓'; margin-right: 4px; font-weight: 800; }
.task-action { width: 100%; min-height: 44px; margin-top: 14px; border: 1px solid #b9ccc1; border-radius: 13px; background: #fff; color: var(--forest); font-size: 13px; font-weight: 700; transition: transform .18s, background .18s, border-color .18s; }
.task-action::before { content: '◉'; margin-right: 7px; color: var(--coral); }
.task-action:hover { background: #f6faf5; border-color: #83a590; }
.done .task-action { display: none; }

.add-card { margin-top: 16px; padding: 18px; border: 1px dashed #9aae9f; border-radius: 20px; background: rgba(255,253,248,.65); }
.add-card::before { content: 'งานนอกแผน'; display: inline-block; margin-bottom: 12px; padding: 5px 8px; border-radius: 7px; background: #fff0d1; color: #77520a; font-size: 10px; font-weight: 700; }
.add-card select { margin-bottom: 10px; }
.add-card button { width: 100%; margin-top: 10px; }

.pin-card { margin-top: 16px; padding: 18px; border: 1px dashed #9aae9f; border-radius: 20px; background: rgba(255,253,248,.65); }
.pin-card::before { content: 'ความปลอดภัย'; display: inline-block; margin-bottom: 12px; padding: 5px 8px; border-radius: 7px; background: #fff0d1; color: #77520a; font-size: 10px; font-weight: 700; }
.pin-card select { margin-bottom: 10px; }
.pin-card button { width: 100%; margin-top: 10px; }

.employee-card { margin-top: 16px; padding: 18px; border: 1px dashed #9aae9f; border-radius: 20px; background: rgba(255,253,248,.65); }
.employee-card::before { content: 'พนักงานใหม่'; display: inline-block; margin-bottom: 12px; padding: 5px 8px; border-radius: 7px; background: #fff0d1; color: #77520a; font-size: 10px; font-weight: 700; }
.employee-card input { margin-bottom: 10px; }
.employee-card button { width: 100%; margin-top: 10px; }
.secondary { min-height: 46px; border: 1px solid var(--line); border-radius: 13px; padding: 11px 16px; background: #fff; color: var(--ink); font-weight: 700; transition: transform .18s, background .18s; }
.secondary:hover { background: #f6f7f3; }
.submit-dock { display: none; }

/* Upload modal */
.modal-wrap { position: fixed; z-index: 10; inset: 0; display: flex; align-items: flex-end; padding-top: 30px; background: rgba(5,28,21,.68); backdrop-filter: blur(6px); }
.modal { width: 100%; max-width: 760px; max-height: 92svh; margin: auto; padding: 22px 20px calc(24px + env(safe-area-inset-bottom)); overflow: auto; border-radius: 28px 28px 0 0; background: var(--canvas); box-shadow: var(--shadow-lg); animation: rise .22s ease-out; }
@keyframes rise { from { transform: translateY(25px); opacity: .5; } }
.handle { width: 44px; height: 4px; margin: -8px auto 20px; border-radius: 5px; background: #b7c0bb; }
.modal h2 { margin: 0 0 5px; font-size: 23px; letter-spacing: -.025em; }
.modal p { margin: 0 0 18px; color: var(--muted); line-height: 1.5; }
.file-zone { position: relative; min-height: 142px; display: grid; place-items: center; align-content: center; padding: 24px 15px; border: 1.5px dashed #799987; border-radius: 20px; background: var(--paper); text-align: center; box-shadow: inset 0 0 0 5px rgba(191,227,195,.14); }
.file-zone::before { content: '＋'; width: 44px; height: 44px; display: grid; place-items: center; margin-bottom: 9px; border-radius: 15px; background: var(--forest); color: var(--sun); font: 700 23px Manrope; }
.file-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-zone strong { display: block; color: var(--forest); }
.file-zone span { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.photo-picker { padding: 15px; border: 1px solid var(--line); border-radius: 20px; background: var(--paper); }
.photo-picker-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 11px; }
.photo-picker-head > strong { color: var(--forest); font-size: 14px; }
.photo-picker-head > span { padding: 4px 8px; border-radius: 999px; background: var(--mint-soft); color: var(--forest-2); font: 800 10px Manrope, sans-serif; }
.photo-options { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.photo-option { position: relative; min-height: 112px; display: grid; place-items: center; align-content: center; gap: 2px; margin: 0; padding: 14px 8px; overflow: hidden; border: 1px solid #bdd0c4; border-radius: 16px; background: #f4faf3; color: var(--forest); text-align: center; cursor: pointer; }
.photo-option.album-option { border-color: #ead29e; background: #fff9ea; }
.photo-option input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; opacity: 0; cursor: pointer; }
.photo-option .photo-icon { width: 34px; height: 34px; display: grid; place-items: center; margin-bottom: 4px; border-radius: 11px; background: var(--forest); color: var(--sun); font: 800 16px Manrope; }
.photo-option.album-option .photo-icon { background: var(--sun); color: var(--forest); }
.photo-option strong { font-size: 13px; }
.photo-option small { color: var(--muted); font-size: 9px; font-weight: 500; }
.photo-help { display: block; margin-top: 9px; color: var(--muted); text-align: center; font-size: 10px; }
.preview { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin: 12px 0; }
.preview-item { position: relative; }
.preview img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border: 2px solid #fff; border-radius: 12px; box-shadow: var(--shadow-sm); }
.preview-item button { position: absolute; top: -5px; right: -5px; width: 23px; height: 23px; display: grid; place-items: center; padding: 0; border: 2px solid #fff; border-radius: 50%; background: var(--danger); color: #fff; font: 700 15px/1 sans-serif; box-shadow: 0 3px 8px rgba(0,0,0,.2); }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .primary { flex: 1; }
.error { margin-bottom: 12px; padding: 11px 12px; border: 1px solid #f1c4ba; border-radius: 11px; background: var(--danger-soft); color: var(--danger); font-size: 12px; }

/* Supervisor */
.review-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 17px; padding: 16px; border: 1px solid var(--line); border-radius: 20px; background: var(--paper); box-shadow: var(--shadow-sm); }
.review-controls .primary { grid-column: 1/-1; }
.review-summary { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-bottom: 14px; }
.review-summary > div { display: grid; gap: 2px; padding: 13px 8px; border: 1px solid var(--line); border-radius: 15px; background: var(--paper); text-align: center; box-shadow: var(--shadow-sm); }
.review-summary strong { color: var(--forest); font: 800 22px Manrope, sans-serif; }
.review-summary span { color: var(--muted); font-size: 10px; font-weight: 600; }
.review-summary .pending-count { border-color: #efc4b9; background: var(--danger-soft); }
.review-summary .pending-count strong { color: var(--danger); }
.empty { padding: 44px 24px; border: 1px dashed #b7c0ba; border-radius: 20px; background: rgba(255,253,248,.6); color: var(--muted); text-align: center; }
.empty::before { content: '✓'; width: 52px; height: 52px; display: grid; place-items: center; margin: 0 auto 12px; border-radius: 18px; background: var(--mint-soft); color: var(--forest); font: 800 24px Manrope; }
.review-item { position: relative; margin-bottom: 13px; padding: 17px; border: 1px solid var(--line); border-radius: 20px; background: var(--paper); box-shadow: var(--shadow-sm); }
.review-item.pending { border-color: #edc9c0; background: linear-gradient(135deg, #fffaf7, #fff2ed); box-shadow: none; }
.review-item h3 { margin: 0 0 8px; font-size: 15px; line-height: 1.5; }
.review-item.pending h3 { padding-right: 84px; color: #70463c; }
.review-status { float: right; margin: 0 0 8px 10px; padding: 5px 9px; border-radius: 999px; font-size: 10px; font-weight: 700; }
.done-status { background: #dcefd9; color: #29613a; }
.pending-status { background: #f7d6cd; color: var(--danger); }
.review-meta { display: inline-flex; padding: 5px 8px; border-radius: 8px; background: #edf1eb; color: var(--muted); font-size: 11px; margin-bottom: 12px; }
.gallery { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px; }
.gallery a { overflow: hidden; border-radius: 13px; background: #e9ece7; }
.gallery img { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; transition: transform .2s; }
.gallery a:hover img { transform: scale(1.025); }
.note { margin-top: 10px; padding: 10px 11px; border-left: 3px solid var(--sun); border-radius: 4px 10px 10px 4px; background: #f6f3e9; color: #52645e; font-size: 12px; }

#toast { position: fixed; z-index: 30; top: max(16px, env(safe-area-inset-top)); left: 50%; max-width: calc(100% - 32px); padding: 11px 16px; transform: translate(-50%,-150%); border-radius: 999px; background: #10251e; color: #fff; box-shadow: var(--shadow-lg); text-align: center; font-size: 13px; transition: transform .25s; }
#toast.show { transform: translate(-50%,0); }

@media (min-width: 720px) {
  .login { grid-template-columns: 1.15fr .85fr; grid-template-rows: auto 1fr; column-gap: 70px; align-items: center; padding: 38px; }
  .login > .brand-mark { grid-column: 1/-1; align-self: start; }
  .login-copy { grid-column: 1; padding: 60px 0; }
  .login-card { grid-column: 2; align-self: center; padding: 28px; }
  .topbar { margin-top: 20px; border-radius: 32px; padding: 24px 28px 30px; }
  .content { padding: 28px 8px; }
  .task-list { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .add-card { grid-column: 1/-1; }
  .modal-wrap { align-items: center; padding: 30px; }
  .modal { border-radius: 28px; }
  .gallery { grid-template-columns: repeat(4,1fr); }
}

@media (max-width: 390px) {
  .header-meta { flex-direction: column; }
  .shift, .live-clock { width: 100%; }
  .live-clock { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
