:root {
  color-scheme: light;
  --bg: #eef1ed;
  --panel: #ffffff;
  --panel-soft: #f8f7f1;
  --ink: #18201d;
  --muted: #657168;
  --line: #dfe4dc;
  --line-strong: #c4cec3;
  --green: #315c43;
  --green-dark: #203d2d;
  --amber: #d99a25;
  --red: #b54838;
  --blue: #2d5870;
  --shadow: 0 18px 48px rgb(24 32 29 / 12%);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

a {
  color: inherit;
  text-decoration: none;
}

.is-hidden {
  display: none !important;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgb(24 32 29 / 86%), rgb(49 92 67 / 80%)),
    url("/assets/worksite.svg") center / cover;
}

.login-panel {
  width: min(100%, 480px);
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 8px;
  background: rgb(255 255 255 / 94%);
  box-shadow: 0 24px 70px rgb(0 0 0 / 24%);
  padding: clamp(22px, 5vw, 34px);
}

.login-brand,
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-brand img,
.brand img {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
}

.login-copy {
  margin: 18px 0 24px;
  color: var(--muted);
  line-height: 1.55;
}

.login-form,
.stack-form {
  display: grid;
  gap: 14px;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-weight: 800;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  height: 100vh;
  flex-direction: column;
  gap: 28px;
  border-right: 1px solid var(--line);
  background: #18201d;
  color: #f7f4ea;
  padding: 22px;
}

.brand span {
  display: grid;
  gap: 2px;
}

.brand strong {
  font-size: 1.02rem;
  letter-spacing: 0;
}

.brand small {
  color: #c9d4ca;
  font-size: 0.82rem;
  font-weight: 750;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #dbe4dc;
  font-weight: 820;
  letter-spacing: 0;
  padding: 10px 12px;
  text-align: left;
}

.nav-item:hover,
.nav-item:focus-visible,
.nav-item.is-active {
  border-color: rgb(255 255 255 / 14%);
  background: rgb(255 255 255 / 10%);
  color: #ffffff;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  border: 1px solid rgb(255 255 255 / 14%);
  border-radius: 8px;
  color: #c9d4ca;
  font-size: 0.86rem;
  line-height: 1.35;
  padding: 12px;
}

.status-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #67c587;
  box-shadow: 0 0 0 5px rgb(103 197 135 / 16%);
}

.workspace {
  min-width: 0;
  padding: 24px clamp(18px, 3vw, 34px) 42px;
}

.topbar,
.section-title,
.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.topbar {
  align-items: center;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 0.95;
}

h2 {
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  line-height: 1.05;
}

h3 {
  font-size: 1rem;
}

.top-actions,
.form-actions,
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 850;
  line-height: 1.1;
}

.button-dark {
  background: var(--green-dark);
  color: #ffffff;
}

.button-light {
  border-color: var(--line);
  background: #ffffff;
  color: var(--ink);
}

.user-chip,
.badge,
.pill {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 900;
}

.user-chip,
.badge {
  border: 1px solid var(--line);
  background: #eaf0e8;
  color: var(--green-dark);
}

.notice {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  border: 1px solid #e2c981;
  border-radius: 8px;
  background: #fff8df;
  color: #513f14;
  padding: 12px 14px;
}

.notice strong {
  flex: 0 0 auto;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

.metric span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin: 14px 0 6px;
  font-size: 2.2rem;
  line-height: 1;
}

.metric p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.content-grid,
.forms-layout,
.tracking-layout,
.safety-layout,
.builder-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.95fr);
  gap: 18px;
}

.content-grid.lower,
.tracker-table-wrap,
.submissions-panel,
.build-notes {
  margin-top: 18px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel-heading {
  align-items: center;
  margin-bottom: 16px;
}

.section-title {
  align-items: flex-end;
  margin-bottom: 18px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 12px;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 850;
}

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

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

.compact-form {
  margin-bottom: 16px;
}

fieldset {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

legend {
  color: var(--green-dark);
  font-weight: 900;
  padding: 0 8px;
}

.checklist,
.template-list,
.action-list,
.incident-list,
.tracker-list,
.tracker-summary,
.build-notes {
  display: grid;
  gap: 10px;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 750;
  line-height: 1.35;
}

.check-item input {
  width: 18px;
  min-height: 18px;
  margin-top: 1px;
}

.template-card,
.action-item,
.incident-item,
.tracker-card,
.summary-card,
.note-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 13px;
}

button.template-card,
button.tracker-card {
  width: 100%;
  text-align: left;
}

.template-card.is-active,
.tracker-card.is-active {
  border-color: var(--green);
  background: #eef6ef;
}

.template-card strong,
.action-item strong,
.incident-item strong,
.tracker-card strong,
.summary-card strong,
.note-item strong {
  display: block;
  margin-bottom: 4px;
}

.template-card span,
.template-card small,
.action-item span,
.incident-item span,
.tracker-card span,
.summary-card span,
.note-item span {
  color: var(--muted);
  line-height: 1.4;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 950;
  text-transform: uppercase;
}

td {
  font-size: 0.94rem;
}

.compact table {
  min-width: 560px;
}

.pill.low,
.pill.current,
.pill.complete,
.pill.closed,
.pill.ready {
  background: #e7f3eb;
  color: #22633f;
}

.pill.medium,
.pill.draft,
.pill.needs-review,
.pill.in-progress,
.pill.monitoring {
  background: #fff2cb;
  color: #795412;
}

.pill.high,
.pill.expiring,
.pill.open,
.pill.needs-repair,
.pill.out-of-service {
  background: #f8ded9;
  color: #943424;
}

.risk-chart {
  display: grid;
  gap: 14px;
}

.risk-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 10px;
}

.risk-track {
  height: 12px;
  border-radius: 999px;
  background: #e7ebe4;
  overflow: hidden;
}

.risk-fill {
  height: 100%;
  border-radius: 999px;
}

.risk-fill.low {
  background: var(--green);
}

.risk-fill.medium {
  background: var(--amber);
}

.risk-fill.high {
  background: var(--red);
}

.action-item {
  display: grid;
  gap: 10px;
}

.action-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.action-meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  padding: 4px 8px;
  font-size: 0.78rem;
  font-weight: 800;
}

.dense .action-item {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.json-preview {
  min-height: 300px;
  max-height: 520px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111a17;
  color: #eaf4ed;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.84rem;
  line-height: 1.55;
  margin: 0;
  padding: 14px;
  white-space: pre-wrap;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  border-radius: 8px;
  background: #18201d;
  color: #ffffff;
  box-shadow: var(--shadow);
  opacity: 0;
  padding: 12px 14px;
  transform: translateY(12px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1120px) {
  .metrics,
  .content-grid,
  .forms-layout,
  .tracking-layout,
  .safety-layout,
  .builder-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .nav-item {
    text-align: center;
  }

  .sidebar-footer {
    display: none;
  }

  .topbar,
  .section-title,
  .panel-heading,
  .notice {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics,
  .content-grid,
  .forms-layout,
  .tracking-layout,
  .safety-layout,
  .builder-layout,
  .form-grid,
  .form-grid.two {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .workspace {
    padding-inline: 14px;
  }

  .sidebar {
    padding: 16px;
  }

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

  .top-actions,
  .filter-bar,
  .button {
    width: 100%;
  }

  .dense .action-item {
    grid-template-columns: 1fr;
  }
}
