:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-alt: #eef3f1;
  --text: #16201f;
  --muted: #66706e;
  --line: #dce4e1;
  --green: #1f7a5a;
  --green-dark: #135b42;
  --blue: #285b8f;
  --amber: #9a6a13;
  --red: #a4423f;
  --shadow: 0 10px 30px rgba(31, 46, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

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

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  padding: 9px 13px;
}

button:hover {
  border-color: #b9c8c4;
}

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

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

.primary:hover {
  background: var(--green-dark);
  border-color: var(--green-dark);
}

.danger {
  border-color: #e3b7b5;
  color: var(--red);
}

.ghost {
  background: transparent;
}

.app {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(245, 247, 248, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  flex: 1;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.brand small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px;
}

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

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

.login-panel h1 {
  margin: 0 0 6px;
  font-size: 24px;
}

.login-panel p {
  margin: 0 0 18px;
  color: var(--muted);
}

.nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  margin-bottom: 18px;
}

.nav button {
  white-space: nowrap;
  background: var(--surface);
}

.nav button.active {
  background: #dceee6;
  border-color: #b7d8cb;
  color: var(--green-dark);
}

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

.two {
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
}

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

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.panel h2,
.panel h3 {
  margin: 0 0 12px;
  font-size: 18px;
}

.panel h3 {
  font-size: 16px;
}

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

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

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

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

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

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

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

.case-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.case-card.active {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 122, 90, 0.12);
}

.case-card button {
  justify-self: start;
}

.meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
}

.badge.pending {
  background: #fff8e8;
  border-color: #ead6a4;
  color: var(--amber);
}

.badge.approved {
  background: #e7f3ed;
  border-color: #bfdccc;
  color: var(--green-dark);
}

.badge.revision {
  background: #faeeee;
  border-color: #e6c0be;
  color: var(--red);
}

.doc-list {
  display: grid;
  gap: 12px;
}

.doc-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

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

.doc-title {
  display: grid;
  gap: 2px;
  font-weight: 700;
}

.doc-title small {
  color: var(--muted);
  font-weight: 400;
}

.faults {
  display: grid;
  gap: 8px;
}

.check-row {
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: start;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.check-row input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
}

.component-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px auto;
  gap: 8px;
  align-items: end;
}

.line-items {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.line-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 94px auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
}

.line-item strong,
.case-card strong {
  overflow-wrap: anywhere;
}

.empty {
  border: 1px dashed #b8c6c2;
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.metric strong {
  display: block;
  font-size: 24px;
  margin-bottom: 2px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.table-like {
  display: grid;
  gap: 8px;
}

.table-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) 92px;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.reference-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 8px;
}

.reference-list {
  display: grid;
  gap: 14px;
}

.reference-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

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

.reference-head h3 {
  margin: 6px 0 0;
  font-size: 20px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.info-grid div {
  min-width: 0;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.info-grid .wide {
  grid-column: span 2;
}

.info-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 3px;
}

.info-grid strong {
  display: block;
  overflow-wrap: anywhere;
}

.reference-section {
  margin-top: 14px;
}

.reference-section h4 {
  margin: 0 0 8px;
  font-size: 14px;
}

.battery-list,
.case-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.battery-list button,
.case-links button {
  min-height: 34px;
  font-weight: 600;
}

.error {
  margin-top: 10px;
  color: var(--red);
  font-weight: 700;
}

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

@media (max-width: 860px) {
  .two,
  .three,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .component-picker,
  .line-item,
  .table-row,
  .reference-search,
  .info-grid {
    grid-template-columns: 1fr;
  }

  .info-grid .wide {
    grid-column: auto;
  }

  .topbar-inner {
    align-items: flex-start;
  }
}

@media (max-width: 560px) {
  .shell {
    padding: 12px;
  }

  .topbar-inner {
    padding: 10px 12px;
  }

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

  .panel {
    padding: 12px;
  }

  button {
    width: 100%;
  }

  .doc-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
