:root {
  color-scheme: light;
  --bg: #eef0ed;
  --surface: #ffffff;
  --surface-soft: #f7f8f5;
  --ink: #151a20;
  --muted: #66707a;
  --line: #c8cec9;
  --strong-line: #8d9694;
  --accent: #136f63;
  --accent-ink: #ffffff;
  --warn: #a15c00;
  --danger: #a42a2a;
  --shadow: 0 12px 28px rgba(21, 26, 32, 0.12);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  background: linear-gradient(180deg, #dfe6e2 0, var(--bg) 220px);
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 14px max(94px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 2px 14px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(1.9rem, 10vw, 2.8rem);
}

h2 {
  font-size: 1.08rem;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 1.55rem;
  font-weight: 900;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.tab {
  min-height: 44px;
  border: 1px solid var(--strong-line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-soft);
  font-weight: 900;
}

.tab.is-active {
  color: var(--accent-ink);
  border-color: var(--accent);
  background: var(--accent);
}

.tab span {
  display: inline-grid;
  min-width: 24px;
  min-height: 24px;
  margin-left: 5px;
  place-items: center;
  border-radius: 999px;
  color: currentColor;
  background: rgba(255, 255, 255, 0.2);
}

.view {
  display: none;
}

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

.summary-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--surface);
}

label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--strong-line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
}

.totals-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.totals-grid div {
  min-height: 62px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.total-label {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.totals-grid strong {
  display: block;
  margin-top: 3px;
  font-size: 1.55rem;
}

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

.result-button,
.quick-mark,
.ghost-button,
.primary-button {
  min-height: 46px;
  border-radius: 8px;
  font-weight: 900;
}

.result-button,
.quick-mark,
.ghost-button {
  border: 1px solid var(--strong-line);
  color: var(--ink);
  background: var(--surface);
}

.result-button.is-active {
  border-color: var(--ink);
  color: var(--accent-ink);
  background: var(--ink);
}

.result-button span,
.quick-mark span,
.mark-button span {
  display: inline-grid;
  min-width: 22px;
  min-height: 22px;
  margin-left: 4px;
  place-items: center;
  border-radius: 999px;
  background: rgba(21, 26, 32, 0.1);
  font-size: 0.78rem;
}

.result-button.is-active span {
  background: rgba(255, 255, 255, 0.22);
}

.quick-section {
  margin: 14px 0;
}

.quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.quick-mark {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  text-align: left;
}

.quick-mark.is-on {
  border-color: var(--accent);
  color: var(--accent);
  background: #edf8f4;
}

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

.section-card {
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--surface);
}

summary {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 950;
  list-style: none;
}

summary::-webkit-details-marker {
  display: none;
}

.section-count {
  display: inline-grid;
  min-width: 32px;
  min-height: 32px;
  place-items: center;
  border: 1px solid var(--strong-line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-soft);
}

.section-body {
  display: grid;
  gap: 8px;
  padding: 0 10px 10px;
}

.skill-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px 48px;
  gap: 7px;
  min-height: 48px;
}

.fault-button,
.mark-button {
  border: 1px solid var(--strong-line);
  border-radius: 8px;
  background: #fff;
}

.fault-button {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 6px;
  text-align: left;
}

.fault-count {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 999px;
  color: var(--ink);
  background: #dfe1df;
  font-weight: 950;
}

.fault-count.has-value {
  color: #fff;
  background: var(--accent);
}

.fault-label {
  overflow: hidden;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 750;
}

.mark-button {
  color: var(--muted);
  font-weight: 950;
}

.mark-button.serious.has-value {
  border-color: var(--warn);
  color: #fff;
  background: var(--warn);
}

.mark-button.dangerous.has-value {
  border-color: var(--danger);
  color: #fff;
  background: var(--danger);
}

.mark-button.has-value span {
  background: rgba(255, 255, 255, 0.22);
}

.sticky-actions {
  position: fixed;
  z-index: 5;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: 0.8fr 0.8fr 1.4fr;
  gap: 8px;
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 10px 14px max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(238, 240, 237, 0.94);
  backdrop-filter: blur(14px);
}

.primary-button {
  border: 0;
  color: var(--accent-ink);
  background: var(--accent);
}

.ghost-button {
  padding: 0 12px;
}

.ghost-button:disabled {
  opacity: 0.45;
}

.compact {
  min-height: 38px;
}

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

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

.saved-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--surface);
}

.saved-card h3 {
  margin: 0;
  font-size: 1rem;
}

.saved-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.saved-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--strong-line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.6);
  text-align: center;
  font-weight: 800;
}

.toast {
  position: fixed;
  z-index: 10;
  right: 14px;
  bottom: 90px;
  left: 14px;
  width: min(calc(100% - 28px), 732px);
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: var(--ink);
  box-shadow: var(--shadow);
  font-weight: 850;
  text-align: center;
}

@media (min-width: 680px) {
  .summary-panel {
    grid-template-columns: 1fr 1fr 1.3fr;
    align-items: end;
  }

  .quick-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
