/* Fleet Panel — custom dark UI */
:root {
  --bg: #0f1115;
  --bg-elev: #171a21;
  --bg-hover: #1d212b;
  --border: #262b36;
  --border-soft: #1f242e;
  --text: #e4e7ee;
  --text-dim: #8b93a3;
  --text-faint: #5b6270;
  --accent: #f0a35e;
  --accent-dim: rgba(240, 163, 94, 0.14);
  --green: #4cc38a;
  --red: #e5534b;
  --yellow: #d8a13c;
  --blue: #4f8cff;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, "Courier New", monospace;
  --sans: "Inter", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus { border-color: var(--accent); }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 210px;
  flex-shrink: 0;
  background: var(--bg-elev);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 20px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .3px;
}
.brand-dot {
  width: 10px; height: 10px;
  border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(240,163,94,.5);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-dim);
  font-weight: 500;
  margin-bottom: 2px;
  transition: background .12s, color .12s;
  user-select: none;
  cursor: pointer;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-footer {
  margin-top: auto;
  padding: 12px 10px 4px;
  border-top: 1px solid var(--border-soft);
  color: var(--text-faint);
  font-size: 12px;
}
.sidebar-footer .user-line { display: flex; justify-content: space-between; align-items: center; }
.sidebar-footer .logout { color: var(--text-dim); cursor: pointer; }
.sidebar-footer .logout:hover { color: var(--red); }

.main { flex: 1; padding: 28px 32px; min-width: 0; }
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.page-sub { color: var(--text-dim); margin-bottom: 22px; font-size: 13px; }

/* ---------- auth screens ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(700px 400px at 20% 10%, rgba(240,163,94,.05), transparent),
    radial-gradient(600px 400px at 85% 90%, rgba(79,140,255,.04), transparent),
    var(--bg);
}
.auth-card {
  width: 360px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 34px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.auth-card h1 { font-size: 18px; margin-bottom: 4px; }
.auth-card .sub { color: var(--text-dim); font-size: 13px; margin-bottom: 24px; }
.auth-card .brand { padding: 0 0 18px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
.field input { width: 100%; }

/* ---------- buttons ---------- */
.btn {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #232836; }
.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1208;
}
.btn-accent:hover { background: #f5b377; border-color: #f5b377; }
.btn-block { width: 100%; padding: 10px; font-size: 14px; }
.btn-danger { color: var(--red); border-color: rgba(229,83,75,.35); }
.btn-danger:hover { background: rgba(229,83,75,.1); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

.error-box {
  background: rgba(229,83,75,.1);
  border: 1px solid rgba(229,83,75,.3);
  color: var(--red);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}
.ok-box {
  background: rgba(76,195,138,.1);
  border: 1px solid rgba(76,195,138,.3);
  color: var(--green);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* ---------- device grid ---------- */
.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.device-card {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px;
  cursor: pointer;
  transition: border-color .15s, transform .1s;
}
.device-card:hover { border-color: var(--border); transform: translateY(-1px); }
.device-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.device-model { font-weight: 700; font-size: 15px; }
.device-id-short { color: var(--text-faint); font-family: var(--mono); font-size: 12px; }
.dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #3a4050;
  flex-shrink: 0;
}
.dot.online { background: var(--green); animation: pulse 2s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(76,195,138,.45); }
  70% { box-shadow: 0 0 0 7px rgba(76,195,138,0); }
  100% { box-shadow: 0 0 0 0 rgba(76,195,138,0); }
}
.device-meta { color: var(--text-dim); font-size: 12.5px; display: grid; gap: 3px; margin-bottom: 14px; }
.device-meta b { color: var(--text); font-weight: 600; }
.device-foot { display: flex; align-items: center; justify-content: space-between; }
.badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 3px 8px;
  border-radius: 20px;
}
.badge.online { background: rgba(76,195,138,.12); color: var(--green); }
.badge.offline { background: rgba(139,147,163,.12); color: var(--text-dim); }

/* ---------- toggle switch ---------- */
.switch {
  position: relative;
  width: 38px; height: 21px;
  display: inline-block;
  flex-shrink: 0;
}
.switch input { display: none; }
.slider {
  position: absolute; inset: 0;
  background: #2a303d;
  border-radius: 20px;
  transition: background .18s;
}
.slider::before {
  content: "";
  position: absolute;
  width: 15px; height: 15px;
  left: 3px; top: 3px;
  background: #aab2c0;
  border-radius: 50%;
  transition: transform .18s, background .18s;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(17px); background: #1a1208; }
.switch-label { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-dim); }

