:root {
  --bg: #eef1f4;
  --panel: #ffffff;
  --ink: #1e252c;
  --muted: #66727f;
  --line: #d8dee5;
  --primary: #155e75;
  --primary-dark: #0f4859;
  --green: #1f7a4c;
  --yellow: #a16207;
  --red: #b42318;
  --shadow: 0 18px 45px rgba(28, 40, 52, 0.1);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 28px clamp(18px, 4vw, 48px);
  background: #17212b;
  color: #fff;
}
.eyebrow {
  margin: 0 0 5px;
  color: #9cc8d3;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
}
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.45rem, 3vw, 2.2rem); }
h2 { margin-bottom: 16px; font-size: 1rem; }
main { width: min(1500px, calc(100% - 32px)); margin: 24px auto 48px; }
.top-actions, .panel-heading, .score-row, .row-actions { display: flex; gap: 12px; align-items: center; }
.primary, .secondary, .button-link {
  border: 1px solid transparent;
  border-radius: 6px;
  min-height: 40px;
  padding: 0 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.primary { background: var(--primary); color: #fff; }
.primary:hover { background: var(--primary-dark); }
.secondary, .button-link { background: #fff; color: var(--ink); border-color: var(--line); }
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.summary-grid article, .summary-card, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.summary-grid article, .summary-card { padding: 18px; }
.summary-card {
  display: block;
  transition: border-color .15s ease, transform .15s ease;
}
.summary-card:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}
.summary-grid span { display: block; font-size: 1.7rem; font-weight: 800; }
.summary-grid p { margin: 2px 0 0; color: var(--muted); }
.summary-grid small { display: block; margin-top: 6px; color: var(--muted); }
.tabs { display: flex; gap: 8px; margin-bottom: 18px; overflow-x: auto; }
.tabs a {
  min-width: 112px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 11px 14px;
  font-weight: 800;
  color: var(--muted);
  text-align: center;
}
.tabs a.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.layout {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}
.panel { padding: 18px; margin-bottom: 18px; }
.wide { min-width: 0; }
.panel-heading { justify-content: space-between; margin-bottom: 12px; }
.panel-heading h2 { margin-bottom: 0; }
label {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  color: #34414d;
  font-size: .9rem;
  font-weight: 800;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 11px;
}
textarea { resize: vertical; }
.two-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.score-row { align-items: stretch; margin-bottom: 14px; }
.score-row label { flex: 1; margin-bottom: 0; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 860px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; }
.muted { color: var(--muted); font-size: .86rem; }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 2px 10px;
  color: #fff;
  font-weight: 800;
  white-space: nowrap;
}
.badge.low { background: var(--green); }
.badge.medium { background: var(--yellow); }
.badge.high { background: var(--red); }
.row-actions form { margin: 0; }
.row-actions button { min-height: 40px; }
.dictionary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(260px, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}
.dictionary-form { display: grid; align-content: start; }
.dictionary-form select { margin-top: 10px; }
.dictionary-form button { margin-top: 10px; }
.chips {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}
.chips li {
  background: #f6f8fa;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
}
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.plan-card {
  border: 1px solid var(--line);
  border-left: 6px solid var(--red);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}
.plan-card h3 { margin: 0 0 8px; font-size: 1rem; }
.hint { color: var(--muted); font-size: .88rem; }
.matrix {
  display: grid;
  grid-template-columns: 92px repeat(5, minmax(72px, 1fr));
  gap: 8px;
}
.matrix-cell, .matrix-head {
  min-height: 72px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 8px;
  background: #fff;
  overflow: hidden;
}
.matrix-head { min-height: 42px; display: grid; place-items: center; color: var(--muted); font-weight: 800; }
.matrix-cell strong { display: block; margin-bottom: 6px; }
.matrix-cell.low { background: #e9f7ef; }
.matrix-cell.medium { background: #fff4d6; }
.matrix-cell.high { background: #ffe6e3; }
.mini-risk { display: block; margin-top: 4px; font-size: .76rem; line-height: 1.2; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.error-box { border-color: #f3b3ae; background: #fff1ef; }
.auth-card {
  width: min(460px, 100%);
  margin: 42px auto;
}
.split-page {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.side-menu {
  display: grid;
  gap: 8px;
  align-content: start;
}
.side-menu a {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 800;
  display: flex;
  align-items: center;
  background: #fff;
}
.side-menu a:hover { border-color: var(--primary); color: var(--primary); }
.side-menu a.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.filter-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr)) auto auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}
.filter-bar label {
  margin-bottom: 0;
}
.inline-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}
.inline-form label {
  margin-bottom: 0;
}
.inline-form button {
  align-self: end;
}
.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  gap: 18px;
}
.compact table {
  min-width: 520px;
}
@media (max-width: 1040px) {
  .layout, .dictionary-grid, .summary-grid, .admin-grid { grid-template-columns: 1fr 1fr; }
  .layout .wide { grid-column: 1 / -1; }
  .split-page { grid-template-columns: 1fr; }
  .side-menu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .topbar, .top-actions, .panel-heading, .score-row { align-items: stretch; flex-direction: column; }
  .summary-grid, .layout, .dictionary-grid, .two-cols, .admin-grid, .inline-form, .side-menu, .filter-bar { grid-template-columns: 1fr; }
  .matrix { grid-template-columns: 70px repeat(5, minmax(58px, 1fr)); gap: 5px; }
  .matrix-cell, .matrix-head { min-height: 64px; padding: 6px; font-size: .78rem; }
}
