:root {
  --bg: #0a0c0a;
  --surface: #14170f;
  --surface-2: #1b1f16;
  --border: #2a2f22;
  --text: #e7e3d3;
  --text-muted: #8a9078;
  --accent: #e8b339;
  --accent-dim: #8a6a1f;
  --ok: #6fa33b;
  --danger: #b23b2e;
  --danger-dim: #6e241c;
  --font-display: 'Fjalla One', 'Arial Narrow', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
  --radius: 3px;
}

* { box-sizing: border-box; }

/* Garante que o atributo hidden sempre vença, independente da
   especificidade de outras regras (ex.: .login-screen, .app-shell) */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.5;
}

body {
  background-image:
    linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px);
  background-size: 100% 3px;
}

h1, h2, h3 {
  font-family: var(--font-display);
  letter-spacing: 0.03em;
  margin: 0;
  text-transform: uppercase;
  font-weight: 400;
}

code {
  background: var(--surface-2);
  padding: 0 4px;
  border-radius: var(--radius);
  color: var(--accent);
}

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

::selection { background: var(--accent-dim); color: var(--bg); }

/* ---------- focus visibility ---------- */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ================= LOGIN ================= */

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

.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
}

.login-crest {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.login-crest h1 { font-size: 22px; color: var(--text); }

.login-sub {
  color: var(--text-muted);
  font-size: 12px;
  margin: 4px 0 24px;
}

.crest-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  flex-shrink: 0;
}

.error-text {
  color: var(--danger);
  font-size: 12px;
  margin-top: 10px;
}

/* ================= APP SHELL ================= */

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

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand h1 { font-size: 16px; }

.sidebar-brand p {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 13px;
  text-align: left;
  padding: 10px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  border-left: 2px solid transparent;
}

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

.nav-item.active {
  color: var(--accent);
  border-left: 2px solid var(--accent);
  background: var(--surface-2);
}

.nav-index {
  font-size: 10px;
  color: var(--text-muted);
  min-width: 16px;
}

.nav-item.active .nav-index { color: var(--accent-dim); }

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

/* ---------- vitals strip (signature element) ---------- */

.vitals {
  display: flex;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 22px;
  overflow: hidden;
}

.vital {
  padding: 12px 20px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
}

.vital:last-child { border-right: none; }

.vital-actions {
  margin-left: auto;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

.vital-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.vital-value {
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.vital-value.mono { font-variant-numeric: tabular-nums; }

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
  display: inline-block;
}

.status-dot.online {
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
  animation: pulse 2s ease-in-out infinite;
}

.status-dot.offline { background: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* ---------- views ---------- */

.view { display: none; }
.view.active { display: block; }

.view-header { margin-bottom: 18px; }
.view-header h2 { font-size: 19px; color: var(--text); margin-bottom: 4px; }
.view-header p { color: var(--text-muted); font-size: 12.5px; margin: 0; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

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

.card h3 {
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 12px;
}

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

/* ---------- forms ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.field span { text-transform: uppercase; letter-spacing: 0.04em; font-size: 11px; }

.field input[type="text"],
.field input[type="password"],
.field input[type="number"],
.field textarea,
select,
.inline-form input[type="text"] {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13.5px;
  padding: 9px 10px;
  border-radius: var(--radius);
}

.field-check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.field-check input { accent-color: var(--accent); width: 16px; height: 16px; }
.field-check span { text-transform: none; font-size: 13px; color: var(--text); }

.field-wide { grid-column: 1 / -1; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px 20px;
  align-items: start;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
}

.hint { color: var(--text-muted); font-size: 11.5px; }

.inline-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.inline-form input, .inline-form select { flex: 1; min-width: 160px; }

/* ---------- buttons ---------- */

.btn {
  font-family: var(--font-mono);
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

.btn:hover { border-color: var(--accent-dim); color: var(--accent); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1400;
  font-weight: 600;
}

.btn-primary:hover { color: #1a1400; filter: brightness(1.08); }

.btn-danger { border-color: var(--danger-dim); color: var(--danger); }
.btn-danger:hover { background: var(--danger-dim); color: var(--text); }

.btn-ghost { background: transparent; }

.btn-sm { padding: 8px 12px; font-size: 11.5px; }

.btn-block { width: 100%; }

/* ---------- lists / chips / table ---------- */

.simple-list { list-style: none; margin: 0; padding: 0; }
.simple-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.simple-list li:last-child { border-bottom: none; }

.chip-input { display: flex; gap: 8px; margin-bottom: 12px; }
.chip-input input { flex: 1; }

.chip-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 12.5px;
}

.chip button {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0;
}

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td {
  text-align: left;
  padding: 9px 8px;
  border-bottom: 1px solid var(--border);
}
.table th {
  color: var(--text-muted);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid var(--border);
}

.badge-ready { color: var(--ok); border-color: var(--ok); }
.badge-provisioning { color: var(--accent); border-color: var(--accent-dim); }
.badge-started { color: var(--ok); border-color: var(--accent-dim); }
.badge-stopped { color: var(--text-muted); border-color: var(--border); }
.badge-error { color: var(--danger); border-color: var(--danger-dim); }
.badge-removed { color: var(--text-muted); }

.credentials-box {
  margin-top: 14px;
  background: var(--surface-2);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.8;
}

/* ---------- log boxes ---------- */

.log-box {
  background: #050604;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 12px;
  color: #b8c4a8;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 260px;
  overflow-y: auto;
  margin: 0;
}

.log-box-sm { max-height: 160px; }
.log-box-lg { max-height: 520px; }

/* ---------- toasts ---------- */

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 12.5px;
  max-width: 320px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}

.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--ok); }

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
  }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .main { padding: 18px 16px 60px; }
  .vitals { flex-wrap: wrap; }
  .vital { border-right: none; border-bottom: 1px solid var(--border); flex: 1 1 45%; }
  .vital-actions { justify-content: flex-start; }
}
