:root {
  --bg: #0f172a;
  --panel: #111827;
  --card: #1f2937;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #facc15;
  --accent-dark: #eab308;
  --border: #334155;
  --ok: #14532d;
  --err: #7f1d1d;
  --online: #22c55e;
  --offline: #ef4444;
}

* {
  box-sizing: border-box;
}

html {
  direction: rtl;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #0b1220, #111827);
  color: var(--text);
  font-family: Arial, sans-serif;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.9);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  font-size: 28px;
  font-weight: 800;
}

.nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.nav a,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: 0.2s ease;
  min-height: 42px;
}

.nav a:hover,
.btn:hover {
  border-color: #475569;
  transform: translateY(-1px);
}

.btn.primary {
  background: var(--accent);
  color: #111827;
  border-color: var(--accent-dark);
  font-weight: 700;
}

.btn.primary:hover {
  background: var(--accent-dark);
}

.btn.danger {
  background: #3b0a0a;
  color: #fff;
  border-color: #7f1d1d;
}

.btn.danger:hover {
  background: #7f1d1d;
}

.btn.secondary {
  background: #172033;
  color: var(--text);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.panel,
.card {
  background: rgba(17, 24, 39, 0.9);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 18px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.big {
  font-size: 42px;
  font-weight: 800;
  color: var(--accent);
}

h1,
h2,
h3 {
  margin-top: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.form-grid.single {
  grid-template-columns: 1fr;
  max-width: 520px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 700;
}

input,
select,
textarea {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #020617;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
}

.actions {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 10px;
  text-align: right;
  vertical-align: middle;
}

th {
  color: #cbd5e1;
  font-weight: 700;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.flash {
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 12px;
}

.flash.success {
  background: var(--ok);
}

.flash.error {
  background: var(--err);
}

.muted {
  color: var(--muted);
  font-size: 0.92rem;
}

.auth {
  max-width: 520px;
  margin: 48px auto;
}

.table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.status-online,
.online {
  color: var(--online);
  font-weight: 700;
}

.status-offline,
.offline {
  color: var(--offline);
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.badge.online {
  color: var(--online);
}

.badge.offline {
  color: var(--offline);
}

.card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.card-link .card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  transition: 0.2s ease;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 24px 12px;
}

@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .brand {
    text-align: center;
    font-size: 24px;
  }

  .nav {
    justify-content: center;
  }

  .container {
    padding: 16px;
  }

  .big {
    font-size: 34px;
  }

  th,
  td {
    padding: 8px;
    font-size: 0.95rem;
  }
.devices-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(140px,1fr));
  gap:15px;
}

.device-card{
  background:#111c33;
  border-radius:20px;
  padding:15px;
  text-align:center;
  cursor:pointer;
  transition:0.2s;
}

.device-card:hover{
  transform:scale(1.05);
}

.device-card img{
  width:60px;
  height:60px;
  margin-bottom:10px;
}

.status.online{
  color:#39d353;
}

.status.offline{
  color:#ff5c5c;
}
}