/* ===========================================================
   ECINSA Control Plane — estilos
   Tema: industrial/utilitarian dark, denso, operacional.
   =========================================================== */

:root {
  --bg-0: #0a0c10;
  --bg-1: #11141a;
  --bg-2: #161a22;
  --bg-3: #1c2230;
  --bg-hover: #232a3a;
  --border: #262d3b;
  --border-strong: #344056;
  --text: #e6e9ef;
  --text-dim: #99a3b3;
  --text-mute: #6b7587;
  --accent: #ff7a1a;
  --accent-hover: #ff8c3d;
  --accent-dim: #5a2d0d;
  --info: #4dabf7;
  --ok: #51cf66;
  --warn: #ffc107;
  --err: #ff6b6b;
  --shadow-lg: 0 16px 48px rgba(0,0,0,.4);
  --radius: 6px;
  --radius-sm: 4px;
  --font-sans: 'Manrope', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background:
    radial-gradient(1200px 800px at 100% 0%, rgba(255,122,26,.04), transparent 60%),
    radial-gradient(1000px 600px at 0% 100%, rgba(77,171,247,.03), transparent 60%),
    var(--bg-0);
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); }
p { margin: 0; }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--font-mono); font-size: .9em; background: var(--bg-2); padding: 1px 5px; border-radius: 3px; }
small { font-size: 12px; }

.muted { color: var(--text-mute); }
.center { text-align: center; }
.mono { font-family: var(--font-mono); font-size: 13px; }
.small { font-size: 12px; }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.text-err { color: var(--err); }
.mt-1 { margin-top: 12px; }

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

.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(800px 600px at 50% 0%, rgba(255,122,26,.08), transparent 60%),
    var(--bg-0);
}

.login-card {
  width: 100%; max-width: 380px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

.login-brand {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 28px;
}
.brand-mark {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: var(--accent);
  color: #000;
  border-radius: 6px;
  font-size: 22px;
  font-weight: 800;
}
.brand-mark.sm { width: 28px; height: 28px; font-size: 14px; border-radius: 4px; }
.brand-title { font-size: 20px; font-weight: 800; letter-spacing: .04em; }
.brand-subtitle { font-size: 12px; color: var(--text-mute); }

.login-form {
  display: flex; flex-direction: column; gap: 14px;
}
.login-form label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12px; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: .05em; font-weight: 600;
}
.login-footer {
  margin-top: 24px;
  font-size: 11px; color: var(--text-mute);
  text-align: center;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* =============== INPUTS / FORMS =============== */

input[type=text], input[type=password], input[type=email],
input[type=number], input[type=search], input[type=color],
select, textarea {
  width: 100%;
  background: var(--bg-0);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  transition: border-color .12s, background .12s;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-1);
}
input[type=color] { padding: 2px; height: 36px; cursor: pointer; }
textarea { resize: vertical; min-height: 60px; }
input:disabled { color: var(--text-mute); background: var(--bg-1); }

label.checkbox, label.checkbox.compact {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  font-size: 13px;
}
label.checkbox input[type=checkbox] { width: auto; }
label.checkbox.compact { font-size: 12px; }

.form-error {
  background: rgba(255, 107, 107, .08);
  border: 1px solid rgba(255, 107, 107, .3);
  color: var(--err);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

/* =============== BUTTONS =============== */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: var(--bg-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .04s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-3); border-color: var(--text-mute); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #000; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--bg-2); color: var(--text); border-color: var(--border); }

.btn-ok { background: rgba(81, 207, 102, .12); border-color: rgba(81, 207, 102, .3); color: var(--ok); }
.btn-ok:hover { background: rgba(81, 207, 102, .2); }

.btn-warn { background: rgba(255, 193, 7, .12); border-color: rgba(255, 193, 7, .3); color: var(--warn); }
.btn-warn:hover { background: rgba(255, 193, 7, .2); }

.btn-danger { background: rgba(255, 107, 107, .12); border-color: rgba(255, 107, 107, .3); color: var(--err); }
.btn-danger:hover { background: rgba(255, 107, 107, .2); }

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

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 18px 12px;
  position: sticky; top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 18px 10px;
  font-weight: 800;
  letter-spacing: .06em;
  font-size: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

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

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: inherit; font-size: 13px;
  font-weight: 500;
  text-align: left;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .1s, color .1s;
}
.nav-item:hover { background: var(--bg-2); color: var(--text); }
.nav-item.active {
  background: var(--bg-3); color: var(--text);
  box-shadow: inset 3px 0 0 var(--accent);
}
.nav-icon { width: 14px; text-align: center; color: var(--text-mute); }
.nav-item.active .nav-icon { color: var(--accent); }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.user-avatar {
  width: 32px; height: 32px;
  background: var(--bg-3);
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  font-size: 13px;
}
.user-name { font-weight: 600; font-size: 13px; }
.user-role { font-size: 11px; color: var(--text-mute); text-transform: uppercase; letter-spacing: .04em; }

