:root {
  color-scheme: light;
  --ink: #211916;
  --muted: #75645d;
  --paper: #faf4ea;
  --panel: #fffaf2;
  --line: #e2d2c3;
  --ember: #bc2f21;
  --ember-dark: #7e1912;
  --brass: #b58235;
  --green: #28684d;
  --shadow: 0 18px 50px rgba(62, 31, 21, 0.12);
  --radius: 8px;
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(126, 25, 18, 0.08) 0 1px, transparent 1px 100%),
    linear-gradient(180deg, rgba(181, 130, 53, 0.08) 0 1px, transparent 1px 100%),
    radial-gradient(circle at 10% 8%, rgba(188, 47, 33, 0.16), transparent 32rem),
    var(--paper);
  background-size: 42px 42px, 42px 42px, auto, auto;
}

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

button {
  cursor: pointer;
}

.shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(20px, 4vw, 48px) 0 56px;
}

.masthead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 8px 0 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--ember-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.05;
}

h1 {
  font-size: clamp(34px, 5vw, 76px);
  font-weight: 900;
}

h2 {
  font-size: clamp(22px, 2vw, 34px);
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(92px, 1fr));
  border: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.82);
  box-shadow: var(--shadow);
}

.status-strip span {
  min-width: 0;
  padding: 16px 18px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.status-strip span:first-child {
  border-left: 0;
}

.status-strip strong {
  display: block;
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(320px, 430px) 1fr;
  gap: clamp(18px, 3vw, 32px);
  align-items: start;
}

.inventory-panel,
.form-panel,
.history-band {
  border: 1px solid var(--line);
  background: rgba(255, 250, 242, 0.92);
  box-shadow: var(--shadow);
}

.inventory-panel {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  display: flex;
  flex-direction: column;
  min-height: 640px;
}

.panel-head,
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ember-dark);
  background: transparent;
  font-size: 24px;
  line-height: 1;
}

.search-box,
.repair-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search-box {
  padding: 18px 22px 10px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
  color: var(--ink);
  background: #fffdf8;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--ember);
  box-shadow: 0 0 0 3px rgba(188, 47, 33, 0.13);
}

.filter-row {
  display: flex;
  gap: 8px;
  padding: 0 22px 16px;
  overflow-x: auto;
}

.chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  background: transparent;
}

.chip.active {
  color: #fff7ef;
  border-color: var(--ember-dark);
  background: var(--ember-dark);
}

.device-list {
  overflow: auto;
  padding: 0 12px 14px;
}

.device-card {
  width: 100%;
  display: grid;
  grid-template-columns: 94px 1fr;
  gap: 7px 12px;
  min-height: 104px;
  margin: 8px 0;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 14px;
  text-align: left;
  color: var(--ink);
  background: transparent;
}

.device-card:hover,
.device-card.active {
  border-color: var(--brass);
  background: #fff8ed;
}

.device-code {
  grid-row: span 3;
  align-self: stretch;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: #fff7ef;
  background: var(--ember-dark);
  font-weight: 900;
  font-size: 13px;
  text-align: center;
  word-break: break-word;
}

.device-card strong {
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.device-card small,
.device-meta {
  color: var(--muted);
}

.device-meta {
  font-size: 12px;
}

.form-panel {
  min-height: 640px;
}

.selected-device {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  padding: clamp(22px, 4vw, 38px);
  color: #fff6ea;
  background:
    linear-gradient(135deg, rgba(126, 25, 18, 0.96), rgba(188, 47, 33, 0.92)),
    var(--ember-dark);
}

.selected-device h2 {
  max-width: 760px;
  font-size: clamp(28px, 4vw, 58px);
  overflow-wrap: anywhere;
}

.selected-device dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(88px, 1fr));
  gap: 14px;
  margin: 22px 0 0;
}

.selected-device dt {
  color: rgba(255, 246, 234, 0.72);
  font-size: 12px;
}

.selected-device dd {
  margin: 4px 0 0;
  font-weight: 800;
}

.risk-badge {
  align-self: start;
  border: 1px solid rgba(255, 246, 234, 0.45);
  border-radius: 999px;
  padding: 10px 14px;
  white-space: nowrap;
  font-weight: 800;
}

.risk-badge.ok {
  background: rgba(40, 104, 77, 0.35);
}

.repair-form {
  display: grid;
  gap: 22px;
  padding: clamp(22px, 4vw, 38px);
}

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

.issue-set {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  border: 0;
  padding: 0;
}

.issue-set legend {
  grid-column: 1 / -1;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.issue-set label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--ink);
  background: #fffdf8;
}

.issue-set input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--ember);
}

.wide {
  grid-column: 1 / -1;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.primary,
.secondary {
  min-height: 46px;
  border-radius: var(--radius);
  padding: 12px 18px;
  font-weight: 900;
}

.primary {
  border: 1px solid var(--ember-dark);
  color: #fff7ef;
  background: var(--ember-dark);
}

.secondary {
  border: 1px solid var(--line);
  color: var(--ember-dark);
  background: #fffdf8;
}

.secondary.small {
  min-height: 40px;
  padding: 8px 14px;
}

.submit-note {
  min-height: 22px;
  margin: 0;
  color: var(--green);
  font-weight: 800;
}

.history-band {
  margin-top: 32px;
}

.history-tools {
  display: flex;
  gap: 10px;
  align-items: center;
}

.history-tools input {
  min-width: min(280px, 42vw);
}

.record-timeline {
  display: grid;
  gap: 0;
}

.record-row {
  display: grid;
  grid-template-columns: 150px 120px 1fr 160px;
  gap: 18px;
  align-items: center;
  padding: 18px 22px;
  border-top: 1px solid var(--line);
}

.record-row:first-child {
  border-top: 0;
}

.record-row strong {
  display: block;
}

.record-row small {
  color: var(--muted);
}

.pill {
  justify-self: start;
  border-radius: 999px;
  padding: 7px 11px;
  color: #fff7ef;
  background: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.pill.bad,
.pill.high {
  background: var(--ember);
}

.pill.mid {
  background: var(--brass);
}

.empty {
  padding: 34px 22px;
  color: var(--muted);
}

@media (max-width: 980px) {
  .masthead,
  .workbench,
  .selected-device,
  .history-head {
    grid-template-columns: 1fr;
  }

  .masthead,
  .history-head {
    align-items: stretch;
  }

  .inventory-panel {
    position: relative;
    top: auto;
    max-height: none;
    min-height: 0;
  }

  .device-list {
    max-height: 420px;
  }

  .selected-device dl,
  .issue-set {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .record-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100% - 20px, 1480px);
    padding-top: 16px;
  }

  .status-strip,
  .form-grid,
  .selected-device dl,
  .issue-set {
    grid-template-columns: 1fr;
  }

  .status-strip span {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .status-strip span:first-child {
    border-top: 0;
  }

  .device-card {
    grid-template-columns: 86px 1fr;
  }

  .history-tools {
    display: grid;
  }

  .history-tools input {
    min-width: 0;
  }
}
