:root {
  --brand: #F5A300;
  --brand-2: #FFC233;
  --brand-soft: #FFF4DA;
  --ink: #1C1C1C;
  --ink-2: #4A4A4A;
  --muted: #8C8577;
  --bg: #FFFBF3;
  --card: #FFFFFF;
  --line: #F0E6D2;
  --wait: #F2B705;
  --wait-bg: #FFF8E1;
  --claim: #E07A00;
  --claim-bg: #FFF0DD;
  --carry-bg: #FFF6EA;
  --carry-line: #F6C98A;
  --prog: #2F6FEB;
  --prog-bg: #EAF1FF;
  --done: #1E9E5A;
  --done-bg: #E8F7EE;
  --danger: #D64545;
  --radius: 18px;
  --shadow: 0 2px 10px rgba(80, 55, 0, .08);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Prompt", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.45;
  min-height: 100vh; padding-bottom: calc(76px + var(--safe-b));
}
button { font: inherit; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 12px; background: rgba(255,255,255,.92); flex: none;
  display: grid; place-items: center; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.12);
}
.brand-logo img { width: 36px; height: 36px; object-fit: contain; display: block; }
.brand-logo .brand-fallback { display: none; }
.brand-logo.fallback { background: var(--ink); }
.brand-logo.fallback .brand-fallback { display: block; color: var(--brand-2); font-weight: 800; font-size: 20px; }
.brand-text { min-width: 0; }
.brand-name { font-weight: 700; font-size: 16px; color: var(--ink); white-space: nowrap; }
.brand-date { font-size: 13px; color: #3b2c00; }
.me { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink);
  background: rgba(255,255,255,.55); padding: 4px 10px 4px 4px; border-radius: 999px; max-width: 45%; }
.me img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }
.me span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me:empty { display: none; }

.view { padding: 16px; max-width: 980px; margin: 0 auto; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 12px; }
.section-title h2 { font-size: 20px; margin: 0; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; font-size: 13px; }
.pill { padding: 3px 10px; border-radius: 999px; font-weight: 600; }
.pill.wait { background: var(--wait-bg); color: #8a6500; }
.pill.prog { background: var(--prog-bg); color: var(--prog); }
.pill.claim { background: var(--claim-bg); color: var(--claim); }
.pill.done { background: var(--done-bg); color: var(--done); }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 340px) { .grid { grid-template-columns: 1fr; } }

