/* =========================================================================
   ASO Toolytics — Light Redesign stylesheet
   Mirrors the Claude-Design "ASO Toolytics" design language while keeping
   the existing HTML structure / class names so all JS keeps working.
   ========================================================================= */

/* ---------- Design tokens ----------------------------------------------- */
:root {
  --bg:           #F4F6F9;
  --bg-soft:      #EEF1F6;
  --surface:      #FFFFFF;
  --surface-2:    #FAFBFD;
  --border:       #E6E9EF;
  --border-strong:#D5DAE3;
  --ink:          #0F1729;
  --ink-2:        #2A3245;
  --muted:        #5B6478;
  --muted-2:      #8B93A6;
  --primary:      #2D6BFF;
  --primary-ink:  #1F4FCC;
  --primary-soft: #EAF1FF;
  --violet:       #6B5BFF;
  --violet-soft:  #EEEBFF;
  --success:      #16A34A;
  --success-soft: #E6F7EC;
  --danger:       #E5484D;
  --danger-soft:  #FDECEC;
  --warn:         #D97706;
  --warn-soft:    #FEF3E2;

  /* Legacy aliases used throughout the existing JS-rendered markup */
  --text:         var(--ink);
  --text-muted:   var(--muted);
  --accent:       var(--primary);
  --accent-hover: var(--primary-ink);
  --good:         var(--success);
  --bad:          var(--danger);

  --shadow-sm:    0 1px 2px rgba(15,23,41,.04);
  --shadow:       0 4px 16px rgba(15,23,41,.06);
  --shadow-lg:    0 12px 32px rgba(15,23,41,.10);

  --radius:       14px;
  --radius-sm:    8px;
  --r-sm:         6px;
  --r:            10px;
  --r-lg:         14px;
  --gap:          1rem;
  --gap-lg:       1.5rem;
}

/* ---------- Reset / base ------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code, kbd, .mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
}
.muted { color: var(--muted); }

/* =========================================================================
   App shell — icon rail + secondary sidebar + main
   ========================================================================= */
.app {
  display: grid;
  grid-template-columns: 64px 260px 1fr;
  min-height: 100vh;
}
.main { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }

/* Icon rail */
.rail {
  background: #0F1729;
  color: #FFF;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0 18px;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 60;
}
.rail-logo {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--violet) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFF;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
  flex-shrink: 0;
}
.rail-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9AA4BC;
  background: transparent;
  border: none;
  transition: background .15s ease, color .15s ease;
  position: relative;
  cursor: pointer;
}
.rail-btn:hover { color: #FFF; background: rgba(255,255,255,.06); }
.rail-btn.active { color: #FFF; background: rgba(45,107,255,.18); }
.rail-btn.active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}
.rail-spacer { flex: 1; }

/* Secondary sidebar header */
.workspace-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.workspace-head .wsicon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, #FFE7C2 0%, #FFC79A 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.workspace-head .wsname {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
}
.workspace-head .wsname span {
  background: linear-gradient(135deg, var(--primary) 0%, var(--violet) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Collapsible nav groups (section headers w/ chevron) */
.nav-group { padding: 4px 0; }
.nav-group + .nav-group {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 8px;
}
.nav-group-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 10px;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink-2);
  cursor: pointer;
  border-radius: 7px;
  user-select: none;
  margin: 0 2px;
  transition: background .12s;
}
.nav-group-head:hover { background: var(--bg-soft); }
.nav-group-head .chev {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-2);
  transition: transform .15s ease;
  width: 14px;
  height: 14px;
}
.nav-group.collapsed .chev { transform: rotate(-90deg); }
.nav-group.collapsed .nav-items { display: none; }
.nav-items { display: flex; flex-direction: column; gap: 1px; padding: 2px 0 4px 0; }
.nav-group-flat { padding: 8px 0 0; border-top: 1px solid var(--border); margin-top: 6px; }

/* =========================================================================
   Top app header (now lives inside .main)
   ========================================================================= */
.app-header {
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.app-header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  max-width: 1600px;
  margin: 0 auto;
}
.app-header-brand .brand {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--ink);
}
.app-header-brand .brand span {
  background: linear-gradient(135deg, var(--primary) 0%, var(--violet) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.quick-analyze {
  flex: 1 1 320px;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 560px;
  height: 38px;
  padding: 0 4px 0 12px;
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted);
  transition: background .12s, border-color .12s;
}
.quick-analyze:focus-within { background: #FFF; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(45,107,255,.15); }
.quick-analyze input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 13.5px;
  color: var(--ink);
}
.quick-analyze input::placeholder { color: var(--muted); }
.quick-analyze button {
  height: 30px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #FFF;
  font-weight: 600;
  font-size: 12.5px;
  box-shadow: 0 1px 2px rgba(45,107,255,.25);
}
.quick-analyze button:hover { background: var(--primary-ink); }

.app-header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.country-chip {
  height: 38px;
  appearance: none;
  background: #FFF;
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 0 32px 0 14px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235B6478' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.country-chip:hover { border-color: var(--border-strong); }
.country-chip:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(45,107,255,.15); }

/* =========================================================================
   Workspace shell (sidebar + main) — the .workspace-nav is column 2 of .app
   ========================================================================= */
.workspace-nav {
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 40;
}
.workspace-main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 24px;
  max-width: 1500px;
  width: 100%;
  margin: 0;
}

/* =========================================================================
   Sidebar nav
   ========================================================================= */
.primary-nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 10px 14px;
}
.primary-nav::-webkit-scrollbar { width: 6px; }
.primary-nav::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.nav-section { padding: 4px 0 6px; }
.nav-section + .nav-section { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; }
.nav-section-title {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 12px 6px;
  font-weight: 600;
}
.primary-nav-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-tab {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 7px 10px;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background .12s, color .12s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-tab:hover { background: var(--bg-soft); }
.nav-tab-active {
  background: var(--primary-soft);
  color: var(--primary-ink);
  font-weight: 600;
}
.nav-tab-danger { color: var(--danger); }
.nav-tab-danger.nav-tab-active { background: var(--danger-soft); color: var(--danger); }
.nav-tab-logout { color: var(--muted); }
.nav-tab-logout:hover { color: var(--ink); background: var(--bg-soft); }

/* Sub-nav: shown only when its primary group is active */
.sub-nav {
  list-style: none;
  margin: 4px 0 8px 6px;
  padding: 2px 0 2px 10px;
  border-left: 2px solid var(--border);
  display: none;
}
.primary-nav-group.is-active .sub-nav { display: block; }
.sub-nav li { margin: 0; padding: 0; }
.sub-nav-tab {
  width: 100%;
  background: transparent;
  border: none;
  text-align: left;
  padding: 5px 10px;
  margin: 1px 0;
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px;
  transition: color .12s, background .12s;
}
.sub-nav-tab:hover { color: var(--ink); background: var(--bg-soft); }
.sub-nav-tab-active {
  color: var(--primary-ink);
  background: var(--primary-soft);
  font-weight: 600;
}

/* =========================================================================
   Sidebar footer (user card + plan)
   ========================================================================= */
.sidebar-footer {
  flex: 0 0 auto;
  padding: 10px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .12s;
}
.sidebar-user-card:hover { background: var(--bg-soft); }
.sidebar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #FFF;
  background: linear-gradient(135deg, #F59E0B, #EF4444);
  font-size: 13px;
  flex-shrink: 0;
}
.sidebar-user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
  flex: 1 1 auto;
}
.sidebar-user-meta strong {
  font-size: 13px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}
