/* ADB Panel — base styles */
:root {
  --bg: #0e1116;
  --bg-elev: #161b22;
  --bg-elev-2: #1c2230;
  --border: #2a3140;
  --border-strong: #3a4253;
  --text: #e6edf3;
  --text-dim: #9aa5b1;
  --text-muted: #6b7785;
  --accent: #2f81f7;
  --accent-hover: #4f98ff;
  --green: #3fb950;
  --yellow: #d29922;
  --red: #f85149;
  --orange: #db6d28;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --radius: 6px;
  --radius-lg: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  height: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: var(--text);
}

input, select, textarea {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  outline: none;
  transition: border-color 0.15s;
}

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

button {
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
button:hover:not(:disabled) {
  background: var(--bg-elev);
  border-color: var(--accent);
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
button.danger {
  background: transparent;
  border-color: var(--red);
  color: var(--red);
}
button.danger:hover:not(:disabled) {
  background: rgba(248, 81, 73, 0.12);
}
button.ghost {
  background: transparent;
  border-color: transparent;
}
button.ghost:hover:not(:disabled) {
  background: var(--bg-elev);
}

label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .brand {
  font-weight: 700;
  letter-spacing: 0.3px;
  margin-right: 8px;
}

.topbar nav {
  display: flex;
  gap: 6px;
  flex: 1;
}

.topbar nav a {
  color: var(--text-dim);
  padding: 6px 10px;
  border-radius: var(--radius);
}
.topbar nav a.active,
.topbar nav a:hover {
  color: var(--text);
  background: var(--bg-elev-2);
  text-decoration: none;
}

.topbar .user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: var(--bg-elev-2);
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
}

.topbar .conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
}
.topbar .conn-dot.ok { background: var(--green); }
.topbar .conn-dot.warn { background: var(--yellow); }
.topbar .conn-dot.bad { background: var(--red); }

.container {
  padding: 20px;
  flex: 1;
}

.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 16px 0;
}
.page-title h1 {
  margin: 0;
  font-size: 22px;
}

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.toolbar .grow { flex: 1; }
.toolbar .spacer { flex: 1; }

.toolbar input, .toolbar select {
  min-width: 160px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  transition: border-color 0.15s, transform 0.15s;
  position: relative;
}
.card:hover {
  border-color: var(--border-strong);
}

.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.mono { font-family: var(--mono); }

.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: var(--bg-elev-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.badge.online { background: rgba(63, 185, 80, 0.15); color: var(--green); border-color: rgba(63, 185, 80, 0.4); }
.badge.offline { background: rgba(248, 81, 73, 0.12); color: var(--red); border-color: rgba(248, 81, 73, 0.35); }
.badge.unauthorized { background: rgba(210, 153, 34, 0.15); color: var(--yellow); border-color: rgba(210, 153, 34, 0.35); }
.badge.warn { background: rgba(210, 153, 34, 0.15); color: var(--yellow); border-color: rgba(210, 153, 34, 0.35); }
.badge.role { text-transform: uppercase; letter-spacing: 0.5px; }

.empty {
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
  background: var(--bg-elev);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
}

.pagination {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  margin: 20px 0 0;
  color: var(--text-dim);
}

/* Toasts */
.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  max-width: 380px;
}
.toast {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: var(--shadow);
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: toast-in 0.18s ease-out;
}
.toast.success { border-left-color: var(--green); }
.toast.warning { border-left-color: var(--yellow); }
.toast.error { border-left-color: var(--red); }
.toast .x {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
}
.toast .x:hover { color: var(--text); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Login */
.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 0%, rgba(47, 129, 247, 0.08), transparent 50%),
    radial-gradient(circle at 80% 100%, rgba(63, 185, 80, 0.05), transparent 50%),
    var(--bg);
}
.auth-card {
  width: min(420px, 92vw);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
}
.auth-card h1 {
  margin: 0 0 4px;
  font-size: 22px;
}
.auth-card p.sub {
  color: var(--text-dim);
  margin: 0 0 20px;
  font-size: 13px;
}
.field {
  margin-bottom: 14px;
}
.field input { width: 100%; padding: 10px 12px; }
.field-error {
  color: var(--red);
  font-size: 12px;
  margin-top: 4px;
}
.auth-card button[type="submit"] {
  width: 100%;
  padding: 10px;
  margin-top: 4px;
}
.auth-foot {
  margin-top: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

/* Device card */
.device-card {
  padding-top: 8px;
}
.device-card .card-checkbox {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  z-index: 2;
}
.device-card .card-checkbox input[type=checkbox] {
  transform: scale(1.1);
  cursor: pointer;
}
.device-card .card-preview {
  width: fit-content;
  margin: 0 auto 10px;
  position: relative;
  /* Phone bezel — Android Studio device preview style */
  background: linear-gradient(180deg, #1c1f24 0%, #14161a 100%);
  padding: 8px 4px 10px;
  border-radius: 22px;
  border: 1px solid #2a2f37;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 6px 20px rgba(0, 0, 0, 0.45);
}
.device-card .card-preview-inner {
  position: relative;
  width: 130px;
  aspect-ratio: 9 / 19.5;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  /* Subtle screen rim */
  box-shadow:
    0 0 0 1px #000 inset,
    0 0 0 2px rgba(255, 255, 255, 0.03) inset;
}
.device-card .card-preview-inner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  display: block;
}
/* Notch/punch-hole style ornament */
.device-card .card-preview-inner::before {
  content: '';
  position: absolute;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #1a1a1a;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
  z-index: 2;
}
/* Speaker grill above the screen */
.device-card .card-preview::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 2px;
  border-radius: 1px;
  background: #2a2f37;
}
.device-card .head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}
.device-card .name {
  font-weight: 600;
  font-size: 14px;
  word-break: break-all;
}
.device-card .id {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono);
}
.device-card .meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  font-size: 12px;
  color: var(--text-dim);
  margin: 8px 0;
}
.device-card .meta .k { color: var(--text-muted); }
.device-card .meta .v { color: var(--text); }
.device-card .actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.device-card .actions button {
  padding: 4px 10px;
  font-size: 12px;
}
.device-card .tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.bar {
  display: block;
  height: 4px;
  background: var(--bg-elev-2);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 2px;
}
.bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
}
.bar > span.ok { background: var(--green); }
.bar > span.warn { background: var(--yellow); }
.bar > span.bad { background: var(--red); }

.summary {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-dim);
}
.summary b { color: var(--text); }

.hidden { display: none !important; }
