:root {
  --blue: #0058a3;
  --blue-dark: #003b72;
  --yellow: #ffda1a;
  --green: #00853e;
  --red: #d32f2f;
  --orange: #b45309;
  --ink: #111827;
  --muted: #667085;
  --line: #d0d5dd;
  --surface: #ffffff;
  --background: #f3f6f9;
  --shadow: 0 4px 14px rgb(17 24 39 / 9%);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--background);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  padding-bottom: calc(82px + env(safe-area-inset-bottom));
}

button, select, textarea, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .6; }
[hidden] { display: none !important; }

.app-header {
  min-height: 88px;
  padding: 18px max(18px, calc((100vw - 720px) / 2));
  color: white;
  background: var(--blue);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow, .section-kicker {
  margin: 0 0 3px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .13em;
}

.app-header h1 { margin: 0; font-size: 21px; }

.connection {
  max-width: 130px;
  text-align: right;
  font-size: 12px;
  font-weight: 700;
}
.connection[data-kind="syncing"] { color: var(--yellow); }
.connection[data-kind="error"] { color: #fecaca; }

.demo-banner {
  padding: 10px 16px;
  color: #713f12;
  background: #fef3c7;
  border-bottom: 1px solid #fde68a;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

main {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 18px 14px 30px;
}

.section-heading {
  margin: 2px 2px 14px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}
.section-kicker { color: var(--blue); }
.section-heading h2 { margin: 0; font-size: 23px; }
.sla-note { color: var(--muted); font-size: 12px; }

.panel {
  padding: 16px;
  background: var(--surface);
  border: 1px solid #e4e7ec;
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.landing { text-align: center; }
.landing h2 { margin: 0; }
.landing p { color: var(--muted); }
.entry-link {
  display: block;
  margin-top: 12px;
  padding: 15px;
  color: white;
  background: var(--blue);
  border-radius: 10px;
  font-weight: 800;
  text-decoration: none;
}
.board-entry { color: var(--ink); background: var(--yellow); }
.request-result {
  margin-top: 12px;
  padding: 15px;
  color: #065f46;
  background: #d1fae5;
  border-radius: 12px;
  font-weight: 700;
}
.task-reminders { margin: 8px 0 0; color: var(--red); font-size: 13px; font-weight: 800; }
.task-photo-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.task-photo-link {
  padding: 7px 10px;
  color: var(--blue);
  background: #eaf2f8;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}
.task-photo-link.completion { color: var(--green); background: #e8f5ed; }
body[data-mode="request"] .bottom-nav { display: none; }
body[data-mode="board"] .nav-button[data-target="request"] { display: none; }
body[data-mode="board"] .bottom-nav { grid-template-columns: repeat(2, 1fr); }

.form-grid { display: grid; gap: 15px; }

label, legend {
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

select, textarea {
  width: 100%;
  margin-top: 7px;
  padding: 12px;
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
input[type="file"] {
  width: 100%;
  margin-top: 7px;
  padding: 10px;
  color: var(--muted);
  background: #f8fafc;
  border: 1px dashed var(--line);
  border-radius: 10px;
}
.field-hint { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; font-weight: 400; }
select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgb(0 88 163 / 12%); }
textarea { resize: vertical; }

fieldset { margin: 0; padding: 0; border: 0; }
.choice-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 7px; }
.choice-options.combined-options { grid-template-columns: 1fr; }
.choice-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 12px;
  background: #eef4fb;
  border: 1px solid #cbdff1;
  border-radius: 10px;
}
.choice-options label:has(input:checked) {
  color: var(--blue);
  background: #dbeeff;
  border-color: var(--blue);
}
.choice-options label:focus-within { box-shadow: 0 0 0 3px rgb(0 88 163 / 12%); }
.choice-options input { accent-color: var(--blue); }
.priority-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 7px; }
.priority-options label {
  padding: 12px;
  background: #eef4fb;
  border: 1px solid #cbdff1;
  border-radius: 10px;
  text-align: center;
}
.priority-options .urgent-option { color: #991b1b; background: #fef2f2; border-color: #fecaca; }

button {
  min-height: 44px;
  padding: 10px 14px;
  border: 0;
  border-radius: 10px;
  font-weight: 800;
}
.primary { color: white; background: var(--blue); }
.success { color: white; background: var(--green); }
.quiet { color: var(--blue); background: #eaf2f8; }
.danger-text { color: var(--red); background: #fef2f2; }
.submit-button { min-height: 52px; font-size: 16px; }

.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.summary-card {
  padding: 16px;
  color: white;
  background: var(--blue);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.summary-card span { font-size: 14px; font-weight: 700; }
.summary-card strong { font-size: 28px; }
.overdue-summary { background: var(--red); }

.board-controls { margin-bottom: 12px; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.desktop-only { display: none; }
.reset-data-button { width: 100%; margin-top: 8px; }

.segmented {
  margin-bottom: 12px;
  padding: 4px;
  background: #e4e7ec;
  border-radius: 12px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
}
.segmented button { min-height: 38px; padding: 7px 5px; color: #475467; background: transparent; font-size: 12px; }
.segmented button.active { color: var(--blue); background: white; box-shadow: 0 1px 4px rgb(17 24 39 / 10%); }
.segmented.days { grid-template-columns: repeat(2, 1fr); }

.task-list { display: grid; gap: 10px; }
.task-card {
  padding: 15px;
  background: white;
  border: 1px solid #dbe4ec;
  border-left: 5px solid var(--blue);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.task-card.accepted { border-left-color: var(--orange); }
.task-card.completed { border-left-color: var(--green); opacity: .8; }
.task-card.cancelled { border-left-color: #98a2b3; opacity: .7; }
.task-card.overdue { border-color: #fca5a5; border-left-color: var(--red); background: #fff7f7; animation: overdue-pulse 1.8s ease-in-out 2; }
@keyframes overdue-pulse { 50% { box-shadow: 0 0 0 5px rgb(211 47 47 / 12%); } }

.task-card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.task-tool { font-size: 19px; }
.task-status {
  padding: 4px 8px;
  color: var(--blue);
  background: #eaf2f8;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}
.overdue .task-status { color: white; background: var(--red); }
.task-priority {
  margin-top: 10px;
  padding: 10px 12px;
  color: var(--blue-dark);
  background: #eaf2f8;
  border: 1px solid #cbdff1;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.task-priority.urgent {
  color: #991b1b;
  background: #fee2e2;
  border-color: #ef4444;
}
.task-priority-label {
  padding: 4px 8px;
  color: white;
  background: var(--blue);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}
.task-priority.urgent .task-priority-label { background: var(--red); }
.task-priority-area { text-align: right; font-size: 15px; }
.task-route { margin-top: 9px; font-size: 14px; font-weight: 700; }
.task-meta { margin-top: 5px; color: var(--muted); font-size: 12px; }
.task-note { margin: 10px 0 0; padding: 9px 10px; color: #344054; background: #f2f4f7; border-radius: 8px; font-size: 13px; }
.completion-photo-label { display: block; margin-top: 12px; }
.task-actions { margin-top: 12px; display: flex; gap: 8px; }
.task-actions button { flex: 1; }

.empty-state { padding: 40px 16px; color: var(--muted); text-align: center; }
.empty-state.compact { padding: 20px 0; }

.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.metric {
  min-height: 96px;
  padding: 14px;
  background: white;
  border-radius: 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.metric span { color: var(--muted); font-size: 13px; font-weight: 700; }
.metric strong { color: var(--blue); font-size: 25px; }
.metric.wide { grid-column: span 2; min-height: 82px; flex-direction: row; align-items: center; }
.metric.warning strong { color: var(--red); }

.ranking-panel { margin-top: 12px; }
.ranking-panel h3 { margin: 0 0 14px; font-size: 16px; }
.rank-row + .rank-row { margin-top: 12px; }
.rank-label { margin-bottom: 5px; display: flex; justify-content: space-between; font-size: 13px; }
.rank-track { height: 8px; overflow: hidden; background: #e4e7ec; border-radius: 99px; }
.rank-track span { display: block; height: 100%; background: var(--blue); border-radius: inherit; }

.bottom-nav {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  min-height: 68px;
  padding: 7px max(8px, calc((100vw - 720px) / 2)) calc(7px + env(safe-area-inset-bottom));
  background: white;
  border-top: 1px solid #d0d5dd;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}
.nav-button {
  min-height: 52px;
  padding: 4px;
  color: #667085;
  background: transparent;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.nav-button span { font-size: 21px; line-height: 1; }
.nav-button.active { color: var(--blue); }

.toast {
  position: fixed;
  z-index: 40;
  right: 18px;
  bottom: 90px;
  left: 18px;
  max-width: 520px;
  margin: auto;
  padding: 13px 16px;
  color: white;
  background: #101828;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgb(17 24 39 / 25%);
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  opacity: 0;
  transform: translateY(15px);
  pointer-events: none;
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast[data-kind="error"] { background: var(--red); }
.toast[data-kind="warning"] { color: #111; background: var(--yellow); }

@media (min-width: 600px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid label:has(textarea), .form-grid fieldset, .form-grid .submit-button { grid-column: span 2; }
}

@media (min-width: 900px) and (hover: hover) and (pointer: fine) {
  .desktop-only { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