.main {
  padding: 28px 32px;
  min-height: 100vh;
  overflow-x: hidden;
}

.view { display: none; }
.view.active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.view-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 22px;
  gap: 12px;
  flex-wrap: wrap;
}
.view-header h1 { margin-top: 4px; }
.view-header > div { display: flex; flex-direction: column; gap: 4px; }

.action-bar { display: flex; gap: 8px; flex-wrap: wrap; }

/* =============== DASHBOARD =============== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute; inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: .6;
}
.stat-label {
  font-size: 11px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-mute);
  font-weight: 600;
}
.stat-value { font-size: 32px; font-weight: 800; margin-top: 4px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: var(--text-mute); margin-top: 2px; }

.platform-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 2fr;
  gap: 16px;
}
@media (max-width: 900px) { .platform-grid { grid-template-columns: 1fr; } }

.panel {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.panel h3 { margin-bottom: 14px; }

.kv-list { list-style: none; padding: 0; margin: 0; }
.kv-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.kv-list li:last-child { border-bottom: none; }
.kv-list li > span:first-child { color: var(--text-dim); }

.recent-list { display: flex; flex-direction: column; gap: 8px; }
.recent-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px;
  background: var(--bg-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.recent-item:hover { border-color: var(--border-strong); cursor: pointer; }

/* =============== BADGES =============== */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  background: var(--bg-3);
  color: var(--text-dim);
  border: 1px solid var(--border-strong);
  font-variant-numeric: tabular-nums;
}
.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge.running { color: var(--ok); border-color: rgba(81,207,102,.3); background: rgba(81,207,102,.08); }
.badge.stopped { color: var(--text-dim); }
.badge.error { color: var(--err); border-color: rgba(255,107,107,.3); background: rgba(255,107,107,.08); }
.badge.provisioning { color: var(--warn); border-color: rgba(255,193,7,.3); background: rgba(255,193,7,.08); }
.badge.ok { color: var(--ok); border-color: rgba(81,207,102,.3); background: rgba(81,207,102,.08); }
.badge.warn { color: var(--warn); border-color: rgba(255,193,7,.3); background: rgba(255,193,7,.08); }
.badge.err { color: var(--err); border-color: rgba(255,107,107,.3); background: rgba(255,107,107,.08); }

/* =============== TABLES =============== */

.toolbar {
  display: flex; gap: 10px; align-items: center;
  margin-bottom: 14px;
}
.toolbar input[type=search] { max-width: 320px; }
.toolbar select { max-width: 200px; }

.table-wrap {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-mute);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-1);
  white-space: nowrap;
}
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-2); }
.data-table.compact td, .data-table.compact th { padding: 7px 10px; font-size: 12px; }
.data-table .row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* =============== TABS =============== */

.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.tab {
  padding: 10px 16px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .1s, border-color .1s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* =============== CONFIG FORM =============== */

.config-form {
  display: flex; flex-direction: column; gap: 16px;
  max-width: 980px;
}
.config-form fieldset {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.config-form legend {
  padding: 0 8px;
  font-size: 11px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--accent);
  font-weight: 700;
}
.config-form label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 12px; color: var(--text-dim);
  font-weight: 500;
  margin-top: 10px;
}
.config-form label:first-of-type { margin-top: 4px; }
.config-form .grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 700px) { .config-form .grid-2 { grid-template-columns: 1fr; } }

.form-actions {
  display: flex; justify-content: flex-end; align-items: center;
  gap: 10px;
  padding: 14px 0;
}
.form-actions > .muted { margin-right: auto; }

/* =============== LOGS =============== */

.logs-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }

.logs-pane {
  background: #050608;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  height: 60vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: #c4c8d0;
}
.logs-pane .log-line { display: block; }

/* =============== MODALS =============== */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  z-index: 100;
  padding: 24px;
  animation: fadeIn .15s ease;
}
.modal {
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  width: 100%; max-width: 580px;
  max-height: 90vh; overflow: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-close {
  background: transparent; border: none;
  color: var(--text-mute);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.modal-body label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-dim); }
.modal-body .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-body details { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.modal-body details > summary { cursor: pointer; font-size: 13px; font-weight: 600; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* =============== TOASTS =============== */

.toast-stack {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 200;
}
.toast {
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--info);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  max-width: 360px;
  animation: slideIn .2s ease;
}
.toast.ok { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); }
.toast.err { border-left-color: var(--err); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* =============== UTILITIES =============== */

[hidden] { display: none !important; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-0); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-mute); }

@media (max-width: 720px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .main { padding: 18px; }
}
