/* ===== LSB Keyword Research – Design tokens ===== */
:root {
  --lsb-blue: #1f6fb6;
  --lsb-blue-dark: #155d9e;
  --lsb-blue-2: #2f8acb;
  --lsb-orange: #f3a23a;
  --lsb-orange-dark: #d97f0d;
  --lsb-text: #1f2937;
  --lsb-muted: #64748b;
  --lsb-line: #e5e9f0;
  --lsb-bg: #f7f8fb;
  --lsb-card: #ffffff;
  --lsb-up: #16a34a;
  --lsb-down: #dc2626;
  --lsb-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--lsb-text);
  background: var(--lsb-bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--lsb-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ===== Top navigation ===== */
.lsb-nav {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 24px;
  background: #fff;
  border-bottom: 1px solid var(--lsb-line);
  position: sticky; top: 0; z-index: 100;
}
.lsb-nav-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--lsb-text); }
.lsb-nav-brand img { width: 32px; height: 32px; }
.lsb-nav-brand span { font-size: 16px; letter-spacing: -0.01em; }
.lsb-nav-brand small { font-weight: 500; color: var(--lsb-muted); margin-left: 4px; }
.lsb-nav-search {
  flex: 1; max-width: 720px;
  display: flex; align-items: center;
  background: #f1f3f7; border: 1px solid transparent;
  border-radius: 999px; padding: 4px 6px 4px 16px;
  transition: all .15s;
}
.lsb-nav-search:focus-within { background: #fff; border-color: var(--lsb-blue); box-shadow: 0 0 0 3px rgba(31, 111, 182, .15); }
.lsb-nav-search input {
  flex: 1; border: none; outline: none; background: transparent;
  padding: 6px 4px; font-size: 14px;
}
.lsb-nav-search .lsb-marketplace {
  border: none; background: transparent; color: var(--lsb-muted);
  font-size: 13px; outline: none; padding: 0 8px;
  border-left: 1px solid var(--lsb-line);
}
.lsb-nav-search button {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--lsb-orange); color: #fff;
  border: none; display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.lsb-nav-search button:hover { background: var(--lsb-orange-dark); }
.lsb-nav-search button svg { width: 16px; height: 16px; }
.lsb-nav-actions { display: flex; align-items: center; gap: 8px; }
.lsb-user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px 6px 6px; border-radius: 999px;
  border: 1px solid var(--lsb-line); background: #fff;
}
.lsb-user-chip .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--lsb-blue), var(--lsb-blue-2));
  color: #fff; font-weight: 700; font-size: 12px;
  display: inline-flex; align-items: center; justify-content: center;
}
.lsb-user-chip .name { font-size: 13px; font-weight: 600; }
.lsb-user-menu {
  position: absolute; right: 24px; top: 56px; min-width: 200px;
  background: #fff; border: 1px solid var(--lsb-line); border-radius: var(--radius);
  box-shadow: var(--lsb-shadow); padding: 6px; z-index: 200;
}
.lsb-user-menu.hidden { display: none; }
.lsb-user-menu a {
  display: block; padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--lsb-text); font-size: 13px;
}
.lsb-user-menu a:hover { background: #f1f5fa; text-decoration: none; }
.lsb-user-menu .divider { height: 1px; background: var(--lsb-line); margin: 4px 0; }

/* ===== Layout ===== */
.lsb-page { max-width: 1280px; margin: 0 auto; padding: 24px; }
.lsb-h1 { font-size: 22px; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.01em; }
.lsb-section-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.12em;
  color: var(--lsb-muted); text-transform: uppercase; margin: 0 0 12px;
}
.lsb-card {
  background: var(--lsb-card); border: 1px solid var(--lsb-line);
  border-radius: var(--radius); box-shadow: var(--lsb-shadow);
}

/* ===== Performance Insights row ===== */
.perf-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 0; padding: 24px 28px;
}
.perf-cell { padding: 0 12px; border-right: 1px solid var(--lsb-line); }
.perf-cell:last-child { border-right: none; }
.perf-cell .label {
  font-size: 10px; letter-spacing: 0.12em; color: var(--lsb-muted);
  font-weight: 600; text-transform: uppercase; margin-bottom: 6px;
}
.perf-cell .value { font-size: 28px; font-weight: 700; color: var(--lsb-text); letter-spacing: -0.02em; }
.perf-cell .value.up { color: var(--lsb-up); }
.perf-cell .value.down { color: var(--lsb-down); }

