:root {
  --bg: #f4f6f5;
  --card: #ffffff;
  --ink: #1b2523;
  --muted: #66736f;
  --line: #e1e7e5;
  --brand: #0f766e;
  --brand-soft: #e3f3f0;
  --cart: #ea580c;
  --cart-soft: #fdeee4;
  --live: #be185d;
  --live-soft: #fbe7f0;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --ok: #15803d;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101615;
    --card: #19211f;
    --ink: #e6eeec;
    --muted: #93a29e;
    --line: #2a3532;
    --brand: #2dd4bf;
    --brand-soft: #123330;
    --cart: #fb923c;
    --cart-soft: #3a2316;
    --live: #f472b6;
    --live-soft: #3a1729;
    --warn: #fbbf24;
    --warn-soft: #3a2f10;
    --ok: #4ade80;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: "Noto Sans Thai", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  font-size: 16px;
}
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }

.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--brand); color: #fff;
}
@media (prefers-color-scheme: dark) { .top { background: #0b3b37; } }
.brand { display: flex; gap: 10px; align-items: center; }
.brand small { display: block; opacity: .85; font-size: 12px; line-height: 1.2; }
.logo { font-size: 26px; }
.icon-btn { background: rgba(255,255,255,.15); border: 0; border-radius: 10px; padding: 6px 10px; font-size: 18px; cursor: pointer; }

main { max-width: 720px; margin: 0 auto; padding: 14px 16px; }
h2 { font-size: 19px; margin: 8px 0 10px; }
h3 { font-size: 16px; margin: 16px 0 8px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button { background: none; border: 0; padding: 8px 0 10px; font-size: 13px; color: var(--muted); cursor: pointer; }
.tabs button span { display: block; font-size: 21px; line-height: 1.3; }
.tabs button.on { color: var(--brand); font-weight: 700; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { min-width: 0; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); cursor: pointer; font-weight: 600; font-size: 15px;
  text-decoration: none;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #062421; } }
.btn.cart { background: var(--cart); border-color: var(--cart); color: #fff; }
.btn.danger { color: #dc2626; }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 10px; font-size: 14px; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.chip { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--brand-soft); color: var(--brand); white-space: nowrap; }
.chip.cart { background: var(--cart-soft); color: var(--cart); }
.chip.live { background: var(--live-soft); color: var(--live); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.gray { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

.hint { background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-bottom: 10px; }
.hint.info { background: var(--brand-soft); color: var(--brand); }
.hint b { color: inherit; }

.filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 6px; scrollbar-width: none; }
.filters button { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 5px 12px; font-size: 14px; cursor: pointer; }
.filters button.on { background: var(--brand); color: #fff; border-color: var(--brand); }

.prod { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.prod .thumb { width: 56px; height: 56px; border-radius: 10px; background: var(--bg); display: grid; place-items: center; font-size: 26px; flex: none; overflow: hidden; }
.prod .thumb video { width: 100%; height: 100%; object-fit: cover; }
.prod b { display: block; overflow-wrap: anywhere; }
.money { color: var(--ok); font-weight: 700; }

.day { margin-bottom: 12px; }
.day-h { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; color: var(--muted); margin: 0 2px 6px; }
.day-h b { color: var(--ink); font-size: 15px; }
.day.today .day-h b { color: var(--brand); }
.item { display: flex; gap: 10px; align-items: center; background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 12px; padding: 10px 12px; margin-bottom: 6px; cursor: pointer; }
.item.cart { border-left-color: var(--cart); }
.item.live { border-left-color: var(--live); }
.item.done { opacity: .6; }
.item.done .t { text-decoration: line-through; }
.item .t { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.empty-day { border: 1px dashed var(--line); border-radius: 12px; padding: 8px 12px; color: var(--muted); font-size: 14px; cursor: pointer; }

.script-out .sec { margin-bottom: 14px; }
.script-out .sec h4 { margin: 0 0 4px; font-size: 14px; color: var(--brand); }
.script-out .box { background: var(--bg); border-radius: 10px; padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.shots { list-style: none; padding: 0; margin: 0; }
.shots li { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.shots li:last-child { border: 0; }
.shots .tm { flex: none; width: 62px; font-weight: 700; color: var(--cart); font-size: 14px; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat small { color: var(--muted); display: block; font-size: 13px; }
.stat b { font-size: 22px; }
.bar-row { margin-bottom: 10px; }
.bar-row .row { justify-content: space-between; font-size: 14px; }
.bar { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; margin-top: 3px; }
.bar i { display: block; height: 100%; background: var(--cart); border-radius: 99px; }

.sheet-wrap { position: fixed; inset: 0; z-index: 20; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto;
  background: var(--card); border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  max-width: 720px; margin: 0 auto;
}
.sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 9px; background: var(--line); margin: -6px auto 12px; }
.sheet h2 { margin-top: 0; }

.videos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.vid { background: var(--bg); border-radius: 12px; overflow: hidden; }
.vid video { width: 100%; aspect-ratio: 9/16; object-fit: cover; background: #000; display: block; }
.vid .vb { padding: 6px; display: grid; gap: 4px; }
.vid .vb .btn { padding: 6px; font-size: 13px; }
.vid .nm { font-size: 12px; color: var(--muted); padding: 4px 6px 0; overflow-wrap: anywhere; }

.toast { position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #111; color: #fff; padding: 10px 16px; border-radius: 99px; font-size: 14px; z-index: 30; max-width: calc(100% - 32px); text-align: center; }
.fab { position: fixed; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 4; border-radius: 99px; box-shadow: 0 6px 18px rgba(0,0,0,.2); padding: 12px 18px; }
.center { text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.empty .big { font-size: 40px; }
