:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --panel: #ffffff;
  --ink: #172026;
  --muted: #61707b;
  --line: #d8dee4;
  --accent: #1967d2;
  --ok: #137333;
  --warn: #b06000;
  --bad: #b3261e;
  --blocked: #7d2e00;
}

* {
  box-sizing: border-box;
}

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

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

button {
  min-height: 38px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
}

button.secondary,
.tabs button {
  background: white;
  color: var(--ink);
  border-color: var(--line);
}

button.active {
  border-color: var(--accent);
  color: var(--accent);
}

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px;
}

.login-panel {
  max-width: 420px;
  margin: 12vh auto 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

.login-panel h1,
.topbar h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.login-form,
.admin-form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 8px;
}

textarea {
  min-height: 110px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.safety-banner {
  border-left: 4px solid var(--blocked);
  background: #fff7ed;
  padding: 10px 12px;
  margin: 8px 0 12px;
  border-radius: 6px;
}

.notice {
  grid-column: 1 / -1;
  border-left: 4px solid var(--ok);
  background: #eef7f0;
  color: var(--ok);
  padding: 10px 12px;
  border-radius: 6px;
}

.tabs {
  display: flex;
  overflow-x: auto;
  gap: 8px;
  padding: 4px 0 12px;
}

.tabs button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.item-card,
.empty {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.report-group {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.detail-panel {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.detail-panel header {
  display: grid;
  gap: 8px;
}

.back-button {
  justify-self: start;
}

.report-group header h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.report-group header p {
  margin: 0 0 6px;
  color: var(--muted);
}

.report-items {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.item-head {
  display: grid;
  gap: 8px;
}

.item-card h2 {
  margin: 0;
  font-size: 18px;
}

.item-card p {
  color: #2d3a42;
  line-height: 1.45;
}

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

.facts div {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

dt {
  color: var(--muted);
  font-size: 12px;
}

dd {
  margin: 2px 0 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

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

.actions button {
  min-height: 34px;
  font-size: 13px;
}

.chip {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--muted);
  background: #fafafa;
  font-size: 12px;
  margin: 2px;
}

.chip.approved,
.chip.resolved,
.chip.ok {
  border-color: #b7dfc2;
  color: var(--ok);
}

.chip.needs_info,
.chip.open,
.chip.warning {
  border-color: #f4cf9a;
  color: var(--warn);
}

.chip.rejected,
.chip.blocked,
.chip.error {
  border-color: #f3b8b4;
  color: var(--bad);
}

.table-wrap {
  grid-column: 1 / -1;
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.table-wrap.compact {
  border-radius: 6px;
}

.empty.compact {
  padding: 10px;
}

.history-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-list li {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.history-list span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.history-list p {
  margin: 8px 0 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 10px;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
}

pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 360px;
  overflow: auto;
  background: #f2f4f6;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.error-text {
  color: var(--bad);
}

@media (max-width: 640px) {
  .app {
    padding: 10px;
  }

  .topbar {
    display: grid;
  }

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

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

.summary-value { font-size: 2rem; font-weight: 800; margin: 0.5rem 0; }
.summary-card { min-height: 140px; }
.wide-card { grid-column: 1 / -1; }
.inline-label { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.inline-label input { width: auto; min-width: 160px; }
.inner-empty { border: 0; padding: 8px 0 0; color: var(--muted); }
