:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-2: #eef3f5;
  --text: #172026;
  --muted: #68757d;
  --line: #d8e0e4;
  --brand: #006d77;
  --brand-2: #00545c;
  --accent: #f2b84b;
  --ok: #1d8a5a;
  --warn: #b66a00;
  --bad: #b64040;
  --radius: 8px;
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(18, 52, 59, .92);
}

.logged-in .login-screen {
  display: none;
}

.login-card {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  padding: 22px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.login-card h2 {
  margin-bottom: 0;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 28px;
  background: #12343b;
  color: #fff;
}

.eyebrow {
  margin: 0 0 4px;
  color: #b8d3d8;
  font-size: 13px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
}

h2 {
  margin-bottom: 6px;
  font-size: 24px;
}

h3 {
  margin-bottom: 14px;
  font-size: 17px;
}

.title-count {
  margin-left: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.today {
  min-width: 138px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: var(--radius);
  text-align: right;
}

.user-box {
  min-width: 150px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: var(--radius);
}

.user-box span {
  display: block;
  color: #b8d3d8;
  font-size: 12px;
}

.logout-button {
  margin-top: 6px;
  min-height: 28px;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: var(--radius);
  background: transparent;
  color: #fff;
  cursor: pointer;
}

.today span {
  display: block;
  color: #b8d3d8;
  font-size: 12px;
}

.app-shell {
  width: min(1220px, calc(100% - 28px));
  margin: 18px auto 34px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
}

.tab {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}

.tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.tight-head {
  margin-bottom: 10px;
}

.section-head p {
  margin-bottom: 0;
  color: var(--muted);
}

.section-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

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

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.panel,
.form-panel,
.scan-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.panel + .panel {
  margin-top: 14px;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-title-row h3 {
  margin-bottom: 0;
}

.global-table-filter {
  width: min(320px, 100%);
}

.form-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

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

input,
select {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 10px;
  color: var(--text);
  background: #fff;
}

.primary-button,
.ghost-button,
.danger-button,
.small-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 700;
}

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

.primary-button:hover {
  background: var(--brand-2);
}

.ghost-button {
  background: var(--surface);
  border-color: var(--brand);
  color: var(--brand);
}

.ghost-link {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  padding: 9px 14px;
  background: var(--surface);
  color: var(--brand);
  font-weight: 700;
  text-decoration: none;
}

.danger-button {
  background: #fff3f3;
  border-color: #efcaca;
  color: var(--bad);
}

.small-button {
  min-height: 30px;
  padding: 5px 9px;
  background: #fff;
  border-color: #efcaca;
  color: var(--bad);
  font-size: 12px;
}

.hidden {
  display: none;
}

.breakdown {
  display: grid;
  gap: 10px;
}

.breakdown-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 10px;
  background: var(--surface-2);
  border-radius: var(--radius);
}

.breakdown-row span {
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
}

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

.filter-row th {
  padding-top: 0;
}

.table-filter {
  width: 100%;
  min-width: 92px;
  min-height: 30px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  text-transform: none;
}

.notes-cell {
  display: grid;
  gap: 5px;
  min-width: 130px;
}

.notes-cell span {
  max-width: 220px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface-2);
}

.badge.ok {
  background: #e5f4ec;
  color: var(--ok);
}

.badge.warn {
  background: #fff2da;
  color: var(--warn);
}

.badge.bad {
  background: #ffe7e7;
  color: var(--bad);
}

.empty-state {
  padding: 18px;
  background: var(--surface-2);
  border-radius: var(--radius);
  color: var(--muted);
}

.scan-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 14px;
  margin-bottom: 14px;
}

.single-scan {
  grid-template-columns: 1fr;
}

.scan-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

.scan-result {
  grid-column: 1 / -1;
  min-height: 42px;
  border-radius: var(--radius);
  padding: 12px;
  font-weight: 700;
}

.scan-result.neutral {
  background: var(--surface-2);
  color: var(--muted);
}

.scan-result.ok {
  background: #e5f4ec;
  color: var(--ok);
}

.scan-result.warn {
  background: #fff2da;
  color: var(--warn);
}

.scan-result.bad {
  background: #ffe7e7;
  color: var(--bad);
}

.scan-result.alarm {
  animation: alarmPulse .8s ease-in-out 2;
  background: #b64040;
  color: #fff;
}

@keyframes alarmPulse {
  0% {
    transform: translateX(0);
  }

  20% {
    transform: translateX(-8px);
  }

  40% {
    transform: translateX(8px);
  }

  60% {
    transform: translateX(-5px);
  }

  80% {
    transform: translateX(5px);
  }

  100% {
    transform: translateX(0);
  }
}

.compact-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: flex-start;
}

.compact-panel h3 {
  width: 100%;
}

.code-chip {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 8px 10px;
  cursor: pointer;
}

.plain-list {
  margin: 0;
  padding-left: 18px;
  color: var(--text);
}

.plain-list li {
  margin-bottom: 8px;
}

.config-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.inline-form {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.reason-select {
  min-height: 30px;
  min-width: 130px;
  padding: 5px 8px;
  font-size: 12px;
}

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

.ml-warning-cell {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-top: 4px;
  padding: 3px 8px;
  border: 1px solid var(--bad);
  border-radius: 999px;
  background: #ffe7e7;
  color: var(--bad);
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 860px) {
  .topbar,
  .section-head {
    flex-direction: column;
  }

  .today {
    text-align: left;
  }

  .metric-grid,
  .two-column,
  .form-panel,
  .scan-layout,
  .scan-box {
    grid-template-columns: 1fr;
  }
}