.sidebar-user-meta .muted {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-role-badge {
  display: inline-block;
  align-self: flex-start;
  margin-top: 3px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.sidebar-role-admin { background: var(--primary-soft); color: var(--primary-ink); }

.sidebar-plan-card {
  background: linear-gradient(135deg, #EEEBFF 0%, #DFE9FF 100%);
  border: 1px solid #D5D5FF;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-plan-card strong {
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
  flex: 1;
}
.sidebar-trial-btn {
  background: var(--ink);
  color: #FFF;
  border: 0;
  font-size: 11.5px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.sidebar-trial-btn:hover { background: var(--ink-2); }

/* =========================================================================
   Page toolbar (settings/account pages)
   ========================================================================= */
.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-toolbar h2 {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.page-toolbar h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}
.page-toolbar-right {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.page-toolbar-right input[type=search],
.page-toolbar-right select {
  padding: 8px 12px;
  border-radius: 8px;
  background: #FFF;
  border: 1px solid var(--border);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
}

/* =========================================================================
   Cards
   ========================================================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
  margin-bottom: 16px;
}

/* =========================================================================
   Forms
   ========================================================================= */
.form-card form {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto auto;
  gap: 14px;
  align-items: end;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field label,
.field .field-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  letter-spacing: 0;
}
.field input[type="text"],
.field input[type="url"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field select,
.field textarea {
  background: #FFF;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  height: 38px;
  font-size: 13.5px;
  transition: border-color .12s, box-shadow .12s;
  width: 100%;
}
.field textarea {
  height: auto;
  padding: 10px 12px;
  min-height: 160px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45,107,255,.15);
}
.field select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235B6478' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}
.field-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  align-self: flex-end;
}
.field-hint.over-limit { color: var(--danger); font-weight: 600; }
.field-hint.near-limit { color: var(--warn); font-weight: 600; }

/* Store toggle — segmented control */
.store-toggle {
  display: inline-flex;
  background: var(--bg-soft);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
  align-self: flex-start;
}
.store-toggle label {
  position: relative;
  cursor: pointer;
}
.store-toggle input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.store-toggle span {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  user-select: none;
  transition: background .12s, color .12s, box-shadow .12s;
}
.store-toggle input[type="radio"]:checked + span {
  background: #FFF;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.store-toggle label:hover input[type="radio"]:not(:checked) + span { color: var(--ink); }

/* Per-store sub-tabs */
.store-subtabs { margin-top: 12px; }
.store-subtabs-bar {
  display: inline-flex;
  background: var(--bg-soft);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
  margin-bottom: 12px;
}
.store-subtab {
  background: transparent;
  border: 0;
  padding: 6px 14px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
}
.store-subtab:hover { color: var(--ink); }
.store-subtab-active {
  background: #FFF;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* =========================================================================
   Buttons (incl. primary submit ids used throughout)
   ========================================================================= */
#submit-btn, #suggest-btn, #bulk-btn, #spy-btn, #listing-btn,
#project-add-btn, #project-refresh-btn, #tracker-check-btn,
#new-project-btn, #tracker-add-btn, #quick-analyze-btn,
.form-card .field-submit > button[type="submit"] {
  height: 38px;
  padding: 0 18px;
  background: var(--primary);
  color: #FFF;
  border: 1px solid var(--primary);
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(45,107,255,.25);
  transition: background .12s, border-color .12s, transform .05s;
}
#submit-btn:hover:not(:disabled),
#suggest-btn:hover:not(:disabled),
#bulk-btn:hover:not(:disabled),
#spy-btn:hover:not(:disabled),
#listing-btn:hover:not(:disabled),
#project-add-btn:hover:not(:disabled),
#project-refresh-btn:hover:not(:disabled),
#tracker-check-btn:hover:not(:disabled),
#new-project-btn:hover:not(:disabled),
#tracker-add-btn:hover:not(:disabled),
.form-card .field-submit > button[type="submit"]:hover:not(:disabled) {
  background: var(--primary-ink);
  border-color: var(--primary-ink);
}
#submit-btn:disabled, #suggest-btn:disabled, #bulk-btn:disabled,
#spy-btn:disabled, #listing-btn:disabled, #project-add-btn:disabled,
#project-refresh-btn:disabled, #tracker-check-btn:disabled,
#new-project-btn:disabled, #tracker-add-btn:disabled {
  background: var(--border);
  color: var(--muted);
  border-color: var(--border);
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: #FFF;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 14px;
  height: 38px;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn-secondary:hover {
  background: var(--bg-soft);
  border-color: var(--border-strong);
}

.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #FFF;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  height: 32px;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn-export:hover {
  background: var(--bg-soft);
  border-color: var(--border-strong);
}

.btn-danger {
  background: #FFF;
  color: var(--danger);
  border: 1px solid var(--danger-soft);
}
.btn-danger:hover {
  background: var(--danger);
  color: #FFF;
  border-color: var(--danger);
}

.primary-btn {
  background: var(--primary);
  color: #FFF;
  border: 1px solid var(--primary);
  border-radius: 8px;
  padding: 0 16px;
  height: 38px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(45,107,255,.25);
  transition: background .12s;
}
.primary-btn:hover:not(:disabled) {
  background: var(--primary-ink);
  border-color: var(--primary-ink);
}
.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.ghost-btn {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 14px;
  height: 38px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}
.ghost-btn:hover {
  background: var(--bg-soft);
  border-color: var(--border-strong);
}

.danger-btn {
  background: var(--danger);
  color: #FFF;
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 0 16px;
  height: 38px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
}
.danger-btn:hover { filter: brightness(1.05); }

.form-error {
  margin: 1rem 0 0;
  padding: 10px 14px;
  background: var(--danger-soft);
  border: 1px solid #F5C7C9;
  color: var(--danger);
  border-radius: 8px;
  font-size: 13px;
}
.form-error ul { margin: 6px 0 0 18px; padding: 0; }
.form-error-inline {
  margin: 6px 0 8px;
  padding: 6px 10px;
  font-size: 12.5px;
}

/* =========================================================================
   Loading + Spinner
   ========================================================================= */
.loading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 1.5rem;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  color: var(--muted);
  font-size: 13.5px;
  box-shadow: var(--shadow-sm);
}
.spinner {
  width: 22px; height: 22px;
  border: 2.5px solid rgba(45,107,255,0.18);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.tab-panel { animation: fadeIn .15s ease-out; }
.nav-panel { animation: fadeIn .18s ease-out; }

/* =========================================================================
   Results / store panels (Analyze)
   ========================================================================= */
.results { display: grid; gap: var(--gap-lg); margin-top: 1.5rem; }
.results.both-mode { grid-template-columns: 1fr 1fr; }

.store-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}
.store-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.store-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

/* Tag pills (live / cache / error / source) */
.tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid;
}
.tag-live          { background: var(--success-soft); color: var(--success); border-color: #C7EAD3; }
.tag-cache         { background: var(--primary-soft); color: var(--primary-ink); border-color: #CFE0FF; }
.tag-error         { background: var(--danger-soft); color: var(--danger); border-color: #F5C7C9; }
.tag-source-apple    { background: var(--success-soft); color: var(--success); border-color: #C7EAD3; }
.tag-source-estimate { background: var(--warn-soft); color: var(--warn); border-color: #F9DEB3; }

.store-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

/* Score tiles */
.scores {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.score-tile {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  text-align: center;
}
.score-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.score-label {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.score-source { margin-top: 8px; }
.score-low    { color: var(--success); }
.score-medium { color: var(--warn); }
.score-high   { color: var(--danger);  }

.score-tile-highlight {
  background: linear-gradient(180deg, var(--primary-soft) 0%, #FFF 80%);
  border-color: #CFE0FF;
}

/* =========================================================================
   Apps table (Analyze results)
   ========================================================================= */
.apps-table-wrap { overflow-x: auto; }
.apps-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.apps-table th, .apps-table td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: middle;
}
.apps-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
  background: var(--surface-2);
}
.apps-table tr:last-child td { border-bottom: none; }
.apps-table .col-rank   { width: 1%; color: var(--muted); font-variant-numeric: tabular-nums; }
.apps-table .col-title  { white-space: normal; }
.apps-table .col-numeric { text-align: right; font-variant-numeric: tabular-nums; }
.apps-table a { color: var(--ink); }
.apps-table a:hover { color: var(--primary); }

.empty-state {
  padding: 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

/* App icon thumbs */
.app-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  vertical-align: middle;
  flex-shrink: 0;
}
.app-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.app-icon-mono { font-weight: 700; color: var(--muted); font-size: 13px; line-height: 1; }
.col-icon { width: 44px; }

.fetched-app-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 10px 0 14px;
}
.fetched-app-card .fetched-app-title {
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 36ch;
}
.fetched-app-card .fetched-app-sub { color: var(--muted); font-size: 12.5px; }

/* =========================================================================
   Suggest/Bulk/Spy/Folder tables
   ========================================================================= */
.suggest-results { margin-top: 1.5rem; }
.suggest-summary {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.suggest-summary strong { color: var(--ink); }
.suggest-summary .summary-text { flex: 1 1 auto; min-width: 12rem; }

.suggest-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.suggest-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 600px;
}
.suggest-table th, .suggest-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-align: left;
  vertical-align: middle;
}
.suggest-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
  background: var(--surface-2);
  position: sticky;
  top: 0;
  z-index: 1;
}
.suggest-table tbody tr:last-child td { border-bottom: 0; }
.suggest-table tbody tr:hover td { background: var(--surface-2); }
.suggest-table .col-kw { white-space: normal; min-width: 12rem; font-weight: 500; color: var(--ink); }
.suggest-table .col-num { text-align: right; font-variant-numeric: tabular-nums; }
.suggest-table .col-group {
  border-left: 1px solid var(--border);
  padding-left: 16px;
}
.col-group-header {
  text-align: center !important;
  border-left: 1px solid var(--border);
  background: var(--surface-2);
}
.col-group-header.ios     { color: var(--warn); }
.col-group-header.android { color: var(--success); }

/* Per-cell color helpers */
.score-cell-low    { color: var(--success); font-weight: 600; }
.score-cell-medium { color: var(--warn);    font-weight: 600; }
.score-cell-high   { color: var(--danger);  font-weight: 600; }

/* Inline tag inside table cells */
.suggest-table .inline-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-left: 6px;
  vertical-align: middle;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--muted);
}

/* Sortable column headers */
.suggest-table th.sortable { cursor: pointer; user-select: none; }
.suggest-table th.sortable:hover { color: var(--ink); }
.suggest-table th.sort-asc::after  { content: ' ▲'; font-size: 0.75em; }
.suggest-table th.sort-desc::after { content: ' ▼'; font-size: 0.75em; }
.suggest-table th { user-select: none; cursor: grab; }
.suggest-table th.th-dragging { opacity: 0.4; }

/* Header help tooltip */
.th-label { margin-right: 5px; }
.th-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  cursor: help;
  vertical-align: 1px;
  border: 1px solid var(--border);
}
.th-help:hover {
  background: var(--primary-soft);
  color: var(--primary-ink);
  border-color: var(--primary);
}

/* Selection column */
.suggest-table th.col-select,
.suggest-table td.col-select {
  width: 32px;
  padding-left: 12px;
  padding-right: 4px;
  text-align: center;
}
.suggest-table th.col-select { cursor: pointer; }
.suggest-table input.row-select-input {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
}

.selection-info {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-ink);
  font-weight: 600;
  font-size: 12px;
  border: 1px solid #CFE0FF;
}
.btn-export.selection-clear {
  color: var(--danger);
  border-color: #F5C7C9;
}
.btn-export.selection-clear:hover {
  background: var(--danger);
  color: #FFF;
  border-color: var(--danger);
}

/* "All sweet spot" row highlight */
.row-all-easy,
.row-all-sweet {
  background: var(--success-soft);
  border-left: 3px solid var(--success);
}
.row-all-easy td,
.row-all-sweet td {
  background: var(--success-soft);
}

/* Failed scrape row */
.row-failed td { opacity: 0.78; }
.row-failed:hover td { opacity: 1; }

/* Save-to-folder picker */
.save-to-project {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.save-to-project select {
  background: #FFF;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12.5px;
}
.save-to-project select:focus { outline: none; border-color: var(--primary); }
.save-to-project-status { font-size: 12px; color: var(--muted); margin-left: 4px; }
.save-to-project-status.success { color: var(--success); }
.save-to-project-status.error { color: var(--danger); }

/* Bulk progress / project refresh */
.bulk-progress {
  margin-top: 16px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.bulk-progress-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--muted);
}
.bulk-progress-counter {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink);
  font-family: 'JetBrains Mono', monospace;
}
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--violet));
  border-radius: 999px;
  transition: width 0.25s ease-out;
}

