:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f232c;
  --border: #2a2f3a;
  --text: #e6e8ec;
  --muted: #8a90a0;
  --accent: #4f8cff;
  --accent-2: #3fd68f;
  --danger: #ff5c6c;
  --warn: #ffb84f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#app { min-height: 100vh; }

.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 340px;
}

.login-box h1 {
  font-size: 20px;
  margin: 0 0 4px;
}
.login-box p.subtitle {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 20px;
}

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 12px 0 4px;
}

input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
}

textarea {
  font-family: inherit;
  resize: vertical;
  min-height: 60px;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
}

.btn-primary { background: var(--accent); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }

.btn-primary:hover, .btn-danger:hover, .btn-secondary:hover { filter: brightness(1.1); }

.error-msg { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 16px; }

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
}

.sidebar h2 { font-size: 16px; margin: 0 0 4px; }
.sidebar .status { font-size: 12px; margin-bottom: 20px; }
.status.online { color: var(--accent-2); }
.status.offline { color: var(--danger); }

.nav-item {
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  margin-bottom: 4px;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active { background: var(--accent); color: white; }

.content { flex: 1; padding: 28px 32px; overflow-y: auto; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.card h3 { margin: 0 0 4px; font-size: 15px; }
.card p.desc { color: var(--muted); font-size: 13px; margin: 0 0 14px; }

.module-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.module-row:first-child { border-top: none; }

.checkbox-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  max-height: 160px;
  overflow-y: auto;
}
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 400;
  margin: 0;
  padding: 4px 8px;
  background: var(--panel);
  border-radius: 6px;
  cursor: pointer;
}
.checkbox-item input[type="checkbox"] { width: auto; }

/* Randuri de reguli editabile live (Auto Move, Server Group Protection):
   fiecare regula e un rand cu select-uri care se salveaza pe loc, plus un
   rand gol la final pentru adaugarea urmatoarei reguli. */
.rule-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.rule-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.rule-row .rule-select { flex: 1; min-width: 0; }
.rule-row .rule-arrow {
  color: var(--muted);
  font-size: 15px;
  flex: 0 0 auto;
}
.rule-row.rule-row-new .rule-select { opacity: 0.75; }
.rule-row.rule-row-new .rule-select:focus { opacity: 1; }

.icon-btn-danger {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--danger);
  border-radius: 8px;
}
.icon-btn-danger:hover { background: var(--danger); color: white; border-color: var(--danger); }
.icon-btn-danger svg { width: 16px; height: 16px; }

.rule-row-uid input[type="text"] { flex: 1; }

/* Module Avansate, in acordeon: fiecare card e restrans implicit, ca
   pagina sa nu coplesesca vizual -- se vede doar titlul, descrierea scurta
   si switch-ul, iar restul campurilor apar doar cand dai click sa-l
   deschizi. Folosim `display: revert` la expandare ca sa nu conteze ce tip
   de element e (div, table, button...), fiecare isi ia display-ul lui
   normal inapoi. */
.card.advanced-collapsible > .module-row:first-child {
  cursor: pointer;
  user-select: none;
}
.card.advanced-collapsible:not(.expanded) > *:not(:first-child) {
  display: none !important;
}
.advanced-chevron {
  margin-left: 14px;
  color: var(--muted);
  display: inline-block;
  transition: transform 0.15s ease;
  font-size: 12px;
}
.card.advanced-collapsible.expanded .advanced-chevron { transform: rotate(180deg); }
.card.advanced-collapsible .module-row:first-child { flex-wrap: nowrap; }

.switch {
  position: relative;
  width: 42px;
  height: 24px;
  display: inline-block;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background-color: var(--border); border-radius: 24px; transition: .2s;
}
.slider:before {
  position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px;
  background-color: white; border-radius: 50%; transition: .2s;
}
input:checked + .slider { background-color: var(--accent-2); }
input:checked + .slider:before { transform: translateX(18px); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}
.tag.info { background: #24344f; color: #7fb0ff; }
.tag.warn { background: #4a3a1e; color: var(--warn); }
.tag.action { background: #234a34; color: var(--accent-2); }
.tag.error { background: #4a2323; color: var(--danger); }

.inline-form { display: flex; gap: 8px; margin-top: 10px; }
.inline-form input { flex: 1; }

.top-actions { display: flex; justify-content: flex-end; gap: 10px; margin-bottom: 16px; }

.small-muted { font-size: 12px; color: var(--muted); }
