:root {
  color-scheme: light;
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f0f2f7;
  --text: #171b2e;
  --muted: #667085;
  --border: #d7dbe7;
  --navy: #17236b;
  --navy-2: #24358f;
  --red: #a00000;
  --red-soft: #fff0f0;
  --green: #16794a;
  --green-soft: #eaf8f1;
  --amber: #9a6200;
  --amber-soft: #fff6dd;
  --blue-soft: #edf1ff;
  --shadow: 0 18px 50px rgba(23, 35, 107, 0.08);
  --radius: 18px;
  --radius-sm: 11px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 100% 0, rgba(36, 53, 143, 0.07), transparent 30rem),
    var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
canvas:focus-visible {
  outline: 3px solid rgba(36, 53, 143, 0.28);
  outline-offset: 2px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.45rem;
  font-size: clamp(1.65rem, 4vw, 2.35rem);
  line-height: 1.12;
}

h2 {
  margin-bottom: 0.4rem;
  font-size: clamp(1.2rem, 3vw, 1.55rem);
  line-height: 1.2;
}

h3 {
  margin-bottom: 0.45rem;
  font-size: 1rem;
}

p {
  margin-bottom: 0.8rem;
}

small {
  font-size: 0.79rem;
}

a {
  color: var(--navy-2);
}

