:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --line: #e2e8f0;
  --text: #0f172a;
  --muted: #475569;
  --subtle: #64748b;
  --font-sans: "Be Vietnam Pro", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(circle at top right, rgba(244, 63, 94, 0.05), transparent 40%), var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}
input, select, button, textarea {
  font-family: inherit;
}
.hidden { display: none !important; }
.muted { color: var(--subtle); font-size: 12.5px; }

.btn-ico, .badge-ico, .search-ico {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.badge-ico { width: 12px; height: 12px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: linear-gradient(135deg, #f43f5e, #e11d48);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 8px 18px rgba(225, 29, 72, 0.25);
  flex-shrink: 0;
}
.brand-mark.sm { width: 36px; height: 36px; border-radius: 10px; font-size: 14px; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 20px 44px rgba(15, 23, 42, 0.08);
  display: grid;
  gap: 14px;
}
.login-card h1 { margin: 4px 0 0; font-size: 20px; font-weight: 700; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 11px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.topbar-left strong { display: block; font-size: 15px; font-weight: 700; color: var(--text); }

.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px 22px 40px;
  display: grid;
  gap: 16px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 16px 18px;
  display: grid;
  gap: 5px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.03);
  border-top: 3px solid #cbd5e1;
}
.kpi-card.kpi-accounts { border-top-color: #6366f1; }
.kpi-card.kpi-devices { border-top-color: #0ea5e9; }
.kpi-card.is-online { border-top-color: #22c55e; }
.kpi-card.kpi-active { border-top-color: #2563eb; }
.kpi-card small { font-size: 11.5px; font-weight: 600; text-transform: uppercase; color: var(--muted); letter-spacing: 0.02em; }
.kpi-card strong { font-size: 28px; font-weight: 700; line-height: 1.15; color: var(--text); }
.kpi-card.is-online strong { color: #16a34a; }

.toolbar-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
}
.search-wrap {
  position: relative;
  flex: 1 1 280px;
}
.search-ico {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--subtle);
  pointer-events: none;
}
.search-wrap input {
  width: 100%;
  height: 38px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 0 12px 0 36px;
  background: #f8fafc;
  font-size: 13.5px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.search-wrap input:focus {
  border-color: #f43f5e;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.12);
}

.filter-pills { display: flex; gap: 7px; flex-wrap: wrap; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.pill:hover { background: #f1f5f9; border-color: #94a3b8; }
.pill.is-active[data-filter="all"] { background: #0f172a; color: #fff; border-color: #0f172a; }
.pill.is-active[data-filter="online"] { background: #16a34a; color: #fff; border-color: #16a34a; }
.pill.is-active[data-filter="active"] { background: #2563eb; color: #fff; border-color: #2563eb; }
.pill.is-active[data-filter="inactive"] { background: #e11d48; color: #fff; border-color: #e11d48; }

.ws-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}
.ws-pill i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.ws-pill.is-live { background: #dcfce7; color: #15803d; border-color: #86efac; }
.ws-pill.is-live i { background: #22c55e; animation: pulseDot 1.8s infinite; }
.ws-pill.is-connecting { background: #fef3c7; color: #b45309; border-color: #fcd34d; }
.ws-pill.is-offline { background: #ffe4e6; color: #be123c; border-color: #fda4af; }
@keyframes pulseDot { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.45; transform: scale(0.85); } }

.accounts-list { display: grid; gap: 14px; }
.account-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 3px 14px rgba(15, 23, 42, 0.04);
}
.account-head {
  padding: 13px 18px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.account-info { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.account-name { font-size: 15.5px; font-weight: 700; color: var(--text); }
.account-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }

/* Distinct Semantic Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.badge-online { background: #dcfce7; color: #15803d; border-color: #86efac; }
.badge-online.badge-dot::before { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2); }
.badge-offline { background: #f1f5f9; color: #64748b; border-color: #cbd5e1; }
.badge-active { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.badge-inactive { background: #fff1f2; color: #be123c; border-color: #fecdd3; }
.badge-locked { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.badge-pending { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.badge-quota { background: #eef2ff; color: #4338ca; border-color: #c7d2fe; }
button.badge { transition: transform 0.12s ease, filter 0.12s ease; }
button.badge:hover { filter: brightness(0.96); transform: translateY(-1px); }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 880px; }
th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  letter-spacing: 0.02em;
}
td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  font-size: 13.5px;
}
tr:hover td { background: #fafcff; }
tr:last-child td { border-bottom: 0; }
.empty-devices { padding: 20px; text-align: center; color: var(--subtle); font-size: 13px; }

.serial-cell { display: flex; align-items: center; gap: 7px; }
.serial-code {
  display: inline-block;
  max-width: 310px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 5px 10px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: #0f172a;
}
.live-timer {
  font-family: var(--font-mono);
  font-weight: 600;
  color: #15803d;
  font-size: 13px;
}
.sub-meta { display: block; font-size: 11.5px; color: var(--subtle); margin-top: 2px; }
.tinder-cell { display: flex; align-items: center; gap: 10px; }
.tinder-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
  color: #475569;
  font-weight: 700;
  font-size: 13px;
  border: 2px solid #ffe4e6;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}
.tinder-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tinder-meta { min-width: 0; }
.nick-row { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.nick-row strong { font-weight: 600; color: var(--text); }

/* Distinct Semantic Button Styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 13px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  border: 1px solid transparent;
  transition: transform 0.14s ease, filter 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.sm { height: 31px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; height: 42px; font-size: 13.5px; }

.btn-primary {
  background: linear-gradient(135deg, #f43f5e, #e11d48);
  color: #fff;
  box-shadow: 0 4px 12px rgba(225, 29, 72, 0.24);
}
.btn-primary:hover { filter: brightness(1.05); box-shadow: 0 6px 16px rgba(225, 29, 72, 0.32); }

.btn-info {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}
.btn-info:hover { background: #dbeafe; border-color: #93c5fd; }

.btn-indigo {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #4338ca;
}
.btn-indigo:hover { background: #e0e7ff; border-color: #a5b4fc; }

.btn-cyan {
  background: #ecfeff;
  border-color: #a5f3fc;
  color: #0e7490;
}
.btn-cyan:hover { background: #cffafe; border-color: #67e8f9; }

.btn-emerald {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #047857;
}
.btn-emerald:hover { background: #d1fae5; border-color: #6ee7b7; }

.btn-amber {
  background: #fffbeb;
  border-color: #fde68a;
  color: #b45309;
}
.btn-amber:hover { background: #fef3c7; border-color: #fcd34d; }

.btn-danger {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #be123c;
}
.btn-danger:hover { background: #ffe4e6; border-color: #fda4af; }

.btn-ghost {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #334155;
}
.btn-ghost:hover { background: #f8fafc; border-color: #94a3b8; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  color: #475569;
  cursor: pointer;
}
.icon-btn:hover { background: #f1f5f9; color: #0f172a; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 12.5px; font-weight: 600; color: #334155; }
.field input, .field select {
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 0 12px;
  font-size: 13.5px;
  color: var(--text);
  background: #f8fafc;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus, .field select:focus {
  border-color: #f43f5e;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.12);
}
.input-action {
  display: flex;
  align-items: center;
  gap: 8px;
}
.input-action input { flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 12.5px; }
.input-action .btn { height: 38px; }
.form-error { margin: 0; color: #be123c; font-size: 12.5px; font-weight: 600; }
.hint-text { margin: 0; line-height: 1.5; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 16px;
}
.modal-card {
  width: 100%;
  max-width: 470px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 24px 52px rgba(15, 23, 42, 0.24);
  display: grid;
  gap: 14px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal-head h3 { margin: 0; font-size: 16.5px; font-weight: 700; color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: grid;
  gap: 8px;
}
.toast {
  background: #0f172a;
  color: #fff;
  padding: 10px 15px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.22);
}
.toast.is-error { background: #be123c; }
.toast.is-ok { background: #15803d; }

@media (max-width: 860px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
