/* ==========================================================================
   EMC Work Orders — Cityworks Contractor Portal (v2)
   ========================================================================== */
:root {
  color-scheme: light;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --bg: #eef2f7; --surface: #fff; --surface-2: #f8fafc; --surface-3: #f1f5f9;
  --hover: #eceff4;
  --border: #e5e9f0; --border-strong: #cbd5e1;
  --text: #0f172a; --text-soft: #64748b; --text-faint: #94a3b8;
  --navy: #0f172a; --navy-2: #1e293b;
  --primary: #2563eb; --primary-dark: #1d4ed8; --primary-soft: #eff6ff;
  --blue-bd: #bfdbfe; --blue-hover: #dbeafe;
  --ring: 0 0 0 3px rgba(37,99,235,.35);
  --ring-input: 0 0 0 3px rgba(37,99,235,.16);
  --shadow-sm: 0 1px 2px rgba(15,23,42,.05);
  --shadow: 0 1px 2px rgba(15,23,42,.05), 0 2px 8px rgba(15,23,42,.05);
  --shadow-md: 0 2px 4px rgba(15,23,42,.05), 0 10px 28px rgba(15,23,42,.09);
  --shadow-lg: 0 24px 48px -12px rgba(15,23,42,.24);
  --radius: 14px; --radius-sm: 10px;
  --ease-out: cubic-bezier(.22,.61,.36,1);
  --ease-spring: cubic-bezier(.34,1.56,.64,1);
  --st-open-bg:#f1f5f9; --st-open-fg:#475569; --st-open-bd:#cbd5e1;
  --st-prog-bg:#fef3c7; --st-prog-fg:#92400e; --st-prog-bd:#fcd34d;
  --st-done-bg:#dcfce7; --st-done-fg:#166534; --st-done-bd:#86efac;
  --st-closed-bg:#e2e8f0; --st-closed-fg:#334155; --st-closed-bd:#94a3b8;
  --danger-bg:#fef2f2; --danger-fg:#b91c1c; --danger-bd:#fca5a5;
  --amber-bg:#fffbeb; --amber-fg:#b45309; --amber-bd:#fcd34d;
  --ok-bg:#f0fdf4; --ok-fg:#166534; --ok-bd:#bbf7d0;
}

