/* ═══════════════════════════════════════════════════════════════════════════
   EliteAvo — Dark Dashboard CSS
   Color scheme based on FarmSync.cloud analysis
   Primary BG: #111827  Sidebar BG: #1C252E  Card: #1A2233
   Accent: #3B82F6 (blue)  Text: #F1F5F9  Muted: #94A3B8
   Font: Inter
   ═══════════════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Colors - exact FarmSync match */
  --bg:          #141A21;
  --sidebar-bg:  #141A21;
  --surface:     #1C2330;
  --surface2:    #253040;
  --border:      rgba(45,55,72,0.6);
  --border-hover:rgba(45,55,72,0.9);

  --text:        #FFFFFF;
  --text-sec:    #C4CDD6;
  --muted:       #919EAB;

  --accent:      #00B8A9;
  --accent-dim:  rgba(0,184,169,0.15);
  --accent-hover:#00A396;

  --danger:      #FF5630;
  --danger-dim:  rgba(255,86,48,0.15);
  --warning:     #FFAB00;
  --warning-dim: rgba(255,171,0,0.15);
  --info:        #00B8D9;
  --info-dim:    rgba(0,184,217,0.15);

  --green:       #36B37E;
  --red:         #FF5630;
  --blue:        #0065FF;
  --purple:      #6554C0;
  --orange:      #FF8B00;

  /* Layout */
  --sidebar-w:   260px;
  --topbar-h:    64px;
  --radius:      10px;
  --radius-sm:   8px;
  --radius-xs:   4px;

  /* Typography */
  --font:        'Nunito Sans Variable', 'Nunito Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono:   'Consolas', 'Courier New', monospace;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
input, select, textarea, button { font-family: var(--font); }

/* ─── Auth Pages ──────────────────────────────────────────────────────────── */

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.auth-container {
  width: 100%;
  max-width: 420px;
  padding: 1rem;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: .625rem;
  margin-bottom: 1.5rem;
}

.auth-logo-icon { font-size: 1.75rem; }

.auth-logo-text {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.auth-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: .25rem;
}

.auth-subtitle {
  color: var(--muted);
  font-size: .85rem;
  margin-bottom: 1.5rem;
}

.auth-form { display: flex; flex-direction: column; gap: 1rem; }

.auth-footer {
  margin-top: 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
}

.auth-footer a { color: var(--accent); }

/* ─── Layout ──────────────────────────────────────────────────────────────── */

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 100;
  transition: transform .25s;
  scrollbar-width: thin;
  scrollbar-color: var(--surface2) transparent;
}

.sidebar.collapsed { transform: translateX(-100%); }

.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left .25s;
}

.sidebar.collapsed ~ .main-wrapper { margin-left: 0; }

/* ─── Sidebar Logo ────────────────────────────────────────────────────────── */

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}

.logo-icon { font-size: 1.5rem; }

.logo-text {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.01em;
}

/* ─── Sidebar Nav ─────────────────────────────────────────────────────────── */

.sidebar-nav {
  flex: 1;
  padding: .75rem 0 1rem;
}

.nav-group {
  margin-bottom: .25rem;
}

.nav-group-label {
  padding: .625rem 1.25rem .25rem;
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--muted);
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem 1.25rem;
  color: var(--text-sec);
  font-size: .875rem;
  font-weight: 500;
  border-radius: 0;
  transition: background .15s, color .15s;
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(255,255,255,.04);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}

.nav-item-danger { color: var(--danger); }
.nav-item-danger:hover { background: var(--danger-dim); color: var(--danger); }

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: .7;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon { opacity: 1; }

/* ─── Topbar ──────────────────────────────────────────────────────────────── */

.topbar {
  height: var(--topbar-h);
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: .375rem;
  border-radius: var(--radius-sm);
  display: flex;
}

.sidebar-toggle:hover { background: var(--surface2); color: var(--text); }

.topbar-breadcrumb {
  flex: 1;
  font-size: .85rem;
  color: var(--muted);
}