/* Bulk-form layout */
.form-card-bulk form { display: block; }
.field-keywords textarea {
  width: 100%;
  min-height: 9rem;
  resize: vertical;
  background: #FFF;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.6;
  transition: border-color .12s, box-shadow .12s;
}
.field-keywords textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45,107,255,.15);
}
.bulk-controls {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 14px;
  margin-top: 14px;
  align-items: end;
}

/* =========================================================================
   Projects layout (Folders)
   ========================================================================= */
.projects-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  margin-top: 0;
  align-items: start;
}
.projects-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  position: sticky;
  top: 80px;
}
.projects-sidebar-header h2 {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.new-project-form {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}
.new-project-form input {
  flex: 1 1 auto;
  background: #FFF;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  min-width: 0;
}
.new-project-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45,107,255,.15);
}
.new-project-form button {
  height: 36px;
  padding: 0 12px;
  font-size: 12.5px;
}

.projects-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.project-item {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.project-item:hover { background: var(--bg-soft); }
.project-item.active {
  background: var(--primary-soft);
  border-color: #CFE0FF;
}
.project-item.active .project-item-name { color: var(--primary-ink); }
.project-item-name {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-item-meta {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}
.projects-empty {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 14px 8px;
}

.projects-main { min-width: 0; }
.project-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px 22px;
  margin-bottom: 16px;
}
.project-detail-meta { flex: 1 1 18rem; min-width: 0; }
.project-detail-meta h2 {
  margin: 0 0 4px;
  font-size: 20px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.project-detail-stats {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.project-detail-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.project-add-card form {
  display: grid;
  grid-template-columns: 2fr 1fr auto;
  gap: 14px;
  align-items: end;
}

.project-keyword-remove {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  transition: color .12s, border-color .12s, background .12s;
}
.project-keyword-remove:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-soft);
}

/* Trend / chart card */
.tracker-chart-card { margin-top: 16px; }
.tracker-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.tracker-chart-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}
#tracker-chart-area, #project-trend-area { width: 100%; min-height: 240px; }
#tracker-chart-area svg, #project-trend-area svg { width: 100%; height: 240px; display: block; }
.chart-line { fill: none; stroke: var(--primary); stroke-width: 2; }
.chart-line-android { stroke-dasharray: 5 4; }
.chart-line-difficulty { stroke: var(--warn); }
.chart-line-difficulty.chart-line-android { stroke-dasharray: 5 4; }
.chart-point { fill: var(--primary); stroke: var(--surface); stroke-width: 2; }
.chart-point-difficulty { fill: var(--warn); }
.chart-axis-line { stroke: var(--border-strong); stroke-width: 1; }
.chart-axis-label { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart-grid-line { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; opacity: 0.6; }
.chart-tooltip-box { fill: var(--surface); stroke: var(--border); stroke-width: 1; }

.favorites-only-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  margin-right: 6px;
}
.favorites-only-toggle input { accent-color: var(--primary); }