/* ---------- tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-soft);
  margin: 18px 0 0;
}
.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 16px;
  transition: color .12s, border-color .12s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-pane { padding-top: 4px; }

/* ---------- device detail / logs ---------- */
.detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; flex-wrap: wrap; }
.back-link { color: var(--text-dim); cursor: pointer; font-size: 13px; }
.back-link:hover { color: var(--accent); }
.log-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 12px;
  flex-wrap: wrap;
}
.chip {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-dim);
  border-radius: 20px;
  padding: 4px 13px;
  font-size: 12px;
  font-weight: 700;
  transition: all .12s;
}
.chip:hover { color: var(--text); }
.chip.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.chip.lvl-D.active { border-color: var(--text-dim); color: var(--text); background: rgba(139,147,163,.15); }
.chip.lvl-I.active { border-color: var(--blue); color: var(--blue); background: rgba(79,140,255,.12); }
.chip.lvl-W.active { border-color: var(--yellow); color: var(--yellow); background: rgba(216,161,60,.12); }
.chip.lvl-E.active { border-color: var(--red); color: var(--red); background: rgba(229,83,75,.12); }
.log-controls input { padding: 6px 12px; font-size: 13px; }
.log-view {
  background: #0b0d11;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  height: calc(100vh - 345px);
  min-height: 320px;
  overflow-y: auto;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
}
.log-line { display: flex; gap: 10px; white-space: pre-wrap; word-break: break-all; }
.log-line .ts { color: var(--text-faint); flex-shrink: 0; }
.log-line .tag { color: var(--accent); flex-shrink: 0; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-line .lvl { flex-shrink: 0; width: 14px; font-weight: 700; }
.log-line .lvl.D { color: var(--text-dim); }
.log-line .lvl.I { color: var(--blue); }
.log-line .lvl.W { color: var(--yellow); }
.log-line .lvl.E { color: var(--red); }
.log-line .msg { color: var(--text); }
.log-empty { color: var(--text-faint); padding: 20px; text-align: center; }
.paused-banner {
  background: var(--accent-dim);
  color: var(--accent);
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  padding: 4px;
  border-radius: 6px 6px 0 0;
}

/* ---------- tables ---------- */
.table-card {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-faint);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  font-weight: 700;
}
td { padding: 11px 16px; border-bottom: 1px solid var(--border-soft); font-size: 13.5px; }
tr:last-child td { border-bottom: none; }
.role-pill {
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 20px;
  background: rgba(79,140,255,.12);
  color: var(--blue);
}
.role-pill.admin { background: var(--accent-dim); color: var(--accent); }

/* ---------- forms / cards ---------- */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  max-width: 560px;
}
.card h3 { font-size: 14px; margin-bottom: 14px; }
.form-row { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.form-row input, .form-row select { flex: 1; min-width: 140px; }
.radio-row { display: flex; gap: 18px; margin-bottom: 16px; }
.radio-opt {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  transition: border-color .12s;
}
.radio-opt.selected { border-color: var(--accent); background: var(--accent-dim); }
.radio-opt input { accent-color: var(--accent); }
.hint { color: var(--text-faint); font-size: 12.5px; margin-top: 10px; }

.placeholder-box {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 60px 30px;
  text-align: center;
  color: var(--text-faint);
}
.placeholder-box .big { font-size: 16px; color: var(--text-dim); margin-bottom: 6px; }

.loading { color: var(--text-faint); padding: 40px; text-align: center; }
.section-gap { margin-top: 24px; }
.mono { font-family: var(--mono); font-size: 12px; }
.scope-cb {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: var(--text-dim);
  margin-right: 10px;
  cursor: pointer;
  user-select: none;
}
.scope-cb input { accent-color: var(--accent); cursor: pointer; }

/* ---------- OTA update status ---------- */
.st {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.st-downloaded { background: rgba(79,140,255,.13); color: var(--blue); }
.st-installing { background: rgba(216,161,60,.13); color: var(--yellow); }
.st-updated { background: rgba(76,195,138,.13); color: var(--green); }
.st-failed { background: rgba(229,83,75,.13); color: var(--red); }
.ast-cell { font-size: 12px; max-width: 260px; }
.ast-line { margin-bottom: 5px; }
input[type="file"] { padding: 6px 12px; }
input[type="file"]::file-selector-button {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 12px;
  margin-right: 10px;
  cursor: pointer;
  font-family: inherit;
}
