:root {
  --bg: #f6f6f4;
  --surface: #fff;
  --surface-2: #f0f0ee;
  --line: #e2e2de;
  --text: #1d1d1f;
  --muted: #6b6b6b;
  --accent: #1f5fbf;
  --accent-text: #fff;
  --danger: #b3261e;
  --ok: #0b6e2e;
  --hover: #f3f6fb;
  --selected: #e3ecff;
  --radius: 10px;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { overflow-wrap: anywhere; margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--accent); }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 10px; }
main { max-width: 1400px; margin: 0 auto; padding: 16px; padding-bottom: 48px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1000; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; font-size: 17px; }

button, .button { font: inherit; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 8px; padding: 7px 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; }
button:hover, .button:hover { background: var(--surface-2); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; color: var(--accent); padding: 4px 6px; min-height: 0; }
button:disabled { opacity: .55; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, .button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input[type=text], input[type=number], input[type=password], input[type=time], select {
  font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); min-height: 36px; max-width: 100%;
}
input[type=number] { width: 7.5em; }
label { display: inline-flex; align-items: center; gap: 6px; }

.page-head > * { min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.muted { color: var(--muted); }
.error { color: var(--danger); background: #fdecea; border: 1px solid #f3c5c1; border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; white-space: pre-wrap; }
.notice { background: #fff6e0; border: 1px solid #efd9a0; border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.profile-card { display: flex; flex-direction: column; gap: 10px; }
.profile-card h2 { margin: 0; }
.profile-card h2 a { color: var(--text); text-decoration: none; }
.status { font-size: 13px; }
.status-done { color: var(--ok); }
.status-failed, .status-interrupted { color: var(--danger); }
.empty { text-align: center; padding: 40px 16px; }

.login { max-width: 360px; margin: 10vh auto; display: flex; flex-direction: column; gap: 12px; }

form.settings { display: flex; flex-direction: column; gap: 14px; max-width: 960px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 14px 16px 16px; margin: 0; min-width: 0; }
legend { font-weight: 600; padding: 0 6px; }
.row { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin-top: 10px; }
.row:first-of-type { margin-top: 4px; }
.field { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; min-width: 0; max-width: 100%; }
.field > span { font-size: 13px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; background: var(--surface); cursor: pointer; user-select: none; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:checked) { background: var(--selected); border-color: var(--accent); }
.chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; }

.dest { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-top: 10px; background: var(--bg); }
.dest-head { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.dest-head .grow { flex: 1 1 260px; }
.dest-head .grow input { width: 100%; }
.geo-results { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.geo-results button { justify-content: flex-start; text-align: left; white-space: normal; }
.pin { font-size: 13px; color: var(--ok); margin-top: 6px; }

.sticky-save { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 16px 0 calc(8px + env(safe-area-inset-bottom, 0px)); display: flex; gap: 8px; }

.progress { margin: 0 0 12px; }
.progress .bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 6px 0 4px; }
.progress .bar > div { height: 100%; background: var(--accent); transition: width .4s; }
.progress-line { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; font-size: 14px; }

@media (max-width: 600px) {
  main { padding: 12px; }
  h1 { font-size: 19px; }
  .hh-map { height: 50vh; }
}