/* ---------- Dark mode (darker grays + darker blues) ----------
   data-theme is resolved before first paint (index.html): stored choice wins,
   else the system preference; the appbar moon/sun button toggles it. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a101c; --surface: #101a2c; --surface-2: #0c1322; --surface-3: #1a2740;
  --hover: #182642;
  --border: #1d2a45; --border-strong: #2e3f63;
  --text: #e7edf8; --text-soft: #97a7c6; --text-faint: #5d6f92;
  --primary: #3b82f6; --primary-dark: #60a5fa; --primary-soft: #12233f;
  --blue-bd: #234a7d; --blue-hover: #1a3357;
  --ring: 0 0 0 3px rgba(96,165,250,.45);
  --ring-input: 0 0 0 3px rgba(96,165,250,.22);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.45);
  --shadow: 0 1px 2px rgba(0,0,0,.45), 0 2px 8px rgba(0,0,0,.35);
  --shadow-md: 0 2px 4px rgba(0,0,0,.4), 0 10px 28px rgba(0,0,0,.5);
  --shadow-lg: 0 24px 48px -12px rgba(0,0,0,.65);
  --st-open-bg:#16233a; --st-open-fg:#a9b8d6; --st-open-bd:#2e3f63;
  --st-prog-bg:#2b2210; --st-prog-fg:#fcd34d; --st-prog-bd:#6b5518;
  --st-done-bg:#0e2417; --st-done-fg:#4ade80; --st-done-bd:#1d5c38;
  --st-closed-bg:#131c2e; --st-closed-fg:#8091b1; --st-closed-bd:#2a3853;
  --danger-bg:#2a1214; --danger-fg:#f87171; --danger-bd:#7f2a2a;
  --amber-bg:#271c07; --amber-fg:#fbbf24; --amber-bd:#6b5518;
  --ok-bg:#0e2417; --ok-fg:#4ade80; --ok-bd:#1d5c38;
}
/* Dark component pieces that don't flow from the tokens. */
:root[data-theme="dark"] .login {
  background:
    radial-gradient(1000px 480px at 18% -10%, rgba(37,99,235,.28) 0%, transparent 60%),
    radial-gradient(900px 460px at 92% 4%, rgba(99,102,241,.2) 0%, transparent 55%),
    var(--bg);
}
:root[data-theme="dark"] .login__card { background: rgba(16,26,44,.72); border-color: rgba(148,163,184,.16); }
:root[data-theme="dark"] .skeleton-row { background: linear-gradient(90deg,#101a2c 25%,#1a2740 37%,#101a2c 63%); background-size: 400% 100%; }
:root[data-theme="dark"] .toast { background: #1e2b47; border: 1px solid var(--border-strong); }
:root[data-theme="dark"] .toast--ok { background: #14532d; border-color: #1d5c38; }
:root[data-theme="dark"] .toast--error { background: #7f1d1d; border-color: #7f2a2a; }
:root[data-theme="dark"] .modal { background: rgba(2,6,17,.72); }
:root[data-theme="dark"] .appbar { border-bottom-color: rgba(46,63,99,.5); }
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
[hidden] { display: none !important; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.45; -webkit-font-smoothing: antialiased; }
svg { display: block; }
.icon { width: 1.1em; height: 1.1em; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.brandmark { width: 36px; height: 36px; flex: none; border-radius: 9px; box-shadow: var(--shadow-sm);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect width='24' height='24' rx='5' fill='%232563eb'/%3E%3Cpath d='M7 8h10M7 12h10M7 16h6' stroke='white' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") center/contain no-repeat; }
.brandmark--sm { width: 30px; height: 30px; }

/* ---------- Buttons / inputs ---------- */
/* One focus ring everywhere (keyboard only). */
:where(.btn, .linkbtn, .tab, .seg, .stat, .dropzone):focus-visible { outline: none; box-shadow: var(--ring); }
:where(.text-input, .search__input, .field__input, .field__textarea, .add-row__author, .add-row__input,
       .select select, .select input[type=date]):focus { outline: none; border-color: var(--primary); box-shadow: var(--ring-input); }
.btn { display: inline-flex; align-items: center; gap: .45rem; font: inherit; font-weight: 600; font-size: .9rem;
  border: 1px solid transparent; border-radius: var(--radius-sm); padding: .5rem .85rem; cursor: pointer;
  background: var(--surface-2); color: var(--text);
  transition: background .15s, border-color .15s, box-shadow .15s, opacity .15s, transform .12s var(--ease-out); }
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn--primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn--primary:hover { background: var(--primary-dark); box-shadow: 0 2px 8px rgba(37,99,235,.35); }
.btn--ghost { background: transparent; border-color: var(--border-strong); color: var(--text-soft); }
.btn--ghost:hover { background: var(--surface-3); color: var(--text); }
.btn--toggled { background: var(--primary-soft); border-color: var(--blue-bd); color: var(--primary-dark); }
.btn--toggled:hover { background: var(--blue-hover); }
.btn--block { width: 100%; justify-content: center; margin-top: .6rem; padding: .6rem; }
.btn--icon { padding: .45rem; }
.btn--sm { padding: .3rem .6rem; font-size: .8rem; }
.btn__icon { display: inline-flex; }
.btn__icon .icon { width: 1.05em; height: 1.05em; }
.linkbtn { background: none; border: none; color: var(--primary); font: inherit; font-weight: 600; font-size: .82rem; cursor: pointer; padding: 0; border-radius: 4px; }
.linkbtn:hover { text-decoration: underline; }
.text-input { width: 100%; padding: .6rem .7rem; font: inherit; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); transition: border-color .15s, box-shadow .15s; }
.field-label { display: block; font-size: .78rem; font-weight: 600; color: var(--text-soft); margin: .8rem 0 .3rem; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; padding: 1.5rem;
  background:
    radial-gradient(1000px 480px at 18% -10%, #d6e4ff 0%, transparent 60%),
    radial-gradient(900px 460px at 92% 4%, #e4e0ff 0%, transparent 55%),
    var(--bg); }
.login__card { width: 100%; max-width: 390px; border-radius: 18px; padding: 1.9rem;
  background: rgba(255,255,255,.75); border: 1px solid rgba(255,255,255,.7);
  -webkit-backdrop-filter: blur(16px) saturate(1.4); backdrop-filter: blur(16px) saturate(1.4);
  box-shadow: var(--shadow-lg); }
@supports not (backdrop-filter: blur(1px)) { .login__card { background: var(--surface); border-color: var(--border); } }
.login__brand { display: flex; align-items: center; gap: .7rem; margin-bottom: 1.4rem; }
.login__brandname { font-weight: 800; font-size: 1.15rem; letter-spacing: -.01em; }
.login__brandsub { color: var(--text-soft); font-size: .82rem; }
.login__error { color: var(--danger-fg); font-size: .85rem; min-height: 1.2em; margin: .6rem 0 0; }
.login__note { color: var(--text-soft); font-size: .78rem; margin: 1.1rem 0 0; text-align: center; }
.login__footer { color: var(--text-faint); font-size: .76rem; max-width: 390px; text-align: center; }

/* ---------- App bar (frosted, content scrolls beneath) ---------- */
.appbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem 1.25rem;
  background: linear-gradient(180deg, rgba(15,23,42,.9), rgba(30,41,59,.86));
  -webkit-backdrop-filter: blur(12px) saturate(1.4); backdrop-filter: blur(12px) saturate(1.4);
  border-bottom: 1px solid rgba(148,163,184,.16); color: #e2e8f0; }
@supports not (backdrop-filter: blur(1px)) { .appbar { background: linear-gradient(180deg, var(--navy), var(--navy-2)); } }
.appbar__brand { display: flex; align-items: center; gap: .6rem; }
.appbar__titles { display: flex; flex-direction: column; line-height: 1.15; }
.appbar__title { font-weight: 800; font-size: 1rem; color: #fff; letter-spacing: -.01em; }
.appbar__subtitle { font-size: .72rem; color: #94a3b8; }
.appbar__right { display: flex; align-items: center; gap: .9rem; }
.appbar__user { display: flex; align-items: center; gap: .5rem; }
.appbar__avatar { width: 28px; height: 28px; border-radius: 50%; flex: none; background: linear-gradient(135deg,#3b82f6,#6366f1); color: #fff; display: grid; place-items: center; font-size: .72rem; font-weight: 700; }
.appbar__email { font-size: .83rem; color: #cbd5e1; }
.appbar .btn--ghost { border-color: rgba(148,163,184,.35); color: #cbd5e1; }
.appbar .btn--ghost:hover { background: rgba(148,163,184,.18); color: #fff; }
.appbar__lastimport { display: inline-flex; align-items: center; gap: .35rem; font-size: .76rem; color: #94a3b8; white-space: nowrap; }
.appbar__lastimport [data-icon] { display: inline-flex; }
.appbar__lastimport .icon { width: .95em; height: .95em; }
.appbar__lastimport strong { color: #cbd5e1; font-weight: 600; font-variant-numeric: tabular-nums; }
.appbar__li-short { display: none; } /* phones swap in the short date (no year) */
.sync { display: inline-flex; align-items: center; gap: .4rem; font-size: .76rem; color: #94a3b8; }
.sync__dot { width: 8px; height: 8px; border-radius: 50%; background: #64748b; }
.sync.is-live .sync__dot { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.18); }
.sync.is-live { color: #cbd5e1; }
.sync.is-error .sync__dot { background: #ef4444; }
.sync.is-offline .sync__dot { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.18); }
.sync.is-offline { color: #fcd34d; }
.sync.is-pulse .sync__dot { animation: pulse .8s ease; }
@keyframes pulse { 0%{transform:scale(1);} 50%{transform:scale(1.6);} 100%{transform:scale(1);} }

/* ---------- Boundary (slim, neutral; the amber icon carries the warning) ---------- */
.boundary { display: flex; align-items: center; gap: .6rem; background: var(--surface); border-bottom: 1px solid var(--border); color: var(--text-soft); font-size: .8rem; padding: .45rem 1.25rem; }
.boundary strong { color: var(--text); font-weight: 600; }
.boundary__icon .icon { color: #d97706; width: 1rem; height: 1rem; }

/* ---------- Tabs (sliding active indicator, positioned by app.js) ---------- */
.tabsbar { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 1rem; max-width: 1140px; margin: 0 auto; padding: .75rem 1.25rem 0; }
.tabs { display: flex; gap: .4rem; }
.tabs__indicator { position: absolute; left: 0; bottom: 0; height: 3px; width: 0; border-radius: 999px 999px 0 0; background: var(--primary);
  transition: transform .22s var(--ease-out), width .22s var(--ease-out); will-change: transform, width; }
.tab { display: inline-flex; align-items: center; gap: .5rem; font: inherit; font-weight: 700; font-size: .95rem; color: var(--text-soft); background: transparent; border: none; border-bottom: 3px solid transparent; padding: .55rem .4rem; cursor: pointer; border-radius: 6px 6px 0 0; transition: color .15s; }
.tab:hover { color: var(--text); }
.tab--active { color: var(--primary); }
.tab__badge { font-size: .74rem; font-weight: 700; background: var(--surface-3); color: var(--text-soft); border: 1px solid var(--border); padding: .05rem .45rem; border-radius: 999px; min-width: 1.4rem; text-align: center; font-variant-numeric: tabular-nums; }
.tab--active .tab__badge { background: var(--primary-soft); color: var(--primary-dark); border-color: var(--blue-bd); }

/* ---------- Main / stats / toolbar ---------- */
.main { max-width: 1140px; margin: 0 auto; padding: 1rem 1.25rem 1.25rem; }
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: .6rem; margin-bottom: 1.1rem; }
.stat { text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem .8rem; cursor: pointer; box-shadow: var(--shadow-sm); transition: border-color .18s var(--ease-out), box-shadow .18s var(--ease-out), transform .18s var(--ease-out); position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--border-strong); }
.stat:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat--active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,.18); }
.stat__num { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat__label { font-size: .74rem; color: var(--text-soft); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat--total::before { background: var(--primary); }
.stat--open::before { background: var(--st-open-bd); }
.stat--in-progress::before { background: #f59e0b; }
.stat--completed::before { background: #22c55e; }
.stat--closed::before { background: var(--st-closed-bd); }

.toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: .6rem; margin-bottom: .5rem; }
.search { position: relative; flex: 1 1 240px; }
.search__icon { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--text-faint); pointer-events: none; }
.search__input { width: 100%; padding: .6rem .8rem .6rem 2.2rem; font: inherit; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.select { display: flex; flex-direction: column; gap: .2rem; }
.select__label { font-size: .7rem; color: var(--text-soft); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.select select, .select input[type=date] { padding: .55rem .6rem; font: inherit; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.toolbar__spacer { flex: 1 1 auto; }
.wo-meta { display: flex; align-items: center; gap: .75rem; margin: .5rem 0 .75rem; }
.wo-meta__count { color: var(--text-soft); font-size: .82rem; }

/* ---------- Work order list ---------- */
.wo-list { display: flex; flex-direction: column; gap: .5rem; }
.wo { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  /* clip (not hidden): rounds the corners WITHOUT creating a scroll context,
     so the mobile sticky Contractor Status bar can pin to the viewport. */
  overflow: hidden; overflow: clip;
  transition: border-color .18s var(--ease-out), box-shadow .18s var(--ease-out); }
.wo:not(.wo--open):hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.wo--open { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.wo--review { border-left: 3px solid #f59e0b; }
/* Grid with FIXED tracks for everything right of the description, so the
   location column, equipment column, and dates line up across all rows.
   [chevron][WO #][description+flags][location][equipment/Tile No][date][status] */
.wo__summary {
  display: grid;
  grid-template-columns: 18px 64px minmax(0, 1fr) 150px 170px 92px 104px;
  gap: .7rem;
  align-items: center;
  padding: .7rem .9rem;
  cursor: pointer; user-select: none;
}
.wo__summary:hover { background: var(--hover); }
.wo__summary:focus-visible { outline: none; box-shadow: inset var(--ring); }
.wo__chev { color: var(--text-faint); transition: transform .2s var(--ease-out); }
.wo--open .wo__chev { transform: rotate(90deg); }
.wo__id { font-weight: 700; font-variant-numeric: tabular-nums; }
.wo__main { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.wo__desc { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Location + equipment columns: left-aligned within their centered fixed tracks. */
.wo__loccol { display: inline-flex; align-items: center; gap: .25rem; min-width: 0; color: var(--text-soft); font-size: .85rem; font-weight: 600; }
.wo__loccol .icon { width: .95em; height: .95em; flex: none; color: var(--text-faint); }
.wo__loctext { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wo__equipcol { display: inline-flex; align-items: center; min-width: 0; color: var(--text-faint); font-size: .82rem; }
.wo__equiptext { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* Tile-as-location stand-in: hidden wherever the equipment column exists;
   phones (which hide that column) reveal it on the row's second line. */
.wo__equipfallback { display: none; align-items: center; gap: .25rem; min-width: 0; color: var(--text-faint); }
.wo__equipfallback .icon { width: .95em; height: .95em; flex: none; }
.wo__date { color: var(--text-soft); font-size: .86rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.wo__status { justify-self: end; }
.flag-emergency { display: inline-flex; align-items: center; gap: .2rem; color: var(--danger-fg); font-weight: 700; font-size: .74rem; }
.flag-emergency .icon { width: 1em; height: 1em; }
.flag-review { font-size: .7rem; font-weight: 700; color: var(--amber-fg); background: var(--amber-bg); border: 1px solid var(--amber-bd); padding: .1rem .4rem; border-radius: 999px; }
.flag-new { font-size: .68rem; font-weight: 800; letter-spacing: .02em; color: var(--primary-dark); background: var(--primary-soft); border: 1px solid var(--blue-bd); padding: .08rem .4rem; border-radius: 999px; text-transform: uppercase; }
.flag-refreshed { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); opacity: .55; flex: none; }
/* Amber "No location" chip in the location column (all location sources blank). */
.loc-missing { font-size: .7rem; font-weight: 700; color: var(--amber-fg); background: var(--amber-bg); border: 1px solid var(--amber-bd); padding: .1rem .45rem; border-radius: 999px; white-space: nowrap; }
.notes-badge { display: inline-flex; align-items: center; gap: .25rem; color: var(--text-faint); font-size: .8rem; font-weight: 600; }
.notes-badge .icon { width: .95em; height: .95em; }
.notes-badge--unsynced { color: var(--amber-fg); } /* has notes not yet copied into Cityworks */

/* Status pills: neutral chip + colored status dot. */
.pill { display: inline-flex; align-items: center; gap: .4rem; font-size: .73rem; font-weight: 600; padding: .24rem .62rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-soft); white-space: nowrap; box-shadow: var(--shadow-sm); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--border-strong); }
.pill--open::before { background: #64748b; }
.pill--in-progress::before { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.16); }
.pill--completed::before { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.16); }
.pill--closed::before { background: #cbd5e1; }
.pill--closed { color: var(--text-faint); }

/* ---------- Detail card ---------- */
.wo__detail { border-top: 1px solid var(--border); padding: 1rem; background: var(--surface-2); }
/* Applied only on a real user expand (app.js), so live re-renders don't replay it. */
.wo__detail--anim { animation: detail-in .2s var(--ease-out); }
@keyframes detail-in { from { opacity: 0; transform: translateY(-6px); } }
.wo__detailtop { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .8rem; flex-wrap: wrap; }
.wo__updated { font-size: .78rem; color: var(--text-faint); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .8rem .9rem; margin-bottom: .9rem; }
.panel__title { display: flex; align-items: center; gap: .4rem; margin: 0 0 .6rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-soft); font-weight: 700; }
.panel__actions { margin-left: auto; display: inline-flex; gap: .35rem; }
.panel__actions .btn { text-transform: none; letter-spacing: 0; }
.panel__editbtn { padding: .2rem .45rem; }
.panel__editbtn .icon { width: .95em; height: .95em; }
.panel__hint { color: var(--amber-fg); font-size: .76rem; margin: .5rem 0 0; }
/* requireAny panel with every field blank: amber outline + fill-it hint. */
.panel--attn { border-color: var(--amber-bd); box-shadow: 0 0 0 2px rgba(245,158,11,.12); }
.panel__attn { color: var(--amber-fg); font-size: .78rem; font-weight: 600; margin: .5rem 0 0; }
.field--editing { background: var(--primary-soft); border-color: var(--blue-bd); }
.field__textarea { width: 100%; font: inherit; font-size: .95rem; padding: .5rem .6rem; border: 1px solid var(--border-strong); border-radius: 6px; resize: vertical; transition: border-color .15s, box-shadow .15s; }
.panel__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .6rem; }
.field { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .5rem .65rem; }
.field--edit { background: var(--primary-soft); border-color: var(--blue-bd); }
.field__label { font-size: .68rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-soft); font-weight: 700; margin-bottom: .15rem; display: flex; align-items: center; gap: .3rem; }
.field__req { color: var(--danger-fg); }
.field__value { font-size: .92rem; word-break: break-word; font-variant-numeric: tabular-nums; }
.field__input { width: 100%; max-width: 100%; min-width: 0; font: inherit; font-size: .9rem; padding: .35rem .45rem; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); transition: border-color .15s, box-shadow .15s; }
/* iOS Safari gives date/time inputs an intrinsic width that IGNORES width:100%
   and overflows narrow field cards — strip the UA sizing and clamp. min-height
   keeps the tap target when the (empty) control renders no text on iOS. */
input[type="datetime-local"], input[type="date"] {
  -webkit-appearance: none; appearance: none;
  min-width: 0; max-width: 100%; min-height: 2.15rem;
}
/* "Clear" / "Now" quick-sets under datetime inputs, right-aligned. */
.field__nowrow { display: flex; justify-content: flex-end; gap: .3rem; margin-top: .3rem; }
.field__now { padding: .12rem .5rem; font-size: .72rem; gap: .28rem; background: var(--surface); }
.field__now .icon { width: .95em; height: .95em; }
.field__now:hover { color: var(--primary-dark); border-color: var(--blue-bd); background: var(--primary-soft); }
.field__now--clear:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-3); }

.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .8rem .9rem; margin-bottom: .9rem; border-left: 4px solid var(--primary); }
.tile--cw { border-left-color: #94a3b8; }
.tile--cw .tile__body { max-height: 220px; overflow: auto; }
.tile__title { display: flex; align-items: center; gap: .4rem; margin: 0 0 .45rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-soft); }
.tile__body { white-space: pre-wrap; word-break: break-word; font-size: .95rem; }

.control { margin-bottom: 1.1rem; }
.control__title { display: flex; align-items: center; gap: .4rem; margin: 0 0 .5rem; font-size: .95rem; }
.control__sub { font-weight: 400; color: var(--text-soft); font-size: .8rem; }
.control__hint { color: var(--text-soft); font-size: .8rem; margin: .5rem 0 0; }
.completion-error { color: var(--danger-fg); font-size: .82rem; margin: .5rem 0 0; min-height: 0; }
.completion-error:empty { display: none; }

.seg-group { display: inline-flex; flex-wrap: wrap; gap: .4rem; }
.seg { font: inherit; font-weight: 600; font-size: .85rem; padding: .4rem .85rem; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-soft); cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .12s var(--ease-out); }
.seg:hover { border-color: var(--text-soft); }
.seg:active { transform: scale(.97); }
.seg--active { box-shadow: inset 0 0 0 1px currentColor; }
.seg--active.seg--open { background: var(--st-open-bg); color: var(--st-open-fg); border-color: var(--st-open-bd); }
.seg--active.seg--in-progress { background: var(--st-prog-bg); color: var(--st-prog-fg); border-color: var(--st-prog-bd); }
.seg--active.seg--completed { background: var(--st-done-bg); color: var(--st-done-fg); border-color: var(--st-done-bd); }
.seg--active.seg--closed { background: var(--st-closed-bg); color: var(--st-closed-fg); border-color: var(--st-closed-bd); }

/* ---------- Contractor Notes (copied into Cityworks manually) ---------- */
.log { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .8rem .9rem; }
.log__head { display: flex; align-items: center; gap: .5rem; margin: 0 0 .5rem; flex-wrap: wrap; }
.log__title { font-size: .95rem; font-weight: 700; margin: 0; }
.log__spacer { flex: 1 1 auto; }
.log__tag { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: .1rem .4rem; border-radius: 999px; }
.log__tag--portal { color: #475569; background: var(--surface-3); }
.add-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .6rem; }
.add-row__author { width: 90px; font: inherit; padding: .45rem .55rem; border: 1px solid var(--border-strong); border-radius: 6px; }
.add-row__input { flex: 1 1 160px; font: inherit; padding: .45rem .55rem; border: 1px solid var(--border-strong); border-radius: 6px; resize: vertical; min-height: 2.2rem; }
.log-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.entry { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: .5rem .6rem; }
.entry__head { display: flex; align-items: center; gap: .5rem; margin-bottom: .2rem; flex-wrap: wrap; }
.entry__author { font-size: .74rem; font-weight: 700; color: var(--text); background: var(--surface-3); padding: .05rem .4rem; border-radius: 999px; }
.entry__time { font-size: .72rem; color: var(--text-faint); }
.entry__text { white-space: pre-wrap; word-break: break-word; font-size: .9rem; }
.entry--empty { color: var(--text-soft); font-style: italic; border-style: dashed; }
.entry__copied { display: inline-flex; align-items: center; gap: .2rem; font-size: .68rem; font-weight: 700; color: var(--ok-fg); background: var(--ok-bg); border: 1px solid var(--ok-bd); padding: .05rem .4rem; border-radius: 999px; }
.entry__copied .icon { width: .9em; height: .9em; }
.entry__uncopied { font-size: .68rem; font-weight: 700; color: var(--amber-fg); background: var(--amber-bg); border: 1px solid var(--amber-bd); padding: .05rem .4rem; border-radius: 999px; }
.entry__copy { margin-left: auto; padding: .15rem .5rem; font-size: .74rem; }
.entry__delete { padding: .15rem .4rem; font-size: .74rem; }
.entry__delete:hover { background: var(--danger-bg); border-color: var(--danger-bd); color: var(--danger-fg); }
.field__hint { font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--text-faint); }
.field__manual { font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--amber-fg); background: var(--amber-bg); border: 1px solid var(--amber-bd); padding: .05rem .3rem; border-radius: 999px; }

/* ---------- Empty / skeleton / notices / footer ---------- */
.empty { text-align: center; padding: 3rem 1rem; color: var(--text-soft); background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.empty h2 { margin: 0 0 .5rem; color: var(--text); }
.empty .btn { margin-top: 1rem; display: inline-flex; }
.notice { padding: .75rem 1rem; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); }
.notice--ok { background: var(--ok-bg); border-color: var(--ok-bd); color: var(--ok-fg); }
.notice--error { background: var(--danger-bg); border-color: var(--danger-bd); color: var(--danger-fg); }
.notice--warn { background: var(--amber-bg); border-color: var(--amber-bd); color: var(--amber-fg); margin-top: .6rem; }
.skeleton { display: flex; flex-direction: column; gap: .5rem; }
.skeleton-row { height: 48px; border-radius: var(--radius); background: linear-gradient(90deg,#eef2f7 25%,#e2e8f0 37%,#eef2f7 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { 0%{background-position:100% 0;} 100%{background-position:-100% 0;} }
.footer { max-width: 1140px; margin: 1.5rem auto; padding: 0 1.25rem 2rem; color: var(--text-faint); font-size: .78rem; text-align: center; }

/* ---------- Modal / toasts ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(15,23,42,.5); display: grid; place-items: center; padding: 1rem; backdrop-filter: blur(2px); }
.modal__card { width: 100%; max-width: 520px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 1.25rem 1.4rem 1.5rem; }
.modal__card--wide { max-width: 720px; }
.modal__head { display: flex; align-items: center; justify-content: space-between; }
.modal__head h2 { margin: 0; font-size: 1.1rem; }
.modal__desc { color: var(--text-soft); font-size: .85rem; margin: .5rem 0 1rem; }
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 2rem 1rem; text-align: center; cursor: pointer; color: var(--text-soft); transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone:focus-visible { border-color: var(--primary); background: var(--primary-soft); outline: none; }
.dropzone--over { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); }
.dropzone__icon { display: inline-flex; margin-bottom: .4rem; }
.dropzone__icon .icon { width: 1.6rem; height: 1.6rem; }
.progress { margin-top: 1rem; height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress__bar { height: 100%; width: 0; background: var(--primary); transition: width .15s; }
#import-summary { margin-top: 1rem; }
#import-summary:empty { margin-top: 0; }
.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 60; display: flex; flex-direction: column; gap: .5rem; max-width: min(360px, 90vw); }
.toast { display: flex; align-items: center; gap: .5rem; background: var(--navy); color: #fff; padding: .65rem .85rem; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: .88rem;
  opacity: 0; transform: translateY(10px) scale(.96); transition: opacity .18s ease, transform .3s var(--ease-spring); }
.toast--in { opacity: 1; transform: none; }
.toast--ok { background: #166534; }
.toast--error { background: #b91c1c; }
.toast .icon { width: 1.1em; height: 1.1em; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  /* Drop the date + equipment columns; keep location. */
  .wo__summary { grid-template-columns: 18px 60px minmax(0, 1fr) 150px 104px; }
  .wo__date, .wo__equipcol { display: none; }
}
@media (max-width: 620px) {
  .appbar__email { display: none; }
  /* Keep "Last import" on the sticky bar: shed the label, sync text, avatar
     and subtitle, and swap in the short (no-year) timestamp. */
  .appbar__lastimport-label, .appbar__li-full, #sync-label, .appbar__avatar, .appbar__subtitle { display: none; }
  .appbar__li-short { display: inline; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  /* Phones: two-line row header — [chevron][WO #][description][status] on top,
     location (or tile stand-in, or the No-location chip) on a second line. */
  .wo__summary { grid-template-columns: 16px 56px minmax(0, 1fr) 96px; row-gap: .2rem; }
  .wo__chev, .wo__id, .wo__main { grid-row: 1; }
  .wo__status { grid-row: 1; grid-column: 4; }
  .wo__loccol { grid-row: 2; grid-column: 3 / -1; font-size: .8rem; }
  .wo__loccol:empty { display: none; } /* no second line when there's nothing to show */
  .wo__equipfallback { display: inline-flex; }
  .toolbar__spacer { display: none; }
  .btn__text { display: none; }
  /* Phones: shrink the nested gutters so cards get the width, and stack
     detail fields one per row (two squeezed columns overflow date inputs). */
  .appbar { padding: .55rem .75rem; }
  .boundary { padding: .45rem .75rem; }
  .tabsbar { padding: .6rem .75rem 0; }
  .main { padding: .75rem .75rem 1rem; }
  .footer { padding: 0 .75rem 1.5rem; }
  .wo__detail { padding: .7rem .55rem; }
  .panel, .tile, .log { padding: .7rem .65rem; }
  .panel__grid { grid-template-columns: 1fr; }
  /* Contractor Status floats at the bottom of the screen while reading a long
     detail, so recording never needs a scroll back down. */
  .wo__detail .control { position: sticky; bottom: 0; z-index: 5; margin: 0 -0.55rem 1.1rem;
    padding: .6rem .55rem .65rem; background: var(--surface-2);
    border-top: 1px solid var(--border); box-shadow: 0 -6px 16px -8px rgba(15,23,42,.18); }
  /* 16px inputs stop iOS Safari's auto-zoom-on-focus. */
  .field__input, .field__textarea, .add-row__author, .add-row__input { font-size: 16px; }
}
