:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --ink: #18202a;
  --muted: #657386;
  --line: #dce3ea;
  --panel: #ffffff;
  --accent: #1267a8;
  --accent-dark: #0c4775;
  --ok: #1f7a4d;
  --danger: #a83232;
}

* { 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;
  letter-spacing: 0;
}
a { color: inherit; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 236px;
  background: #101926;
  color: #dce7f2;
  padding: 22px 16px;
}
.brand { display: grid; gap: 10px; margin-bottom: 24px; }
.brand img {
  width: 176px;
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
  background: transparent;
}
.brand strong { font-size: 20px; line-height: 1.1; }
nav { display: grid; gap: 5px; }
nav a, .logout {
  display: block;
  padding: 10px 12px;
  border-radius: 7px;
  color: #dce7f2;
  text-decoration: none;
  font-weight: 650;
}
nav a.active, nav a:hover, .logout:hover { background: #203047; }
.logout { position: absolute; left: 16px; right: 16px; bottom: 18px; color: #ffcfcc; }
main { margin-left: 236px; padding: 28px; }
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
header p { margin: 0 0 3px; color: var(--muted); font-size: 14px; font-weight: 700; }
h1 { margin: 0; font-size: 28px; line-height: 1.2; }
.top-search {
  flex: 1;
  max-width: 520px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
.top-search input { min-width: 0; }
.top-search button { align-self: stretch; }
h2 { margin: 0 0 16px; font-size: 18px; }
.user, .badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  padding: 7px 11px;
  color: #405066;
  font-size: 13px;
  font-weight: 700;
}
.kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.kpi, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(16, 25, 38, .06);
}
.kpi {
  display: grid;
  gap: 8px;
  padding: 16px;
  text-decoration: none;
}
.kpi span { color: var(--muted); font-size: 13px; font-weight: 750; }
.kpi strong { font-size: 30px; }
.grid-two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.panel { padding: 18px; margin-bottom: 18px; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: #46566a; font-size: 12px; text-transform: uppercase; }
.records {
  display: grid;
  gap: 10px;
}
.record {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #f8fafc;
}
.record p {
  margin: 6px 0;
  color: #405066;
}
.small {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}
.inline-form {
  display: inline;
  margin-left: 8px;
}
.link-button {
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.link-button:hover {
  background: transparent;
  color: var(--accent-dark);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
label { display: grid; gap: 6px; color: #46566a; font-size: 13px; font-weight: 800; }
input, select, textarea {
  width: 100%;
  border: 1px solid #ccd6e2;
  border-radius: 7px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}
textarea { min-height: 96px; resize: vertical; }
.wide { grid-column: 1 / -1; }
button {
  align-self: end;
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  padding: 11px 15px;
  font: inherit;
  font-weight: 850;
  cursor: pointer;
}
button:hover { background: var(--accent-dark); }
.flash {
  border-radius: 7px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-weight: 750;
}
.flash.ok { background: #e8f6ef; color: var(--ok); border: 1px solid #b9e3cd; }
.flash.error { background: #fff0f0; color: var(--danger); border: 1px solid #efc1c1; }
.badge.ok { border-color: #b9e3cd; background: #e8f6ef; color: var(--ok); }
.badge.danger { border-color: #efc1c1; background: #fff0f0; color: var(--danger); }
.subpanel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fafc;
}
.subpanel h2 { margin-bottom: 12px; }
.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #405066;
}
.checkline input {
  width: auto;
}
.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
}
.template-list {
  display: grid;
  gap: 14px;
}
.template {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fafc;
}
.template p { margin: 8px 0; }
.hint {
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.5;
}
.notification-rules {
  display: grid;
  gap: 16px;
  margin-bottom: 14px;
}
.notification-rule {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 14px;
}
.rule-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.rule-head h3 {
  margin: 7px 0 0;
  font-size: 17px;
}
.rule-head small {
  color: var(--muted);
  font-weight: 800;
}
.rule-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.rule-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}
.rule-card textarea {
  min-height: 150px;
}
pre {
  white-space: pre-wrap;
  border: 1px solid #ccd6e2;
  border-radius: 7px;
  background: #fff;
  padding: 12px;
  margin: 0;
  color: #2a3544;
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}
.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #eef5fb, #f7f8fa);
}
.login {
  width: min(430px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 18px 60px rgba(16, 25, 38, .12);
  display: grid;
  gap: 15px;
}
.login-brand {
  background: #101926;
  border-radius: 8px;
  padding: 16px;
}
.login-brand img {
  display: block;
  width: min(260px, 100%);
  height: auto;
  margin: 0 auto;
}
.login p { margin: -8px 0 10px; color: var(--muted); }
@media (max-width: 980px) {
  .sidebar { position: static; width: auto; }
  .logout { position: static; margin-top: 10px; }
  main { margin-left: 0; padding: 18px; }
  header { align-items: stretch; flex-direction: column; }
  .top-search { max-width: none; width: 100%; }
  .kpis, .grid-two, .form-grid { grid-template-columns: 1fr; }
  .rule-grid { grid-template-columns: 1fr; }
  .rule-head { flex-direction: column; }
}
