:root {
  --white: #ffffff;
  --frost: #d8e0eb;
  --sky:   #bccbdd;
  --red:   #ff0000;
  --black: #212121;
  --muted: #8895a8;
  --bg:    #f6f7f9;
  --red-soft: rgba(255, 0, 0, 0.08);
  --red-soft-2: rgba(255, 0, 0, 0.14);
  --green: #22a04a;
  --green-soft: rgba(34, 160, 74, 0.12);
  --yellow: #e4a11b;
  --yellow-soft: rgba(228, 161, 27, 0.15);
  --shadow: 0 1px 2px rgba(33, 33, 33, 0.04);
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--black);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; line-height: 1.4;
}
a { color: inherit; text-decoration: none; }

/* ---------- Layout ---------- */
body { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--white);
  border-right: 1px solid var(--frost);
  display: flex; flex-direction: column;
  padding: 18px 12px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; }
.brand-logo { width: 34px; height: 34px; border-radius: 8px; }
.brand-name { font-size: 18px; font-weight: 700; letter-spacing: -0.2px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 2px; padding-top: 14px; border-top: 1px solid var(--frost); }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--black); font-size: 14px;
  background: transparent; border: none; cursor: pointer;
  width: 100%; text-align: left; font-family: inherit;
  transition: background .12s;
}
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--red-soft); color: var(--red); }
.nav-item.active svg { color: var(--red); }
.nav-item svg { color: var(--muted); flex-shrink: 0; }
.nav-item:hover svg { color: var(--black); }

/* ---------- Main ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--white); border-bottom: 1px solid var(--frost);
  padding: 16px 28px; position: sticky; top: 0; z-index: 5;
}
.topbar h1 { margin: 0; font-size: 18px; font-weight: 600; }
.content { padding: 24px 28px 48px; max-width: 900px; width: 100%; margin: 0 auto; }
.content.wide { max-width: 1280px; }

/* ---------- Cards & forms ---------- */
.card {
  background: var(--white); border: 1px solid var(--frost);
  border-radius: var(--radius); padding: 18px 20px;
  margin-bottom: 14px; box-shadow: var(--shadow);
}
.card.no-pad { padding: 0; overflow: hidden; }
.card h3 { margin: 0 0 14px; font-size: 14px; font-weight: 600; color: var(--black); }
.card-title { margin: 14px 20px 10px; font-size: 14px; font-weight: 600; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.spacer { flex: 1; }

.search-wrap {
  position: relative; display: flex; align-items: center;
  background: var(--white); border: 1px solid var(--frost);
  border-radius: 10px; padding: 0 14px;
  max-width: 420px; width: 100%; flex: 0 1 420px;
  transition: border-color .12s, box-shadow .12s;
}
.search-wrap:focus-within {
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(188, 203, 221, 0.25);
}
.search-wrap svg { color: var(--muted); flex-shrink: 0; }
.search-wrap input[type=search] {
  border: none; background: transparent; padding: 11px 10px;
  width: 100%; outline: none; font: inherit;
  border-radius: 0; box-shadow: none;
  -webkit-appearance: none; appearance: none;
}
.search-wrap input[type=search]:focus {
  border: none; box-shadow: none;
}
.search-wrap input::-webkit-search-decoration,
.search-wrap input::-webkit-search-cancel-button,
.search-wrap input::-webkit-search-results-button,
.search-wrap input::-webkit-search-results-decoration { -webkit-appearance: none; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--white); color: var(--black);
  border: 1px solid var(--frost); padding: 8px 14px;
  border-radius: 8px; cursor: pointer; font: inherit; font-size: 13px;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--red); color: #fff; border-color: var(--red); font-weight: 600; }