.topbar-breadcrumb a { color: var(--muted); }
.topbar-breadcrumb a:hover { color: var(--text); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.topbar-user {
  font-size: .85rem;
  color: var(--muted);
}

.topbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .875rem;
  font-weight: 700;
  color: #fff;
}

/* ─── Flash Messages ──────────────────────────────────────────────────────── */

.flash-container {
  padding: .75rem 1.5rem 0;
}

.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: .5rem;
  font-size: .875rem;
}

.flash-success { background: rgba(34,197,94,.12); color: var(--green); border: 1px solid rgba(34,197,94,.3); }
.flash-danger,
.flash-error   { background: var(--danger-dim); color: var(--danger); border: 1px solid rgba(239,68,68,.3); }
.flash-warning { background: var(--warning-dim); color: var(--warning); border: 1px solid rgba(245,158,11,.3); }
.flash-info    { background: var(--info-dim); color: var(--info); border: 1px solid rgba(0,184,217,.3); }

.flash-close {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  opacity: .6;
  font-size: 1rem;
  padding: 0 .25rem;
}
.flash-close:hover { opacity: 1; }

/* ─── Page Content ────────────────────────────────────────────────────────── */

.page-content {
  flex: 1;
  padding: 1.5rem;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: .625rem;
}

.page-subtitle {
  color: var(--muted);
  font-size: .875rem;
  margin-top: .25rem;
}

.page-header-actions {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-shrink: 0;
}

/* ─── Stat Cards ──────────────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 24px; height: 24px; }

.stat-icon-green  { background: rgba(34,197,94,.15);  color: var(--green);  }
.stat-icon-blue   { background: rgba(59,130,246,.15); color: var(--blue);   }
.stat-icon-purple { background: rgba(168,85,247,.15); color: var(--purple); }
.stat-icon-orange { background: rgba(249,115,22,.15); color: var(--orange); }

.stat-body { flex: 1; min-width: 0; }

.stat-value {
  font-size: 1.625rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.stat-label {
  font-size: .8rem;
  color: var(--muted);
  margin-top: .25rem;
}

.stat-total { color: var(--muted); font-weight: 400; }

/* ─── Panels ──────────────────────────────────────────────────────────────── */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .875rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  font-size: .9375rem;
  font-weight: 600;
}

.panel-body {
  padding: 1.25rem;
}

/* ─── Tables ──────────────────────────────────────────────────────────────── */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.table th {
  padding: .75rem 1rem;
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr:hover { background: rgba(255,255,255,.02); }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .375rem;
  padding: .5rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, opacity .15s, border-color .15s;
  line-height: 1.4;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { opacity: .85; }

.btn-ghost {
  background: transparent;
  color: var(--text-sec);
  border-color: var(--border-hover);
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

.btn-sm { padding: .3rem .65rem; font-size: .8rem; }
.btn-full { width: 100%; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: .2rem;
  border-radius: var(--radius-xs);
  display: inline-flex;
}
.btn-icon:hover { color: var(--text); background: var(--surface2); }

/* ─── Forms ───────────────────────────────────────────────────────────────── */

.form-group {
  margin-bottom: 1rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-label {
  display: block;
  margin-bottom: .375rem;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-sec);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: .5rem .75rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  transition: border-color .15s;
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
}

.form-select {
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%23919EAB'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  padding-right: 2rem;
}

.form-textarea { resize: vertical; min-height: 80px; }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 22px;
  cursor: pointer;
  transition: background .2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  top: 2px;
  background: var(--muted);
  border-radius: 50%;
  transition: transform .2s, background .2s;
}

.toggle input:checked + .toggle-slider { background: var(--accent-dim); border-color: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); background: var(--accent); }

/* ─── Badges ──────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .55rem;
  border-radius: 100px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}

.badge-green  { background: rgba(34,197,94,.15);   color: var(--green); }
.badge-red    { background: var(--danger-dim);      color: var(--danger); }
.badge-gray   { background: rgba(145,158,171,.12);  color: var(--muted); }
.badge-blue   { background: rgba(59,130,246,.15);   color: var(--blue); }
.badge-purple { background: rgba(168,85,247,.15);   color: var(--purple); }
.badge-orange { background: rgba(249,115,22,.15);   color: var(--orange); }
.badge-yellow { background: var(--warning-dim);     color: var(--warning); }

/* ─── Device Cards ────────────────────────────────────────────────────────── */

