:root {
  --bg: #0d0f12;
  --panel: #16191f;
  --panel-2: #1e2229;
  --border: #2a2f38;
  --text: #e8eaed;
  --muted: #9aa3af;
  --accent: #ff9500;
  --accent-dim: #b36800;
  --green: #22c55e;
  --red: #ef4444;
  --radius: 14px;
  font-size: 16px;
}

* { box-sizing: border-box; }

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

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* Brand */
.brand { display: flex; align-items: center; gap: .55rem; }
.brand-mark { color: var(--accent); font-size: 1.6rem; line-height: 1; }
.brand h1 {
  font-size: 1.35rem;
  margin: 0;
  letter-spacing: .5px;
  font-weight: 700;
}

/* Buttons */
.ghost-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: .5rem .9rem;
  border-radius: 10px;
  cursor: pointer;
  font-size: .9rem;
}
.ghost-btn:hover { color: var(--text); border-color: var(--muted); }

/* Layout */
.layout {
  max-width: 640px;
  margin: 0 auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.card-head h2 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.card-head-actions { display: flex; align-items: center; gap: .6rem; }

/* Status card */
.status-card { text-align: center; }
.status-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  font-weight: 600;
  font-size: 1.05rem;
  margin-bottom: .5rem;
}
.dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  display: inline-block;
}
.dot-on { background: var(--green); box-shadow: 0 0 10px var(--green); }
.dot-off { background: var(--red); box-shadow: 0 0 10px var(--red); }
.dot-unknown { background: var(--muted); }

.status-flag { font-size: 3.5rem; line-height: 1; margin: .35rem 0 .75rem; }

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  text-align: left;
}
.status-grid > div {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .6rem .75rem;
  display: flex;
  flex-direction: column;
  gap: .2rem;
  min-width: 0;
}
.status-grid .k { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; }
.status-grid .v { font-size: .95rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }

.status-error {
  margin: .85rem 0 0;
  color: var(--red);
  font-size: .85rem;
}

/* Upload */
.upload-btn {
  cursor: pointer;
  color: var(--accent);
  border: 1px dashed var(--accent-dim);
  padding: .45rem .8rem;
  border-radius: 10px;
  font-size: .85rem;
  font-weight: 600;
}
.upload-btn:hover { background: rgba(255,149,0,.08); }
.upload-status { margin: 0 0 .75rem; font-size: .85rem; color: var(--muted); }

/* Profile list */
.profile-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.profile-list .empty { color: var(--muted); padding: .5rem; text-align: center; }

.profile {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .7rem .85rem;
  cursor: pointer;
  transition: border-color .15s;
}
.profile:hover { border-color: var(--muted); }
.profile.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.profile.active { border-color: var(--green); }

.profile .radio {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  flex: 0 0 auto;
}
.profile.selected .radio { border-color: var(--accent); background: var(--accent); }

.profile .info { flex: 1 1 auto; min-width: 0; }
.profile .name { font-weight: 600; }
.profile .endpoint { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.profile .badge {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--green);
  border: 1px solid var(--green);
  border-radius: 6px;
  padding: .1rem .4rem;
  flex: 0 0 auto;
}

.profile .row-actions { display: flex; gap: .35rem; flex: 0 0 auto; }
.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: .3rem .5rem;
  cursor: pointer;
  font-size: .8rem;
}
.icon-btn:hover { color: var(--text); border-color: var(--muted); }

/* Actions */
.actions { display: flex; gap: 1rem; }
.actions button {
  flex: 1;
  padding: 1.1rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  transition: opacity .15s, transform .05s;
}
.actions button:active { transform: translateY(1px); }
.btn-connect { background: var(--green); }
.btn-disconnect { background: var(--red); }
.actions button:disabled { opacity: .4; cursor: not-allowed; }

.msg {
  text-align: center;
  color: var(--muted);
  min-height: 1.2rem;
  margin: 0;
  font-size: .9rem;
}
.msg.error { color: var(--red); }
.msg.ok { color: var(--green); }

/* Login */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-card .brand { justify-content: center; margin-bottom: .5rem; }
.login-sub { color: var(--muted); font-size: .9rem; margin: 0 0 1.5rem; }
.login-form { display: flex; flex-direction: column; gap: .75rem; }
.login-form input {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: .8rem 1rem;
  font-size: 1rem;
}
.login-form input:focus { outline: none; border-color: var(--accent); }
.login-form button {
  background: var(--accent);
  color: #111;
  border: none;
  border-radius: 10px;
  padding: .8rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}
.login-form button:hover { opacity: .92; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  z-index: 100;
}
.modal[hidden] { display: none; }
.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 360px;
}
.modal-box h3 { margin: 0 0 .5rem; font-size: 1.1rem; }
.modal-sub { color: var(--muted); font-size: .85rem; margin: 0 0 1rem; }
.modal-box input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: .75rem 1rem;
  font-size: 1rem;
  margin-bottom: .6rem;
}
.modal-box input:focus { outline: none; border-color: var(--accent); }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: .5rem; }
.btn-accent {
  background: var(--accent);
  color: #111;
  border: none;
  border-radius: 10px;
  padding: .6rem 1.1rem;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-accent:hover { opacity: .92; }

@media (max-width: 420px) {
  .status-grid { grid-template-columns: 1fr; }
}
