:root {
  color-scheme: dark;
  --bg: #090b0e;
  --surface: #14171b;
  --surface-2: #1b2026;
  --line: #2a3038;
  --line-soft: #20262d;
  --text: #f4f7fb;
  --muted: #98a2af;
  --muted-2: #6f7a87;
  --blue: #4d8dff;
  --green: #1fd08d;
  --red: #ff5d68;
  --amber: #f2a900;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #111418;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #1f5eff;
  color: white;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 4px;
  padding: 14px 10px;
}

.nav-item {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text);
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--amber);
}

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

.status-dot.error {
  background: var(--red);
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 11, 14, 0.92);
  backdrop-filter: blur(14px);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 15px;
  line-height: 1.3;
}

.topbar p {
  margin-top: 4px;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.content {
  padding: 24px 28px 40px;
}

.hidden {
  display: none !important;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.login-panel {
  min-height: calc(100vh - 82px);
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-box {
  width: min(440px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-box h2 {
  margin-bottom: 18px;
  font-size: 21px;
}

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

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

input,
select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1014;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(77, 141, 255, 0.16);
}

.primary-button,
.ghost-button,
.icon-button {
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--text);
}

.primary-button {
  padding: 0 16px;
  border-color: #2e67d9;
  background: var(--blue);
  font-weight: 700;
}

.ghost-button {
  padding: 0 14px;
  background: var(--surface);
}

.icon-button {
  width: 40px;
  display: grid;
  place-items: center;
  background: var(--surface);
  font-size: 20px;
}

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

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

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 30px;
  line-height: 1;
}

.metric small {
  display: block;
  margin-top: 9px;
  color: var(--muted-2);
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.panel {
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 52px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.inline-form,
.grid-form {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

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

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

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  height: 44px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #101318;
  color: var(--muted);
  font-size: 12px;
}

.badge.ok {
  border-color: rgba(31, 208, 141, 0.28);
  background: rgba(31, 208, 141, 0.12);
  color: #7ff0c4;
}

.badge.error {
  border-color: rgba(255, 93, 104, 0.3);
  background: rgba(255, 93, 104, 0.12);
  color: #ff9ca3;
}

.badge.warn {
  border-color: rgba(242, 169, 0, 0.3);
  background: rgba(242, 169, 0, 0.12);
  color: #ffd36a;
}

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

.empty {
  padding: 28px 16px;
  color: var(--muted);
  text-align: center;
}

.alert {
  margin: 18px 28px 0;
  padding: 12px 14px;
  border: 1px solid rgba(255, 93, 104, 0.3);
  border-radius: 8px;
  background: rgba(255, 93, 104, 0.12);
  color: #ffb6bc;
}

@media (max-width: 1120px) {
  .summary-grid,
  .two-column,
  .inline-form,
  .grid-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .content {
    padding: 18px;
  }

  .alert {
    margin: 18px 18px 0;
  }

  .summary-grid,
  .two-column,
  .inline-form,
  .grid-form {
    grid-template-columns: 1fr;
  }
}
