* { box-sizing: border-box; }

/* Palette pulled from enqrew.co.jp (Sweets Lab): warm espresso text,
   a burnt-orange CTA accent, and cream/neutral surfaces — swapped in for
   the old blue scheme so this tool reads as part of the same brand. */
:root {
  --blue: #d9682e;
  --blue-dark: #432514;
  --bg: #faf5ef;
  --card: #ffffff;
  --border: #e6dccd;
  --text: #3a2417;
  --muted: #8a7666;
  --warn: #b8860b;
  --danger: #c0392b;
  --ok: #2e7d32;
  --gold: #c9a227;
}

body {
  margin: 0;
  font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
}

.topbar {
  background: var(--blue-dark);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}
.topbar .brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; letter-spacing: 0.02em; }
.date-badge { margin-left: auto; background: rgba(255,255,255,0.15); padding: 4px 12px; border-radius: 999px; font-size: 0.9rem; }

.tabs {
  display: flex;
  gap: 4px;
  background: linear-gradient(to bottom, #4a2c1a, var(--blue-dark));
  padding: 0 10px;
  overflow-x: auto;
}
.tabs a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  padding: 12px 14px;
  font-size: 0.95rem;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.tabs a:hover, .tabs a.active { color: #fff; border-bottom-color: var(--blue); background: rgba(255,255,255,0.06); }

main { max-width: 980px; margin: 0 auto; padding: 20px 16px 60px; }

h1 { font-size: 1.5rem; font-weight: 700; color: var(--blue-dark); margin: 4px 0 18px; letter-spacing: 0.01em; }
h2 { font-size: 1.1rem; font-weight: 700; color: var(--blue-dark); margin: 24px 0 10px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(67, 37, 20, 0.06);
}

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; text-align: center; box-shadow: 0 1px 3px rgba(67, 37, 20, 0.06); }
.stat .num { font-size: 1.8rem; font-weight: 700; color: var(--blue-dark); }
.stat .label { font-size: 0.85rem; color: var(--muted); margin-top: 2px; }
.stat.warn .num { color: var(--warn); }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 600;
  min-height: 46px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, box-shadow 0.15s;
}
button:hover, .btn:hover { background: var(--blue-dark); box-shadow: 0 2px 6px rgba(67, 37, 20, 0.2); }
button.secondary, .btn.secondary { background: #fff; color: var(--blue); border: 1px solid var(--blue); }
button.secondary:hover, .btn.secondary:hover { background: #fdf1e9; box-shadow: none; }
button.danger, .btn.danger { background: #fff; color: var(--danger); border: 1px solid var(--danger); }
button.ok, .btn.ok { background: var(--ok); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input[type=text], input[type=time], input[type=date], select, textarea {
  font-size: 1rem;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  min-height: 44px;
  width: 100%;
}

label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; }
.badge.review { background: #fff3cd; color: var(--warn); }
.badge.confirmed { background: #e3f3e5; color: var(--ok); }
.badge.processing { background: #fdf1e9; color: var(--blue); }
.badge.error { background: #fde3e0; color: var(--danger); }
.badge.mansion { background: #eef0ff; color: #4b4bb8; }
.badge.kodate { background: #f1f1f1; color: #555; }
.badge.violation { background: #fde3e0; color: var(--danger); }
.badge.completed { background: #e3f3e5; color: var(--ok); }
.badge.neutral { background: #f1f1f1; color: #555; }

.timing-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  font-size: 0.7rem; font-weight: 700; flex-shrink: 0;
  line-height: 1;
}
.timing-badge.early { background: #e6eef7; color: var(--blue-dark); border: 1px solid var(--blue); }
.timing-badge.close { background: #fff3cd; color: #8a6100; border: 1px solid #8a6100; }
.timing-badge.early_excessive { background: #fde3e0; color: var(--danger); border: 1px solid var(--danger); }

/* Heading row: title on the left, the day's headline number tucked to the
   right of it rather than taking a full-width band of its own. */
.page-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin: 4px 0 18px;
}
.page-head h1 { margin: 0; }

/* Wrong-day warning on a freshly shot photo. Loud on purpose: it is worth
   interrupting a run of photos for, since carrying on means filing more
   slips under a day they don't belong to. */
.status-wrong-day {
  color: #b3261e; font-weight: 700;
  background: #fdecea; border-radius: 6px; padding: 2px 8px;
}

/* The day being worked on, set beside the page title. Sized down and
   given its own colour so it reads as a label on the heading rather than
   part of it, while still being impossible to miss from arm's length. */
.working-date {
  display: inline-block; vertical-align: middle;
  margin-left: 10px; padding: 3px 12px;
  border-radius: 999px; background: #eef2ff; color: #3949ab;
  font-size: 0.62em; font-weight: 700; letter-spacing: 0.02em;
  white-space: nowrap;
}

/* Pinned to the viewport rather than the heading: the number's whole
   purpose is to react while cards are being dragged between groups, which
   happens well below the fold on a day with several trips. */
.day-total {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 50;
  display: inline-flex; align-items: baseline; gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--blue);
  border-radius: 999px;
  padding: 7px 16px;
  white-space: nowrap;
  box-shadow: 0 3px 14px rgba(0,0,0,0.18);
}
.day-total-label { font-size: 0.78rem; color: var(--muted); }
.day-total-value { font-size: 1.15rem; color: var(--blue-dark); }
.day-total-sub { font-size: 0.78rem; color: var(--muted); }

/* The board scrolls horizontally and its last column would otherwise sit
   under the pinned total on a narrow screen. */
@media (max-width: 600px) {
  .board { padding-bottom: 56px; }
}

.group-drag-handle {
  cursor: grab; touch-action: none; user-select: none;
  color: var(--muted); font-size: 1.1rem; padding: 0 2px; flex-shrink: 0;
}
.board-col.col-dragging { opacity: 0.6; box-shadow: 0 4px 14px rgba(0,0,0,0.18); }

.slip-list { display: flex; flex-direction: column; gap: 10px; }
.slip-card {
  display: flex;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: var(--card);
}
.slip-card.needs-review { border-color: var(--warn); background: #fffdf5; }
.slip-card img.thumb {
  width: 84px; height: 84px; object-fit: cover; border-radius: 6px; flex-shrink: 0;
  border: 1px solid var(--border); cursor: pointer;
}
.slip-card .body { flex: 1; min-width: 0; }
.slip-card .row1 { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }

.upload-zone {
  border: 2px dashed var(--blue);
  border-radius: 12px;
  padding: 30px 16px;
  text-align: center;
  background: #fdf1e9;
}
.thumb-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.thumb-strip .item { width: 88px; }
.thumb-strip img { width: 88px; height: 88px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.thumb-strip .status { font-size: 0.72rem; text-align: center; margin-top: 3px; }

.stop-list { display: flex; flex-direction: column; gap: 8px; }
.stop-item {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--card);
}
.stop-item.completed { opacity: 0.55; }
.stop-item.violation { border-color: var(--danger); background: #fff6f5; }
.stop-item.stop-break { background: #fff8e6; border-color: #e0c568; }
.stop-item.stop-base { background: #eef4ff; border-color: #a9c2ec; }
.stop-item.stop-wholesaler { background: #f1eefc; border-color: #c3aeef; }
.stop-num {
  min-width: 30px; height: 30px; padding: 0 8px; border-radius: 15px; background: var(--blue); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; font-size: 0.85rem;
}
.stop-item.completed .stop-num { background: var(--ok); }
.stop-body { flex: 1; min-width: 0; }
.stop-actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }

.drag-handle {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--muted);
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.stop-item.dragging { opacity: 0.5; border-color: var(--blue); box-shadow: 0 2px 8px rgba(0,0,0,0.15); }

/* The active stop carries two full-size buttons (🧭 ナビ開始 / 配達完了),
   which is more than fits beside the address on a phone screen. Left as a
   single row, .stop-actions' own flex-wrap stacks them on top of each
   other and stretches just that one card tall next to its neighbours.
   Wrapping the row instead drops the button pair to a full-width line of
   its own, side by side, which is what "収まりきらず縦長になる" was asking
   to fix. */
@media (max-width: 600px) {
  .stop-item { flex-wrap: wrap; }
  .stop-item .stop-actions { flex-basis: 100%; margin-top: 8px; }
  .stop-item .stop-actions > .btn,
  .stop-item .stop-actions > button { flex: 1; }
}

.error-banner { background: #fde3e0; color: var(--danger); padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; }
.info-banner { background: #fdf1e9; color: var(--blue-dark); padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 0.9rem; }
.hint { font-size: 0.82rem; color: var(--muted); margin-top: 4px; }

.board {
  display: flex; flex-wrap: nowrap; gap: 14px; overflow-x: auto; padding-bottom: 8px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.board-col {
  flex: 1 1 260px;
  min-width: 260px;
  max-width: 360px;
  background: #f7f1e9;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  scroll-snap-align: start;
}
.board-col-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.board-col-body {
  flex: 1;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px;
  border-radius: 8px;
}
.board-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.board-card.violation { border-color: var(--danger); background: #fff6f5; }
.board-card.dragging { opacity: 0.5; box-shadow: 0 4px 10px rgba(0,0,0,0.2); border-color: var(--blue); }
.board-card.stop-break { background: #fff8e6; border-color: #e0c568; }
.board-card.stop-base { background: #eef4ff; border-color: #a9c2ec; }
.board-card.stop-wholesaler { background: #f1eefc; border-color: #c3aeef; }
.board-card select { min-height: 34px; padding: 4px 8px; font-size: 0.85rem; width: auto; }

.stop-remove-btn {
  min-height: auto; padding: 0 8px; font-size: 1rem; line-height: 1.6; border-radius: 6px;
  background: transparent; color: var(--muted); border: 1px solid var(--border);
}
.stop-remove-btn:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.stop-lock-btn {
  min-height: auto; padding: 0 6px; font-size: 0.9rem; line-height: 1.6; border-radius: 6px;
  background: transparent; border: 1px solid var(--border); opacity: 0.45;
}
.stop-lock-btn:hover { opacity: 1; background: transparent; }
/* A locked card is the one thing on the board a re-plan will not touch, so
   it reads as deliberate rather than as another faded icon. */
.stop-lock-btn.on { opacity: 1; border-color: var(--blue); background: #e6eef7; }
.board-card:has(.stop-lock-btn.on) { border-left: 4px solid var(--blue); }

.palette { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.palette-card {
  display: flex; align-items: center; gap: 8px;
  border: 1px dashed var(--border); border-radius: 8px; padding: 8px 10px;
  background: var(--card);
  flex: 0 0 auto;
}
.palette-drag-handle { cursor: grab; touch-action: none; user-select: none; font-size: 0.9rem; white-space: nowrap; }
.palette-card select { min-width: 130px; }

.provider-note { font-size: 0.78rem; color: var(--muted); margin-top: 24px; border-top: 1px solid var(--border); padding-top: 10px; }
