:root {
  color-scheme: dark;
  --bg: #101114;
  --surface: #191b20;
  --surface-2: #21242b;
  --border: #333844;
  --text: #f2f4f8;
  --muted: #aeb6c3;
  --accent: #35c189;
  --accent-strong: #22a978;
  --warning: #f2b84b;
  --danger: #ef6262;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Segoe UI, Arial, sans-serif;
  display: grid;
  grid-template-columns: 260px 1fr;
}

body.locked {
  display: block;
}

body.locked .sidebar,
body.locked .main {
  display: none;
}

body:not(.locked) .login-screen {
  display: none;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  display: grid;
  gap: 16px;
}

.login-card h1 {
  margin-top: 16px;
}

.form-message {
  min-height: 22px;
  color: var(--danger);
}

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

button,
a,
input,
select {
  min-height: 44px;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: #15171c;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #07100c;
  font-weight: 800;
}

.brand small,
.section-heading p,
.topbar p,
td small,
.list-item small {
  color: var(--muted);
}

.brand strong,
.brand small,
td strong,
td small,
.list-item strong,
.list-item small {
  display: block;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 12px 14px;
  border-radius: 8px;
  display: flex;
  align-items: center;
}

.nav a:hover,
.nav a:focus,
.nav a.active {
  background: var(--surface-2);
  color: var(--text);
  outline: none;
}

.main {
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

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

.logout-button {
  width: 100%;
  margin-top: 18px;
}

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

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

h2 {
  font-size: 19px;
  margin-bottom: 4px;
}

.primary-button,
.secondary-button {
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.primary-button {
  background: var(--accent);
  color: #07100c;
}

.secondary-button {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.inline-form,
.stack-form {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-bottom: 16px;
}

.inline-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
}

.stack-form {
  display: grid;
  gap: 10px;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #111319;
  color: var(--text);
  padding: 0 12px;
}

textarea {
  min-height: 86px;
  padding-top: 10px;
  resize: vertical;
}

.check-field {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 8px;
}

.check-field input {
  width: 18px;
  min-height: 18px;
}

.table-action {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  padding: 0 12px;
  cursor: pointer;
}

.table-action.danger {
  border-color: rgba(239, 98, 98, 0.45);
  color: #ff9a9a;
}

.table-action.success {
  border-color: rgba(53, 193, 137, 0.45);
  color: #76e7b8;
}

.source-url {
  overflow-wrap: anywhere;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metrics.compact .metric {
  padding: 14px;
}

.metrics.compact .metric strong {
  font-size: 24px;
}

.metric,
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.metric {
  padding: 18px;
}

.metric span {
  color: var(--muted);
  display: block;
  margin-bottom: 8px;
}

.metric strong {
  font-size: 30px;
}

.section {
  padding: 18px;
  margin-bottom: 18px;
}

.section-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

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

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  border-top: 1px solid var(--border);
  padding: 14px 10px;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.pill.success {
  background: rgba(53, 193, 137, 0.16);
  color: #76e7b8;
}

.pill.muted {
  background: rgba(174, 182, 195, 0.12);
  color: var(--muted);
}

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

.list-item {
  min-height: 64px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface-2);
}

.list-item.stack {
  align-items: flex-start;
}

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

.inline-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.empty {
  color: var(--muted);
  text-align: center;
}

@media (max-width: 920px) {
  body {
    grid-template-columns: 1fr;
  }

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

  .nav {
    grid-template-columns: repeat(6, minmax(110px, 1fr));
    overflow-x: auto;
  }

  .metrics,
  .section-grid {
    grid-template-columns: 1fr 1fr;
  }

  .inline-form {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .main {
    padding: 18px;
  }

  .topbar,
  .top-actions,
  .section-heading {
    display: grid;
  }

  .metrics,
  .section-grid,
  .inline-form {
    grid-template-columns: 1fr;
  }
}
