/* MS Rollout manager portal. One stylesheet for the whole portal.
   Colours are tokens on :root (light), redefined for dark mode. Base font
   is 17px for reading outdoors; every tap target is at least 44px high. */
:root {
  --accent: #F26B1D;          /* brand orange: fills, icons, borders */
  --accent-ink: #A9440A;      /* orange for text and links on light backgrounds */
  --accent-soft: #FDEBDD;
  --on-accent: #1A1208;       /* text on orange buttons */
  --bg: #F7F5F2;
  --surface: #FFFFFF;
  --surface-2: #F0ECE7;
  --text: #1C1A17;
  --muted: #57514B;
  --border: #D9D3CB;
  --ok: #1B6E36;
  --ok-soft: #E1F2E6;
  --warn: #8A5A00;
  --warn-soft: #FFF1D1;
  --danger: #B3261E;
  --danger-soft: #FCE4E2;
  --info: #1F5FA8;
  --info-soft: #E1ECF8;
  --grey: #5F6368;
  --grey-soft: #ECEDEE;
  --focus: #1F5FA8;
  --shadow: 0 1px 2px rgba(28, 26, 23, .06), 0 4px 16px rgba(28, 26, 23, .06);
  --radius: 12px;
  --gutter: 16px;
  --nav-w: 232px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent-ink: #FF9A5C;
    --accent-soft: #3A2414;
    --bg: #141311;
    --surface: #1D1B19;
    --surface-2: #27241F;
    --text: #F2EEE9;
    --muted: #BDB5AC;
    --border: #413C36;
    --ok: #6FD08E;
    --ok-soft: #173322;
    --warn: #F3C35B;
    --warn-soft: #3A2E10;
    --danger: #FF8A80;
    --danger-soft: #3D1A17;
    --info: #8AB8F0;
    --info-soft: #172A40;
    --grey: #B9BCC0;
    --grey-soft: #2C2D2F;
    --focus: #8AB8F0;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --accent-ink: #FF9A5C;
  --accent-soft: #3A2414;
  --bg: #141311;
  --surface: #1D1B19;
  --surface-2: #27241F;
  --text: #F2EEE9;
  --muted: #BDB5AC;
  --border: #413C36;
  --ok: #6FD08E;
  --ok-soft: #173322;
  --warn: #F3C35B;
  --warn-soft: #3A2E10;
  --danger: #FF8A80;
  --danger-soft: #3D1A17;
  --info: #8AB8F0;
  --info-soft: #172A40;
  --grey: #B9BCC0;
  --grey-soft: #2C2D2F;
  --focus: #8AB8F0;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { font-size: 17px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  line-height: 1.45; overflow-x: hidden;
}
a { color: var(--accent-ink); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; line-height: 1.2; }
h2 { font-size: 1.2rem; margin: 1.25rem 0 .5rem; }
h3 { font-size: 1.05rem; margin: 1rem 0 .4rem; }
p { margin: .4rem 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.red { color: var(--danger); font-weight: 600; }
.pre { white-space: pre-wrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---- Buttons and inputs ---- */
button, .btn {
  font: inherit; min-height: 44px; padding: .45rem .95rem; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; text-decoration: none;
}
button:hover, .btn:hover { border-color: var(--accent); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
button.danger { color: var(--danger); border-color: var(--danger); }
button.small, .btn.small { min-height: 36px; padding: .25rem .6rem; font-size: .9rem; }
button:disabled { opacity: .55; cursor: not-allowed; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: .5rem .65rem; min-height: 44px; width: 100%; max-width: 100%;
}
textarea { min-height: 90px; resize: vertical; }
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); }
label.check { display: inline-flex; align-items: center; gap: .5rem; min-height: 44px; }

/* ---- Sign-in ---- */
.signin { min-height: 100vh; display: grid; place-items: center; padding: var(--gutter); }
.signin .card { width: 100%; max-width: 420px; }
.signin .brand { display: flex; align-items: center; gap: .6rem; margin-bottom: .8rem; }
.signin .brand img { width: 44px; height: 44px; }
.signin form { display: grid; gap: .8rem; }

/* ---- App shell: left nav on desktop, slide-in menu on phone ---- */
.shell { display: flex; min-height: 100vh; }
.nav {
  width: var(--nav-w); flex: 0 0 var(--nav-w); background: var(--surface); border-right: 1px solid var(--border);
  padding: .75rem .5rem; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
}
.nav .brand { display: flex; align-items: center; gap: .5rem; padding: .25rem .5rem .75rem; font-weight: 700; }
.nav .brand img { width: 32px; height: 32px; }
.nav a {
  display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border-radius: 10px;
  color: var(--text); text-decoration: none; min-height: 44px;
}
.nav a .ico { width: 1.4rem; text-align: center; }
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav .foot { margin-top: auto; padding: .5rem; display: grid; gap: .4rem; font-size: .9rem; }
.main { flex: 1; min-width: 0; padding: var(--gutter) calc(var(--gutter) * 1.5) 3rem; }
.topbar { display: none; }
.syncline { font-size: .85rem; color: var(--muted); display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.syncline.err { color: var(--danger); }
.scrim { display: none; }

@media (max-width: 899px) {
  .shell { display: block; }
  .topbar {
    display: flex; align-items: center; gap: .5rem; position: sticky; top: 0; z-index: 900;
    background: var(--surface); border-bottom: 1px solid var(--border); padding: .4rem var(--gutter);
  }
  .topbar .title { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav {
    position: fixed; z-index: 1000; left: 0; top: 0; bottom: 0; height: 100%;
    transform: translateX(-105%); transition: transform .2s; width: min(300px, 85vw); box-shadow: var(--shadow);
  }
  .nav.open { transform: none; }
  .scrim.open { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 950; }
  .main { padding: var(--gutter) var(--gutter) 3rem; }
}

/* ---- Page blocks ---- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.tiles { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; text-decoration: none; color: var(--text); display: block; }
a.tile:hover { border-color: var(--accent); }
.tile .num { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.tile .lbl { color: var(--muted); font-size: .92rem; }
.tile .sub { font-size: .88rem; margin-top: .2rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; margin: .5rem 0 1rem; }
.toolbar > * { flex: 1 1 170px; min-width: 0; }
.toolbar > button, .toolbar > .btn { flex: 0 0 auto; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: .6rem 1rem; text-decoration: none; color: var(--text); border-bottom: 3px solid transparent; min-height: 44px; }
.tabs a.active { border-color: var(--accent); font-weight: 600; color: var(--accent-ink); }
.kv { display: grid; grid-template-columns: minmax(110px, max-content) 1fr; gap: .35rem 1rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.form { display: grid; gap: .8rem; }
.form .row { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.field { display: grid; gap: .25rem; min-width: 0; }
.field > .lab { font-weight: 600; font-size: .95rem; display: flex; align-items: center; gap: .3rem; }
.field .help { font-size: .85rem; color: var(--muted); }
.empty { padding: 1.25rem; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); background: var(--surface); }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: .5rem 0; border-bottom: 1px solid var(--border); }
.list-plain li:last-child { border-bottom: 0; }
.back { display: inline-flex; margin-bottom: .5rem; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .85rem; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.b-grey { background: var(--grey-soft); color: var(--grey); }
.b-info { background: var(--info-soft); color: var(--info); }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-danger { background: var(--danger-soft); color: var(--danger); }
.b-warn { background: var(--warn-soft); color: var(--warn); }

/* ---- Tables: cards on phones ---- */
.tablewrap { width: 100%; overflow-x: auto; } /* a very long word scrolls inside the table, never the page */
table.data { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table.data th, table.data td { padding: .55rem .65rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: break-word; }
table.data th { background: var(--surface-2); font-size: .9rem; color: var(--muted); font-weight: 600; cursor: help; }
table.data th.sortable { cursor: pointer; }
table.data tr.click { cursor: pointer; }
table.data tr.click:hover td { background: var(--surface-2); }
table.data tr.flag td { background: var(--warn-soft); }
table.data td.num, table.data th.num { text-align: right; white-space: nowrap; }
table.data tfoot td { font-weight: 700; background: var(--surface-2); }
@media (max-width: 700px) {
  table.data, table.data tbody, table.data tfoot, table.data tr, table.data td { display: block; width: 100%; }
  table.data thead { display: none; }
  table.data { border: 0; background: transparent; }
  table.data tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .6rem; padding: .35rem .2rem; }
  table.data td { border: 0; padding: .3rem .6rem; display: grid; grid-template-columns: 40% 1fr; gap: .5rem; }
  table.data td.num { text-align: left; }
  table.data td::before { content: attr(data-label); color: var(--muted); font-size: .88rem; }
  table.data td.nolabel { grid-template-columns: 1fr; }
  table.data td.nolabel::before { content: none; }
}

/* ---- Info (i) icons and their pop-over (title does not show on touch) ---- */
.info {
  display: inline-grid; place-items: center; width: 22px; height: 22px; min-height: 0; padding: 0;
  border-radius: 50%; font-size: .78rem; font-weight: 700; font-style: italic; font-family: Georgia, serif;
  border: 1px solid var(--muted); color: var(--muted); background: transparent; vertical-align: middle; flex: 0 0 auto;
}
.info:hover { border-color: var(--accent); color: var(--accent-ink); }
.pop {
  position: absolute; z-index: 3000; max-width: min(320px, calc(100vw - 32px)); background: var(--text); color: var(--bg);
  padding: .55rem .75rem; border-radius: 10px; font-size: .92rem; box-shadow: var(--shadow); font-style: normal; font-weight: 400;
}

/* ---- Dialogs, toasts ---- */
dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 1.1rem; width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog .actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 4000; display: grid; gap: .5rem; width: min(480px, calc(100vw - 32px)); }
.toast { background: var(--text); color: var(--bg); padding: .7rem 1rem; border-radius: 10px; box-shadow: var(--shadow); }
.toast.err { background: var(--danger); color: #fff; }
.alert { padding: .7rem 1rem; border-radius: 10px; margin: .5rem 0; }
.alert.err { background: var(--danger-soft); color: var(--danger); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.code-big { font-size: 2.6rem; font-weight: 800; letter-spacing: .18em; font-family: ui-monospace, Menlo, Consolas, monospace; text-align: center; padding: .6rem; background: var(--accent-soft); border-radius: var(--radius); overflow-wrap: anywhere; user-select: all; }

/* ---- Maps and photos ---- */
.map { height: 420px; width: 100%; border-radius: var(--radius); border: 1px solid var(--border); z-index: 0; }
@media (max-width: 700px) { .map { height: 320px; } }
.pin { background: var(--accent); color: #111; border: 2px solid #fff; border-radius: 50%; width: 30px !important; height: 30px !important; display: grid; place-items: center; font-weight: 800; font-size: 14px; box-shadow: 0 1px 4px rgba(0,0,0,.5); }
.pin.done { background: #43A047; color: #fff; }
.pin.active { background: #FB8C00; }
.pin.skipped, .pin.delayed { background: #D32F2F; color: #fff; }
.pin.person { background: #1E88E5; color: #fff; border-radius: 8px; width: auto !important; padding: 0 6px; white-space: nowrap; font-size: 12px; }
.legend { display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-size: .88rem; margin-top: .4rem; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: .3rem; border: 1px solid rgba(0,0,0,.3); }
.photos { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); }
.photos figure { margin: 0; }
.photos img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: var(--surface-2); display: block; }
.photos figcaption { font-size: .85rem; color: var(--muted); }
.logo-preview { max-width: 300px; max-height: 140px; background: #fff; padding: .5rem; border: 1px solid var(--border); border-radius: 8px; }
pre.json { background: var(--surface-2); padding: .75rem; border-radius: 8px; overflow: auto; max-height: 260px; font-size: .85rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.runlist .ctl { display: flex; gap: .3rem; flex-wrap: wrap; }

/* ---- Printing: only the report ---- */
.print-only { display: none; }
@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --muted: #333; --border: #999; }
  html { font-size: 12pt; }
  .nav, .topbar, .scrim, .no-print, .toasts, .syncline { display: none !important; }
  .main { padding: 0; }
  .print-only { display: block; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .report-visit { break-inside: avoid; border-top: 1px solid #999; padding: .5rem 0; }
  .photos { grid-template-columns: repeat(4, 1fr); }
  table.data th { cursor: auto; }
}