/* =========================================================================
   Tracker form
   ========================================================================= */
.tracker-add-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 6px;
}
.tracker-add-form select,
.tracker-add-form input {
  width: 100%;
  background: #FFF;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
}
.tracker-add-form select:focus,
.tracker-add-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45,107,255,.15);
}
.tracker-add-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 6px;
}
.tracker-add-row button { height: 36px; padding: 0 14px; font-size: 12.5px; }
.tracker-url-hint { font-size: 11.5px; margin: 2px 0 0; line-height: 1.4; }

/* Rank cells */
.rank-cell { font-variant-numeric: tabular-nums; font-weight: 600; }
.rank-good   { color: var(--success); }
.rank-medium { color: var(--warn); }
.rank-bad    { color: var(--danger);  }
.rank-none   { color: var(--muted); font-weight: 400; }
.rank-row { cursor: pointer; }
.rank-row:hover td { background: var(--surface-2); }

/* =========================================================================
   Listing analyzer (My App)
   ========================================================================= */
.form-card-listing form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.form-card-listing textarea,
.form-card-listing input[type="text"],
.form-card-listing select {
  width: 100%;
  background: #FFF;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13.5px;
}
.form-card-listing textarea {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
}
.form-card-listing input:focus,
.form-card-listing select:focus,
.form-card-listing textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45,107,255,.15);
}
.form-card-listing #listing-btn { align-self: flex-end; min-width: 120px; }

