:root {
  --bg: #f4f1ea;
  --card: #ffffff;
  --ink: #1a1a1a;
  --muted: #6b6b6b;
  --george: #1E66F5;
  --miruna: #C44EC4;
  --miruna-deep: #8B3AA8;
  --line: #e2ddd3;
  --danger: #c0392b;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(0,0,0,.08);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); min-height: 100%; }
body { -webkit-tap-highlight-color: transparent; }
#app { max-width: 720px; margin: 0 auto; min-height: 100dvh; padding: 12px 12px 96px; }
.screen[hidden] { display: none !important; }
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.gate-card { margin-top: 12vh; text-align: center; }
h1 { font-size: 1.6rem; margin: 0 0 8px; }
h2 { font-size: 1.15rem; margin: 16px 0 8px; }
.lede { color: var(--muted); margin: 0 0 16px; }
.field { display: flex; flex-direction: column; gap: 6px; text-align: left; margin: 12px 0; }
.field input, .field textarea, .review-edit {
  font: inherit; padding: 14px; border-radius: 12px; border: 1px solid var(--line); background: #fafafa;
}
.btn {
  appearance: none; border: 0; border-radius: 14px; padding: 12px 16px;
  font: inherit; font-weight: 650; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--ink); background: #ece7de;
}
.btn.big { width: 100%; padding: 18px; font-size: 1.15rem; margin-top: 8px; }
.btn.primary { background: var(--george); color: #fff; }
.btn.secondary { background: #ece7de; }
.btn.ghost { background: transparent; color: var(--muted); padding: 8px 10px; }
.btn.who.george { background: var(--george); color: #fff; }
.btn.who.miruna { background: linear-gradient(135deg, var(--miruna), var(--miruna-deep)); color: #fff; }
.who-grid { display: grid; gap: 12px; }
.error { color: var(--danger); min-height: 1.2em; }
.muted { color: var(--muted); }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 8px;
}
.badge {
  display: inline-block; margin-left: 8px; padding: 2px 10px; border-radius: 999px;
  background: #fff; font-size: .85rem; border: 1px solid var(--line);
}
.sync-status { color: var(--muted); font-size: .92rem; margin: 0 0 10px; }
.fab {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: max(16px, env(safe-area-inset-bottom));
  width: calc(100% - 32px); max-width: 688px; z-index: 5;
  box-shadow: var(--shadow);
}

.calendar { background: var(--card); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow); }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-title { margin: 0; font-size: 1.1rem; }
.cal-nav { border: 0; background: #f0ebe3; width: 40px; height: 40px; border-radius: 12px; font-size: 1.4rem; cursor: pointer; }
.cal-weekdays, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-weekdays { margin-bottom: 4px; color: var(--muted); font-size: .75rem; text-align: center; }
.cal-cell {
  min-height: 78px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; padding: 4px; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px; font: inherit; color: inherit;
}
.cal-cell.empty { background: transparent; border-color: transparent; min-height: 0; }
.cal-cell.today { outline: 2px solid var(--george); }
.cal-daynum { font-size: .75rem; font-weight: 700; color: var(--muted); }
.cal-duty { display: flex; flex-direction: column; border-radius: 6px; padding: 2px 3px; line-height: 1.15; }
.cal-duty .d1 { font-size: .68rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-duty .d2 { font-size: .62rem; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-duty.george { background: rgba(30,102,245,.12); color: #0b3fb8; }
.cal-duty.miruna { background: rgba(196,78,196,.14); color: #7a2080; }
.cal-duty.empty-duty { min-height: 0; padding: 0; background: transparent; }

.progress { height: 10px; background: #ece7de; border-radius: 999px; overflow: hidden; margin: 12px 0 6px; }
#ocr-progress-bar { height: 100%; width: 0; background: var(--george); transition: width .2s; }
.file-btn { position: relative; }
.review-row {
  display: grid; grid-template-columns: auto 96px 1fr; gap: 8px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.day-content { display: flex; flex-direction: column; gap: 16px; }
.person-day { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.person-day.george { border-top: 4px solid var(--george); }
.person-day.miruna { border-top: 4px solid var(--miruna); }
.person-day h3 { margin: 0 0 10px; }
.sector-card {
  display: grid; grid-template-columns: 96px 1fr; gap: 10px; margin-bottom: 10px;
  background: #faf8f4; border-radius: 12px; overflow: hidden;
}
.sector-card.meta { grid-template-columns: 1fr; padding: 10px 12px; }
.city-photo { width: 96px; height: 72px; object-fit: cover; }
.sector-body { display: flex; flex-direction: column; gap: 2px; padding: 8px 8px 8px 0; font-size: .92rem; }
.sector-card.meta .sector-body { padding: 0; }
.route { color: var(--muted); }
.day-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.day-actions .btn { font-size: .9rem; padding: 10px 12px; }

@media (max-width: 420px) {
  .cal-cell { min-height: 70px; padding: 2px; }
  .cal-duty .d1 { font-size: .6rem; }
  .cal-duty .d2 { font-size: .55rem; }
  .sector-card { grid-template-columns: 1fr; }
  .city-photo { width: 100%; height: 120px; }
}
