.ai-geo-page {
  --geo-primary: var(--ui-primary, #2563eb);
  --geo-primary-dark: #1d4ed8;
  --geo-border: var(--ui-line, #e2e8f0);
  --geo-text: #172033;
  --geo-muted: #64748b;
  min-width: 0;
  color: var(--geo-text);
}

body[data-active-page="ai-geo"] .top-actions-geo { display: flex !important; }
body:not([data-active-page="ai-geo"]) .top-actions-geo { display: none !important; }

.geo-search-card {
  margin-bottom: 18px;
  padding: 17px 20px 19px;
  border: 1px solid var(--geo-border);
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, .035);
}

.geo-prompt-field {
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 0 17px;
  border: 1px solid #dbe3ef;
  border-radius: 9px;
  background: #fbfcfe;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.geo-prompt-field:focus-within { border-color: #93b4f8; background: #fff; box-shadow: 0 0 0 3px rgba(37, 99, 235, .08); }
.geo-prompt-field svg, .geo-filter-field svg { width: 21px; height: 21px; flex: 0 0 auto; color: #7183a2; }
.geo-prompt-field input { width: 100%; border: 0; outline: 0; background: transparent; color: #25324a; font-size: 14px; }
.geo-prompt-field input::placeholder, .geo-filter-field input::placeholder { color: #94a3b8; }

.geo-search-controls { display: grid; grid-template-columns: 1.08fr 1.08fr 1fr .88fr; gap: 15px; margin-top: 14px; }
.geo-select-field {
  min-width: 0;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 5px 13px;
  border: 1px solid #dbe3ef;
  border-radius: 9px;
  background: #fff;
}
.geo-control-icon { width: 24px; flex: 0 0 auto; color: #27436b; font-size: 21px; line-height: 1; text-align: center; }
.geo-select-copy { min-width: 0; flex: 1; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 7px; }
.geo-select-copy small { color: #15243b; font-size: 13px; font-weight: 700; white-space: nowrap; }
.geo-select-copy small::after { content: ':'; }
.geo-select-copy select { min-width: 0; width: 100%; height: 36px; padding: 0 25px 0 0; border: 0; outline: 0; background-color: transparent; color: #172033; font-size: 13px; font-weight: 600; }
.geo-analyze-btn {
  min-height: 48px;
  border: 0;
  border-radius: 9px;
  background: linear-gradient(135deg, #2f70f5, #0d57ed);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 17px rgba(37, 99, 235, .22);
  transition: transform .18s ease, box-shadow .18s ease;
}
.geo-analyze-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(37, 99, 235, .28); }
.geo-analyze-btn:disabled { opacity: .58; cursor: wait; transform: none; }
.geo-analyze-btn span { margin-right: 8px; font-size: 17px; }

.geo-tabs { display: flex; gap: 31px; min-height: 46px; border-bottom: 1px solid var(--geo-border); }
.geo-tabs button { position: relative; padding: 0 2px 13px; border: 0; background: transparent; color: #6a7891; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.geo-tabs button::after { content: ''; position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; border-radius: 2px 2px 0 0; background: transparent; }
.geo-tabs button.is-active { color: var(--geo-primary); font-weight: 700; }
.geo-tabs button.is-active::after { background: var(--geo-primary); }

.geo-explorer-card { margin-top: 17px; overflow: hidden; border: 1px solid var(--geo-border); border-radius: 13px; background: #fff; box-shadow: 0 7px 22px rgba(15, 23, 42, .035); }
.geo-toolbar { min-height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 10px 18px; border-bottom: 1px solid var(--geo-border); }
.geo-toolbar-summary { display: flex; align-items: center; gap: 20px; }
.geo-toolbar-summary > strong { color: #14213a; font-size: 15px; }
.geo-export-btn { min-height: 36px; padding: 0 13px; border: 1px solid #dbe3ef; border-radius: 8px; background: #fff; color: #2b3b55; font-size: 12.5px; font-weight: 700; cursor: pointer; }
.geo-export-btn:hover { border-color: #aac2ef; color: var(--geo-primary); }
.geo-export-btn span { margin-right: 6px; font-size: 17px; }
.geo-filter-field { width: min(270px, 34vw); min-height: 38px; display: flex; align-items: center; gap: 9px; padding: 0 11px; border: 1px solid #dbe3ef; border-radius: 8px; background: #fbfcfe; }
.geo-filter-field svg { width: 17px; height: 17px; }
.geo-filter-field input { min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; color: #344054; font-size: 12.5px; }

.geo-table-wrap { overflow-x: auto; }
.geo-prompt-table { width: 100%; min-width: 980px; border-collapse: collapse; table-layout: fixed; }
.geo-prompt-table th { height: 42px; padding: 0 13px; background: #f8fafc; border-bottom: 1px solid var(--geo-border); color: #66758f; font-size: 12px; font-weight: 600; text-align: left; }
.geo-prompt-table th:nth-child(2) { width: 42%; }
.geo-prompt-table th:nth-child(3) { width: 17%; text-align: center; }
.geo-prompt-table th:nth-child(4) { width: 12%; text-align: center; }
.geo-prompt-table th:nth-child(5) { width: 16%; text-align: center; }
.geo-prompt-table td { height: 48px; padding: 8px 13px; border-bottom: 1px solid #e8edf4; color: #3b4963; font-size: 12.5px; vertical-align: middle; }
.geo-prompt-table tbody tr:last-child td { border-bottom: 0; }
.geo-prompt-table tbody tr.geo-main-row { cursor: pointer; transition: background .15s ease; }
.geo-prompt-table tbody tr.geo-main-row:hover td { background: #f8fbff; }
.geo-prompt-table tbody tr.geo-main-row.is-active td { background: #eff6ff; border-bottom-color: #d4e4fb; color: #172033; }
.geo-prompt-table tbody tr.geo-main-row.is-running td { background: #fbfdff; }
.geo-check-col { width: 48px; text-align: center !important; }
.geo-action-col { width: 52px; text-align: right !important; }
.geo-prompt-table input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--geo-primary); cursor: pointer; }
.geo-prompt-name { display: flex; align-items: center; gap: 8px; color: #33415c; line-height: 1.45; }
.geo-running-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: #3b82f6; box-shadow: 0 0 0 4px #dbeafe; animation: geoPulse 1.3s ease infinite; }
.geo-sort { margin-left: 4px; color: #91a0b7; }
.geo-center { text-align: center; }
.geo-url-count { color: #075fea; font-weight: 700; }
.geo-url-count.is-empty { color: #8290a6; font-weight: 500; }
.geo-row-action { width: 30px; height: 30px; border: 0; border-radius: 7px; background: transparent; color: #6c7d98; font-size: 18px; cursor: pointer; }
.geo-row-action:hover { background: #e5effe; color: var(--geo-primary); }
.geo-engine-icons { display: inline-flex; align-items: center; justify-content: center; gap: 12px; }
.geo-engine-icon { position: relative; width: 25px; height: 25px; display: inline-flex; align-items: center; justify-content: center; border-radius: 7px; color: #fff; font-size: 12px; font-weight: 800; font-style: normal; }
.geo-engine-icon.chatgpt { background: #10a37f; }
.geo-engine-icon.gemini { background: transparent; color: #4f7df3; font-size: 19px; }
.geo-engine-icon.perplexity { background: #071e34; color: #29d8d1; }
.geo-engine-icon.is-absent { opacity: .18; filter: grayscale(100%); }
.geo-engine-icon.is-pending { opacity: .42; filter: grayscale(45%); }
.geo-engine-icon.is-running::after { content: ''; position: absolute; inset: -3px; border: 2px solid #bfdbfe; border-top-color: #2563eb; border-radius: 50%; animation: geoSpin .8s linear infinite; }
.geo-engine-icon.is-error { background: #e5e7eb; color: #8a94a6; }
.geo-engine-icon.is-error::after { content: '!'; position: absolute; right: -5px; top: -6px; width: 13px; height: 13px; display: grid; place-items: center; border-radius: 50%; background: #f59e0b; color: #fff; font-size: 9px; }

.geo-loading-cell, .geo-empty-cell { height: 230px !important; text-align: center; color: var(--geo-muted) !important; }
.geo-empty-state { max-width: 480px; margin: 0 auto; display: grid; justify-items: center; gap: 7px; }
.geo-empty-state i { width: 47px; height: 47px; display: grid; place-items: center; border-radius: 15px; background: #eef4ff; color: var(--geo-primary); font-size: 22px; font-style: normal; }
.geo-empty-state strong { color: var(--geo-text); font-size: 14px; }
.geo-empty-state p { margin: 0; font-size: 12.5px; line-height: 1.55; }

.geo-expanded-row > td { height: auto; padding: 0 !important; background: #f8fbff; }
.geo-expanded-panel { padding: 10px 13px 13px; border-bottom: 1px solid #dce7f6; box-shadow: inset 0 1px 0 #dce7f6; }
.geo-expanded-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.geo-view-switch { display: inline-flex; padding: 3px; border: 1px solid #dbe3ef; border-radius: 9px; background: #fff; }
.geo-view-switch button { min-height: 30px; padding: 0 11px; border: 0; border-radius: 6px; background: transparent; color: #66758f; font-size: 11.5px; font-weight: 700; cursor: pointer; }
.geo-view-switch button.is-active { background: #eaf2ff; color: var(--geo-primary); }
.geo-run-meta { color: #7b8aa2; font-size: 11.5px; }
.geo-engine-tabs { display: inline-flex; overflow: hidden; border: 1px solid #dce5f1; border-radius: 8px; background: #fff; }
.geo-engine-tab { min-width: 112px; min-height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 14px; border: 0; border-right: 1px solid #e7edf5; background: transparent; color: #344054; font-size: 12px; font-weight: 700; cursor: pointer; }
.geo-engine-tab:last-child { border-right: 0; }
.geo-engine-tab.is-active { background: #0ca47e; color: #fff; }
.geo-engine-tab.is-active[data-engine="gemini"] { background: #315fe6; }
.geo-engine-tab.is-active[data-engine="perplexity"] { background: #102a43; }
.geo-engine-tab:disabled { cursor: not-allowed; opacity: .55; }
.geo-summary-strip { display: flex; align-items: center; flex-wrap: wrap; gap: 0; min-height: 38px; margin-bottom: 9px; padding: 0 8px; border: 1px solid #e4eaf3; border-radius: 8px; background: #fff; }
.geo-summary-strip span { padding: 0 13px; border-right: 1px solid #e8edf4; color: #61718a; font-size: 11.5px; line-height: 22px; }
.geo-summary-strip span:last-child { border-right: 0; }
.geo-summary-strip b { color: #22314a; }
.geo-status-badge { display: inline-flex; align-items: center; min-height: 23px; padding: 0 9px !important; border: 0 !important; border-radius: 999px; font-weight: 700; }
.geo-status-badge.yes { background: #dcfce7; color: #168a44; }
.geo-status-badge.no { background: #fee2e2; color: #dc2626; }
.geo-status-badge.pending { background: #eaf2ff; color: #2563eb; }
.geo-status-badge.error { background: #fff3d6; color: #b45309; }
.geo-quick-content { padding: 2px 9px 0; }
.geo-content-title { margin: 0 0 4px; color: #26354e; font-size: 12.5px; }
.geo-ai-content { margin: 0; color: #46556e; font-size: 12px; line-height: 1.62; white-space: pre-wrap; }
.geo-ai-content mark { padding: 1px 2px; border-radius: 3px; background: #fef3c7; color: #624b08; font-weight: 700; }
.geo-url-heading { margin: 8px 0 4px; color: #26354e; font-size: 12.5px; }
.geo-url-inline-list { display: grid; gap: 4px; }
.geo-url-inline-list a { display: inline-flex; align-items: center; gap: 7px; color: #075fea; font-size: 11.8px; word-break: break-all; }
.geo-engine-error { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 14px; border: 1px solid #fde2b8; border-radius: 9px; background: #fffaf0; color: #8a5511; font-size: 12px; }
.geo-retry-btn { flex: 0 0 auto; padding: 7px 10px; border: 1px solid #f1c77b; border-radius: 7px; background: #fff; color: #9a5b08; font-size: 11px; font-weight: 700; cursor: pointer; }

.geo-compare-title { margin: 0 0 7px 5px; color: #172033; font-size: 13px; }
.geo-engine-compare-wrap { overflow-x: auto; border: 1px solid #e0e7f1; border-radius: 9px; background: #fff; }
.geo-engine-compare { width: 100%; min-width: 760px; border-collapse: collapse; table-layout: fixed; }
.geo-engine-compare th { height: 31px; padding: 0 12px; background: #f8fafc; color: #66758f; font-size: 10.8px; font-weight: 600; text-align: left; }
.geo-engine-compare th:nth-child(1) { width: 17%; }.geo-engine-compare th:nth-child(2) { width: 15%; }.geo-engine-compare th:nth-child(3) { width: 12%; }.geo-engine-compare th:nth-child(4) { width: 16%; }
.geo-engine-compare td { height: 36px; padding: 5px 12px; border-top: 1px solid #e8edf4; color: #44536b; font-size: 11.5px; }
.geo-engine-compare tr { cursor: pointer; }
.geo-engine-compare tr.is-selected td { background: #eaf3ff; }
.geo-engine-name { display: flex; align-items: center; gap: 9px; color: #26354e; font-weight: 700; }
.geo-summary-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.geo-detail-grid { display: grid; grid-template-columns: minmax(0, 1.85fr) minmax(280px, 1fr); gap: 11px; margin-top: 9px; }
.geo-detail-card { min-width: 0; padding: 11px 13px; border: 1px solid #e0e7f1; border-radius: 9px; background: #fff; }
.geo-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.geo-detail-head h4 { margin: 0 0 2px; font-size: 12.5px; }
.geo-detail-head p { margin: 0; font-size: 10.5px; }
.geo-engine-link, .geo-export-urls { min-height: 29px; display: inline-flex; align-items: center; padding: 0 10px; border: 1px solid #dbe3ef; border-radius: 7px; background: #fff; color: #2f4668; font-size: 10.8px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.geo-detail-time { margin-left: auto; color: #7c8ba2; font-size: 10.5px; white-space: nowrap; }
.geo-detail-body { max-height: 210px; overflow: auto; color: #46556e; font-size: 11.5px; line-height: 1.6; white-space: pre-wrap; }
.geo-detail-body mark { background: #fef3c7; color: #6e5408; font-weight: 700; }
.geo-detail-url-list { margin: 0 -13px -11px; }
.geo-detail-url-item { display: grid; grid-template-columns: 25px minmax(0, 1fr) 20px; align-items: center; gap: 9px; padding: 8px 13px; border-top: 1px solid #e8edf4; }
.geo-detail-url-item > span:first-child { width: 21px; height: 21px; display: grid; place-items: center; border-radius: 50%; background: #f1f5f9; color: #718096; font-size: 10px; font-weight: 700; }
.geo-detail-url-item a { overflow: hidden; color: #075fea; font-size: 10.8px; text-overflow: ellipsis; white-space: nowrap; }
.geo-detail-url-item small { display: block; overflow: hidden; margin-top: 2px; color: #77869d; text-overflow: ellipsis; white-space: nowrap; }

.geo-placeholder-panel { min-height: 330px; margin-top: 17px; display: flex; align-items: center; justify-content: center; flex-direction: column; border: 1px dashed #d5deec; border-radius: 13px; background: #fff; text-align: center; }
.geo-placeholder-panel[hidden] { display: none; }
.geo-placeholder-icon { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 16px; background: #eef4ff; color: var(--geo-primary); font-size: 20px; font-weight: 800; }
.geo-placeholder-panel h2 { margin-top: 12px; font-size: 16px; }.geo-placeholder-panel p { max-width: 430px; font-size: 13px; }

.geo-dialog { width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; padding: 0; border: 0; background: transparent; }
.geo-dialog::backdrop { background: rgba(15, 23, 42, .46); backdrop-filter: blur(2px); }
.geo-dialog[open] { display: grid; place-items: center; }
.geo-dialog-card { width: min(920px, calc(100vw - 34px)); max-height: calc(100vh - 50px); overflow: auto; border: 1px solid #e2e8f0; border-radius: 18px; background: #fff; box-shadow: 0 28px 70px rgba(15, 23, 42, .24); }
.geo-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 20px 22px; border-bottom: 1px solid #e8edf4; }
.geo-dialog-head h2 { margin: 2px 0 4px; font-size: 20px; }.geo-dialog-head p { margin: 0; font-size: 12.5px; }
.geo-dialog-eyebrow { color: var(--geo-primary); font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.geo-dialog-head > button { width: 34px; height: 34px; border: 0; border-radius: 9px; background: #f1f5f9; color: #53637b; font-size: 21px; cursor: pointer; }
.geo-brand-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 455px; }
.geo-brand-list-panel { padding: 17px; border-right: 1px solid #e8edf4; background: #f8fafc; }
.geo-brand-list-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; font-size: 12.5px; }
.geo-brand-list-head button { border: 0; background: transparent; color: var(--geo-primary); font-size: 12px; font-weight: 700; cursor: pointer; }
.geo-brand-list { display: grid; gap: 8px; }
.geo-brand-item { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px; border: 1px solid #e1e7f0; border-radius: 10px; background: #fff; text-align: left; cursor: pointer; }
.geo-brand-item.is-active { border-color: #9ebbf1; background: #eef5ff; box-shadow: 0 5px 13px rgba(37, 99, 235, .08); }
.geo-brand-item b { display: block; color: #26354e; font-size: 12.5px; }.geo-brand-item small { display: block; margin-top: 3px; color: #7b8aa2; }
.geo-brand-avatar { width: 31px; height: 31px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 9px; background: #dbeafe; color: #1d4ed8; font-size: 12px; font-weight: 800; }
.geo-brand-item > div { min-width: 0; flex: 1; }
.geo-brand-form { display: grid; align-content: start; gap: 13px; padding: 20px 22px; }
.geo-brand-form label { display: grid; gap: 6px; color: #344054; font-size: 12px; font-weight: 700; }
.geo-brand-form label span { display: flex; justify-content: space-between; gap: 10px; }.geo-brand-form label small { color: #98a2b3; font-weight: 500; }
.geo-brand-form input, .geo-brand-form textarea { width: 100%; padding: 10px 11px; border: 1px solid #dbe3ef; border-radius: 9px; outline: 0; color: #26354e; font-size: 12.5px; resize: vertical; }
.geo-brand-form input:focus, .geo-brand-form textarea:focus { border-color: #9bb8ee; box-shadow: 0 0 0 3px rgba(37, 99, 235, .07); }
.geo-form-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 3px; }
.geo-history-dialog-card { width: min(860px, calc(100vw - 34px)); }
.geo-history-list { min-height: 200px; padding: 9px 20px 20px; }
.geo-history-item { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 20px; padding: 13px 4px; border: 0; border-bottom: 1px solid #e8edf4; background: transparent; text-align: left; cursor: pointer; }
.geo-history-item:hover { background: #f8fbff; }
.geo-history-item b { display: block; overflow: hidden; color: #26354e; font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }.geo-history-item small { display: block; margin-top: 4px; color: #7b8aa2; }
.geo-history-kpi { color: #60708a; font-size: 11.5px; white-space: nowrap; }.geo-history-status { padding: 5px 8px; border-radius: 999px; background: #dcfce7; color: #15803d; font-size: 10.5px; font-weight: 700; }
.geo-history-status.error { background: #fee2e2; color: #dc2626; }.geo-history-status.running { background: #eaf2ff; color: #2563eb; }
.geo-muted { color: #7b8aa2; font-size: 12.5px; text-align: center; }

@keyframes geoSpin { to { transform: rotate(360deg); } }
@keyframes geoPulse { 50% { opacity: .45; transform: scale(.84); } }

@media (max-width: 1199px) {
  .geo-search-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .geo-detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 767px) {
  .top-actions-geo { width: 100%; overflow-x: auto; }
  .geo-search-card { padding: 14px; }
  .geo-search-controls { grid-template-columns: 1fr; gap: 9px; }
  .geo-tabs { gap: 18px; overflow-x: auto; }
  .geo-tabs button { white-space: nowrap; }
  .geo-toolbar { align-items: stretch; flex-direction: column; }
  .geo-filter-field { width: 100%; }
  .geo-brand-layout { grid-template-columns: 1fr; }
  .geo-brand-list-panel { border-right: 0; border-bottom: 1px solid #e8edf4; }
  .geo-brand-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .geo-expanded-top { align-items: flex-start; flex-direction: column; }
  .geo-summary-strip span { padding: 3px 8px; }
  .geo-history-item { grid-template-columns: 1fr; gap: 6px; }
}
