:root {
  --blue: #0b74b8;
  --blue-dark: #075f95;
  --border: #d8e1ea;
  --soft: #f7fafc;
  --text: #0f172a;
  --muted: #64748b;
  --green: #15803d;
  --red: #b91c1c;
  --amber: #b45309;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #eef3f8;
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: var(--blue);
  text-decoration: none;
}

h1,
h2,
h3 {
  margin: 0 0 8px;
  line-height: 1.15;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  min-height: 38px;
  padding: 8px 10px;
  background: #fff;
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 5px;
  font-weight: 700;
  color: #334155;
}

.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: #0f172a;
  color: #fff;
}

.brand {
  color: #fff;
  font-size: 18px;
  font-weight: 800;
}

.userbar,
.toolbar,
.hero-row,
.section-head,
.actions-cell,
.list-row,
.bulkbar,
.pager {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.userbar em {
  color: #cbd5e1;
  font-style: normal;
}

.wrap {
  width: min(1540px, calc(100% - 32px));
  margin: 18px auto 40px;
}

.panel,
.auth-panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  margin: 14px 0;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
}

.auth-panel {
  max-width: 420px;
  margin: 80px auto;
}

.safe {
  border-left: 5px solid var(--green);
}

.warning {
  border-left: 5px solid #f59e0b;
}

.danger {
  border-left: 5px solid #dc2626;
}

.notice {
  background: #dcfce7;
  border: 1px solid #86efac;
  border-radius: 8px;
  color: #166534;
  margin: 12px 0;
  padding: 10px 12px;
}

.notice.error {
  background: #fee2e2;
  border-color: #fecaca;
  color: #991b1b;
}

.muted {
  color: var(--muted);
}

.mono,
.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.mono {
  background: #eef6ff;
  border-radius: 5px;
  color: #164e63;
  display: inline-block;
  padding: 3px 5px;
}

.code {
  background: #eef2ff;
  border-radius: 5px;
  color: #3730a3;
  padding: 2px 5px;
}

.button {
  align-items: center;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  color: #1e293b;
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  min-height: 36px;
  padding: 7px 12px;
  white-space: nowrap;
}

.button-primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.button-primary:hover {
  background: var(--blue-dark);
}

.button-danger {
  color: var(--red);
}

.button-light {
  background: transparent;
  color: #fff;
}

.push {
  margin-left: auto;
}

.hero-row {
  justify-content: space-between;
}

.stack {
  display: grid;
  gap: 12px;
}

.import-grid,
.filter-grid,
.edit-grid {
  display: grid;
  gap: 12px;
}

.import-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.filter-grid {
  align-items: end;
  grid-template-columns: 0.8fr 0.8fr 1.5fr 1.6fr 0.7fr auto;
}

.edit-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.form-actions {
  align-self: end;
}

.kpis {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.kpis div {
  background: #0f172a;
  border-radius: 8px;
  color: #fff;
  padding: 14px 16px;
}

.kpis .bad {
  background: #991b1b;
}

.kpis .warn {
  background: #9a4b0b;
}

.kpis span {
  display: block;
  font-size: 12px;
  opacity: 0.9;
}

.kpis strong {
  display: block;
  font-size: 26px;
}

.table {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-collapse: separate;
  border-radius: 8px;
  border-spacing: 0;
  overflow: hidden;
  width: 100%;
}

.table th,
.table td {
  border-bottom: 1px solid #e5e7eb;
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

.table th {
  background: var(--soft);
  color: #334155;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.table tr:last-child td {
  border-bottom: 0;
}

.table tr.high,
.table tr.excluded {
  background: #fff7f7;
}

.table tr.medium {
  background: #fffbeb;
}

.table tr.excluded {
  opacity: 0.65;
}

.table.compact td,
.table.compact th {
  padding: 7px 8px;
}

.badge {
  align-items: center;
  background: #f1f5f9;
  border-radius: 999px;
  color: #334155;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  gap: 5px;
  line-height: 1;
  margin: 2px;
  padding: 5px 9px;
  text-transform: capitalize;
}

.badge.ok {
  background: #dcfce7;
  color: #166534;
}

.badge.warn {
  background: #fef3c7;
  color: #92400e;
}

.badge.bad {
  background: #fee2e2;
  color: #991b1b;
}

.badge.info {
  background: #dbeafe;
  color: #1e40af;
}

.bulkbar {
  background: var(--soft);
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin: 12px 0;
  padding: 10px;
}

.bulkbar input[type="text"] {
  max-width: 360px;
}

.inline {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.inline input[type="checkbox"] {
  min-height: auto;
  width: auto;
}

.admin-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.list-row {
  justify-content: space-between;
  border-top: 1px solid #e5e7eb;
  padding: 10px 0;
}

.merge-group {
  border-top: 1px solid #e5e7eb;
  padding: 14px 0;
}

.raw {
  background: #0f172a;
  border-radius: 8px;
  color: #e2e8f0;
  max-height: 420px;
  overflow: auto;
  padding: 14px;
}

.issue-line {
  margin: 6px 0;
}

@media (max-width: 1100px) {
  .filter-grid,
  .edit-grid,
  .import-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 760px) {
  .wrap {
    width: min(100% - 20px, 1540px);
  }

  .topbar,
  .hero-row,
  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .filter-grid,
  .edit-grid,
  .import-grid,
  .kpis {
    grid-template-columns: 1fr;
  }

  .table {
    display: block;
    overflow-x: auto;
  }

  .push {
    margin-left: 0;
  }
}