.device-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.device-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .875rem;
}

.device-card-header {
  display: flex;
  align-items: center;
  gap: .625rem;
}

.device-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-online  { background: var(--green); box-shadow: 0 0 6px rgba(34,197,94,.5); }
.dot-offline { background: var(--muted); }

.status-dot-inline { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; margin-right: .25rem; }

.device-card-name {
  flex: 1;
  font-weight: 700;
  font-size: .95rem;
}

.device-card-meta {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  font-size: .78rem;
  color: var(--muted);
}

/* Resource bars inside device cards */
.resource-bars { display: flex; flex-direction: column; gap: .5rem; }

.resource-row {
  display: grid;
  grid-template-columns: 40px 1fr 42px;
  align-items: center;
  gap: .5rem;
}

.resource-label { font-size: .75rem; color: var(--muted); }

.resource-bar-track {
  height: 5px;
  background: var(--surface2);
  border-radius: 100px;
  overflow: hidden;
}

.resource-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 100px;
  transition: width .5s;
}

.resource-val { font-size: .75rem; color: var(--muted); text-align: right; }

/* Large resource bars (device detail) */
.resource-row-lg {
  display: grid;
  grid-template-columns: 110px 1fr 80px;
  align-items: center;
  gap: .75rem;
}
.resource-label-lg { font-size: .875rem; color: var(--text-sec); }
.resource-bar-track-lg {
  height: 8px;
  background: var(--surface2);
  border-radius: 100px;
  overflow: hidden;
}
.resource-bar-fill-lg {
  height: 100%;
  background: var(--accent);
  border-radius: 100px;
  transition: width .5s;
}
.resource-bar-fill-lg.fill-warn { background: var(--warning); }
.resource-val-lg { font-size: .8rem; color: var(--muted); }

/* Mini bars (status table) */
.mini-bar-wrap { display: inline-block; width: 60px; height: 4px; background: var(--surface2); border-radius: 100px; vertical-align: middle; overflow: hidden; margin-right: .375rem; }
.mini-bar { height: 100%; background: var(--accent); }

/* Device counts */
.device-card-counts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .5rem;
  padding: .75rem;
  background: var(--surface2);
  border-radius: var(--radius-sm);
}

.count-item { text-align: center; }
.count-val { display: block; font-size: 1.125rem; font-weight: 700; }
.count-label { display: block; font-size: .7rem; color: var(--muted); margin-top: .1rem; }

.device-card-actions {
  display: flex;
  gap: .375rem;
  flex-wrap: wrap;
}

.device-card-key {
  padding: .5rem .75rem;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .75rem;
}

.key-label { color: var(--muted); flex-shrink: 0; }
.key-val   { color: var(--text-sec); flex: 1; overflow: hidden; text-overflow: ellipsis; }

/* Device Detail */
.device-stat-row {
  display: flex;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.device-stat {
  flex: 1;
  padding: 1rem;
  background: var(--surface);
  text-align: center;
}

.device-stat-val { font-size: 1.375rem; font-weight: 700; }
.device-stat-label { font-size: .75rem; color: var(--muted); margin-top: .2rem; }

/* ─── Tabs ────────────────────────────────────────────────────────────────── */

.tabs-container { }

.tabs-header {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: .625rem 1.25rem;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: color .15s, border-color .15s;
  margin-bottom: -1px;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── Config Cards ────────────────────────────────────────────────────────── */

.configs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.config-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.125rem;
  display: flex;
  flex-direction: column;
  gap: .625rem;
}

.config-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}

.config-name { font-weight: 700; font-size: .95rem; }

.config-card-actions { display: flex; gap: .375rem; }

.config-field {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: .5rem;
  font-size: .82rem;
}
.config-label { color: var(--muted); flex-shrink: 0; }
.config-value { text-align: right; word-break: break-word; }

