/* ═══════════════════════════════════════════════════════════
   Android Automation — Design System
   Shared tokens, components, and layout for all dashboard pages.
   ═══════════════════════════════════════════════════════════ */

:root {
  /* Layout */
  --shell-max: 1480px;
  --header-h: 56px;

  /* Core palette */
  --bg: #faf8f4;
  --surface: #fffefb;
  --surface-2: #f7f4ee;
  --surface-3: #fdfbf7;
  --border: rgba(226, 220, 209, 0.96);
  --border-solid: #e3ddd2;
  --border-light: #efe9df;
  --text: #24211c;
  --text-dim: #6d6559;
  --accent: #e2c969;

  /* Semantic */
  --green: #16a34a;
  --green-bg: #dcfce7;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --blue: #2563eb;
  --blue-bg: #dbeafe;
  --purple: #7c3aed;
  --purple-bg: #ede9fe;
  --orange: #ea580c;
  --pink: #db2777;

  /* App brand colors (muted) */
  --snap-yellow: #e2c969;
  --tinder-pink: #a17f11;
  --tinder-orange: #a17f11;
  --doubble-purple: #6d6559;
  --gmail-red: #a17f11;
  --gmail-blue: #6d6559;
  --gmail-green: #6d6559;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: linear-gradient(180deg, #fcfaf7 0%, var(--bg, #f7f3ec) 100%);
  color: var(--text, #27231d);
  font-family: "Segoe UI Variable Text", Aptos, "Segoe UI", system-ui, -apple-system, sans-serif;
}

body.modal-open {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(33, 91, 144, 0.42);
  outline-offset: 2px;
}

.topbar,
.top-bar {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 40;
  background: rgba(255, 254, 251, 0.98);
  border-bottom: 1px solid rgba(226, 220, 209, 0.96);
  backdrop-filter: none;
}

.topbar-inner,
.top-bar {
  width: min(var(--shell-max), calc(100% - 28px));
  margin: 0 auto;
}

.topbar-inner,
.top-bar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand,
.left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #f3d867;
  color: #162235;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  flex: 0 0 auto;
}

.brand-text {
  display: grid;
  gap: 0.08rem;
  min-width: 0;
}

