* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f0f23;
  color: #e0e0e0;
  min-height: 100vh;
}

.container { max-width: 700px; margin: 0 auto; padding: 1rem; }

header { text-align: center; padding: 1.5rem 0 0.5rem; }
header h1 { font-size: 1.6rem; color: #fff; margin-bottom: 0.5rem; }

.status {
  padding: 0.5rem 1rem; border-radius: 8px;
  font-size: 0.85rem; text-align: center;
}
.status-info { background: #1a1a3e; color: #8888cc; }
.status-success { background: #1a3e1a; color: #66cc66; }
.status-error { background: #3e1a1a; color: #cc6666; }
.status-warning { background: #3e3e1a; color: #cccc66; }

/* Tabs */
.tabs {
  display: flex; gap: 0.25rem; margin-top: 1rem;
  background: #16213e; border-radius: 12px 12px 0 0;
  padding: 0.5rem 0.5rem 0; border: 1px solid #1a1a4e; border-bottom: none;
}
.tab {
  flex: 1; padding: 0.6rem; border: none; border-radius: 8px 8px 0 0;
  background: transparent; color: #888; cursor: pointer;
  font-size: 0.85rem; font-weight: 600; transition: all 0.2s;
}
.tab.active { background: #0f0f23; color: #fff; }
.tab:hover { color: #ccc; }

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

/* Cards */
.card {
  background: #16213e; border-radius: 12px; padding: 1.25rem;
  margin-top: 0.75rem; border: 1px solid #1a1a4e;
}
.tabs + .tab-content.active .card:first-child {
  border-radius: 0 0 12px 12px; margin-top: 0;
  border-top: none;
}
.card-header {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 0.75rem;
}
.card h2 { font-size: 1.1rem; color: #fff; }
.card h3 { font-size: 1rem; color: #fff; margin-bottom: 0.75rem; }
.tab-first-card {
  border-radius: 0 0 12px 12px; margin-top: 0; border-top: none;
}

/* Forms */
.form-group { margin: 0.75rem 0; }
.form-group label {
  display: block; margin-bottom: 0.3rem;
  color: #aaa; font-size: 0.8rem;
}
.form-group input {
  width: 100%; padding: 0.65rem 0.8rem;
  border: 1px solid #2a2a5e; border-radius: 8px;
  background: #0f0f23; color: #fff; font-size: 0.95rem;
  outline: none; transition: border-color 0.2s;
}
.form-group input:focus { border-color: #e94560; }

/* Buttons */
.btn {
  padding: 0.5rem 1rem; border: none; border-radius: 8px;
  cursor: pointer; font-size: 0.85rem; font-weight: 600;
  transition: opacity 0.2s, transform 0.1s;
}
.btn:hover { opacity: 0.9; }
.btn:active { transform: scale(0.97); }
.btn-primary {
  width: 100%; padding: 0.8rem; background: #e94560;
  color: #fff; font-size: 1rem; margin-top: 0.5rem;
}
.btn-track { background: #e94560; color: #fff; }
.btn-history { background: #1a73e8; color: #fff; }
.btn-small { padding: 0.4rem 0.7rem; background: #2a2a5e; color: #ccc; font-size: 0.8rem; }
.btn-map {
  display: inline-block; background: #1a73e8;
  color: #fff; text-decoration: none; margin-top: 0.5rem;
}

/* Device cards */
.device-card {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.75rem 0; border-bottom: 1px solid #1a1a4e;
  flex-wrap: wrap; gap: 0.5rem;
}
.device-card:last-child { border-bottom: none; }
.device-info { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; min-width: 0; }
.device-name { font-weight: 600; color: #fff; font-size: 0.95rem; }
.device-meta { font-size: 0.78rem; color: #999; }
.device-date { font-size: 0.75rem; color: #666; }
.badge {
  display: inline-block; background: #e94560; color: #fff;
  font-size: 0.6rem; padding: 0.1rem 0.35rem; border-radius: 4px;
  margin-left: 0.3rem; vertical-align: middle;
}
.badge-admin {
  display: inline-block; background: #e94560; color: #fff;
  font-size: 0.6rem; padding: 0.2rem 0.5rem; border-radius: 4px;
  margin-left: 0.4rem; vertical-align: middle;
}
.device-actions { display: flex; gap: 0.4rem; }

/* Install steps */
.install-steps {
  margin: 1rem 0; padding-left: 1.5rem;
  line-height: 1.8; color: #ccc;
}
.install-note { color: #888; font-size: 0.85rem; margin-top: 1rem; }

/* Map */
#map { border-radius: 8px; z-index: 1; }
.leaflet-popup-content { color: #333; font-size: 0.85rem; }

/* History */
.history-list { max-height: 400px; overflow-y: auto; }
.history-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.5rem 0; border-bottom: 1px solid #1a1a4e;
  font-size: 0.8rem; gap: 0.5rem;
}
.history-item:last-child { border-bottom: none; }
.history-item a { text-decoration: none; font-size: 1rem; }

.empty { text-align: center; color: #666; padding: 1.5rem; }

@media (max-width: 480px) {
  .device-card { flex-direction: column; align-items: flex-start; }
  .device-actions { width: 100%; }
  .device-actions .btn { flex: 1; text-align: center; }
  .container { padding: 0.5rem; }
}