.config-notes {
  font-size: .8rem;
  line-height: 1.5;
  padding-top: .5rem;
  border-top: 1px solid var(--border);
}

.config-footer {
  display: flex;
  justify-content: space-between;
  padding-top: .5rem;
  border-top: 1px solid var(--border);
  font-size: .75rem;
  color: var(--muted);
}

/* ─── Dashboard Grid ──────────────────────────────────────────────────────── */

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 900px) { .dashboard-grid { grid-template-columns: 1fr; } }

/* Device rows in dashboard */
.device-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .625rem 1.25rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: background .15s;
}
.device-row:last-child { border-bottom: none; }
.device-row:hover { background: rgba(255,255,255,.02); }

.device-row-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.device-row-info { flex: 1; }
.device-row-name { font-size: .9rem; font-weight: 600; }
.device-row-sub  { font-size: .75rem; color: var(--muted); }
.device-row-stats { display: flex; align-items: center; gap: .625rem; }
.device-row-accounts { font-size: .78rem; color: var(--muted); }

/* Activity rows */
.activity-row {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .625rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.activity-row:last-child { border-bottom: none; }
.activity-dot { width: 6px; height: 6px; background: var(--accent); border-radius: 50%; margin-top: .4rem; flex-shrink: 0; }
.activity-info { flex: 1; }
.activity-action { font-size: .875rem; font-weight: 600; display: block; }
.activity-desc   { font-size: .78rem; color: var(--muted); display: block; }
.activity-time   { font-size: .75rem; flex-shrink: 0; margin-top: .1rem; }

/* ─── Settings Grid ───────────────────────────────────────────────────────── */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
  align-items: start;
}

/* ─── Info Rows ───────────────────────────────────────────────────────────── */

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: .625rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .875rem;
}
.info-row:last-child { border-bottom: none; }
.info-key { color: var(--muted); flex-shrink: 0; }
.info-val { text-align: right; word-break: break-all; }

/* ─── Modals ──────────────────────────────────────────────────────────────── */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-lg { max-width: 640px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: .95rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.125rem;
  padding: 0 .25rem;
  line-height: 1;
}
.modal-close:hover { color: var(--text); }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: .625rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

/* ─── Filter Bar ──────────────────────────────────────────────────────────── */

.filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .625rem;
  margin-bottom: 1rem;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  flex: 1;
}

.filter-select { width: auto; min-width: 140px; }
.filter-search { max-width: 220px; }

/* ─── Toolbar ─────────────────────────────────────────────────────────────── */

.toolbar {
  display: flex;
  align-items: center;
  gap: .625rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

/* ─── Checkbox list ───────────────────────────────────────────────────────── */

.checkbox-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .5rem;
  max-height: 250px;
  overflow-y: auto;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .375rem .5rem;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-size: .875rem;
}

.checkbox-item:hover { background: var(--surface2); }
.checkbox-item input[type=checkbox] { accent-color: var(--accent); }

/* ─── Empty State ─────────────────────────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
  padding: 2rem;
  color: var(--muted);
  text-align: center;
}

.empty-state-full {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 3rem 2rem;
  color: var(--muted);
  text-align: center;
}

.empty-state-full h3 { color: var(--text-sec); font-size: 1.125rem; }

/* ─── Code ────────────────────────────────────────────────────────────────── */

.code-inline {
  font-family: var(--font-mono);
  font-size: .8em;
  background: var(--surface2);
  padding: .1rem .4rem;
  border-radius: var(--radius-xs);
  color: var(--text-sec);
}

/* ─── Pagination ──────────────────────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  gap: .75rem;
  justify-content: center;
  margin-top: 1.5rem;
  font-size: .875rem;
}

/* ─── Game cards (trackstats) ─────────────────────────────────────────────── */

.game-card-header { display: flex; justify-content: space-between; align-items: center; }
.game-name { font-weight: 700; }
.game-stats { margin-top: .5rem; display: flex; flex-direction: column; gap: .375rem; }
.game-stat-row { display: flex; justify-content: space-between; font-size: .875rem; }
.game-stat-label { color: var(--muted); }
.game-stat-val { font-weight: 700; }

