:root {
  --bg: #0f1714;
  --panel: #16201c;
  --line: #2a3a33;
  --text: #e8f0eb;
  --muted: #8fa399;
  --accent: #3d9b6e;
  --danger: #c45c4a;
  --warn: #c9a227;
  --online: #3d9b6e;
  --offline: #8a6a5a;
  --font: "Vazirmatn", "Tahoma", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(1200px 600px at 10% -10%, #1c2e26 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--font);
  direction: rtl;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.25rem 2rem;
}
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.brand {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.nav a {
  margin-inline-start: 0.85rem;
  color: var(--muted);
}
.nav a:hover { color: var(--text); }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.login-box {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 1.5rem;
}
.login-box h1 {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
}
.login-box p {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.92rem;
}
label {
  display: block;
  margin: 0.7rem 0 0.3rem;
  color: var(--muted);
  font-size: 0.85rem;
}
input, select, button, textarea {
  font: inherit;
}
input[type="text"],
input[type="password"],
input[type="number"],
textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  background: #0e1512;
  color: var(--text);
}
button, .btn {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.65rem 1rem;
  border: 0;
  background: var(--accent);
  color: #04110a;
  font-weight: 700;
  cursor: pointer;
}
button.secondary, .btn.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.err {
  background: rgba(196, 92, 74, 0.15);
  border: 1px solid var(--danger);
  color: #f0c4bc;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}
.ok {
  background: rgba(61, 155, 110, 0.15);
  border: 1px solid var(--accent);
  color: #bfe8d2;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1rem;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--line);
  padding: 0.85rem;
}
.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}
#map {
  height: min(70vh, 640px);
  min-height: 360px;
  border: 1px solid var(--line);
  background: #0a100d;
}

.device-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: min(70vh, 640px);
  overflow: auto;
}
.device-list li {
  border-bottom: 1px solid var(--line);
  padding: 0.65rem 0.25rem;
  cursor: pointer;
}
.device-list li:hover,
.device-list li.active {
  background: rgba(61, 155, 110, 0.08);
}
.device-list .name { font-weight: 600; }
.device-list .meta {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.2rem;
}
.badge {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.12rem 0.4rem;
  margin-inline-start: 0.35rem;
  vertical-align: middle;
}
.badge.online { background: rgba(61, 155, 110, 0.25); color: #9de0bf; }
.badge.offline { background: rgba(138, 106, 90, 0.3); color: #e0c4b5; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th, td {
  text-align: right;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--line);
}
th { color: var(--muted); font-weight: 600; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 0.85rem; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.form-grid label { margin-top: 0; }
.actions form { display: inline; }
.actions button { margin-top: 0; padding: 0.35rem 0.6rem; font-size: 0.8rem; }
.actions button.danger { background: var(--danger); color: #fff; }
.muted { color: var(--muted); }
