:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --panel-2: #eef6f8;
  --text: #17202a;
  --muted: #657487;
  --line: #d9e2ea;
  --accent: #0f766e;
  --accent-2: #155e75;
  --warn: #b45309;
  --danger: #b91c1c;
  --ok: #15803d;
  --shadow: 0 12px 30px rgba(17, 24, 39, 0.08);
}

body.dark {
  color-scheme: dark;
  --bg: #101418;
  --panel: #171d22;
  --panel-2: #202a31;
  --text: #edf3f7;
  --muted: #9aa8b5;
  --line: #2e3a43;
  --accent: #2dd4bf;
  --accent-2: #38bdf8;
  --warn: #f59e0b;
  --danger: #f87171;
  --ok: #4ade80;
  --shadow: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

a {
  color: var(--accent-2);
}

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

button {
  border: 0;
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  min-height: 38px;
}

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

button.danger {
  background: var(--danger);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

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

textarea {
  min-height: 130px;
  resize: vertical;
}

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

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

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

.login h1,
.page-title h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

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

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

.sidebar {
  background: #111827;
  color: #e5edf5;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand {
  font-weight: 800;
  font-size: 18px;
  padding: 8px 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

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

.nav button {
  width: 100%;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  border: 1px solid transparent;
}

.nav button.active,
.nav button:hover {
  background: rgba(45, 212, 191, 0.12);
  border-color: rgba(45, 212, 191, 0.25);
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.main {
  min-width: 0;
  padding: 22px;
}

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

.page-title {
  display: grid;
  gap: 4px;
}

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

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  gap: 16px;
}

.cols-2 {
  grid-template-columns: minmax(320px, 0.8fr) minmax(0, 1.2fr);
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
  min-width: 0;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 16px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.metric .value {
  font-size: 25px;
  font-weight: 800;
  margin-top: 6px;
}

.metric .label {
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

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

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

td.mono,
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

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

.badge.active,
.badge.ok {
  color: var(--ok);
}

.badge.paused,
.badge.warn {
  color: var(--warn);
}

.badge.deleted,
.badge.error {
  color: var(--danger);
}

.row-actions {
  display: flex;
  gap: 6px;
}

.row-actions button {
  min-height: 30px;
  padding: 5px 8px;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 180px 140px;
  gap: 10px;
  margin-bottom: 12px;
}

.split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.alert {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
  margin-bottom: 14px;
}

.error-text {
  color: var(--danger);
  font-weight: 700;
}

.ok-text {
  color: var(--ok);
  font-weight: 700;
}

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

.bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 55px;
  gap: 10px;
  align-items: center;
}

.bar-track {
  height: 10px;
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--accent-2);
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 3;
  }

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

  .cols-2,
  .cols-3,
  .filters {
    grid-template-columns: 1fr;
  }
}
