/* Field app: layout only. Colours, controls, chips, cards, badges, notices and toasts come from ui.css. */

body { padding-bottom: env(safe-area-inset-bottom, 0px); }

/* ---------- top bar ---------- */
.bar { position: sticky; top: 0; z-index: 10; background: var(--espresso); color: #fff; padding-top: env(safe-area-inset-top, 0px); }
.bar-in {
  max-width: 640px; margin: 0 auto; min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: 0 max(var(--s4), env(safe-area-inset-right, 0px)) 0 max(var(--s4), env(safe-area-inset-left, 0px));
}
.brand { all: unset; display: flex; align-items: center; gap: 10px; min-height: 48px; font-weight: 700; font-size: 18px; letter-spacing: -0.01em; cursor: pointer; }
.brand:focus-visible { box-shadow: 0 0 0 3px var(--espresso), 0 0 0 5px #fff; border-radius: 8px; }
.brand img { border-radius: 7px; display: block; }
.sync {
  display: inline-flex; align-items: center; gap: var(--s2); height: 36px; padding: 0 14px 0 12px; border: 0; border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .12); color: #fff; font-size: 14px; font-weight: 600; line-height: 1; cursor: pointer; white-space: nowrap;
}
.sync:focus-visible { box-shadow: 0 0 0 3px var(--espresso), 0 0 0 5px #fff; }
.sync-ic { display: inline-flex; }
.sync-ic .icon { width: 16px; height: 16px; display: none; vertical-align: 0; }
.sync .i-state { display: none; }
.sync[data-state="ok"] { color: #7BD394; }
.sync[data-state="waiting"], .sync[data-state="sending"] { color: #F2B661; }
.sync[data-state="offline"], .sync[data-state="idle"] { color: #E3DAD2; }
.sync[data-state="problem"] { color: #F49387; }
.sync[data-state="ok"] .i-check,
.sync[data-state="waiting"] .i-clock,
.sync[data-state="idle"] .i-clock,
.sync[data-state="sending"] .i-loader,
.sync[data-state="offline"] .i-cloud,
.sync[data-state="problem"] .i-alert { display: block; }
.sync[data-state="sending"] .i-loader { animation: spin 1s linear infinite; }
.sync #sync-text { color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .sync .icon { animation: none !important; } }

/* ---------- page ---------- */
.view {
  max-width: 640px; margin: 0 auto; outline: none;
  padding: var(--s5) max(var(--s4), env(safe-area-inset-right, 0px)) calc(var(--savebar-h, 0px) + 40px) max(var(--s4), env(safe-area-inset-left, 0px));
}
h1 { font-size: 26px; font-weight: 700; line-height: 1.15; }
h2 { font-size: 19px; font-weight: 650; }
.sub { color: var(--text-2); font-size: 15px; }
.loading { color: var(--text-2); }
.page-head { display: grid; gap: var(--s1); margin-bottom: var(--s5); }
.link { all: unset; color: var(--brand); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link:focus-visible { box-shadow: var(--ring); border-radius: 4px; }
.row { display: flex; gap: var(--s2); flex-wrap: wrap; }
.row > .btn { flex: 1 1 auto; }
.stack { display: grid; gap: var(--s3); margin-bottom: var(--s4); }

/* ---------- home ---------- */
.status { display: grid; gap: var(--s3); margin-bottom: var(--s4); }
.status-top { display: flex; align-items: center; gap: var(--s3); }
.avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-soft-ink); font-weight: 700; font-size: 15px; }
.status-who { flex: 1; min-width: 0; display: grid; line-height: 1.25; }
.status-who small { font-size: var(--fs-sm); color: var(--text-3); font-weight: 500; }
.status-who b { font-size: 18px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-sync { display: flex; align-items: center; gap: var(--s2); padding-top: var(--s3); border-top: 1px solid var(--divider); font-size: 15px; color: var(--text-2); }
.status-sync .icon { width: 18px; height: 18px; }
.status-sync.ok .icon { color: var(--ok); }
.status-sync.waiting .icon { color: var(--warn); }
.status-sync.problem .icon { color: var(--bad); }
.status-sync b { color: var(--text); font-weight: 650; }

.sect-title { margin: var(--s6) 0 var(--s2); font-size: var(--fs-sm); font-weight: 650; color: var(--text-2); letter-spacing: .04em; text-transform: uppercase; }

.actions, .list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-1); }
.action, .list-row {
  display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 64px; padding: var(--s3) var(--s4); text-align: left;
  background: transparent; border: 0; border-top: 1px solid var(--divider); color: var(--text); text-decoration: none; cursor: pointer; font-size: 17px;
}
.actions > :first-child, .list > :first-child { border-top: 0; }
.action:hover, .list-row:hover { background: var(--surface-2); color: var(--text); }
.action:active, .list-row:active { background: var(--surface-3); }
.action:focus-visible, .list-row:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }
.action .ico { flex: none; width: 44px; height: 44px; border-radius: var(--r-md); background: var(--brand-soft); color: var(--brand-soft-ink); display: grid; place-items: center; }
.action .ico .icon { width: 24px; height: 24px; }
.action .txt, .list-row .txt { flex: 1; min-width: 0; display: grid; line-height: 1.25; }
.action .t { font-size: 17px; font-weight: 650; }
.action .h, .list-row .h { color: var(--text-2); font-size: 15px; }
.chev { flex: none; color: var(--text-3); display: inline-flex; }
.chev .icon { width: 20px; height: 20px; }
.list-row .li { flex: none; color: var(--text-2); display: inline-flex; }
.list-row .li .icon { width: 22px; height: 22px; }
.list-row .t { font-weight: 600; }
.list-row.box { min-height: 56px; }
.list-row.box .t { font-weight: 700; }

/* ---------- forms ---------- */
.sec { margin-top: var(--s8); }
.sec:first-child { margin-top: 0; }
.sec-head { font-size: var(--fs-sm); font-weight: 650; color: var(--text-2); letter-spacing: .04em; text-transform: uppercase; padding-bottom: var(--s2); margin: 0 0 var(--s4); border-bottom: 1px solid var(--border); }
.q { margin: 0 0 var(--s5); border: 0; padding: 0; min-width: 0; }
.q > label, .q > legend { display: block; font-weight: 650; font-size: 17px; margin: 0 0 var(--s2); padding: 0; }
.q .help { color: var(--text-2); font-size: 15px; margin: -2px 0 var(--s2); }
.q.is-error > legend, .q.is-error > label { color: var(--bad); }
.req { color: var(--bad); }
.q .other { margin-top: var(--s2); }
.q .group + .group { margin-top: var(--s3); }
.group-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); margin-bottom: var(--s3); min-height: 44px; }
.group-head .t { font-weight: 650; font-size: 17px; min-width: 0; overflow-wrap: anywhere; }
.group-head .btn { --ctl-h: 44px; font-size: 15px; padding: 0 var(--s3); color: var(--text-2); }
.group > .q:last-of-type { margin-bottom: 0; }
.q > .btn-block { margin-top: var(--s3); }

.temps { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.temps label { display: grid; gap: 2px; min-width: 0; }
.temps .n { text-align: center; font-size: 13px; color: var(--text-3); font-weight: 600; }
.temps input { height: 48px; min-height: 48px; padding: 0 2px; text-align: center; font-size: 18px; }

/* ---------- save bar and its panel ---------- */
.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; background: var(--surface); border-top: 1px solid var(--border);
  padding: var(--s3) max(var(--s4), env(safe-area-inset-right, 0px)) calc(var(--s3) + env(safe-area-inset-bottom, 0px)) max(var(--s4), env(safe-area-inset-left, 0px));
}
.savebar-in { max-width: 640px; margin: 0 auto; display: grid; gap: var(--s3); }
.savebar-btns { display: grid; grid-template-columns: 1fr 2fr; gap: var(--s3); }
.savebar .btn { --ctl-h: 56px; font-size: 18px; }
.savebar .notice { max-height: 46vh; overflow: auto; }
.savebar .notice .btn { --ctl-h: 48px; font-size: 16px; }
.savebar .notice ul { margin: 0; padding-left: 20px; }
.form-foot { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s6); color: var(--text-2); font-size: 15px; text-align: center; }