.listing-results { margin-top: 1.5rem; display: flex; flex-direction: column; gap: 16px; }
.listing-coverage {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}
.listing-coverage-title {
  margin: 0 0 6px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.listing-coverage-pct {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.listing-coverage-meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.field-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  background: #FFF;
  color: var(--muted);
}
.field-badge-active { background: var(--primary-soft); color: var(--primary-ink); border-color: #CFE0FF; }
.field-badge-fits   { background: var(--success-soft); color: var(--success); border-color: #C7EAD3; }
.field-badge-full   { background: #FFF; color: var(--muted); border-color: var(--border); }

.missing-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px 12px;
}
.missing-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 13px;
  color: var(--ink);
}
.missing-list li > span:first-child {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.listing-density { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.listing-density-stat {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 12px;
  align-items: center;
  font-size: 12.5px;
  color: var(--muted);
}
.listing-density-stat .ld-label { font-weight: 600; color: var(--ink); }
.listing-density-stat .ld-bar {
  position: relative;
  height: 6px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
}
.listing-density-stat .ld-bar > span {
  display: block;
  height: 100%;
  background: var(--success);
  border-radius: 999px;
  transition: width .2s;
}
.listing-density-stat.is-near .ld-bar > span { background: var(--warn); }
.listing-density-stat.is-over .ld-bar > span { background: var(--danger); width: 100% !important; }
.listing-density-stat .ld-num {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  white-space: nowrap;
}

/* =========================================================================
   Spy
   ========================================================================= */
.form-card-spy form { grid-template-columns: 3fr 1fr auto; }
.spy-app-card { margin-top: 16px; }
.spy-app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.spy-app-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.spy-app-icon {
  display: inline-flex;
  width: 56px;
  height: 56px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.spy-app-icon .app-icon { width: 100%; height: 100%; border: none; border-radius: 0; }
.spy-app-header h2 {
  margin: 0 0 4px;
  font-size: 18px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.spy-app-header p { margin: 0; font-size: 13px; }
.spy-tokens {
  margin-top: 8px;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  font-family: 'JetBrains Mono', monospace;
}

/* =========================================================================
   Score / status pills
   ========================================================================= */
.score-pill {
  display: inline-block;
  min-width: 38px;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
  border: 1px solid transparent;
  font-size: 12.5px;
}
.score-pill.score-easy   { background: var(--success-soft); color: var(--success); border-color: #C7EAD3; }
.score-pill.score-medium { background: var(--warn-soft);    color: var(--warn);    border-color: #F9DEB3; }
.score-pill.score-hard   { background: var(--danger-soft);  color: var(--danger);  border-color: #F5C7C9; }
.score-pill.score-na     { color: var(--muted); background: var(--bg-soft); border-color: var(--border); }
.score-pill.score-failed {
  background: var(--danger-soft); color: var(--danger); border-color: #F5C7C9;
  font-size: 11px; letter-spacing: 0.02em; text-transform: uppercase; cursor: help;
}

/* Generic pills used by table cells and headers */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid;
}
.pill-success { background: var(--success-soft); color: var(--success); border-color: #C7EAD3; }
.pill-warn    { background: var(--warn-soft);    color: var(--warn);    border-color: #F9DEB3; }
.pill-danger  { background: var(--danger-soft);  color: var(--danger);  border-color: #F5C7C9; }
.pill-info    { background: var(--primary-soft); color: var(--primary-ink); border-color: #CFE0FF; }
.pill-muted   { background: var(--bg-soft);      color: var(--muted);   border-color: var(--border); }
.pill-violet  { background: var(--violet-soft);  color: var(--violet);  border-color: #DDD7FF; }
.pill .dot-s { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* =========================================================================
   Favorites + row-action icons
   ========================================================================= */
.col-fav { width: 36px; text-align: center; }
.fav-toggle {
  background: transparent;
  border: none;
  color: var(--muted-2);
  font-size: 16px;
  line-height: 1;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: 4px;
  transition: color .12s, background .12s;
}
.fav-toggle:hover { color: var(--warn); background: var(--warn-soft); }
.fav-toggle.is-favorite { color: #F59E0B; }

.col-actions { text-align: right; white-space: nowrap; }
.btn-icon {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  margin-right: 4px;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.btn-icon:hover:not(:disabled) {
  color: var(--ink);
  border-color: var(--border-strong);
  background: var(--bg-soft);
}
.btn-icon:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-folder-icon  { color: #B45309; border-color: #F9DEB3; background: var(--warn-soft); position: relative; }
.btn-folder-icon.is-in-folder { color: #92400E; border-color: #F59E0B; background: #FEF3C7; }
.btn-folder-icon .folder-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: 999px;
  background: var(--warn);
  color: #FFF;
  font-size: 9px;
  font-weight: 800;
  line-height: 14px;
  text-align: center;
}
.btn-ideas-icon  { color: var(--success); border-color: #C7EAD3; background: var(--success-soft); }
.btn-search-icon { color: var(--primary-ink); border-color: #CFE0FF; background: var(--primary-soft); }
.btn-retry-icon  { color: var(--danger); border-color: #F5C7C9; background: var(--danger-soft); font-weight: 700; }

/* Pop sparkline */
.pop-spark {
  display: inline-flex;
  align-items: center;
  width: 80px;
  height: 22px;
  cursor: pointer;
  border-radius: 4px;
  padding: 1px;
  transition: background .12s;
}
.pop-spark:hover { background: var(--primary-soft); }
.pop-spark-svg { width: 100%; height: 100%; display: block; }
.pop-spark-line {
  fill: none;
  stroke: var(--primary);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.pop-spark-baseline {
  stroke: var(--muted-2);
  stroke-dasharray: 3 3;
  stroke-width: 1;
  opacity: 0.5;
}

.col-chart { width: 100px; }
.col-results { font-variant-numeric: tabular-nums; }
.col-results-link {
  background: transparent;
  border: none;
  color: var(--primary);
  font: inherit;
  cursor: pointer;
  padding: 0;
}
.col-results-link:hover { text-decoration: underline; }

.kw-cell { display: inline-block; }
.kw-cell-marked {
  background: var(--warn-soft);
  border: 1px solid #F9DEB3;
  border-radius: 4px;
  padding: 0 4px;
}

/* Analyze-tab folder-membership notice */
.analyze-folder-notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin: 0 0 14px;
  background: var(--warn-soft);
  border: 1px solid #F9DEB3;
  border-radius: 10px;
  color: var(--ink);
  font-size: 13px;
}
.analyze-folder-icon { font-size: 16px; }
.analyze-folder-link {
  background: #FFF;
  border: 1px solid #F9DEB3;
  border-radius: 999px;
  padding: 3px 10px;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}
.analyze-folder-link:hover { background: var(--warn-soft); border-color: var(--warn); }
.analyze-folder-manage {
  margin-left: auto;
  background: transparent;
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
}
.analyze-folder-manage:hover { color: var(--ink); border-color: var(--primary); }

/* =========================================================================
   Modal
   ========================================================================= */
.aso-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.aso-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15,23,41,.45);
  backdrop-filter: blur(2px);
}
.aso-modal-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  width: min(1400px, 96vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: fadeIn .15s ease-out;
}
.aso-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
}
.aso-modal-header strong {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}
.aso-modal-body {
  padding: 18px 22px;
  overflow-y: auto;
}
.aso-modal-body input[type="text"],
.aso-modal-body select {
  background: #FFF;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13.5px;
  margin-right: 8px;
  min-width: 14rem;
}
.modal-section { margin-top: 16px; }
.modal-section h4 { margin: 0 0 8px; font-size: 14px; color: var(--ink); font-weight: 600; }

.modal-folder-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 10px 0;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.modal-folder-tab {
  background: #FFF;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12.5px;
  cursor: pointer;
}
.modal-folder-tab:hover { background: var(--bg-soft); border-color: var(--border-strong); }
.modal-folder-tab.active {
  background: var(--primary);
  color: #FFF;
  border-color: var(--primary);
}
.modal-folder-list {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  max-height: 50vh;
  overflow-y: auto;
}
.modal-folder-list li {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.modal-folder-list li.is-focal {
  background: var(--warn-soft);
  font-weight: 600;
  color: var(--ink);
}

.search-results-table-wrap { overflow-x: auto; max-height: 64vh; }
.search-results-table { width: 100%; }
.search-results-table .col-icon { width: 44px; }
.search-results-table th { position: sticky; top: 0; background: var(--surface-2); z-index: 1; }

.search-results-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.search-result-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.search-result-rank {
  font-weight: 700;
  color: var(--muted);
  min-width: 2.4rem;
}
.search-result-meta { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.search-result-title {
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-dev { color: var(--muted); font-size: 12px; }
.search-result-flags { display: flex; gap: 6px; flex-shrink: 0; }
.flag-pill {
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.flag-on  { background: var(--success-soft); color: var(--success); border-color: #C7EAD3; }
.flag-off { background: var(--bg-soft); color: var(--muted); }
.flag-na  { background: var(--bg-soft); color: var(--muted); font-style: italic; }

/* Add-to-folders multi-folder picker */
.add-to-folders-list {
  max-height: 320px;
  overflow-y: auto;
  margin: 8px 0 14px;
  padding: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.add-to-folders-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 6px;
}
.add-to-folders-row:hover { background: var(--bg-soft); }
.add-to-folders-row input[type="checkbox"] { accent-color: var(--primary); }
.add-to-folders-name { flex: 1 1 auto; }
.add-to-folders-meta { color: var(--muted); font-size: 12px; }
.add-to-folders-new {
  width: 100%;
  background: #FFF;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
}
.add-to-folders-actions { display: flex; gap: 8px; }
.add-to-folders-status { margin-top: 8px; font-size: 13px; }
.add-to-folders-status.error { color: var(--danger); }

.btn-add-folders {
  background: var(--warn-soft);
  border: 1px solid #F9DEB3;
  color: var(--warn);
}
.btn-add-folders:hover { background: #F9DEB3; }

/* Ideas modal controls */
.ideas-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 0 0 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.ideas-control { display: flex; align-items: center; gap: 6px; }
.ideas-control-label { color: var(--muted); font-size: 12.5px; }
.ideas-control select {
  background: #FFF;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12.5px;
}
.ideas-table-host { min-height: 4rem; }

/* =========================================================================
   Dashboard stat cards
   ========================================================================= */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: var(--gap);
  margin: 1.5rem 0 1rem;
}
.stat-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 20px;
}
.stat-card .stat-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--ink);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-card .stat-meta { font-size: 12.5px; color: var(--muted); }
.dashboard-suggestions {
  margin: 0;
  padding-left: 18px;
  line-height: 1.7;
  color: var(--ink);
}
.dashboard-suggestions li { margin-bottom: 4px; }
.dashboard-suggestions strong { color: var(--primary-ink); }

/* =========================================================================
   Filters bar (Tier-2)
   ========================================================================= */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 12px 16px;
  margin: 8px 0 12px;
  box-shadow: var(--shadow-sm);
}
.filters-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.filters-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.filters-bar input[type="number"],
.filters-bar input[type="search"] {
  background: #FFF;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12.5px;
  width: 56px;
}
.filters-bar input[type="search"] { width: 14rem; }
.filters-bar input[type="number"]:focus,
.filters-bar input[type="search"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45,107,255,.15);
}
.filters-sep { color: var(--muted-2); }
.filters-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
}
.filters-check input { accent-color: var(--primary); }

/* =========================================================================
   Site footer
   ========================================================================= */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 18px 0;
  color: var(--muted-2);
  font-size: 12.5px;
  text-align: center;
}

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 1000px) {
  .scores { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .form-card form { grid-template-columns: 1fr 1fr; }
  .field-keyword  { grid-column: 1 / -1; }
  .field-submit   { grid-column: 1 / -1; }
  .results.both-mode { grid-template-columns: 1fr; }
  .projects-layout { grid-template-columns: 1fr; }
  .projects-sidebar { position: static; }
  .project-add-card form { grid-template-columns: 1fr; }
  .bulk-controls { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .form-card form { grid-template-columns: 1fr; }
  .scores { grid-template-columns: 1fr 1fr; }
  .score-value { font-size: 22px; }
  .app-header-inner { flex-wrap: wrap; }
  .quick-analyze { order: 3; flex-basis: 100%; }
}

/* =========================================================================
   Section headings inside page panels
   ========================================================================= */
.section-h3 {
  margin: 24px 0 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}
.page-toolbar-left { display: flex; align-items: center; gap: 12px; }
.sub-toolbar { gap: 12px; }

/* =========================================================================
   Toggle switch (annual billing)
   ========================================================================= */
.annual-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
}
.toggle {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
}
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle .slider {
  position: absolute;
  inset: 0;
  background: var(--border-strong);
  border-radius: 999px;
  transition: background .15s;
  cursor: pointer;
}
.toggle .slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 2px;
  top: 2px;
  background: #FFF;
  border-radius: 50%;
  transition: transform .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.toggle input:checked + .slider { background: var(--primary); }
.toggle input:checked + .slider::before { transform: translateX(16px); }

/* =========================================================================
   Plan tiles (Subscription page)
   ========================================================================= */
.plan-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.plan-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  transition: border-color .12s;
  box-shadow: var(--shadow-sm);
}
.plan-tile:hover { border-color: var(--border-strong); }
.plan-tile.plan-tile-current {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45,107,255,.08), var(--shadow-sm);
}
.plan-tile.plan-tile-best {
  border-color: var(--violet);
  background: linear-gradient(180deg, #FBFAFF 0%, #FFF 60%);
}
.plan-tile .ribbon {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--violet);
  color: #FFF;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 4px 12px;
  border-radius: 5px;
  text-transform: uppercase;
}
.plan-tile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.plan-tile-head h4 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.plan-tile .desc {
  color: var(--muted);
  font-size: 13px;
  min-height: 40px;
  line-height: 1.5;
}
.plan-tile .save {
  display: inline-block;
  background: var(--success-soft);
  color: var(--success);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
  align-self: flex-start;
}
.plan-tile .plan-price {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 0;
}
.plan-tile .plan-price .num {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.plan-tile .plan-price .per { color: var(--muted); font-size: 13px; }
.plan-tile .plan-monthly { color: var(--muted); font-size: 12.5px; }
.plan-tile ul.plan-features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.plan-tile ul.plan-features li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
  padding: 0;
}
.plan-tile ul.plan-features li::before { content: none; }
.plan-tile ul.plan-features li.feature-heading {
  font-weight: 600;
  color: var(--ink-2);
  margin-top: 4px;
}
.plan-tile ul.plan-features .chk {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--success);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.plan-tile .plan-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
}
.plan-tile .plan-actions button {
  width: 100%;
  height: 40px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background .12s;
}
.plan-tile .plan-btn-primary {
  background: var(--primary);
  color: #FFF;
  border-color: var(--primary);
  box-shadow: 0 1px 2px rgba(45,107,255,.25);
}
.plan-tile .plan-btn-primary:hover { background: var(--primary-ink); border-color: var(--primary-ink); }
.plan-tile .plan-btn-violet {
  background: linear-gradient(135deg, var(--violet), #5A47F2);
  color: #FFF;
}
.plan-tile .plan-btn-violet:hover { filter: brightness(1.05); }
.plan-tile .plan-btn-current {
  background: var(--bg-soft);
  color: var(--ink);
  border-color: var(--border);
  cursor: default;
}

.plan-grid-fineprint {
  text-align: center;
  font-size: 12.5px;
  margin: 16px 0 8px;
}

/* =========================================================================
   Add-on tiles
   ========================================================================= */
.addon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.addon-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}
.addon-tile.addon-tile-active {
  border-color: var(--success);
  background: linear-gradient(180deg, #F5FCF7 0%, #FFF 60%);
}
.addon-tile .ah {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.addon-tile h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}
.addon-tile .desc {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  margin: 8px 0 12px;
}
.addon-tile .features {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.addon-tile .features li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
}
.addon-tile .features li .chk-tick {
  color: var(--success);
  font-weight: 700;
}
.addon-tile .addon-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
}
.addon-tile .addon-price {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.addon-tile .addon-price small {
  font-weight: 500;
  color: var(--muted);
  font-size: 12.5px;
}

/* =========================================================================
   Usage tiles
   ========================================================================= */
.usage-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}
.usage-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}
.usage-tile .label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.usage-tile .num {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.usage-tile .num small {
  font-weight: 500;
  color: var(--muted);
  font-size: 13px;
}
.usage-tile .pbar { margin-top: 10px; }

/* =========================================================================
   Filter search input (used in My Team + filter bar)
   ========================================================================= */
.filter-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--muted);
  max-width: 520px;
}
.filter-search:focus-within {
  background: #FFF;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45,107,255,.15);
}
.filter-search input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 13.5px;
  color: var(--ink);
  width: 100%;
}
.filter-search input::placeholder { color: var(--muted); }

/* =========================================================================
   My Team page
   ========================================================================= */
.team-card { padding: 0; overflow: hidden; }
.team-search-row {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.team-section { }
.team-section + .team-section { border-top: 1px solid var(--border); }
.team-section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 18px;
  border: 0;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.team-section-head:hover { background: var(--bg-soft); }
.team-section-head .chev {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-2);
  transition: transform .15s ease;
}
.team-section-head[aria-expanded="false"] .chev { transform: rotate(-90deg); }
.team-section-head .pill { margin-left: auto; }
.team-section-body[hidden] { display: none; }
.team-table { border-radius: 0; }
.team-table tr td:first-child { font-weight: 500; }
.team-name-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}
.team-name-cell .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #FFF;
  background: linear-gradient(135deg, #F59E0B, #EF4444);
  font-size: 13px;
  flex-shrink: 0;
}
.team-name-cell .who { display: flex; flex-direction: column; min-width: 0; }
.team-name-cell .who strong { font-weight: 600; color: var(--ink); }
.team-name-cell .who small { color: var(--muted); font-size: 12px; }

.role-pill {
  display: inline-block;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-left: 6px;
  vertical-align: middle;
}

/* =========================================================================
   Drawer (Invite / Edit member)
   ========================================================================= */
.drawer {
  position: fixed;
  inset: 0;
  z-index: 1000;
}
.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15,23,41,.35);
}
.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(520px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: slideIn .2s ease-out;
}
.drawer-panel-small { width: min(440px, 100vw); }
.drawer-panel-wide { width: min(720px, 100vw); }
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.drawer-head h3 { margin: 0; font-size: 16px; font-weight: 600; color: var(--ink); }
.drawer-head .x {
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
}
.drawer-head .x:hover { background: var(--bg-soft); color: var(--ink); }
.drawer-body { flex: 1; padding: 22px; overflow-y: auto; }
.drawer-foot {
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--surface-2);
}

/* =========================================================================
   Account settings layout (profile card + form card)
   ========================================================================= */
.account-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  align-items: flex-start;
}
.account-profile-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.account-avatar {
  width: 140px;
  height: 140px;
  margin: 4px auto 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FFE3D5 0%, #FFC1A1 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 54px;
  border: 4px solid #FFF;
  box-shadow: 0 0 0 1px var(--border), var(--shadow-sm);
}
.account-name {
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
  margin-top: 4px;
}
.account-joined { font-size: 12.5px; }
.account-upload-btn { width: 100%; margin-top: 14px; }

.account-form-card .card-form-actions {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* =========================================================================
   Credit-card preview (Billing settings)
   ========================================================================= */
.cc-section { display: flex; flex-direction: column; gap: 12px; }
.cc-section-label {
  font-size: 13px;
  margin: 0 0 4px;
}
.cc-card {
  background: linear-gradient(135deg, #1F2A44 0%, #0F1729 100%);
  color: #FFF;
  padding: 22px;
  border-radius: 12px;
  min-height: 170px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.cc-card-blob {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  animation: ccBlob 8s ease-in-out infinite;
}
.cc-card-blob-1 {
  top: -30px;
  right: -20px;
  width: 130px;
  height: 130px;
  background: rgba(45,107,255,.28);
}
.cc-card-blob-2 {
  top: 40px;
  right: 30px;
  width: 70px;
  height: 70px;
  background: rgba(107,91,255,.4);
  animation-delay: 2s;
}
@keyframes ccBlob {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(-10px, 8px) scale(1.05); }
}
.cc-card-label {
  font-size: 11px;
  letter-spacing: 0.06em;
  opacity: 0.6;
  text-transform: uppercase;
}
.cc-card-number {
  font-size: 18px;
  letter-spacing: 0.18em;
  font-family: 'JetBrains Mono', monospace;
  margin-top: 18px;
}
.cc-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}
.cc-card-exp {
  font-family: 'JetBrains Mono', monospace;
  opacity: 0.75;
  font-size: 12.5px;
}
.cc-card-brand {
  font-weight: 700;
  letter-spacing: 0.06em;
  font-size: 14px;
}

.cc-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
}
.cc-secure {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
}

/* Auth-field tweaks for the new settings/account layouts */
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field > span { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.auth-field input,
.auth-field select {
  height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  background: #FFF;
  border: 1px solid var(--border);
  color: var(--ink);
  font-size: 13.5px;
  transition: border-color .12s, box-shadow .12s;
}
.auth-field input:focus,
.auth-field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45,107,255,.15);
}
.auth-field input:disabled { background: var(--bg-soft); color: var(--muted); }
.auth-field .hint { font-size: 12px; color: var(--muted); }
.auth-field-wide { grid-column: 1 / -1; }

.card-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Inline radio row (for Yes / No / Don't know) */
.radio-row-inline {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}
.radio-row-inline .radio-row {
  border-bottom: 0;
  padding: 6px 0;
}

.deactivate-list { list-style: none; padding: 0; }
.deactivate-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-2);
  font-size: 13.5px;
  padding: 6px 0;
}
.deact-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

/* =========================================================================
   Responsive trims
   ========================================================================= */
@media (max-width: 1100px) {
  .plan-grid { grid-template-columns: 1fr 1fr; }
  .usage-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 64px 1fr; }
  .workspace-nav {
    position: fixed;
    left: 64px;
    top: 0;
    width: 260px;
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  .workspace-nav.is-open { transform: translateX(0); }
  .account-layout { grid-template-columns: 1fr; }
  .billing-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .plan-grid { grid-template-columns: 1fr; }
  .addon-grid { grid-template-columns: 1fr; }
  .usage-grid { grid-template-columns: 1fr 1fr; }
}

/* =========================================================================
   Bad-keyword highlight — keywords containing "app" or "free" can never be
   indexed and waste characters. We strike them through in red and surface a
   tooltip on hover explaining why.
   ========================================================================= */
.kw-bad {
  color: var(--danger) !important;
  text-decoration: line-through;
  text-decoration-color: var(--danger);
  text-decoration-thickness: 1.5px;
  position: relative;
}
tr.row-kw-bad td {
  background: rgba(229, 72, 77, 0.03);
}
tr.row-kw-bad:hover td {
  background: rgba(229, 72, 77, 0.06);
}
.kw-bad-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--danger);
  color: #FFF;
  font-size: 12px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 8px;
  white-space: normal;
  width: max-content;
  max-width: 280px;
  line-height: 1.4;
  box-shadow: 0 4px 12px rgba(229, 72, 77, .35);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
  z-index: 30;
  text-decoration: none;
}
.kw-bad-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--danger);
}
.kw-bad:hover .kw-bad-tooltip,
tr.row-kw-bad:hover .kw-bad-tooltip {
  opacity: 1;
}

