/* AutoWorkFlowGuided - frontend styles
   Design intent: a worksite instrument panel, not a SaaS card kit.
   The chrome stays deliberately neutral so each tenant's accent colour is the
   only strong hue on screen. Layout is a central responsive workspace with a
   horizontal section rail - never a permanent sidebar. */

:root {
  --ink: #14181d;
  --ink-soft: #4a5560;
  --ink-faint: #7b8794;
  --paper: #f5f6f4;
  --surface: #ffffff;
  --rule: #d9ddd8;
  --rule-strong: #b9c0b8;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --accent-wash: rgba(37, 99, 235, 0.09);
  --signal-wait: #b45309;
  --signal-done: #15803d;
  --signal-alert: #b91c1c;
  --tap: 44px;
  --gutter: clamp(16px, 4vw, 40px);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

body.is-field { background: #eef0ec; }

h1, h2, h3 { margin: 0 0 .4em; font-weight: 650; letter-spacing: -0.015em; line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8em; max-width: 68ch; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: .82rem; color: var(--ink-soft); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- shell ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px var(--gutter);
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-weight: 650;
}
.brand img { height: 26px; width: auto; max-width: 120px; }
.brand .mark {
  width: 26px; height: 26px; flex: 0 0 26px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid; place-items: center;
  font-size: .8rem; font-weight: 700;
}
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topbar-spacer { flex: 1 1 auto; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  font-size: .78rem;
  color: var(--ink-soft);
  background: var(--surface);
  white-space: nowrap;
}
.chip.warn { border-color: var(--signal-wait); color: var(--signal-wait); }
.chip.alert { border-color: var(--signal-alert); color: var(--signal-alert); }
.chip.ok { border-color: var(--signal-done); color: var(--signal-done); }

/* Section rail: scrolls horizontally on phones instead of collapsing into a drawer. */
.rail {
  display: flex;
  gap: 2px;
  padding: 0 var(--gutter);
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky;
  top: 47px;
  z-index: 19;
}
.rail::-webkit-scrollbar { display: none; }
.rail button {
  appearance: none;
  border: 0;
  background: none;
  padding: 12px 14px;
  min-height: var(--tap);
  font: inherit;
  font-size: .92rem;
  color: var(--ink-soft);
  border-bottom: 3px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}
.rail button[aria-current="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

main { padding: var(--gutter); max-width: 1180px; margin: 0 auto; }

/* ---------- primitives ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 16px;
}
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }

.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.metrics { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.metric {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 14px 16px;
}
.metric .value { font-size: 1.9rem; font-weight: 680; font-variant-numeric: tabular-nums; line-height: 1.1; }
.metric .label { font-size: .84rem; color: var(--ink-soft); }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.tight { gap: 6px; }
.spread { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }

button.btn, .btn {
  appearance: none;
  font: inherit;
  font-weight: 560;
  min-height: var(--tap);
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn.quiet { background: var(--surface); color: var(--ink); border-color: var(--rule-strong); }
.btn.danger { background: var(--surface); color: var(--signal-alert); border-color: var(--signal-alert); }
.btn.small { min-height: 34px; padding: 5px 11px; font-size: .87rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; }

label { display: block; font-size: .86rem; color: var(--ink-soft); margin: 10px 0 4px; }
input, select, textarea {
  font: inherit;
  width: 100%;
  min-height: var(--tap);
  padding: 9px 11px;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}
textarea { min-height: 88px; resize: vertical; }
input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-size: .8rem; color: var(--ink-soft); font-weight: 600; }
.scroll-x { overflow-x: auto; }

.empty {
  border: 1px dashed var(--rule-strong);
  border-radius: 10px;
  padding: 26px 18px;
  text-align: center;
  color: var(--ink-soft);
  background: var(--surface);
}

.notice {
  border-left: 4px solid var(--accent);
  background: var(--accent-wash);
  padding: 11px 14px;
  border-radius: 0 8px 8px 0;
  margin-bottom: 14px;
  font-size: .92rem;
}
.notice.warn { border-left-color: var(--signal-wait); background: rgba(180, 83, 9, .08); }
.notice.alert { border-left-color: var(--signal-alert); background: rgba(185, 28, 28, .08); }

.toast {
  position: fixed;
  left: 50%; bottom: 18px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 11px 16px;
  border-radius: 8px;
  z-index: 100;
  max-width: min(92vw, 520px);
  font-size: .92rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .22);
}
.toast.err { background: var(--signal-alert); }

/* ---------- the state rail: the one bold element ----------
   Renders a job's real workflow template as segments, so position in the
   pipeline is legible at a glance without reading any text. */

.staterail { display: flex; gap: 3px; margin: 8px 0 4px; }
.staterail i {
  flex: 1 1 0;
  height: 6px;
  border-radius: 2px;
  background: var(--rule);
  display: block;
}
.staterail i.past { background: var(--rule-strong); }
.staterail i.now { background: var(--accent); }
.staterail.blocked i.now { background: var(--signal-wait); }
.staterail-label { font-size: .84rem; color: var(--ink-soft); }
.staterail-label b { color: var(--ink); font-weight: 620; }

/* ---------- job list / cards ---------- */

.joblist { display: grid; gap: 10px; }

.jobcard {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--rule-strong);
  border-radius: 10px;
  padding: 13px 15px;
  cursor: pointer;
}
.jobcard.p-URGENT { border-left-color: var(--signal-alert); }
.jobcard.p-HIGH { border-left-color: var(--signal-wait); }
.jobcard.p-NORMAL { border-left-color: var(--rule-strong); }
.jobcard.p-LOW { border-left-color: var(--rule); }
.jobcard .id { font-variant-numeric: tabular-nums; font-size: .8rem; color: var(--ink-faint); }
.jobcard .title { font-weight: 600; margin: 1px 0 3px; }
.jobcard .meta { font-size: .86rem; color: var(--ink-soft); }

/* ---------- field mode ---------- */

.field-wrap { max-width: 640px; margin: 0 auto; padding: var(--gutter); }
.field-job {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
}
.field-job .headline { font-size: 1.12rem; font-weight: 640; }
.field-actions {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--rule);
  padding: 12px var(--gutter);
  display: grid;
  gap: 8px;
  margin: 0 calc(-1 * var(--gutter)) calc(-1 * var(--gutter));
}
.checkitem {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--rule);
  min-height: var(--tap);
}
.checkitem.done label { color: var(--ink-faint); text-decoration: line-through; }
.checkitem label { margin: 0; font-size: 1rem; color: var(--ink); flex: 1; }

.requirement { display: flex; gap: 8px; align-items: center; font-size: .92rem; padding: 6px 0; }
.requirement .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--signal-alert); flex: 0 0 9px; }
.requirement.met .dot { background: var(--signal-done); }

/* ---------- sign-in / gate ---------- */

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--gutter);
}
.gate-inner {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 28px;
  max-width: 420px;
  width: 100%;
}
.gate-inner h1 { font-size: 1.35rem; }

.tenant-pick { display: grid; gap: 8px; margin-top: 14px; }
.tenant-pick button {
  font: inherit;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: 9px;
  padding: 12px 14px;
  min-height: var(--tap);
  cursor: pointer;
}

.hidden { display: none !important; }

@media (max-width: 620px) {
  .topbar { padding: 8px 14px; }
  .rail { top: 43px; }
  main { padding: 14px; }
  .panel { padding: 14px; }
}
