:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #f1f4f7;
  --surface-strong: #e8edf2;
  --line: #d9e0e8;
  --line-strong: #b8c3cf;
  --text: #15202b;
  --muted: #5f6d7b;
  --primary: #0f766e;
  --primary-dark: #0b5e58;
  --primary-soft: #e0f3f0;
  --success: #247a4b;
  --warning: #9a6315;
  --danger: #a13a3a;
  --info: #256b9b;
  --shadow: 0 10px 28px rgba(18, 31, 45, 0.08);
  --radius: 8px;
  --content-max: 2100px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.48 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

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

button {
  border: 0;
}

.app-shell,
.layout {
  min-height: 100vh;
}

.layout {
  display: grid;
  grid-template-columns: clamp(220px, 13vw, 296px) minmax(0, 1fr);
  grid-template-rows: 70px 1fr;
}

.shell-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 22px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 12;
}

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

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.brand-name {
  font-size: 18px;
  font-weight: 780;
  letter-spacing: 0;
}

.brand-user {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.sidebar {
  grid-row: 2;
  background: #ffffff;
  border-right: 1px solid var(--line);
  padding: 16px 12px;
}

.nav {
  display: grid;
  gap: 6px;
  position: sticky;
  top: 86px;
}

.nav button {
  width: 100%;
  min-height: 42px;
  border-radius: 8px;
  padding: 9px 12px;
  text-align: left;
  color: #324251;
  background: transparent;
  cursor: pointer;
  font-weight: 650;
}

.nav button:hover {
  background: var(--surface-soft);
}

.nav button.active {
  background: var(--primary-soft);
  color: var(--primary-dark);
  box-shadow: inset 3px 0 0 var(--primary);
}

.main {
  grid-column: 2;
  width: 100%;
  max-width: var(--content-max);
  min-width: 0;
  margin: 0 auto;
  padding: 24px;
}

.loading,
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-wrap {
  background: #eef3f6;
}

.login-panel {
  width: min(430px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px;
}

.login-title {
  margin: 0 0 5px;
  font-size: 30px;
  line-height: 1.1;
}

.login-subtitle {
  margin: 0 0 22px;
  color: var(--muted);
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-title {
  margin: 0;
  font-size: 28px;
  line-height: 1.18;
}

.page-subtitle {
  margin: 5px 0 0;
  color: var(--muted);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.grid {
  display: grid;
  gap: 14px;
}

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

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

.workbench-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(340px, 0.75fr);
  gap: 16px;
  margin-top: 16px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.panel,
.metric-card,
.detail-summary {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.panel {
  padding: 16px;
}

.metric-card {
  padding: 18px;
}

.metric-value {
  display: block;
  font-size: 30px;
  line-height: 1;
  font-weight: 800;
}

.metric-label {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

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

.quick-action {
  min-height: 86px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px;
  text-align: left;
  cursor: pointer;
}

.quick-action:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.quick-kicker {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.quick-action strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
}

.panel-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

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

.list.spacious {
  margin-top: 14px;
  gap: 12px;
  align-items: start;
}

.item-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  gap: 10px;
}

.work-order {
  border-left: 4px solid var(--line-strong);
  align-self: start;
}

.work-order:has(.badge.warning) {
  border-left-color: var(--warning);
}

.work-order:has(.badge.success) {
  border-left-color: var(--success);
}

.row-main,
.check-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.row-title {
  font-weight: 760;
  overflow-wrap: anywhere;
}

.row-meta {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.requirements {
  margin-top: 8px;
}

.badge {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--surface-strong);
  color: #4a5b6b;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.success {
  background: #e3f2e8;
  color: var(--success);
}

.badge.warning {
  background: #fff0d8;
  color: var(--warning);
}

.badge.danger {
  background: #f8e4e4;
  color: var(--danger);
}

.progress {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-strong);
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.progress.large {
  height: 12px;
  margin-top: 10px;
}

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

.compact-form {
  align-items: end;
}

.field {
  display: grid;
  gap: 5px;
}

.field.full {
  grid-column: 1 / -1;
}

label {
  font-weight: 700;
  color: #263443;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
}

.search-input {
  flex: 1 1 320px;
}

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

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.20);
  outline-offset: 1px;
  border-color: var(--primary);
}

.btn {
  min-height: 40px;
  border-radius: 7px;
  padding: 8px 12px;
  background: var(--surface-strong);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-decoration: none;
  white-space: nowrap;
  font-weight: 750;
}

.btn:hover {
  filter: brightness(0.98);
}

.btn.primary {
  background: var(--primary);
  color: #fff;
}

.btn.primary:hover {
  background: var(--primary-dark);
}

.btn.success {
  background: var(--success);
  color: #fff;
}

.btn.warning {
  background: var(--warning);
  color: #fff;
}

.btn.danger {
  background: var(--danger);
  color: #fff;
}

.btn.quiet {
  background: #fff;
  color: var(--muted);
  border: 1px solid var(--line);
}

.btn.ghost {
  background: transparent;
  color: inherit;
  border: 1px solid var(--line);
}

.btn.small {
  min-height: 32px;
  padding: 5px 9px;
  font-size: 13px;
}

.template-library {
  display: grid;
  gap: 18px;
  margin-top: 16px;
}

.template-group {
  display: grid;
  gap: 8px;
}

.group-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

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

.start-line {
  display: grid;
  grid-template-columns: minmax(180px, 320px) auto;
  align-items: end;
  gap: 10px;
}

.detail-summary {
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
}

.summary-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.summary-title {
  margin-top: 2px;
  font-size: 22px;
  font-weight: 800;
}

.summary-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.template-items,
.check-items {
  display: grid;
  gap: 12px;
}

.template-item,
.check-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.check-item.done {
  border-left: 5px solid var(--success);
}

.check-item.skipped {
  border-left: 5px solid var(--warning);
}

.check-item.open {
  border-left: 5px solid var(--line-strong);
}

.item-editor {
  display: grid;
  grid-template-columns: minmax(260px, 0.7fr) minmax(260px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.item-editor .field {
  min-width: 0;
}

.item-editor textarea {
  min-height: 72px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(96px, 1fr));
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  overflow: hidden;
}

.segmented button {
  min-height: 38px;
  background: #fff;
  color: var(--text);
  border-right: 1px solid var(--line);
  cursor: pointer;
  font-weight: 750;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: var(--primary);
  color: #fff;
}

.image-block {
  display: grid;
  gap: 9px;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 8px;
}

.image-tile {
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  background: #fff;
}

.image-tile img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.image-tile .btn {
  width: 100%;
  border-radius: 0;
}

.upload-button {
  width: fit-content;
  min-height: 38px;
  border-radius: 7px;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  background: var(--surface-strong);
  color: var(--text);
  cursor: pointer;
  font-weight: 750;
}

.upload-button input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.7);
}

.empty.compact {
  padding: 12px;
  min-height: 72px;
  display: grid;
  place-items: center;
}

.notice {
  border-left: 4px solid var(--info);
  background: #e8f2f8;
  padding: 10px 12px;
  border-radius: 7px;
  color: #17435d;
}

.error {
  border-left: 4px solid var(--danger);
  background: #fbeaea;
  padding: 10px 12px;
  border-radius: 7px;
  color: #7d2626;
}

.inline-form-panel {
  background: #fbfcfd;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  background: #15232d;
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  z-index: 30;
}

.hidden {
  display: none !important;
}

@media (min-width: 1500px) {
  body {
    font-size: 16px;
  }

  .shell-header {
    padding-inline: 30px;
  }

  .main {
    padding: 30px;
  }

  .page-title {
    font-size: 32px;
  }

  .metric-card,
  .panel,
  .detail-summary {
    padding: 20px;
  }

  .list.spacious {
    grid-template-columns: repeat(auto-fit, minmax(520px, 1fr));
  }

  .template-group .list {
    grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
  }

  .image-grid {
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  }
}

@media (min-width: 2200px) {
  :root {
    --content-max: 2300px;
  }

  .main {
    padding: 36px;
  }

  .action-strip {
    grid-template-columns: repeat(3, minmax(360px, 1fr));
  }

  .metric-grid {
    grid-template-columns: repeat(3, minmax(360px, 1fr));
  }

  .workbench-grid {
    grid-template-columns: minmax(0, 1.35fr) minmax(520px, 0.85fr);
    gap: 20px;
  }

  .check-items {
    grid-template-columns: repeat(2, minmax(680px, 1fr));
  }

  .inline-form-panel {
    max-width: 1120px;
  }
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }

  .shell-header,
  .sidebar,
  .main {
    grid-column: 1;
  }

  .sidebar {
    grid-row: 2;
    position: sticky;
    top: 70px;
    z-index: 11;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 10px 14px;
    overflow-x: auto;
  }

  .nav {
    display: flex;
    gap: 8px;
    position: static;
  }

  .nav button {
    width: auto;
    min-width: max-content;
    text-align: center;
    box-shadow: none;
  }

  .nav button.active {
    box-shadow: inset 0 -3px 0 var(--primary);
  }

  .main {
    grid-row: 3;
    max-width: none;
  }

  .workbench-grid,
  .metric-grid,
  .action-strip {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  body {
    font-size: 15px;
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }

  .layout {
    display: block;
    min-height: 100vh;
  }

  .shell-header {
    min-height: 58px;
    padding: 8px 12px;
    align-items: center;
    position: sticky;
    top: 0;
  }

  .brand-mark {
    display: none;
  }

  .brand-name {
    font-size: 16px;
  }

  .brand-user {
    font-size: 12px;
  }

  .shell-header .btn {
    width: auto;
    min-height: 36px;
    padding-inline: 10px;
  }

  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 20;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.98);
    border-top: 1px solid var(--line);
    border-bottom: 0;
    box-shadow: 0 -10px 24px rgba(18, 31, 45, 0.10);
    overflow-x: auto;
  }

  .nav {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(84px, 1fr);
    gap: 6px;
    min-width: max-content;
  }

  .nav button {
    min-height: 52px;
    width: 100%;
    padding: 6px 8px;
    font-size: 12px;
    line-height: 1.15;
    white-space: normal;
    display: grid;
    place-items: center;
    text-align: center;
  }

  .main {
    padding: 14px 12px 20px;
  }

  .page-head,
  .row-main,
  .check-head,
  .detail-summary {
    align-items: flex-start;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .page-head {
    gap: 10px;
    margin-bottom: 12px;
  }

  .page-head .toolbar {
    width: 100%;
  }

  .eyebrow {
    font-size: 11px;
  }

  .page-title {
    font-size: 23px;
  }

  .page-subtitle {
    font-size: 13px;
  }

  .summary-actions {
    justify-content: flex-start;
    width: 100%;
  }

  .grid.two,
  .grid.three,
  .form-grid,
  .start-line {
    grid-template-columns: 1fr;
  }

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

  .panel,
  .metric-card,
  .detail-summary,
  .item-row,
  .template-item,
  .check-item {
    padding: 12px;
  }

  .action-strip,
  .metric-grid,
  .workbench-grid {
    gap: 10px;
  }

  .quick-action {
    min-height: 72px;
    padding: 12px;
  }

  .metric-value {
    font-size: 26px;
  }

  .toolbar {
    width: 100%;
  }

  .toolbar > * {
    flex: 1 1 100%;
  }

  .search-input {
    flex-basis: 100%;
  }

  input,
  select,
  textarea {
    min-height: 46px;
    font-size: 16px;
  }

  textarea {
    min-height: 94px;
  }

  .btn,
  .upload-button {
    width: 100%;
    min-height: 46px;
  }

  .btn.small {
    min-height: 42px;
  }

  .badges {
    gap: 5px;
  }

  .badge {
    max-width: 100%;
    white-space: normal;
    line-height: 1.2;
    padding-block: 4px;
  }

  .item-editor {
    gap: 12px;
  }

  .segmented button {
    min-height: 44px;
  }

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

  .image-tile img {
    aspect-ratio: 1 / 1;
  }
}

@media (max-width: 390px) {
  .nav {
    grid-auto-columns: minmax(74px, 1fr);
  }

  .nav button {
    font-size: 11px;
  }

  .page-title {
    font-size: 21px;
  }

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