/* =========================================================================
   Competitors tab — reuses the .projects-layout shell but its content rows
   render an app-card style list.
   ========================================================================= */
.competitor-app-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  margin-bottom: 10px;
}
.competitor-app-row .app-icon { width: 48px; height: 48px; }
.competitor-app-row .meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.competitor-app-row .meta strong { font-size: 14px; color: var(--ink); }
.competitor-app-row .meta small { font-size: 12px; color: var(--muted); }
.competitor-app-row .pill { white-space: nowrap; }

/* =========================================================================
   My Apps grid + detail card + AI Assistant
   ========================================================================= */
.myapps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.myapp-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
}
.myapp-card:hover { border-color: var(--border-strong); }
.myapp-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45,107,255,.08), var(--shadow-sm);
}
.myapp-card .top {
  display: flex; align-items: center; gap: 12px;
}
.myapp-card .top .app-icon { width: 40px; height: 40px; flex-shrink: 0; }
.myapp-card .top strong { display: block; font-size: 13.5px; color: var(--ink); }
.myapp-card .top small { color: var(--muted); font-size: 11.5px; }
.myapp-card .meta-row {
  display: flex; gap: 8px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--muted);
}

.myapp-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.myapp-detail-meta {
  display: flex; align-items: center; gap: 14px;
}
.myapp-detail-meta h3 { margin: 0; font-size: 17px; color: var(--ink); }
.myapp-detail-meta p  { margin: 0; }
.myapp-detail-actions { display: flex; gap: 8px; }

