* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #fafbff;
  --line: #dde3ef;
  --soft-line: #edf1f7;
  --text: #18202f;
  --muted: #667085;
  --brand: #5365a0;
  --brand-hover: #45568c;
  --brand-soft: #eef2ff;
  --green: #16875a;
  --green-bg: #e8f7ee;
  --amber: #b86e00;
  --amber-bg: #fff7e8;
  --blue: #315f9e;
  --blue-bg: #eaf1fb;
  --red: #b42318;
  --red-bg: #fff0ed;
  --gray-bg: #eef1f6;
  --shadow: 0 8px 24px rgba(26, 37, 62, 0.06);
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 13px;
  overflow-x: hidden;
}

.topbar {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 26px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand-row,
.session-area,
.topnav {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-row strong {
  font-size: 14px;
}

.topnav a {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 10px;
  border-radius: 6px;
  color: #4a5266;
  text-decoration: none;
  font-weight: 600;
}

.topnav a:hover,
.topnav a.active {
  color: var(--brand);
  background: var(--brand-soft);
}

.session-area span {
  color: var(--muted);
  font-size: 12px;
}

.content {
  padding: 22px 26px 28px;
}

button {
  min-height: 32px;
  border: 0;
  border-radius: 7px;
  padding: 0 14px;
  color: #ffffff;
  background: var(--brand);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

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

input,
select {
  height: 34px;
  width: 100%;
  border: 1px solid #c6cedd;
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  outline: none;
}

input {
  padding: 0 10px;
}

select {
  padding: 0 9px;
}

input:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(83, 101, 160, 0.14);
}

label {
  display: block;
  margin: 0;
  min-width: 0;
  color: #394153;
  font-size: 12px;
  font-weight: 700;
}

label input,
label select {
  margin-top: 6px;
}

.login-panel {
  max-width: 380px;
  margin: 8vh auto;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel h1,
.page-head h1,
.panel h2 {
  margin: 0;
  line-height: 1.2;
}

.login-panel h1,
.page-head h1 {
  font-size: 20px;
}

.panel h2 {
  font-size: 15px;
}

.login-panel form {
  display: grid;
  gap: 14px;
}

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

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

.page-actions {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 12px;
  text-align: right;
}

.download-btn {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  padding: 0 12px;
  color: #ffffff;
  background: var(--brand);
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.download-btn:hover {
  background: var(--brand-hover);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.filters,
.panel {
  margin: 0 0 14px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.filters {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 140px 130px 130px 150px 130px auto auto;
  gap: 10px;
  align-items: end;
}

.clear-link {
  display: inline-flex;
  height: 32px;
  align-items: center;
  color: var(--brand);
  font-weight: 700;
  text-decoration: none;
}

.table-action {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  padding: 0 14px;
  color: #4f5f92;
  background: #eef1f7;
  font-weight: 800;
  text-decoration: none;
}

.table-action:hover {
  background: #e3e8f4;
}

.table-shell {
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
  table-layout: fixed;
}

.security-table {
  min-width: 860px;
}

.security-table th,
.security-table td {
  width: auto;
}

th,
td {
  height: 44px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--soft-line);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

th {
  height: 40px;
  color: #485064;
  background: var(--panel-soft);
  font-size: 12px;
  font-weight: 800;
}

tbody tr:hover {
  background: #fbfcff;
}

.id {
  font-weight: 800;
}

.alias-form {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.alias-text {
  display: inline-block;
  min-width: 0;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alias-editor {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(24, 32, 47, 0.22);
}

.alias-dialog {
  width: min(440px, calc(100vw - 32px));
  display: grid;
  gap: 16px;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(24, 32, 47, 0.22);
}

.alias-dialog > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.alias-dialog span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.alias-dialog label {
  display: grid;
  gap: 8px;
  width: 100%;
}

.alias-dialog input {
  width: 100%;
  margin-top: 0;
}

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

.alias-form > button {
  min-height: 30px;
  padding: 0 11px;
}

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

.row-actions form {
  margin: 0;
}

.row-actions button {
  min-height: 30px;
  padding: 0 11px;
}

.ghost-btn,
.archive-btn,
.connect-btn {
  background: #eef1f7;
  color: #4f5f92;
}

.ghost-btn:hover,
.archive-btn:hover,
.connect-btn:hover {
  background: #e3e8f4;
}

.connect-btn {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  padding: 0 11px;
  font-weight: 800;
  text-decoration: none;
}

.permissions-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(24, 32, 47, 0.24);
}

.permissions-dialog {
  width: min(520px, calc(100vw - 32px));
  display: grid;
  gap: 14px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(24, 32, 47, 0.22);
}

.permissions-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.permissions-head div {
  display: grid;
  gap: 4px;
}

.permissions-head span,
.permissions-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.permissions-list {
  display: grid;
  gap: 8px;
}

.permission-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid var(--soft-line);
  border-radius: 7px;
  background: var(--panel-soft);
}

.permission-ok,
.permission-bad {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
}

.permission-ok {
  color: #197642;
  background: var(--green-bg);
}

.permission-bad {
  color: var(--red);
  background: var(--red-bg);
}

.restore-btn {
  background: var(--green-bg);
  color: #197642;
}

.restore-btn:hover {
  background: #d8f0e1;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
}

.status-pill.online {
  color: #197642;
  background: var(--green-bg);
}

.status-pill.offline {
  color: #667085;
  background: var(--gray-bg);
}

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

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #a9afbd;
}

.dot.online {
  background: var(--green);
}

.stack-form {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

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

.user-form-grid {
  grid-template-columns: minmax(160px, 1fr) minmax(200px, 1.2fr) minmax(180px, 1fr) minmax(180px, 1fr);
}

.form-grid.two {
  grid-template-columns: minmax(220px, 320px) minmax(260px, 1fr);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 10px;
}

.module-access-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
}

.module-card {
  min-height: 86px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  cursor: pointer;
}

.module-card input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  flex: 0 0 auto;
}

.module-card span {
  display: grid;
  gap: 5px;
}

.module-card strong {
  color: var(--text);
  font-size: 13px;
}

.module-card small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
}

fieldset {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

legend {
  padding: 0 5px;
  font-weight: 800;
}

fieldset p {
  min-height: 34px;
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 0;
  font-weight: 600;
}

.check-row.inline {
  justify-content: flex-start;
}

.check-row input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.notice {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 8px;
  font-weight: 700;
}

.notice.success {
  color: #197642;
  background: var(--green-bg);
}

.notice.error,
.error {
  color: var(--red);
}

.notice.error {
  background: var(--red-bg);
}

.empty-state {
  max-width: 540px;
  margin: 12vh auto;
  padding: 24px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric-grid,
.hero-metrics {
  display: grid;
  gap: 12px;
}

.metric-grid {
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  margin-bottom: 14px;
}

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(360px, 1.1fr) minmax(520px, 2fr);
  gap: 14px;
  margin-bottom: 14px;
}

.health-card {
  min-height: 132px;
  display: grid;
  grid-template-columns: 112px 1fr;
  align-items: center;
  gap: 18px;
  padding: 18px;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid #d8e0ec;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(27, 40, 70, 0.08);
}

.health-card h2,
.health-card p {
  margin: 0;
}

.health-card h2 {
  margin-bottom: 6px;
  font-size: 20px;
}

.health-card p:not(.eyebrow) {
  color: var(--muted);
  font-weight: 700;
  line-height: 1.4;
}

.score-ring,
.mini-donut {
  display: grid;
  place-items: center;
  border-radius: 999px;
  background:
    radial-gradient(circle at center, var(--panel) 0 58%, transparent 59%),
    conic-gradient(var(--score-color, var(--green)) calc(var(--score) * 1%), #d9e0ea 0);
}

.score-ring.good,
.mini-donut {
  --score-color: var(--green);
}

.score-ring.warn {
  --score-color: var(--amber);
}

.score-ring.bad {
  --score-color: var(--red);
}

.score-ring {
  width: 112px;
  height: 112px;
}

.score-ring strong,
.mini-donut strong {
  font-size: 28px;
  line-height: 1;
}

.score-ring span,
.mini-donut span {
  margin-top: -24px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.hero-metrics {
  grid-template-columns: repeat(4, minmax(120px, 1fr));
}

.metric-card,
.dashboard-panel {
  background: var(--panel);
  border: 1px solid #d9e1ed;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(27, 40, 70, 0.055);
}

.metric-card {
  min-height: 104px;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 14px;
  border-left: 4px solid #8a97ad;
}

.metric-card span,
.metric-card small {
  color: var(--muted);
  font-weight: 700;
}

.metric-card strong {
  font-size: 26px;
  line-height: 1;
}

.metric-good {
  border-left-color: var(--green);
}

.metric-warn {
  border-left-color: var(--amber);
}

.metric-neutral {
  border-left-color: var(--blue);
}

.metric-danger {
  border-left-color: var(--red);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 14px;
}

.dashboard-panel {
  min-width: 0;
  padding: 14px;
}

.dashboard-wide {
  grid-column: span 2;
}

.dashboard-panel {
  min-height: 0;
}

.panel-head {
  display: flex;
  min-height: 38px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1.2;
}

.panel-head strong {
  color: var(--blue);
  white-space: nowrap;
}

.donut-row {
  display: grid;
  grid-template-columns: 150px 1fr;
  align-items: center;
  gap: 18px;
}

.donut {
  width: 150px;
  height: 150px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background:
    radial-gradient(circle at center, var(--panel) 0 55%, transparent 56%),
    conic-gradient(var(--green) calc(var(--online) * 1%), #d8dee9 0);
}

.donut span {
  font-size: 24px;
  font-weight: 900;
}

.legend-list {
  display: grid;
  gap: 10px;
}

.legend-list div {
  display: grid;
  grid-template-columns: 12px auto 1fr;
  align-items: center;
  gap: 8px;
}

.legend-list small {
  color: var(--muted);
  font-weight: 700;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.legend-dot.green {
  background: var(--green);
}

.legend-dot.gray {
  background: #9ca7b8;
}

.legend-dot.orange {
  background: var(--amber);
}

.legend-inline {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 12px;
}

.stacked-bar {
  height: 16px;
  display: flex;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf5;
}

.stacked-bar span {
  min-width: 2px;
}

.stacked-bar .green {
  background: var(--green);
}

.stacked-bar .gray {
  background: #9ca7b8;
}

.stacked-bar .orange {
  background: var(--amber);
}

.bar-list {
  display: grid;
  gap: 12px;
}

.compact-bars {
  gap: 9px;
}

.bar-row {
  display: grid;
  gap: 6px;
}

.bar-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 800;
}

.bar-label span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf5;
}

.bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.current-version .bar-track span {
  background: var(--green);
}

.version-layout {
  display: grid;
  grid-template-columns: 112px 1fr;
  align-items: center;
  gap: 18px;
}

.mini-donut {
  width: 112px;
  height: 112px;
}

.alert-list {
  display: grid;
  gap: 10px;
}

.alert-list a {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 2px 10px;
  padding: 10px 12px;
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.alert-list a:hover {
  border-color: #cbd4e5;
  background: #ffffff;
}

.alert-list strong {
  grid-row: span 2;
  align-self: center;
  font-size: 24px;
  line-height: 1;
}

.alert-list span {
  font-weight: 900;
}

.alert-list small {
  color: var(--muted);
  line-height: 1.3;
}

.compact-table {
  box-shadow: none;
}

.compact-table table {
  min-width: 760px;
}

.compact-table th,
.compact-table td {
  width: auto;
}

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

.issue-tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 900;
}

.issue-tag.warn {
  color: #8a5300;
  background: var(--amber-bg);
}

.issue-tag.bad {
  color: var(--red);
  background: var(--red-bg);
}

.issue-tag.neutral {
  color: var(--blue);
  background: var(--blue-bg);
}

.issue-tag.muted {
  color: var(--muted);
  background: var(--gray-bg);
}

th:nth-child(1),
td:nth-child(1) {
  width: 34px;
}

th:nth-child(2),
td:nth-child(2) {
  width: 130px;
}

th:nth-child(3),
td:nth-child(3) {
  width: 300px;
  overflow: visible;
}

th:nth-child(4),
td:nth-child(4) {
  width: 100px;
}

th:nth-child(5),
td:nth-child(5) {
  width: 100px;
}

th:nth-child(6),
td:nth-child(6) {
  width: 190px;
}

th:nth-child(7),
td:nth-child(7) {
  width: 80px;
}

th:nth-child(8),
td:nth-child(8) {
  width: 190px;
}

th:nth-child(9),
td:nth-child(9) {
  width: 330px;
}

.security-table th,
.security-table td {
  width: auto;
}

@media (max-width: 1000px) {
  .dashboard-hero,
  .metric-grid,
  .dashboard-grid {
    grid-template-columns: 1fr 1fr;
  }

  .health-card,
  .dashboard-wide {
    grid-column: span 2;
  }

  .filters,
  .form-grid,
  .form-grid.two,
  .permission-grid,
  .module-access-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .topbar,
  .brand-row,
  .session-area {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    padding: 12px 16px;
  }

  .content {
    padding: 16px;
  }

  .page-head,
  .page-actions,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-grid,
  .dashboard-hero,
  .dashboard-grid,
  .health-card,
  .dashboard-wide {
    grid-template-columns: 1fr;
    grid-column: span 1;
  }

  .health-card,
  .version-layout {
    justify-items: center;
    text-align: center;
  }

  .hero-metrics,
  .legend-inline,
  .version-layout {
    grid-template-columns: 1fr;
  }

  .donut-row {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .filters,
  .form-grid,
  .form-grid.two,
  .permission-grid,
  .module-access-grid {
    grid-template-columns: 1fr;
  }
}
