:root {
  color-scheme: light;
  --navy: #22364c;
  --navy-2: #182b3f;
  --ink: #1d2939;
  --muted: #667892;
  --line: #dce4ed;
  --canvas: #f4f7fb;
  --card: #ffffff;
  --teal: #11b8aa;
  --teal-soft: #e9f9f7;
  --blue: #2e67e8;
  --blue-soft: #edf3ff;
  --green: #17b764;
  --green-soft: #eaf9f0;
  --amber: #d68518;
  --amber-soft: #fff5df;
  --red: #d83d4b;
  --red-soft: #fff0f1;
  font-family: "Segoe UI", Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  min-width: 320px;
}

button, input, select { font: inherit; }

button {
  min-height: 42px;
  border-radius: 10px;
  padding: 0 16px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 650;
}

button:disabled { opacity: .5; cursor: wait; }

.primary { background: var(--blue); color: white; }
.secondary { background: white; border-color: var(--line); color: var(--ink); }
.danger-text { color: var(--red); }

.button-link {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  padding: 0 16px;
  color: white;
  background: var(--teal);
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
}

.button-link:focus-visible {
  outline: 3px solid rgba(17, 184, 170, .2);
}

input, select {
  min-height: 44px;
  border: 1px solid #cbd6e2;
  border-radius: 10px;
  padding: 0 12px;
  color: var(--ink);
  background: white;
}

input:focus, select:focus, button:focus-visible {
  outline: 3px solid rgba(46, 103, 232, .18);
  border-color: var(--blue);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 78% 20%, rgba(17, 184, 170, .18), transparent 32%),
    linear-gradient(145deg, var(--navy-2), var(--navy));
}

.login-card {
  width: min(440px, 100%);
  padding: 42px 38px 36px;
  border-radius: 22px;
  background: rgba(255, 255, 255, .98);
  box-shadow: 0 24px 80px rgba(7, 23, 40, .3);
}

.login-brand {
  display: grid;
  justify-items: center;
  gap: 12px;
  margin-bottom: 34px;
}

.login-logo {
  display: block;
  width: 126px;
  height: auto;
}

.login-brand strong {
  color: var(--navy-2);
  font-size: 46px;
  line-height: 1;
  font-weight: 750;
  letter-spacing: -1.5px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand strong { display: block; font-size: 19px; }
.brand small { display: block; color: var(--muted); margin-top: 2px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  color: white;
  font-weight: 900;
  font-size: 22px;
  background: linear-gradient(145deg, var(--teal), var(--blue));
}

.login-card form { display: grid; gap: 12px; }
.login-card button { margin-top: 4px; }

.password-field {
  position: relative;
  display: flex;
}

.password-field input {
  width: 100%;
  padding-right: 82px;
}

.password-field .password-toggle {
  position: absolute;
  right: 5px;
  top: 5px;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 12px;
}

.error { min-height: 20px; color: var(--red); font-size: 13px; }
.app-shell { min-height: 100vh; }

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px max(24px, calc((100vw - 1500px) / 2));
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.toolbar { display: flex; gap: 10px; align-items: center; }
.toolbar.wrap { flex-wrap: wrap; justify-content: flex-end; }
.signed-in-user {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.content {
  width: min(1500px, calc(100% - 48px));
  margin: 26px auto 60px;
  display: grid;
  gap: 22px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 14px;
}

.summary-grid article {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 16px;
  padding: 18px;
}

.summary-grid small { display: block; color: var(--muted); margin-bottom: 8px; }
.summary-grid strong { font-size: 28px; }
.summary-grid .attention { background: var(--amber-soft); border-color: #f3dba7; }

.health-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(210px, 1fr));
  gap: 14px;
  padding: 20px;
}

.health-card {
  min-height: 126px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.health-card-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.health-card p {
  min-height: 38px;
  margin: 13px 0 8px;
  color: var(--ink);
  line-height: 1.4;
}

.health-card small { color: var(--muted); }
.health-alert-title { border-top: 1px solid var(--line); }
.health-alert.good { border-left: 4px solid var(--green); }
.health-alert.warn { border-left: 4px solid var(--amber); }
.health-alert.bad { border-left: 4px solid var(--red); }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 22px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.panel-header h1, .panel-header h2, .panel-header p { margin: 0; }
.panel-header p { color: var(--muted); margin-top: 5px; }
.search input { width: min(290px, 30vw); }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 920px; }
th, td { text-align: left; padding: 14px 18px; border-bottom: 1px solid #edf1f5; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
tbody tr { cursor: pointer; }
tbody tr:hover, tbody tr.selected { background: #f6f9ff; }
td strong, td small { display: block; }
td small { color: var(--muted); margin-top: 4px; }

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--blue-soft);
  color: var(--blue);
}

.status.good { background: var(--green-soft); color: var(--green); }
.status.warn { background: var(--amber-soft); color: var(--amber); }
.status.bad { background: var(--red-soft); color: var(--red); }

.empty { text-align: center; color: var(--muted); padding: 28px; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: 12px; color: var(--blue) !important; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  padding: 20px;
}

.subpanel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
}

.subpanel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 17px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}

.subpanel-title h3 { margin: 0; font-size: 16px; }
.badge { padding: 3px 9px; border-radius: 999px; background: var(--blue-soft); color: var(--blue); font-size: 12px; }
.stack > * + * { border-top: 1px solid #edf1f5; }

.row-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 17px;
}

.row-card strong, .row-card small { display: block; }
.row-card small { color: var(--muted); margin-top: 4px; }
.row-actions { display: flex; gap: 8px; align-items: center; }
.row-actions button, .row-actions a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 11px;
  background: white;
  text-decoration: none;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.audit-panel { margin: 0 20px 20px; }
.compact .row-card { padding-block: 11px; }
.muted { color: var(--muted); }

dialog {
  width: min(510px, calc(100% - 32px));
  border: 0;
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 28px 90px rgba(15, 30, 48, .3);
}

dialog::backdrop { background: rgba(16, 31, 48, .55); backdrop-filter: blur(2px); }
dialog form { display: grid; gap: 15px; }
dialog label { display: grid; gap: 7px; font-size: 13px; font-weight: 650; }
.form-fields { display: grid; gap: 15px; }
.dialog-header { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
.dialog-header h2, .dialog-header p { margin: 0; }
.dialog-header p { color: var(--muted); margin-top: 5px; }
.password-hint {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.icon-button { width: 38px; min-height: 38px; padding: 0; background: #f2f5f8; font-size: 22px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.one-time-code {
  padding: 18px;
  border: 1px dashed var(--blue);
  border-radius: 12px;
  background: var(--blue-soft);
  color: var(--blue);
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: .07em;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 430px;
  background: var(--navy);
  color: white;
  padding: 14px 18px;
  border-radius: 12px;
  box-shadow: 0 15px 45px rgba(8, 25, 42, .25);
  z-index: 20;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1050px) {
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
  .health-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
  .panel-header { align-items: flex-start; flex-direction: column; }
  .panel-header .toolbar { width: 100%; }
  .search { flex: 1; }
  .search input { width: 100%; }
}

@media (max-width: 680px) {
  .topbar { align-items: flex-start; }
  .topbar .brand small { display: none; }
  .content { width: min(100% - 24px, 1500px); margin-top: 12px; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .health-grid { grid-template-columns: 1fr; padding: 12px; }
  .panel-header { padding: 16px; }
  .panel-header .toolbar { flex-wrap: wrap; }
  .panel-header .toolbar > * { flex: 1 1 160px; }
  .detail-grid { padding: 12px; }
  .audit-panel { margin: 0 12px 12px; }
}
