:root {
  --bg: #090f1b;
  --bg-soft: #0f1729;
  --bg-card: #131f35;
  --line: #2a3f63;
  --line-soft: #243753;
  --text: #eaf1ff;
  --muted: #9cb1d3;
  --ok: #27c07d;
  --warn: #ffbe3b;
  --bad: #ff5a5a;
  --accent: #1d8dff;
  --accent-2: #11b5a9;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--text);
  font-family: "Segoe UI", "Trebuchet MS", "Lucida Grande", sans-serif;
  background: radial-gradient(circle at 10% -20%, #1d2f4e 0%, var(--bg) 55%);
}

.hidden { display: none !important; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(460px, 100%);
  padding: 24px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #13233e, #0f1a2f);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.45);
}

.login-card h1 { margin-top: 0; }

label {
  display: block;
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 13px;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  padding: 10px;
  color: var(--text);
  background: #0c1630;
}

textarea { resize: vertical; }

.error {
  color: #ffa3a3;
  min-height: 20px;
  margin-bottom: 0;
}

.btn-primary, .btn-secondary, .btn-danger, .btn-ghost {
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 600;
  color: #fff;
}

.btn-primary { background: linear-gradient(180deg, #329eff, #1177e3); }
.btn-secondary { background: linear-gradient(180deg, #50607f, #394963); }
.btn-danger { background: linear-gradient(180deg, #ff6a6a, #d74141); }
.btn-ghost { background: rgba(255,255,255,0.08); border: 1px solid var(--line-soft); }

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 13, 25, 0.82);
  backdrop-filter: blur(10px);
}

.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  width: 12px;
  height: 36px;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
}
.title { font-size: 20px; font-weight: 700; }
.subtitle { color: var(--muted); font-size: 12px; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.lang-switch { width: 74px; }

.main-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 74px);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #0c1527 0%, #0a1221 100%);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-btn {
  text-align: left;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  padding: 12px;
  cursor: pointer;
}

.nav-btn.active {
  border-color: #3a4f74;
  background: linear-gradient(90deg, rgba(29,141,255,0.28), rgba(17,181,169,0.12));
}

.nav-btn.danger { color: #ff9f9f; }

.content { padding: 18px; }
.tab { display: none; }
.tab.active { display: block; }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.section-header.compact { margin-bottom: 8px; }

.inline-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.checkbox-inline { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.checkbox-inline input { width: auto; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.metric-card {
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(180deg, #14243f, #0f1b31);
}
.metric-label { color: var(--muted); font-size: 12px; }
.metric-value { font-size: 20px; font-weight: 700; margin-top: 6px; }

.status-pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 9px;
}
.status-ok { background: rgba(39,192,125,0.2); color: #7cf1bf; border: 1px solid rgba(39,192,125,0.35); }
.status-warn { background: rgba(255,190,59,0.18); color: #ffe09f; border: 1px solid rgba(255,190,59,0.35); }
.status-bad { background: rgba(255,90,90,0.18); color: #ffc1c1; border: 1px solid rgba(255,90,90,0.35); }

.card {
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 14px;
  background: linear-gradient(180deg, var(--bg-card), #101c31);
  margin-bottom: 12px;
}

.card h3 { margin-top: 0; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th, .table td {
  border-bottom: 1px solid #253855;
  padding: 9px;
  text-align: left;
  vertical-align: top;
}

.table th {
  position: sticky;
  top: 0;
  background: #13233c;
  color: #cfe0ff;
  z-index: 1;
}

.output {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: #0a1325;
  color: #c9ddff;
  padding: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
}

.output.tall { min-height: 220px; max-height: 420px; }

.logs-metric-grid {
  margin-bottom: 10px;
}

.logs-controls {
  margin: 10px 0;
}

.logs-controls input {
  flex: 1 1 320px;
}

.logs-controls select {
  width: min(220px, 100%);
}

.logs-raw-wrap {
  margin-top: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 8px 10px;
  background: #0d182d;
}

.logs-raw-wrap summary {
  cursor: pointer;
  color: var(--muted);
  user-select: none;
}

.log-raw-details summary {
  cursor: pointer;
  color: #9fceff;
  text-transform: lowercase;
}

.log-raw-details pre {
  margin: 8px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #c9ddff;
  background: #0a1325;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 8px;
}

.warning-box {
  display: flex;
  gap: 10px;
  align-items: center;
  border: 1px solid rgba(255,190,59,0.4);
  background: rgba(255,190,59,0.14);
  color: #ffe3a6;
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 12px;
}

.warning-box.critical {
  border-color: rgba(255,90,90,0.42);
  background: rgba(255,90,90,0.14);
  color: #ffc0c0;
}

.op-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.row-inline {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.command-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.command-item {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 10px;
  background: #0d182d;
}

.command-item code {
  display: block;
  font-size: 12px;
  margin-bottom: 8px;
  color: #9fceff;
}

@media (max-width: 1200px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .op-grid { grid-template-columns: 1fr; }
  .command-list { grid-template-columns: 1fr; }
}

@media (max-width: 980px) {
  .main-grid { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; overflow: auto; }
}