.btn.primary:hover { background: #d60000; border-color: #d60000; }
.btn.danger { color: var(--red); border-color: var(--frost); }
.btn.danger:hover { background: var(--red-soft); border-color: var(--red-soft-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--black); background: var(--bg); }

input[type=text], input[type=search], input[type=number],
input:not([type]), textarea {
  font: inherit; padding: 14px 16px;
  border: 1px solid var(--frost); border-radius: 10px;
  background: var(--white); width: 100%; outline: none;
  font-size: 14px; color: var(--black);
  transition: border-color .12s, box-shadow .12s;
  -webkit-appearance: none; appearance: none;
}
input[type=text]:focus, input[type=search]:focus, input[type=number]:focus,
input:not([type]):focus, textarea:focus {
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(188, 203, 221, 0.25);
}
textarea { resize: vertical; padding: 12px 16px; }

/* Remove number input spinners for uniform look */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.grid2 label {
  display: flex; flex-direction: column; gap: 8px;
  font-size: 13px; color: var(--muted); font-weight: 500;
}
.grid2 label input { color: var(--black); font-size: 14px; }

/* ---------- List table ---------- */
table { width: 100%; border-collapse: collapse; }
table.list th, table.list td {
  padding: 14px 18px; text-align: left;
  border-bottom: 1px solid var(--frost); font-size: 13px;
  white-space: nowrap;
}
table.list thead th {
  background: var(--bg); font-weight: 600; color: var(--muted);
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px;
  white-space: nowrap;
}
table.list tbody tr:last-child td { border-bottom: none; }
table.list tbody tr:hover { background: var(--bg); }
table.list td:last-child { text-align: right; white-space: nowrap; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 6px;
  background: transparent; border: 1px solid transparent;
  cursor: pointer; color: var(--muted); margin-left: 2px;
}
.icon-btn:hover { background: var(--bg); color: var(--black); border-color: var(--frost); }
.icon-btn.danger:hover { color: var(--red); border-color: var(--red-soft-2); background: var(--red-soft); }

.status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.status-badge.ok    { background: var(--sky);   color: var(--black); }
.status-badge.minor { background: var(--frost); color: var(--black); }
.status-badge.bad   { background: var(--red);   color: #fff; }
.status-badge::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: 0.55;
}
.status-badge.bad::before { opacity: 1; background: #fff; }

.empty { padding: 40px; text-align: center; color: var(--muted); }

.pagination {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px;
  margin-top: 14px; font-size: 13px;
}
.pagination:empty { display: none; }
.page-info { color: var(--muted); }
.page-ctrls { display: flex; align-items: center; gap: 4px; }
.page-btn {
  min-width: 34px; height: 34px; padding: 0 10px;
  background: var(--white); border: 1px solid var(--frost);
  border-radius: 8px; cursor: pointer; font: inherit; font-size: 13px;
  color: var(--black); transition: all .12s;
}
.page-btn:hover:not(:disabled) { background: var(--bg); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-btn.active {
  background: var(--red); border-color: var(--red); color: #fff; font-weight: 600;
}
.page-ellipsis { padding: 0 4px; color: var(--muted); }
.hidden { display: none !important; }

/* ---------- Checklist (form) ---------- */
.section-title {
  margin: 18px 0 8px;
  font-size: 12px; font-weight: 700;
  color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.6px;
}
.section-title:first-child { margin-top: 4px; }

tr.section-row td {
  background: var(--bg);
  font-size: 12px; font-weight: 700;
  color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.6px;
  padding: 10px 16px !important;
}

.check-row {
  border: 1px solid var(--frost); border-radius: 10px;
  padding: 10px 14px; margin-bottom: 8px; background: var(--white);
  transition: border-color .12s;
}
.check-row.invalid { border-color: var(--red); background: var(--red-soft); }
.check-head {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center; gap: 12px;
}
.check-name { font-weight: 500; font-size: 14px; }

.hint-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--frost); color: var(--muted);
  font-size: 11px; font-weight: 700; font-style: italic;
  cursor: help; position: relative; flex-shrink: 0;
}
.hint-ico:hover .tooltip { display: block; }
.tooltip {
  display: none; position: absolute;
  bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--black); color: var(--white);
  padding: 8px 10px; border-radius: 6px;
  font-size: 12px; font-style: normal; font-weight: 400;
  width: 260px; z-index: 20; white-space: normal; line-height: 1.4;
}
.tooltip::after {
  content: ""; position: absolute;
  top: 100%; left: 50%; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: var(--black);
}

/* Icon radio group */
.status-group { display: inline-flex; gap: 6px; }
.status-group label {
  position: relative; cursor: pointer;
  width: 38px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--frost); border-radius: 8px;
  background: var(--white);
  transition: all .12s;
}
.status-group label[data-v=ok]   { color: var(--green); }
.status-group label[data-v=fail] { color: var(--red); }
.status-group label[data-v=na]   { color: var(--yellow); }
.status-group label:hover { background: var(--bg); }
.status-group input { position: absolute; opacity: 0; pointer-events: none; }
.status-group label[data-v=ok]:has(input:checked) {
  background: var(--green); border-color: var(--green); color: #fff;
}
.status-group label[data-v=fail]:has(input:checked) {
  background: var(--red); border-color: var(--red); color: #fff;
}
.status-group label[data-v=na]:has(input:checked) {
  background: var(--yellow); border-color: var(--yellow); color: #fff;
}
.status-group svg { pointer-events: none; }

.comment-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--frost); background: var(--white);
  cursor: pointer; color: var(--muted); transition: all .12s;
}
.comment-btn:hover { color: var(--black); background: var(--bg); }
.comment-btn.has-text { color: var(--red); border-color: var(--red-soft-2); background: var(--red-soft); }

.comment-body { margin-top: 10px; }
.comment-body textarea { font-size: 13px; }

.form-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 4px 0 24px; align-items: center;
}
.err {
  background: var(--red-soft); color: var(--red);
  padding: 10px 14px; border-radius: 8px;
  border: 1px solid var(--red-soft-2);
  margin-bottom: 12px; font-size: 13px;
}

/* ---------- View ---------- */
dl.info { display: grid; grid-template-columns: 220px 1fr; gap: 8px 16px; margin: 0; }
dl.info dt { color: var(--muted); font-size: 13px; }
dl.info dd { margin: 0; font-size: 14px; }

table.items-view { width: 100%; border-collapse: collapse; }
table.items-view th, table.items-view td {
  padding: 10px 16px; border-bottom: 1px solid var(--frost);
  text-align: left; font-size: 13px; vertical-align: top;
}
table.items-view thead th {
  background: var(--bg); color: var(--muted);
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600;
}
table.items-view tbody tr:last-child td { border-bottom: none; }
.status-cell { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.status-cell.ok   { color: var(--green); }
.status-cell.fail { color: var(--red); }
.status-cell.na   { color: var(--yellow); }

.overall {
  margin: 16px 0 0;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-radius: 8px;
  font-size: 15px; font-weight: 600;
}
.overall.ok    { background: var(--sky);   color: var(--black); }
.overall.minor { background: var(--frost); color: var(--black); }
.overall.bad   { background: var(--red);   color: #fff; }

/* Responsive */
@media (max-width: 820px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row;
    padding: 10px; overflow-x: auto; gap: 8px; align-items: center; }
  .brand { padding: 4px 8px; }
  .nav, .sidebar-bottom { flex-direction: row; border: none; padding: 0; margin: 0; }
  .sidebar-bottom { margin-left: auto; }
  .nav-item span { display: none; }
  .grid2 { grid-template-columns: 1fr; }
  dl.info { grid-template-columns: 1fr; }
}