.card {
  position: relative; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; display: flex; flex-direction: column; gap: 4px; min-height: 172px;
  border: 2px solid transparent; transition: transform .15s ease, border-color .2s ease;
  animation: pop .25s ease both;
}
.card.waiting { border-color: #FBE3A0; }
.card.claimed { border-color: #F7CD96; background: linear-gradient(180deg, #FFF7EC 0%, #fff 60%); }
.card.claimed .status { color: var(--claim); }
.card.in_progress { border-color: #BCD2FF; background: linear-gradient(180deg, #F6F9FF 0%, #fff 60%); }
.card.completed { border-color: #BFE8CF; background: linear-gradient(180deg, #F3FBF6 0%, #fff 60%); }
.card.mine { box-shadow: 0 0 0 3px var(--brand) inset, var(--shadow); }
.card .slot-label { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .5px; }
.card .slot { font-size: 44px; font-weight: 800; line-height: 1; color: var(--ink); }
.card .status { font-size: 14px; font-weight: 600; }
.card.waiting .status { color: #8a6500; }
.card.in_progress .status { color: var(--prog); }
.card.completed .status { color: var(--done); }
.card .date-tag { font-size: 11px; font-weight: 700; color: var(--claim); background: var(--claim-bg);
  border-radius: 8px; padding: 1px 7px; align-self: flex-start; }
.card .btns { display: flex; flex-direction: column; gap: 6px; }
.card .btn { min-height: 44px; padding: 10px 12px; font-size: 15px; }
.card .who { font-size: 18px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .meta { font-size: 13px; color: var(--ink-2); }
.card .jobtitle { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .dur { font-size: 16px; font-weight: 700; color: var(--done); }
.card .spacer { flex: 1; }
.card .menu-btn {
  position: absolute; top: 8px; right: 8px; border: 0; background: var(--brand-soft); border-radius: 10px;
  padding: 4px 10px; font-size: 13px; color: var(--ink-2); cursor: pointer;
}
.card .override { font-size: 11px; color: var(--danger); }
.pulse { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--prog); margin-right: 4px;
  animation: pulse 1.6s infinite; vertical-align: middle; }

.btn {
  border: 0; border-radius: 14px; padding: 12px 14px; font-weight: 700; font-size: 16px; cursor: pointer;
  width: 100%; min-height: 48px; transition: transform .08s ease, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn.primary { background: var(--brand); color: var(--ink); }
.btn.dark { background: var(--ink); color: #fff; }
.btn.finish { background: var(--done); color: #fff; }
.btn.start { background: var(--prog); color: #fff; }
.btn.claim { background: var(--brand); color: var(--ink); }
.btn.ghost { background: #fff; color: var(--ink); border: 2px solid var(--line); }
.btn.danger { background: #fff; color: var(--danger); border: 2px solid #F3C9C9; }
.btn.small { min-height: 38px; padding: 8px 12px; font-size: 14px; width: auto; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .btn { flex: 1; }

.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.panel h3 { margin: 0 0 10px; font-size: 17px; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.center-msg { text-align: center; padding: 60px 16px; color: var(--ink-2); }
.center-msg h2 { color: var(--ink); }
.spinner { width: 36px; height: 36px; margin: 0 auto 12px; border-radius: 50%; border: 4px solid var(--brand-soft);
  border-top-color: var(--brand); animation: spin 1s linear infinite; }

.big-active { text-align: center; padding: 22px 16px; }
.big-active .slot { font-size: 64px; font-weight: 800; line-height: 1; }
.big-active .timer { font-size: 34px; font-weight: 700; color: var(--prog); margin: 6px 0 14px; font-variant-numeric: tabular-nums; }

.list { display: flex; flex-direction: column; gap: 8px; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: #FFFCF5; border-radius: 12px; }
.list-item .n { font-weight: 800; font-size: 20px; width: 34px; text-align: center; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .sub { font-size: 13px; color: var(--muted); }
.list-item .right { text-align: right; font-weight: 700; }

.person { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.person:last-child { border-bottom: 0; }
.person .name { font-weight: 700; font-size: 18px; }
.person .cnt { font-size: 14px; color: var(--ink-2); }
.person .total { font-weight: 800; font-size: 18px; }
.totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.totals div { background: #FFFCF5; border-radius: 12px; padding: 10px 4px; }
.totals b { display: block; font-size: 24px; }
.totals small { color: var(--muted); font-size: 12px; }

label.field { display: block; font-size: 14px; font-weight: 600; margin: 10px 0 4px; color: var(--ink-2); }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; padding: 10px 12px; border: 2px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); }
textarea { min-height: 70px; resize: vertical; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button { width: 48px; height: 48px; border-radius: 14px; border: 0; background: var(--brand-soft); font-size: 24px; font-weight: 700; }
.stepper output { font-size: 32px; font-weight: 800; min-width: 48px; text-align: center; }
.hint { font-size: 13px; color: var(--muted); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.scroll-x { overflow-x: auto; }
.member { padding: 12px 0; border-bottom: 1px dashed var(--line); }
.member:last-child { border-bottom: 0; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--brand-soft); font-weight: 600; }
.badge.off { background: #F4F4F4; color: #888; }
.badge.pending { background: #FFE9E9; color: var(--danger); }
.log { font-size: 13px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.subtabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.subtabs button { border: 0; background: #fff; border-radius: 999px; padding: 8px 14px; font-weight: 600; white-space: nowrap; box-shadow: var(--shadow); }
.subtabs button.active { background: var(--ink); color: #fff; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; background: #fff;
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b); box-shadow: 0 -2px 10px rgba(0,0,0,.05);
}
.tabbar button {
  flex: 1; min-width: 0; border: 0; background: none; padding: 7px 2px 9px; font-size: 11px; font-weight: 600; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer;
}
.tabbar button span { font-size: 22px; line-height: 1.1; }
.tabbar button.active { color: var(--ink); }
.tabbar button.active span { transform: scale(1.1); }
.tabbar button[hidden] { display: none; }

.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; animation: fade .2s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: #fff; border-radius: 22px 22px 0 0;
  padding: 18px 16px calc(18px + var(--safe-b)); max-height: 88vh; overflow-y: auto; animation: up .22s ease;
  max-width: 640px; margin: 0 auto;
}
.sheet h3 { margin: 0 0 6px; font-size: 20px; }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: #E5DccA; margin: -6px auto 12px; }
.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600; max-width: 90vw;
  box-shadow: 0 6px 20px rgba(0,0,0,.2); animation: up .2s ease; text-align: center;
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--done); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes up { from { transform: translate(var(--tx, 0), 20px); opacity: 0; } to { opacity: 1; } }
.toast { --tx: -50%; }
@keyframes fade { from { opacity: 0; } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(47,111,235,.5); } 70% { box-shadow: 0 0 0 8px rgba(47,111,235,0); } 100% { box-shadow: 0 0 0 0 rgba(47,111,235,0); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---- V1.1: carry-over sections + day divider */
.day-section { margin-bottom: 18px; }
.carry-section { background: var(--carry-bg); border: 2px dashed var(--carry-line); border-radius: 20px; padding: 12px; }
.carry-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 2px 10px; }
.carry-head h3 { margin: 0; font-size: 16px; color: #8a4a00; }
.carry-head .hint { color: #a0661f; }
.day-divider { display: flex; align-items: center; gap: 10px; margin: 22px 0 14px; color: var(--ink); font-weight: 800; }
.day-divider::before, .day-divider::after { content: ""; flex: 1; height: 3px; border-radius: 2px; background: var(--ink); opacity: .85; }
.day-divider span { background: var(--brand); padding: 4px 14px; border-radius: 999px; font-size: 15px; white-space: nowrap; }
.group-title { font-size: 15px; font-weight: 700; margin: 16px 2px 8px; color: var(--ink-2); }
.ref { font-weight: 800; }
.manage-row { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px dashed var(--line); }
.manage-row:last-child { border-bottom: 0; }
.manage-row .n { font-size: 22px; font-weight: 800; width: 40px; text-align: center; }
.manage-row .grow { flex: 1; min-width: 0; }
.manage-row .sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv { display: grid; grid-template-columns: minmax(120px, 42%) 1fr; gap: 6px 10px; font-size: 14px; }
.kv div:nth-child(odd) { color: var(--muted); font-size: 12px; word-break: break-all; }
.kv div:nth-child(even) { font-weight: 600; word-break: break-word; }
.more-links { display: grid; gap: 8px; }
.more-links .btn { text-align: left; }
.version-foot { text-align: center; color: var(--muted); font-size: 12px; margin: 18px 0 6px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.seg button { border: 2px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font-weight: 600; }
.seg button.active { background: var(--ink); color: #fff; border-color: var(--ink); }
