@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --navy: #11161D;
  --navy-light: #1A222D;
  --blue: #2F7DE1;
  --green: #2E7D32;
  --red: #C62828;
  --orange: #EF6C00;
  --gray: #6B7280;
  --bg: #F4F6F9;
  --surface: #FFFFFF;
  --border: #E5E7EB;
  --text: #1C1C1E;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-head: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --shadow-sm: 0 1px 2px rgba(17,22,29,0.04), 0 1px 3px rgba(17,22,29,0.06);
  --shadow-md: 0 6px 16px rgba(17,22,29,0.07), 0 2px 5px rgba(17,22,29,0.06);
  --ease: cubic-bezier(.4,0,.2,1);
}

* { box-sizing: border-box; }

button, input, select, textarea, optgroup {
  font: inherit;
  color: inherit;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.brand, .topbar h1, .stat-value, .card-header, .step-num {
  font-family: var(--font-head);
}

.app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 230px;
  background: var(--navy);
  color: #C9D2DE;
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 22px 24px;
  font-weight: 800;
  font-size: 17px;
  color: white;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 4px rgba(47,125,225,0.2);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  color: #9AA7B8;
  font-size: 14px;
  text-align: left;
  padding: 11px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover { background: var(--navy-light); color: white; }
.nav-item.active { background: var(--blue); color: white; box-shadow: 0 4px 12px rgba(47,125,225,0.35); }
.nav-icon { font-size: 14px; opacity: 0.9; }
.nav-item.hidden { display: none; }

.sidebar-footer {
  margin-top: auto;
  padding: 16px 22px 0;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.conn { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.conn-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  animation: pulse 1.4s infinite;
}
.conn-dot.offline { background: var(--red); animation: none; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
.version { font-size: 11px; color: #5C6878; margin-top: 6px; }

.user-info { font-size: 13px; color: #C9D2DE; }
.user-info .role-badge {
  display: inline-block;
  margin-top: 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #7F8CA3;
}
.logout-btn {
  margin-top: 10px;
  width: 100%;
  background: var(--navy-light);
  border: none;
  color: #C9D2DE;
  font-size: 12px;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s var(--ease);
}
.logout-btn:hover { background: rgba(255,255,255,0.1); }

.inline-form { display: flex; flex-wrap: wrap; gap: 10px; padding: 16px 20px; align-items: center; }
.inline-form input, .inline-form select {
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.btn-primary {
  background: var(--blue);
  color: white;
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
}
.btn-primary:hover { background: #2569C4; transform: translateY(-1px); box-shadow: 0 6px 14px rgba(47,125,225,0.3); }
.btn-danger {
  background: none;
  border: 1px solid var(--border);
  color: var(--red);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: background .15s var(--ease), border-color .15s var(--ease);
}
.btn-danger:hover { background: #FCE8E8; border-color: var(--red); }
.form-error { color: var(--red); font-size: 13px; padding: 0 20px 12px; }
.license-result {
  margin: 0 20px 16px;
  padding: 12px;
  background: var(--bg);
  border-radius: 10px;
  font-family: monospace;
  font-size: 13px;
  white-space: pre-wrap;
  display: none;
}
.license-result.show { display: block; }

/* Main */
.main {
  flex: 1;
  padding: 28px 36px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
}

.topbar h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.01em; margin: 0; }
.clock { font-size: 13px; color: var(--gray); }

.panel { display: none; }
.panel.active { display: block; animation: panel-in .35s var(--ease); }
@keyframes panel-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--gray);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-card.accent-green { border-left-color: var(--green); }
.stat-card.accent-orange { border-left-color: var(--orange); }
.stat-card.accent-blue { border-left-color: var(--blue); }

.stat-value { font-size: 30px; font-weight: 800; }
.stat-label { font-size: 13px; color: var(--gray); margin-top: 4px; }

/* Cards / tables */
.card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  font-weight: 700;
  font-size: 15px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-header-sub { font-weight: 400; color: var(--gray); font-size: 13px; }

.filters { justify-content: space-between; }
.filter-controls { display: flex; gap: 8px; }
.filter-controls select {
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left;
  padding: 10px 20px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--gray);
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr { transition: background .12s var(--ease); }
.table tbody tr:hover { background: #FAFBFD; }
.table tbody tr:last-child td { border-bottom: none; }

.empty-state {
  text-align: center;
  color: var(--gray);
  padding: 40px 0;
  font-size: 14px;
}

.table-footer {
  padding: 14px 20px;
  display: flex;
  justify-content: center;
}

.btn-secondary {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 18px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s var(--ease);
}
.btn-secondary:hover { background: #ECEFF3; }

/* Status pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}
.pill-dot { width: 7px; height: 7px; border-radius: 50%; }

.pill-online { background: #E5F3E7; color: var(--green); }
.pill-online .pill-dot { background: var(--green); }
.pill-offline { background: #F1F2F4; color: var(--gray); }
.pill-offline .pill-dot { background: var(--gray); }
.pill-stopped { background: #F1F2F4; color: var(--gray); }
.pill-stopped .pill-dot { background: var(--gray); }
.pill-danger { background: #FCE8E8; color: var(--red); }
.pill-danger .pill-dot { background: var(--red); animation: pulse 1.2s infinite; }

.pill-active { background: #E3F0FC; color: var(--blue); }
.pill-inactive { background: #F1F2F4; color: var(--gray); }

.badge-reason {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: #FCE8E8;
  color: var(--red);
}
.badge-reason.manuel { background: #FDEBD3; color: var(--orange); }

.map-link { color: var(--blue); text-decoration: none; font-size: 13px; }
.muted { color: var(--gray); }

.battery-low { color: var(--red); font-weight: 700; }

/* Recent activity list (overview) */
.recent-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.recent-row:last-child { border-bottom: none; }

@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .sidebar { width: 80px; }
  .brand-name, .nav-item span:last-child, .version, #conn-text { display: none; }
  .main { padding: 20px; }
}