.brand-title {
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.brand-subtitle {
  font-size: 0.76rem;
  color: var(--text-dim, #6a6258);
}

.title {
  font-weight: 800;
  font-size: 1rem;
}

.actions,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-btn,
.ghost-btn,
.primary-btn,
.utility-btn,
.refresh-btn,
.shell-button {
  min-height: 38px;
  padding: 0.55rem 0.92rem;
  border-radius: 11px;
  border: 1px solid rgba(226, 220, 209, 0.96);
  background: #fbf8f2;
  color: var(--text, #27231d);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.nav-btn:hover,
.ghost-btn:hover,
.utility-btn:hover,
.refresh-btn:hover,
.shell-button:hover {
  background: #f3eee5;
}

.nav-btn.active,
.nav-btn[aria-current="page"] {
  background: #f0e7d8;
  border-color: #decfab;
  color: #51410b;
}

.utility-btn {
  background: #f5edd2;
  border-color: #e2d2a0;
  color: #51410b;
}

.primary-btn,
.refresh-btn {
  background: #f3e7c1;
  border-color: #dfcf9d;
  color: #2b241d;
}

.primary-btn:hover,
.refresh-btn:hover {
  background: #eadcb1;
  border-color: #d8c58d;
}

.ghost-btn {
  background: #fffdfa;
}

.page {
  width: min(var(--shell-max), calc(100% - 28px));
  margin: 1.25rem auto 2rem;
  display: grid;
  gap: 1rem;
}

.hero,
.panel,
.section,
.card,
.surface-panel {
  border: 1px solid rgba(226, 220, 209, 0.96);
  background: #fffefb;
  box-shadow: none;
}

.hero {
  position: relative;
  overflow: hidden;
  border-radius: 26px;
  padding: 1.55rem 1.7rem;
  color: var(--text, #27231d);
  background: #fffefb;
}

.hero::before {
  display: none;
}

.hero::after {
  display: none;
}

.hero > * {
  position: relative;
  z-index: 1;
}

.hero,
.panel,
.section,
.surface-panel {
  border-radius: 24px;
}

.hero h1,
.hero h2 {
  margin: 0;
  font-size: clamp(1.45rem, 2vw, 2.1rem);
  line-height: 1.08;
  letter-spacing: -0.04em;
  text-wrap: balance;
}

.hero p,
.subtext {
  margin: 0.45rem 0 0;
  max-width: 720px;
  color: var(--text-dim, #6a6258);
  font-size: 0.9rem;
}

.hero-meta,
.hero-highlights {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.hero-meta {
  align-items: flex-end;
  justify-content: flex-end;
}

.pill,
.source-pill,
.hero-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 36px;
  padding: 0.48rem 0.8rem;
  border-radius: 999px;
  border: 1px solid rgba(226, 220, 209, 0.96);
  background: #f7f3eb;
  color: var(--text, #27231d);
  font-size: 0.76rem;
  font-weight: 700;
}

.pill.light,
.source-pill {
  background: #f7f3eb;
  border-color: rgba(226, 220, 209, 0.96);
  color: var(--text, #27231d);
  backdrop-filter: none;
}

.panel,
.section,
.surface-panel {
  position: relative;
  overflow: hidden;
  padding: 1rem;
}

.panel-head,
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.95rem;
}

.panel-head h2,
.section-head h2 {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.08;
  letter-spacing: -0.02em;
}

.panel-note,
.section-note {
  max-width: 420px;
  color: var(--text-dim, #6a6258);
  font-size: 0.82rem;
  text-align: right;
}

.eyebrow,
.panel-eyebrow {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-dim, #6a6258);
  margin-bottom: 0.28rem;
}

.panel .loading,
.panel .no-data,
.loading,
.no-data {
  text-align: center;
  padding: 2.4rem 1rem;
  color: var(--text-dim, #6a6258);
}

.stat-card,
.card,
.field,
.toggle,
.modal-card,
.candidate-item {
  border: 1px solid rgba(226, 220, 209, 0.96);
  background: #fdfbf7;
}

.summary-grid,
.kpi-row,
.grid {
  display: grid;
  gap: 0.75rem;
}

.stat-card {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  padding: 0.85rem 0.95rem;
}

.stat-label {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim, #6a6258);
  font-weight: 800;
}

.stat-value {
  margin-top: 0.2rem;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.stat-card .accent { color: #a17f11; }

.table-wrap,
.tbl-wrap {
  overflow-x: auto;
  border: 1px solid rgba(226, 220, 209, 0.96);
  border-radius: 18px;
  background: #fffefb;
}

.action-btn {
  border: 1px solid rgba(226, 220, 209, 0.96);
  background: #fbf8f2;
  color: var(--text, #27231d);
  padding: 0.42rem 0.72rem;
  border-radius: 10px;
  font: inherit;
  font-size: 0.73rem;
  font-weight: 700;
  cursor: pointer;
}

.action-btn:hover {
  background: #f3eee5;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
}

.badge-dim {
  background: #f7f3eb;
  color: var(--text-dim, #6a6258);
}

.link {
  color: #2563eb;
  font-weight: 700;
}

.link:hover {
  text-decoration: underline;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 24, 18, 0.18);
  backdrop-filter: none;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 1.25rem 1rem;
  overflow-y: auto;
  z-index: 60;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  width: min(980px, 100%);
  max-height: min(88vh, 960px);
  overflow: auto;
  background: #fffefb;
  border: 1px solid rgba(226, 220, 209, 0.98);
  border-radius: 22px;
  padding: 1.15rem;
  box-shadow: 0 12px 30px rgba(36, 33, 28, 0.08);
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.9rem;
  margin-bottom: 0.3rem;
  background: rgba(255, 254, 251, 0.98);
}

.modal-head h2 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
}

.modal-close {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid rgba(226, 220, 209, 0.96);
  background: #fbf8f2;
  color: var(--text-dim, #6a6258);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.modal-close:hover {
  background: #f3eee5;
  color: var(--text, #27231d);
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
}

.modal-card {
  border-radius: 16px;
  padding: 0.9rem;
}

.field {
  display: grid;
  gap: 0.12rem;
  margin-bottom: 0.55rem;
  border-radius: 14px;
  padding: 0.78rem 0.86rem;
}

.field:last-child {
  margin-bottom: 0;
}

.field-label {
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim, #6a6258);
  font-weight: 800;
}

.field-value {
  font-size: 0.82rem;
  color: var(--text, #27231d);
}

.candidate-list {
  display: grid;
  gap: 0.55rem;
}

.candidate-item {
  border-radius: 14px;
  padding: 0.8rem;
}

.reason-list {
  margin-top: 0.45rem;
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

@media (max-width: 920px) {
  .topbar-inner,
  .top-bar {
    min-height: auto;
    padding: 0.8rem 0;
    flex-direction: column;
    align-items: stretch;
  }

  .actions,
  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .nav-btn,
  .ghost-btn,
  .primary-btn,
  .utility-btn,
  .refresh-btn {
    flex: 1 1 0;
  }

  .page {
    width: min(var(--shell-max), calc(100% - 20px));
    margin-top: 1rem;
  }

  .hero,
  .panel,
  .section,
  .surface-panel {
    border-radius: 22px;
  }

  .panel-head,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-note,
  .section-note {
    text-align: left;
  }

  .modal-grid {
    grid-template-columns: 1fr;
  }
}

/* ═══════════════════════════════════════════════════════════
   Extended components (previously duplicated inline)
   ═══════════════════════════════════════════════════════════ */

/* ── Info grid (used on tinder, doubble, gmail, settings) ── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .6rem;
}
.info-card {
  padding: .65rem .75rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-3);
}
.info-card .label {
  font-size: .6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-dim);
  margin-bottom: .12rem;
}
.info-card .value {
  font-size: .92rem;
  font-weight: 700;
  color: var(--text);
}

/* ── Status indicators ── */
.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.idle { background: #b0a898; }
.status-dot.launching { background: #c9a83e; animation: pulse-dot 1.2s infinite; }
.status-dot.login { background: #8a7d6b; animation: pulse-dot 1.2s infinite; }
.status-dot.swiping, .status-dot.active { background: #8a9a6b; animation: pulse-dot 1.2s infinite; }
.status-dot.stopped { background: #b0a898; }
.status-dot.error { background: #b0877a; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

.status-banner {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .65rem 1rem;
  border-radius: 14px;
  font-size: .82rem;
  font-weight: 700;
}
.status-banner.idle { background: #f1f5f9; color: #475569; }
.status-banner.launching { background: #fef3c7; color: #92400e; }
.status-banner.login { background: #dbeafe; color: #1e40af; }
.status-banner.swiping, .status-banner.active { background: #dcfce7; color: #166534; }
.status-banner.stopped { background: #f1f5f9; color: #475569; }
.status-banner.error { background: #fee2e2; color: #991b1b; }

/* ── Status pills ── */
.status-pill {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 6px;
  font-size: .68rem;
  font-weight: 700;
}
.status-pill.available { background: var(--green-bg); color: #166534; }
.status-pill.used { background: #f1f5f9; color: #475569; }
.status-pill.banned { background: var(--red-bg); color: #991b1b; }

/* ── Log panel ── */
.log-panel {
  background: #1a1d23;
  color: #c9d1d9;
  border-radius: 14px;
  padding: .75rem;
  max-height: 420px;
  overflow-y: auto;
  font-family: "Cascadia Code", "Fira Code", "JetBrains Mono", monospace;
  font-size: .72rem;
  line-height: 1.55;
  white-space: pre-wrap;
}
.log-line { display: flex; gap: .5rem; padding: .12rem 0; }
.log-ts { color: #484f58; flex-shrink: 0; min-width: 72px; }
.log-msg { color: #c9d1d9; word-break: break-word; }
.log-msg.error { color: #f87171; }
.log-msg.success { color: #4ade80; }
.log-msg.info { color: #60a5fa; }
.log-empty { color: #484f58; font-style: italic; padding: .5rem 0; }

/* ── Launch / action buttons ── */
.launch-btn {
  min-height: 42px;
  padding: .6rem 1.4rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  font: inherit;
  font-size: .82rem;
  font-weight: 800;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.launch-btn:disabled { opacity: .5; cursor: not-allowed; }
.launch-btn.start { background: #f3e7c1; border-color: #dfcf9d; color: #2b241d; }
.launch-btn.start:hover { background: #eadcb1; border-color: #d8c58d; }
.launch-btn.stop { background: #f5edd2; border-color: #e2d2a0; color: #51410b; }
.launch-btn.stop:hover { background: #ece4c2; border-color: #d8c58d; }
.launch-btn.login-only { background: #f5edd2; border-color: #e2d2a0; color: #51410b; }
.launch-btn.inspect { background: #fbf8f2; border-color: var(--border); color: var(--text); }
.launch-btn.inspect:hover { background: #f3eee5; }
.launch-btn.purple { background: #f5edd2; border-color: #e2d2a0; color: #51410b; }
.danger-btn { min-height: 40px; padding: .5rem 1.2rem; border-radius: 12px; border: 1px solid #d8c58d; background: #f5edd2; color: #51410b; font: inherit; font-size: .78rem; font-weight: 700; cursor: pointer; }
.danger-btn.dark { background: #ece4c2; border-color: #d8c58d; }

/* ── Controls ── */
.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.control-group { display: grid; gap: .55rem; }
.control-group label {
  font-size: .65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--text-dim);
}
.control-group select,
.control-group input[type="number"],
.control-group input[type="text"],
.control-group input[type="password"] {
  min-height: 38px;
  padding: .5rem .75rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fbf8f2;
  color: var(--text);
  font: inherit;
  font-size: .82rem;
  font-weight: 600;
}
.control-group select:focus,
.control-group input:focus {
  outline: 2px solid rgba(33, 91, 144, 0.42);
  outline-offset: 2px;
}

/* ── Action row ── */
.action-row {
  display: flex;
  gap: .55rem;
  flex-wrap: wrap;
}

/* ── Checkbox row ── */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .78rem;
  font-weight: 600;
}
.checkbox-row input { width: 16px; height: 16px; accent-color: #2563eb; }

/* ── SMS balance pill ── */
.sms-balance {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .35rem .65rem;
  border-radius: 999px;
  background: #f7f3eb;
  border: 1px solid var(--border);
  font-size: .72rem;
  font-weight: 700;
  color: var(--text);
}

/* ── Data tables ── */
.data-table,
.account-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .78rem;
}
.data-table th,
.account-table th {
  text-align: left;
  font-size: .62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-dim);
  padding: .5rem .6rem;
  border-bottom: 1px solid var(--border-solid);
}
.data-table td,
.account-table td {
  padding: .55rem .6rem;
  border-bottom: 1px solid #f0ebe3;
}
.data-table tr:hover td,
.account-table tr:hover td { background: var(--surface-3); }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-dim);
  font-size: .85rem;
}
.empty-state .icon { font-size: 2rem; margin-bottom: .5rem; opacity: .4; }

/* ── Category tabs (settings) ── */
.cat-tabs {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.cat-tab {
  padding: .5rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  font: inherit;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}
.cat-tab:hover { background: #ece6dc; }
.cat-tab.active { background: var(--text); color: #fff; border-color: var(--text); }
.cat-group { display: none; }
.cat-group.active { display: grid; gap: 1rem; }

/* ── Settings toggles ── */
.grid.toggles {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid var(--border);
  background: var(--surface-3);
  border-radius: 14px;
  padding: .85rem .9rem;
}
.toggle .meta { min-width: 0; }
.toggle .meta .title {
  display: block;
  font-size: .73rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 800;
  margin-bottom: .45rem;
}
.toggle .meta p { margin: 0; color: var(--text-dim); font-size: .8rem; }
.toggle input[type="checkbox"] { width: 18px; height: 18px; accent-color: #6b5c33; flex: 0 0 auto; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d0d3db; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #b0b3be; }

/* ── Additional responsive ── */
@media (max-width: 760px) {
  .controls-grid { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .info-grid { grid-template-columns: 1fr; }
}