/* ---------- entries ---------- */
.entries { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.entry { padding: 0; overflow: hidden; }
details.entry summary { cursor: pointer; list-style: none; display: grid; gap: 2px; padding: var(--s3) var(--s4); min-height: 56px; }
details.entry summary::-webkit-details-marker { display: none; }
details.entry summary:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }
.entry-top { display: flex; justify-content: space-between; align-items: center; gap: var(--s2); }
.entry .t { font-weight: 650; font-size: 17px; }
.entry .m { color: var(--text-2); font-size: 15px; }
.entry .kv { margin: 0 var(--s4) var(--s4); }
.kv { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: var(--s2) var(--s3); padding-top: var(--s3); border-top: 1px solid var(--divider); font-size: 15px; }
.kv dt { color: var(--text-2); text-transform: capitalize; }
.kv dd { margin: 0; overflow-wrap: anywhere; font-weight: 500; }

/* ---------- person picker, settings ---------- */
.people { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; margin-bottom: var(--s5); }
.person-row { display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 56px; padding: var(--s2) var(--s4); background: transparent; border: 0; border-top: 1px solid var(--divider); text-align: left; cursor: pointer; font-size: 18px; font-weight: 600; color: var(--text); }
.person-row:first-child { border-top: 0; }
.person-row:hover { background: var(--surface-2); }
.person-row:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }
.person-row .avatar { width: 36px; height: 36px; font-size: 14px; }
.person-row .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* ---------- notices ---------- */
.notice { margin-bottom: var(--s4); }
.savebar .notice { margin-bottom: 0; }
.notice .row { margin-top: var(--s2); }
.connect-row { display: grid; gap: var(--s2); margin-top: var(--s2); }