/* ===== Page Highlights & Opportunity Words ===== */
.insights-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px;
}
.insights-card { padding: 18px 20px; }
.insights-card h3 {
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--lsb-muted); font-weight: 700; margin: 0 0 14px;
}
.highlight-row {
  display: grid; grid-template-columns: 90px 1fr 50px;
  align-items: center; gap: 10px; margin-bottom: 8px;
}
.highlight-row .word { font-weight: 600; color: var(--lsb-blue); font-size: 13px; }
.highlight-row .bar {
  height: 8px; background: #eef2f7; border-radius: 4px; overflow: hidden;
}
.highlight-row .bar > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--lsb-blue), var(--lsb-blue-2));
  border-radius: 4px;
}
.highlight-row .pct { text-align: right; font-size: 12px; color: var(--lsb-muted); }

.opportunity-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.opportunity-cell .number {
  font-size: 28px; font-weight: 700; line-height: 1; margin-bottom: 6px;
}
.opportunity-cell .number.up { color: var(--lsb-up); }
.opportunity-cell .number.down { color: var(--lsb-down); }
.opportunity-cell .meta { font-size: 12px; color: var(--lsb-muted); }
.opportunity-cell .meta .arrow { font-weight: 700; }

/* ===== Filter bar ===== */
.filter-bar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin: 22px 0 12px;
}
.filter-bar select {
  padding: 7px 12px; border: 1px solid var(--lsb-line);
  border-radius: 999px; background: #fff; color: var(--lsb-text);
}
.filter-bar .spacer { flex: 1; }
.filter-bar .btn-ghost {
  padding: 7px 14px; border: 1px solid var(--lsb-line);
  border-radius: 999px; background: #fff; color: var(--lsb-text);
  display: inline-flex; align-items: center; gap: 6px;
}
.filter-bar .btn-ghost:hover { background: #f1f5fa; }
.filter-bar .btn-primary {
  padding: 7px 14px; border-radius: 999px;
  background: var(--lsb-blue); color: #fff; border: none;
  display: inline-flex; align-items: center; gap: 6px;
}
.filter-bar .btn-primary:hover { background: var(--lsb-blue-dark); }

/* ===== Keywords table ===== */
.kw-meta {
  font-size: 12px; color: var(--lsb-muted); margin-bottom: 6px;
}
.kw-table-wrap { overflow-x: auto; }
.kw-table { width: 100%; border-collapse: collapse; background: #fff; }
.kw-table thead th {
  text-align: left; padding: 12px 14px; font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--lsb-muted);
  font-weight: 700; border-bottom: 1px solid var(--lsb-line);
  background: #fafbfd; position: sticky; top: 0;
}
.kw-table thead th.num, .kw-table tbody td.num { text-align: right; }
.kw-table tbody td {
  padding: 11px 14px; border-bottom: 1px solid #f1f3f7;
  font-size: 13px; vertical-align: middle;
}
.kw-table tbody tr:hover { background: #fafbff; }
.kw-table .kw-cell {
  display: flex; align-items: center; gap: 10px;
}
.kw-table .kw-cell .name { color: var(--lsb-text); font-weight: 500; }
.kw-table .kw-cell .icons { display: inline-flex; gap: 4px; opacity: .6; }
.kw-table .kw-cell .icons a {
  width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px; color: var(--lsb-muted);
}
.kw-table .kw-cell .icons a:hover { background: #eef2f7; color: var(--lsb-blue); }
.trend-up { color: var(--lsb-up); font-weight: 700; }
.trend-down { color: var(--lsb-down); font-weight: 700; }
.appearance-evergreen { color: var(--lsb-up); }
.appearance-seasonal { color: var(--lsb-orange-dark); }

.spark { display: inline-block; width: 80px; height: 22px; vertical-align: middle; }

/* ===== Pagination ===== */
.pagination {
  display: flex; gap: 6px; align-items: center; justify-content: center;
  margin: 22px 0;
}
.pagination button {
  min-width: 32px; height: 32px; padding: 0 10px;
  border: 1px solid var(--lsb-line); background: #fff;
  border-radius: 6px; color: var(--lsb-text); font-size: 13px;
}
.pagination button:hover:not(:disabled) { background: #eef2f7; }
.pagination button.active {
  background: var(--lsb-blue); color: #fff; border-color: var(--lsb-blue);
}
.pagination button:disabled { opacity: .4; cursor: not-allowed; }
.pagination .info { font-size: 12px; color: var(--lsb-muted); margin: 0 10px; }

/* ===== Empty / loading ===== */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 64px 16px; color: var(--lsb-muted); text-align: center;
}
.empty-state img { width: 96px; opacity: .9; margin-bottom: 14px; }
.empty-state h2 { font-size: 18px; color: var(--lsb-text); margin: 0 0 6px; font-weight: 700; }
.empty-state p { margin: 0; max-width: 420px; }

.loading-card {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 56px 16px; color: var(--lsb-text);
}
.spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid #e5e9f0; border-top-color: var(--lsb-blue);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-card .stage { font-size: 14px; font-weight: 600; }
.loading-card .hint { font-size: 12px; color: var(--lsb-muted); max-width: 480px; text-align: center; }

/* ===== Toasts ===== */
.toast-wrap { position: fixed; right: 16px; top: 70px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 10px 14px; background: #fff; border: 1px solid var(--lsb-line);
  border-left: 4px solid var(--lsb-blue); border-radius: 8px;
  box-shadow: var(--lsb-shadow); font-size: 13px; min-width: 220px;
  animation: toast-in .2s ease-out;
}
.toast.error { border-left-color: var(--lsb-down); }
.toast.success { border-left-color: var(--lsb-up); }
@keyframes toast-in { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ===== Login ===== */
.login-shell {
  min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(135deg, #f7f8fb 0%, #eaf2fb 100%);
}
.login-card {
  width: 380px; background: #fff; border-radius: 14px;
  border: 1px solid var(--lsb-line); padding: 32px 28px; box-shadow: var(--lsb-shadow);
}
.login-card .brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 18px; }
.login-card .brand img { width: 64px; height: 64px; }
.login-card .brand h1 { font-size: 18px; margin: 0; font-weight: 700; }
.login-card .brand p { margin: 0; font-size: 12px; color: var(--lsb-muted); }
.login-form label { display: block; font-size: 12px; font-weight: 600; color: var(--lsb-muted); margin-bottom: 6px; }
.login-form .input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--lsb-line);
  border-radius: 8px; outline: none; transition: all .15s;
  margin-bottom: 14px;
}
.login-form .input:focus { border-color: var(--lsb-blue); box-shadow: 0 0 0 3px rgba(31,111,182,.15); }
.login-form .submit {
  width: 100%; padding: 11px; border: none; border-radius: 8px;
  background: var(--lsb-blue); color: #fff; font-weight: 600; font-size: 14px;
}
.login-form .submit:hover { background: var(--lsb-blue-dark); }
.login-error {
  background: #fef2f2; color: var(--lsb-down); border: 1px solid #fecaca;
  padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px;
}

/* ===== Forms (account / admin) ===== */
.form-row { display: grid; grid-template-columns: 160px 1fr; align-items: center; gap: 16px; margin-bottom: 14px; }
.form-row label { font-size: 13px; color: var(--lsb-muted); font-weight: 600; }
.form-row .input,
.form-row select {
  padding: 8px 10px; border: 1px solid var(--lsb-line); border-radius: 8px; outline: none;
  width: 100%; max-width: 360px;
}
.btn-primary {
  background: var(--lsb-blue); color: #fff; border: none; border-radius: 8px;
  padding: 9px 18px; font-weight: 600; font-size: 13px;
}
.btn-primary:hover { background: var(--lsb-blue-dark); }
.btn-danger {
  background: var(--lsb-down); color: #fff; border: none; border-radius: 8px;
  padding: 7px 12px; font-weight: 600; font-size: 12px;
}
.btn-secondary {
  background: #fff; color: var(--lsb-text); border: 1px solid var(--lsb-line);
  border-radius: 8px; padding: 7px 12px; font-weight: 600; font-size: 12px;
}
.btn-secondary:hover { background: #f1f5fa; }

/* ===== Admin user table ===== */
.admin-table { width: 100%; border-collapse: collapse; background: #fff; }
.admin-table thead th {
  text-align: left; padding: 12px; font-size: 11px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--lsb-muted); border-bottom: 1px solid var(--lsb-line);
  background: #fafbfd; font-weight: 700;
}
.admin-table tbody td { padding: 12px; border-bottom: 1px solid #f1f3f7; font-size: 13px; }
.admin-table .role-badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px;
  font-weight: 700; letter-spacing: 0.04em;
}
.admin-table .role-admin { background: #fef3c7; color: #b45309; }
.admin-table .role-user { background: #e0f2fe; color: #075985; }
.admin-table .status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.admin-table .status-active { background: var(--lsb-up); }
.admin-table .status-inactive { background: #cbd5e1; }

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.45);
  display: flex; align-items: center; justify-content: center; z-index: 500;
}
.modal-backdrop.hidden { display: none; }
.modal {
  width: 460px; background: #fff; border-radius: 12px;
  padding: 22px 24px; box-shadow: 0 10px 40px rgba(15,23,42,.25);
}
.modal h3 { margin: 0 0 16px; font-size: 16px; font-weight: 700; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* ===== Misc ===== */
.muted { color: var(--lsb-muted); }
.right { text-align: right; }
.center { text-align: center; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.mb-12 { margin-bottom: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.hidden { display: none !important; }

@media (max-width: 900px) {
  .perf-grid { grid-template-columns: repeat(3, 1fr); }
  .perf-cell { border-right: none; border-bottom: 1px solid var(--lsb-line); padding: 12px; }
  .insights-grid { grid-template-columns: 1fr; }
  .lsb-nav-search { max-width: none; }
  .form-row { grid-template-columns: 1fr; }
}
