:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --border: #d0d7de;
  --text: #1f2328;
  --muted: #656d76;
  --ok: #1a7f37;
  --warn: #9a6700;
  --crit: #cf222e;
  --ok-bg: #dafbe1;
  --warn-bg: #fff8c5;
  --crit-bg: #ffebe9;
  --accent: #0969da;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.app-header {
  padding: 1rem;
  padding-top: max(1rem, env(safe-area-inset-top));
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.app-header h1 { margin: 0 0 .2rem; font-size: 1.2rem; }
.subtitle { margin: 0; color: var(--muted); font-size: .85rem; }

.layout {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}
.card h2 { margin: 0 0 .75rem; font-size: .95rem; }

.table-card { grid-column: 1 / -1; }

.field { margin-bottom: .75rem; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .25rem; }

.field input, .field select {
  display: block;
  width: 100%;
  padding: .6rem .6rem;
  font-size: 16px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  -webkit-appearance: none;
  appearance: none;
}
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath d='M3 5l3 3 3-3' fill='none' stroke='%23656d76' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .7rem center;
  padding-right: 2rem;
}
.field input:focus, .field select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}
.hint { display: block; color: var(--muted); font-size: .75rem; margin-top: .2rem; }

.result-card { display: flex; flex-direction: column; }

.big-value {
  margin: .3rem 0 .6rem;
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.big-value .unit { font-size: .9rem; color: var(--muted); font-weight: 400; margin-left: .3rem; }

.status {
  padding: .5rem .6rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: .85rem;
  margin-bottom: .6rem;
}
.status.ok { background: var(--ok-bg); color: var(--ok); }
.status.warn { background: var(--warn-bg); color: var(--warn); }
.status.crit { background: var(--crit-bg); color: var(--crit); }
.status.neutral { background: #eaeef2; color: var(--muted); }

.intermediate { width: 100%; border-collapse: collapse; font-size: .85rem; }
.intermediate th, .intermediate td {
  padding: .3rem .4rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.intermediate th { font-weight: 500; color: var(--muted); }
.intermediate td { font-variant-numeric: tabular-nums; }

.note {
  margin-top: auto;
  background: #eaeef2;
  padding: .4rem .6rem;
  border-radius: 6px;
  font-size: .78rem;
  color: var(--muted);
}

.caption { color: var(--muted); font-size: .78rem; margin: .2rem 0 .5rem; }

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 400px;
  overflow-y: auto;
}
.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
  font-variant-numeric: tabular-nums;
}
.ref-table th, .ref-table td {
  padding: .3rem .4rem;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}
.ref-table th:first-child, .ref-table td:first-child { text-align: left; }
.ref-table thead th {
  background: #eaeef2;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}
.ref-table td.hl {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.app-footer {
  text-align: center;
  padding: 1rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--card);
  font-size: .78rem;
}

@media (max-width: 640px) {
  .layout {
    grid-template-columns: 1fr;
    padding: .75rem;
    gap: .75rem;
  }
  .table-card { grid-column: 1; }
  .app-header h1 { font-size: 1.05rem; }
  .subtitle { font-size: .8rem; }
  .card { padding: .85rem; }
  .big-value { font-size: 1.7rem; }
}

@media (max-width: 380px) {
  .app-header h1 { font-size: .98rem; }
  .card { padding: .7rem; }
  .big-value { font-size: 1.5rem; }
  .ref-table { font-size: .75rem; }
  .ref-table th, .ref-table td { padding: .25rem .3rem; }
}