/* ---------- compact chips and the full-screen picker (field app) ---------- */
body.field .chips { gap: 6px; }
body.field .chip-opt span { padding: 0 var(--s3); min-height: max(var(--tap), 44px); }
.chip-btn {
  display: inline-flex; align-items: center; gap: var(--s2); min-height: max(var(--tap), 44px); padding: 0 var(--s3);
  border: var(--ctl-bw) dashed var(--border-strong); border-radius: var(--r-pill); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer;
}
.chip-btn:focus-visible { box-shadow: var(--ring); outline: none; }
.chip-opt[hidden] { display: none; }

dialog.pk {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: var(--bg); color: var(--text); font: inherit; flex-direction: column; overflow: hidden;
}
dialog.pk[open] { display: flex; }
dialog.pk::backdrop { background: rgba(0, 0, 0, .4); }
.pk-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s2) var(--s4); border-bottom: 1px solid var(--border); background: var(--surface); min-height: 60px; }
.pk-bar h2 { font-size: 20px; font-weight: 650; min-width: 0; overflow-wrap: anywhere; }
.pk-close {
  display: inline-flex; align-items: center; gap: var(--s2); min-height: 48px; padding: 0 var(--s3); border: 0; border-radius: var(--r-md);
  background: transparent; color: var(--text); font: inherit; font-size: 16px; font-weight: 600; cursor: pointer;
}
.pk-close:focus-visible { box-shadow: var(--ring); outline: none; }
.pk-searchrow { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); background: var(--surface); }
.pk-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: var(--s2) 0 var(--s6); }
.pk-list { border: 0; margin: 0; padding: 0; min-width: 0; }
.pk-head2 { margin: var(--s4) var(--s4) var(--s1); font-size: 13px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--text-2); }
.pk-row {
  display: flex; align-items: center; gap: var(--s4); min-height: 56px; padding: var(--s2) var(--s4); width: 100%;
  border-bottom: 1px solid var(--divider); background: var(--surface); font-size: 18px; font-weight: 600; cursor: pointer;
}
.pk-row[hidden], .pk-head2[hidden], .pk-skip[hidden] { display: none; }
.pk-row input { width: 24px; height: 24px; margin: 0; flex: none; accent-color: var(--brand); }
.pk-row:has(input:checked) { background: var(--brand-soft); color: var(--brand-soft-ink); }
.pk-row:has(input:focus-visible) { box-shadow: inset 0 0 0 3px var(--focus); }
.pk-txt { min-width: 0; overflow-wrap: anywhere; }
.pk-none { padding: var(--s4); color: var(--text-2); }
.pk-foot { padding: var(--s3) var(--s4) max(var(--s3), env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--surface); }