.muted {
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 0.35rem;
  color: var(--red);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: calc(1.25rem + var(--safe-bottom));
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 76px;
  padding: 0.7rem clamp(1rem, 3vw, 2rem);
  border-bottom: 1px solid rgba(215, 219, 231, 0.9);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.brand-mark {
  position: relative;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
}

.brand-mark::before,
.brand-mark::after {
  position: absolute;
  inset: 0;
  content: "";
  background: var(--navy);
  clip-path: polygon(11% 100%, 43% 0, 57% 0, 32% 100%);
}

.brand-mark::after {
  transform: scaleX(-1);
}

.brand-mark span {
  position: absolute;
  z-index: 1;
  right: 8px;
  bottom: 2px;
  width: 7px;
  height: 16px;
  transform: skewX(-20deg);
  background: var(--red);
}

.brand-copy strong,
.brand-copy span {
  display: block;
}

.brand-copy strong {
  color: var(--navy);
  font-size: 0.92rem;
  letter-spacing: 0.08em;
}

.brand-copy span {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions,
.inline-actions,
.dialog-actions,
.button-row,
.role-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.topbar-actions {
  justify-content: flex-end;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.64rem 0.9rem;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 750;
  line-height: 1.1;
  text-decoration: none;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:active:not(:disabled) {
  transform: translateY(0);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.button-primary {
  background: var(--navy);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(23, 35, 107, 0.18);
}

.button-primary:hover:not(:disabled) {
  background: var(--navy-2);
}

.button-secondary {
  border-color: var(--border);
  background: var(--surface);
  color: var(--navy);
}

.button-ghost {
  background: transparent;
  color: var(--navy);
}

.button-danger {
  background: var(--red);
  color: #ffffff;
}

.button-small {
  min-height: 34px;
  padding: 0.45rem 0.68rem;
  font-size: 0.82rem;
}

.button-block {
  width: 100%;
}

.icon-button {
  width: 42px;
  padding-inline: 0;
}

.status-pill,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  width: fit-content;
  border-radius: 999px;
  font-weight: 750;
  white-space: nowrap;
}

.status-pill {
  min-height: 34px;
  padding: 0.38rem 0.7rem;
  background: var(--green-soft);
  color: var(--green);
  font-size: 0.78rem;
}

.status-pill::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.status-pill.offline {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-pill.pending {
  background: var(--blue-soft);
  color: var(--navy-2);
}

.badge {
  padding: 0.35rem 0.62rem;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.72rem;
}

.badge-planned {
  background: var(--blue-soft);
  color: var(--navy-2);
}

.badge-active {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge-completed {
  background: var(--green-soft);
  color: var(--green);
}

.badge-warning {
  background: var(--red-soft);
  color: var(--red);
}

.main {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem) 0;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1rem;
}

.login-card {
  width: min(460px, 100%);
  padding: clamp(1.25rem, 5vw, 2.25rem);
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-brand {
  margin-bottom: 1.8rem;
}

.login-actions {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
}

.dashboard-head,
.section-head,
.card-head,
.job-card-head,
.detail-head,
.total-row,
.timeline-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.dashboard-head,
.section-head {
  margin-bottom: 1rem;
}

.dashboard-head p,
.section-head p,
.card-head p {
  margin-bottom: 0;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.metric,
.card,
.job-card,
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(23, 35, 107, 0.04);
}

.metric {
  padding: 1rem;
}

.metric span,
.metric strong {
  display: block;
}

.metric span {
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.metric strong {
  color: var(--navy);
  font-size: clamp(1.25rem, 4vw, 1.8rem);
}

.job-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.job-card {
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
}

.job-card:hover {
  border-color: rgba(36, 53, 143, 0.42);
}

.job-card h3 {
  margin-bottom: 0.2rem;
}

.job-meta,
.meta-list {
  display: grid;
  gap: 0.45rem;
}

.meta-item {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 0.55rem;
  align-items: start;
  color: var(--muted);
  font-size: 0.86rem;
}

.meta-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--navy);
  font-size: 0.8rem;
}

.workspace {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.step-nav {
  position: sticky;
  top: 92px;
  display: grid;
  gap: 0.4rem;
}

.step-button {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 0.55rem;
  align-items: center;
  width: 100%;
  min-height: 46px;
  padding: 0.55rem 0.65rem;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 750;
  text-align: left;
}

.step-button span:first-child {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  font-size: 0.78rem;
}

.step-button.is-active {
  background: var(--navy);
  color: #ffffff;
}

.step-button.is-active span:first-child {
  background: rgba(255, 255, 255, 0.18);
}

.step-button.is-done:not(.is-active) {
  color: var(--green);
}

.step-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.panel {
  min-width: 0;
  padding: clamp(1rem, 3vw, 1.5rem);
}

.panel-grid,
.two-column,
.office-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.card {
  min-width: 0;
  padding: 1rem;
}

.card + .card {
  margin-top: 0;
}

.stack {
  display: grid;
  gap: 0.8rem;
}

.stack-tight {
  display: grid;
  gap: 0.45rem;
}

.kv-list {
  display: grid;
  gap: 0;
}

.kv {
  display: grid;
  grid-template-columns: minmax(110px, 0.6fr) minmax(0, 1fr);
  gap: 0.8rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.kv:last-child {
  border-bottom: 0;
}

.kv dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.kv dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

label,
legend {
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-height: 43px;
  margin-top: 0.3rem;
  padding: 0.62rem 0.72rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}

textarea {
  min-height: 88px;
  resize: vertical;
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--surface-2);
  color: var(--muted);
}

input[type="checkbox"],
input[type="radio"] {
  width: 19px;
  min-height: 19px;
  margin: 0;
  accent-color: var(--navy);
}

input[type="file"] {
  min-height: auto;
  padding: 0.45rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.span-2 {
  grid-column: 1 / -1;
}

.check-row,
.radio-row {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.35rem 0;
}

.check-row label,
.radio-row label {
  font-weight: 600;
}

.form-help {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.form-error {
  margin: 0.35rem 0 0;
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 700;
}

.live-strip {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 0.7rem;
  margin-bottom: 0.85rem;
}

.live-value {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--navy);
  font-size: 1rem;
  font-weight: 800;
}

.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(22, 121, 74, 0.1);
}

.timeline {
  position: relative;
  display: grid;
  gap: 0;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: start;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}

.timeline-item:last-child {
  border-bottom: 0;
}

.timeline-icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--navy);
  font-size: 0.72rem;
  font-weight: 800;
}

.timeline-content strong,
.timeline-content span {
  display: block;
}

.timeline-content span {
  margin-top: 0.18rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.gps-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.35rem;
  padding: 0.25rem 0.45rem;
  border-radius: 8px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 0.7rem;
  font-weight: 750;
}

.gps-chip.warning {
  background: var(--red-soft);
  color: var(--red);
}

.action-card {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: linear-gradient(145deg, var(--surface), var(--surface-2));
}

.action-card .button-primary {
  min-height: 54px;
  font-size: 1rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 0.62rem 0.45rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

.data-table td {
  font-size: 0.84rem;
}

.data-table input,
.data-table select {
  min-width: 80px;
  margin-top: 0;
}

.table-wrap {
  overflow-x: auto;
}

.item-list {
  display: grid;
  gap: 0.55rem;
}

.item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.7rem;
  align-items: center;
  padding: 0.65rem;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
}

.item-row strong,
.item-row span {
  display: block;
}

.item-row span {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.total-row {
  align-items: center;
  padding-top: 0.75rem;
  margin-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.total-row strong:last-child {
  color: var(--navy);
  font-size: 1.05rem;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
}

.photo-card {
  position: relative;
  overflow: hidden;
  min-height: 110px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-2);
}

.photo-card img {
  display: block;
  width: 100%;
  height: 130px;
  object-fit: cover;
}

.photo-card button {
  position: absolute;
  top: 6px;
  right: 6px;
}

.signature-canvas {
  display: block;
  width: 100%;
  height: 170px;
  border: 1px dashed var(--navy-2);
  border-radius: 11px;
  background: #ffffff;
  touch-action: none;
}

.signature-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  margin-top: 0.5rem;
}

.validation-list {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding-left: 1.2rem;
  color: var(--red);
  font-size: 0.82rem;
}

.success-panel {
  display: grid;
  justify-items: center;
  padding: clamp(1.4rem, 5vw, 2.6rem) 1rem;
  text-align: center;
}

.success-icon {
  display: grid;
  width: 62px;
  height: 62px;
  margin-bottom: 1rem;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: #ffffff;
  font-size: 1.8rem;
  font-weight: 900;
}

.office-layout {
  grid-template-columns: minmax(300px, 0.85fr) minmax(0, 1.3fr);
}

.office-list {
  display: grid;
  gap: 0.55rem;
}

.office-order {
  display: grid;
  gap: 0.35rem;
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.office-order:hover,
.office-order.is-selected {
  border-color: var(--navy-2);
  background: var(--blue-soft);
}

.office-order-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.office-order span:not(.badge) {
  color: var(--muted);
  font-size: 0.77rem;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.audit-list {
  display: grid;
  gap: 0.5rem;
}

.audit-entry {
  padding-left: 0.7rem;
  border-left: 3px solid var(--border);
  color: var(--muted);
  font-size: 0.78rem;
}

.empty-state {
  display: grid;
  min-height: 180px;
  place-items: center;
  padding: 1rem;
  color: var(--muted);
  text-align: center;
}

.warning-box,
.info-box {
  padding: 0.8rem;
  border-radius: 11px;
  font-size: 0.82rem;
}

.warning-box {
  background: var(--amber-soft);
  color: #694300;
}

.info-box {
  background: var(--blue-soft);
  color: var(--navy);
}

.toast {
  position: fixed;
  z-index: 100;
  right: 1rem;
  bottom: calc(1rem + var(--safe-bottom));
  max-width: min(390px, calc(100% - 2rem));
  padding: 0.78rem 0.95rem;
  border-radius: 11px;
  background: var(--text);
  color: #ffffff;
  box-shadow: var(--shadow);
  font-size: 0.84rem;
  font-weight: 700;
}

dialog {
  width: min(680px, calc(100% - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(14, 18, 44, 0.58);
  backdrop-filter: blur(4px);
}

.dialog-stack {
  display: grid;
  gap: 1rem;
  padding: clamp(1rem, 4vw, 1.5rem);
}

.dialog-actions {
  justify-content: flex-end;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .job-grid,
  .panel-grid,
  .two-column,
  .office-layout {
    grid-template-columns: 1fr;
  }

  .office-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
  }

  .topbar-actions .button-label,
  .brand-copy span {
    display: none;
  }

  .main {
    width: min(100% - 1rem, 1180px);
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .step-nav {
    position: static;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.25rem;
    overflow: hidden;
  }

  .step-button {
    display: flex;
    min-width: 0;
    justify-content: center;
    padding: 0.45rem 0.25rem;
    text-align: center;
  }

  .step-button span:last-child {
    display: none;
  }

  .live-strip {
    grid-template-columns: 1fr;
  }

  .photo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .topbar {
    min-height: 66px;
    padding-inline: 0.75rem;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .brand-copy strong {
    font-size: 0.78rem;
  }

  .topbar-actions {
    gap: 0.35rem;
  }

  .topbar-actions .status-pill {
    display: none;
  }

  .button {
    min-height: 40px;
  }

  .dashboard-head,
  .section-head,
  .card-head,
  .detail-head {
    align-items: stretch;
    flex-direction: column;
  }

  .summary-grid,
  .job-grid,
  .form-grid,
  .office-list,
  .filter-bar {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .panel,
  .card,
  .metric,
  .job-card {
    border-radius: 14px;
  }

  .panel {
    padding: 0.8rem;
  }

  .kv {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }

  .data-table th,
  .data-table td {
    padding-inline: 0.35rem;
  }

  .timeline-item {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .timeline-item > time {
    grid-column: 2;
  }

  .signature-canvas {
    height: 145px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