.myapp-compare-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: 14px;
}
.myapp-compare-mode {
  display: inline-flex;
  background: #FFF;
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--border);
}
.myapp-compare-tab {
  background: transparent;
  border: 0;
  height: 30px;
  padding: 0 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
}
.myapp-compare-tab.on {
  background: var(--primary-soft);
  color: var(--primary-ink);
  box-shadow: var(--shadow-sm);
}

.auth-field-inline {
  height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  background: #FFF;
  border: 1px solid var(--border);
  color: var(--ink);
  font-size: 13.5px;
  min-width: 220px;
}
.auth-field-inline:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45,107,255,.15);
}

.myapp-compare-results { margin-top: 14px; }

/* AI Assistant card */
.myapp-ai-card { background: linear-gradient(180deg, #FBFAFF 0%, #FFF 60%); border-color: #DDD7FF; }
.myapp-ai-head h3 { margin: 0 0 6px; font-size: 16px; color: var(--ink); }
.myapp-ai-head p  { margin: 0 0 12px; font-size: 13px; }
.myapp-ai-rules {
  list-style: none;
  padding: 12px 16px;
  margin: 0 0 14px;
  background: var(--bg-soft);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.myapp-ai-rules li::before { content: "• "; color: var(--violet); font-weight: 700; }
.myapp-ai-controls {
  display: grid;
  grid-template-columns: 2fr 2fr auto;
  gap: 14px;
  align-items: end;
}
.myapp-ai-roles {
  margin-top: 14px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.myapp-ai-roles h4 { margin: 0 0 10px; font-size: 14px; color: var(--ink); }
.myapp-ai-roles .roles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px;
}
.myapp-ai-output {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.myapp-ai-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.myapp-ai-field label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--muted);
}
.myapp-ai-field input,
.myapp-ai-field textarea {
  width: 100%;
  background: #FFF;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13.5px;
  font-family: inherit;
}
.myapp-ai-field input.mono,
.myapp-ai-field textarea.mono {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px;
}
.myapp-ai-field textarea { min-height: 140px; resize: vertical; }
.myapp-ai-field-meta {
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.myapp-ai-field-meta.over { color: var(--danger); font-weight: 600; }

/* Role chips on Folders tab — let user pick keyword's listing role */
.kw-role-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--muted);
  border: 1px solid var(--border);
  cursor: pointer;
  margin-left: 6px;
}
.kw-role-chip-primary    { background: var(--success-soft); color: var(--success); border-color: #C7EAD3; }
.kw-role-chip-subtitle   { background: var(--primary-soft); color: var(--primary-ink); border-color: #CFE0FF; }
.kw-role-chip-field      { background: var(--warn-soft); color: var(--warn); border-color: #F9DEB3; }
.kw-role-chip-description{ background: var(--violet-soft); color: var(--violet); border-color: #DDD7FF; }

/* Role select — replaces the cycling chip with a real dropdown so the user
   can directly assign Primary / Subtitle / Keyword field / Description. */
.kw-role-select {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 2px 22px 2px 7px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--muted);
  border: 1px solid var(--border);
  cursor: pointer;
  margin-left: 6px;
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 11px) 50%, calc(100% - 6px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

/* Per-competitor-app action button row inside a folder. */
.competitor-app-actions {
  margin-left: auto;
}
.competitor-app-actions .btn-export,
.competitor-app-actions .btn-icon { padding: 4px 10px; font-size: 12px; }

/* Compact card used for the inline "+ Add competitor app" form. */
.competitor-add-card form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}
.competitor-add-card .field-submit { align-self: end; }

/* My Apps inline add form. */
#myapps-add-card form {
  display: grid;
  grid-template-columns: 2fr 1fr auto;
  gap: 12px;
  align-items: end;
}
#myapps-add-card .field-submit { align-self: end; display: flex; gap: 8px; }

/* Rank chart sparkline cell. */
.rank-chart-host { display: inline-flex; align-items: center; gap: 6px; }

/* Add-to-competitors button */
.btn-add-competitors {
  background: rgba(107,91,255,.08);
  color: var(--violet);
  border: 1px solid #DDD7FF;
}
.btn-add-competitors:hover {
  background: var(--violet);
  color: #FFF;
  border-color: var(--violet);
}

/* Search results / Analyze table: per-row competitor multi-select cell */
.search-results-table input.competitor-pick,
.suggest-table input.competitor-pick {
  width: 16px; height: 16px;
  accent-color: var(--violet);
  cursor: pointer;
}

/* Avatar upload + clear buttons */
.account-upload-row {
  display: flex; flex-direction: column; gap: 8px; width: 100%;
}
.account-upload-row .upload-actions {
  display: flex; gap: 6px;
}
.account-upload-row .upload-actions button { flex: 1; }

@media (max-width: 720px) {
  .myapp-ai-controls { grid-template-columns: 1fr; }
}