/* ─── Utility ─────────────────────────────────────────────────────────────── */

.text-muted  { color: var(--muted); }
.text-sec    { color: var(--text-sec); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-blue   { color: var(--blue); }
.text-center { text-align: center; }

/* ─── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  :root { --sidebar-w: 240px; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0 !important; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .device-cards { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
}

/* ─── Split Layout (Configs, Scripts) ────────────────────────────────────── */

.split-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 0;
  min-height: calc(100vh - var(--topbar-h) - 3rem);
  margin: -1.5rem;
}

.split-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.split-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.125rem .75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.split-sidebar-title {
  font-weight: 700;
  font-size: .9375rem;
}

.split-sidebar-search {
  padding: .625rem .875rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.split-sidebar-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--surface2) transparent;
}

.split-sidebar-item {
  display: block;
  padding: .625rem 1.125rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: background .15s;
}

.split-sidebar-item:last-child { border-bottom: none; }
.split-sidebar-item:hover { background: rgba(255,255,255,.03); }
.split-sidebar-item.active { background: var(--accent-dim); border-left: 3px solid var(--accent); }

.split-item-name { font-size: .875rem; font-weight: 500; }
.split-item-sub  { font-size: .75rem; margin-top: .125rem; }

.split-content {
  padding: 1.5rem;
  overflow-y: auto;
}

@media (max-width: 768px) {
  .split-layout { grid-template-columns: 1fr; }
  .split-sidebar { max-height: 260px; }
}

/* ─── Status Dots (inline) ────────────────────────────────────────────────── */

.dot-online  { background: var(--green); }
.dot-offline { background: var(--muted); }

.status-dot-inline {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 4px;
}

/* ─── Device stat row ─────────────────────────────────────────────────────── */

.device-stat-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.device-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .875rem 1.25rem;
  min-width: 110px;
}

.device-stat-val   { font-size: 1.375rem; font-weight: 700; line-height: 1.1; }
.device-stat-label { font-size: .75rem; color: var(--muted); margin-top: .2rem; }

/* ─── Tabs (link style) ───────────────────────────────────────────────────── */

.tabs-header a.tab-btn { text-decoration: none; }


/* ─── FarmSync-style Stat Cards (no icons) ─────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 900px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .stats-grid { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
  margin-bottom: .375rem;
}

.stat-value-accent { color: var(--accent); }

.stat-label {
  font-size: .8125rem;
  color: var(--muted);
  font-weight: 600;
}

/* ─── Devices Summary Bar ───────────────────────────────────────────────────── */

.devices-summary {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.25rem;
  font-size: .875rem;
  color: var(--muted);
}

.devices-summary-val {
  font-weight: 700;
  color: var(--text);
  margin-right: .25rem;
}

.devices-summary-sep { color: var(--border-hover); }

/* ─── FarmSync Device Card (clickable link) ─────────────────────────────────── */

.device-card-link {
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s, transform .1s;
}

.device-card-link:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.device-card-title-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .5rem;
}

.device-card-badges {
  display: flex;
  align-items: center;
  gap: .375rem;
  flex-wrap: wrap;
}

.device-note {
  font-size: .75rem;
  color: var(--muted);
  margin-right: .25rem;
}

.device-card-tags {
  display: flex;
  gap: .375rem;
  flex-wrap: wrap;
  margin-bottom: .25rem;
}

.device-tag {
  display: inline-flex;
  align-items: center;
  padding: .15rem .5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-sec);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.device-card-counts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .5rem;
  padding: .75rem;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  margin-top: .5rem;
}

/* ─── Login page improvements ───────────────────────────────────────────────── */

.auth-body {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
}

.auth-logo-text { color: var(--accent); }

/* ─── Sidebar active item indicator ────────────────────────────────────────── */

.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 700;
  border-right: 3px solid var(--accent);
}

.nav-item.active .nav-icon { opacity: 1; }

/* ─── Topbar improvements ───────────────────────────────────────────────────── */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-avatar {
  background: var(--accent);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8125rem;
  font-weight: 700;
  color: #fff;
}
