@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  --bg: #090b10;
  --bg-elevated: #0e1118;
  --surface: rgba(18, 22, 32, 0.85);
  --surface-solid: #121620;
  --surface-hover: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f3f4f6;
  --text-muted: #8b93a7;
  --text-dim: #5c6478;
  --primary: #5b8def;
  --primary-hover: #4a7de0;
  --primary-glow: rgba(91, 141, 239, 0.25);
  --success: #3dd68c;
  --success-bg: rgba(61, 214, 140, 0.12);
  --error: #f07178;
  --error-bg: rgba(240, 113, 120, 0.12);
  --purple: #a78bfa;
  --cyan: #22d3ee;
  --amber: #fbbf24;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 0 40px rgba(91, 141, 239, 0.08);
  --chart-height: 260px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(91, 141, 239, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 90% 10%, rgba(61, 214, 140, 0.08), transparent),
    radial-gradient(ellipse 50% 30% at 50% 100%, rgba(167, 139, 250, 0.06), transparent);
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 32px 24px;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app > main {
  flex: 1 0 auto;
  width: 100%;
}

/* ── Header ── */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  padding: 18px 24px;
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-img {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  object-fit: contain;
  flex-shrink: 0;
  background: #000;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.header h1 {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.8125rem;
  margin-top: 2px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #4a7de0 100%);
  color: white;
  box-shadow: 0 2px 12px var(--primary-glow);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--primary-glow);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-large {
  padding: 14px 28px;
  font-size: 0.9375rem;
  border-radius: var(--radius);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

/* ── Auth ── */
.auth-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 55vh;
  padding: 24px 0;
}

.auth-card {
  background: var(--surface);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 52px 48px;
  text-align: center;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow), var(--shadow-glow);
  position: relative;
  overflow: hidden;
}

.auth-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #4285f4, #34a853, #fbbc05, #ea4335);
}

.auth-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  border-radius: 16px;
  object-fit: contain;
  display: block;
  background: #000;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.auth-card h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.auth-card p {
  color: var(--text-muted);
  font-size: 0.9375rem;
  margin-bottom: 28px;
  line-height: 1.6;
}

.error-text {
  color: var(--error);
  margin-top: 16px;
  font-size: 0.875rem;
}

.success-text {
  color: var(--success, #3dd68c);
  font-size: 0.875rem;
}

.login-form {
  text-align: left;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9375rem;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent, #5b8def);
}

.btn-block {
  width: 100%;
}

.user-email {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-right: 8px;
}

.banner {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.875rem;
}

.banner-warning {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fbbf24;
}

.banner a {
  color: #fde68a;
}

/* ── Admin ── */
.admin-main {
  display: flex;
  flex-direction: column;
  gap: 28px;
  flex: 1 0 auto;
  width: 100%;
  padding-bottom: 8px;
}

.settings-main {
  max-width: 960px;
}

.admin-notifications-banner {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
}

.admin-notifications-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.admin-notifications-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-notifications-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  font-size: 0.9375rem;
}

.admin-notification-time {
  color: var(--text-muted);
  font-size: 0.8125rem;
  white-space: nowrap;
}

.admin-section h2 {
  font-size: 1.25rem;
  margin-bottom: 8px;
}

.admin-desc {
  color: var(--text-muted);
  font-size: 0.9375rem;
  margin-bottom: 16px;
  line-height: 1.5;
}

.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}

.admin-status-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-ok {
  background: rgba(61, 214, 140, 0.15);
  color: #3dd68c;
}

.status-warn {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.admin-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-message {
  margin-top: 12px;
}

.admin-form .form-row {
  display: grid;
  grid-template-columns: 2fr 2fr 1fr auto;
  gap: 12px;
  align-items: end;
}

.form-group-checkbox label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: pointer;
  min-height: 42px;
}

.form-group-action {
  margin-bottom: 16px;
}

.admin-table-wrap {
  margin-top: 16px;
  overflow-x: hidden;
  max-width: 100%;
}

.admin-card.admin-table-wrap {
  padding: 0;
  overflow: hidden;
}

.admin-card.admin-table-wrap .admin-table th:first-child,
.admin-card.admin-table-wrap .admin-table td:first-child {
  padding-left: 20px;
}

.admin-card.admin-table-wrap .admin-table th:last-child,
.admin-card.admin-table-wrap .admin-table td:last-child {
  padding-right: 20px;
}

.admin-card.admin-table-wrap .admin-table thead th {
  padding-top: 14px;
  padding-bottom: 14px;
}

.admin-card.admin-table-wrap .admin-table tbody tr:last-child td {
  padding-bottom: 14px;
}

.admin-table {
  width: 100%;
  table-layout: fixed;
}

.admin-table th {
  cursor: default;
}

.admin-table th:hover {
  color: var(--text-dim);
}

.admin-table td {
  min-width: 0;
  vertical-align: middle;
}

.admin-table td.num {
  vertical-align: middle;
}

.admin-table th.col-num,
.admin-table td.col-num,
.admin-table td.num {
  text-align: center;
}

.admin-table th.col-date,
.admin-table td.col-date {
  text-align: left;
  white-space: nowrap;
  font-size: 0.8125rem;
}

.admin-table th.col-status,
.admin-table td.col-status {
  text-align: center;
}

.admin-table th.col-actions,
.admin-table td.col-actions {
  text-align: right;
}

.admin-table td.cell-message {
  text-align: left;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.45;
  font-size: 0.8125rem;
  color: var(--text-muted);
  vertical-align: top;
}

.admin-table-users .col-email { width: 26%; }
.admin-table-users .col-role { width: 15%; }
.admin-table-users .col-status { width: 11%; }
.admin-table-users .col-date { width: 17%; }
.admin-table-users .col-actions { width: 31%; }

.admin-table-users td.col-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-table-users .role-select {
  width: 100%;
  max-width: 160px;
}

.admin-table-gsc .col-site { width: 20%; }
.admin-table-gsc .col-num { width: 8%; }
.admin-table-gsc .col-date { width: 16%; }
.admin-table-gsc .col-message { width: 56%; }

.admin-table-gsc td.site-url {
  max-width: 0;
}

.admin-table-problems .col-site { width: 14%; }
.admin-table-problems .col-issues { width: 24%; }
.admin-table-problems .col-num { width: 7%; }
.admin-table-problems .col-ser { width: 7%; }

.admin-table-problems td.col-issues {
  white-space: normal;
  line-height: 1.5;
}

.admin-row-actions {
  display: flex;
  gap: 6px;
  white-space: nowrap;
  justify-content: flex-end;
  flex-wrap: wrap;
}

@media (max-width: 900px) {
  .admin-table-wrap {
    overflow-x: auto;
  }

  .admin-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding-bottom: 4px;
  }

  .admin-tab {
    flex-shrink: 0;
  }

  .admin-tab-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .admin-tab-toolbar-actions {
    justify-content: flex-start;
  }

  .problems-search {
    max-width: none;
    flex-basis: 100%;
  }

  .problems-table-wrap {
    display: none;
  }

  .problems-cards {
    display: flex;
  }

  .site-drilldown-grid {
    grid-template-columns: 1fr;
  }

  .site-drilldown-panel {
    width: calc(100% - 16px);
    max-height: calc(100vh - 24px);
  }

  .site-drilldown-body {
    max-height: none;
    flex: 1;
    overflow-y: auto;
  }

  .page-admin .header-right {
    flex-wrap: wrap;
    justify-content: center;
  }

  .admin-table-users .col-actions {
    width: 140px;
  }
}

.btn-small {
  padding: 6px 12px;
  font-size: 0.75rem;
}

.empty-cell {
  text-align: center;
  color: var(--text-dim);
  padding: 24px;
}

@media (max-width: 900px) {
  .admin-form .form-row {
    grid-template-columns: 1fr;
  }
  .form-row-3 {
    grid-template-columns: 1fr;
  }
}

.form-row-3 {
  grid-template-columns: 1fr 1fr auto;
}

.admin-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.admin-section-header h2 {
  margin-bottom: 0;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.admin-tab {
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.admin-tab:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.15);
}

.admin-tab.active {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.45);
  color: var(--text);
}

.admin-tab-panel {
  margin-bottom: 0;
}

.admin-tab-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.admin-tab-toolbar-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.admin-tab-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.today-compare-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.today-compare-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.admin-tab-title {
  font-size: 1.25rem;
  margin: 0;
}

.today-toolbar-hint {
  margin: 0;
  font-size: 0.875rem;
  color: #93c5fd;
}

.problems-toolbar-hint {
  margin: 0;
  font-size: 0.875rem;
  color: #93c5fd;
}

.problems-meta {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.problems-empty-banner {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 16px 20px;
  margin-bottom: 16px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.28);
  border-radius: 12px;
}

.problems-empty-icon {
  font-size: 1.75rem;
  line-height: 1;
  flex-shrink: 0;
}

.problems-empty-banner strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 6px;
  color: var(--text);
}

.problems-empty-banner p {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.problems-table-wrap {
  margin-top: 0;
}

#tabProblems.is-awaiting-scan #loadProblemsBtn {
  animation: today-btn-pulse 2.2s ease-in-out infinite;
}

#tabProblems.is-scanning #loadProblemsBtn {
  animation: none;
}

#tabProblems.is-scanning .problems-table-wrap {
  opacity: 0.55;
  pointer-events: none;
}

.problems-table-wrap .empty-cell {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.admin-section-in-tab {
  margin-top: 28px;
}

.admin-section-in-tab:first-of-type {
  margin-top: 0;
}

#tabHealth > .admin-section-in-tab {
  margin-top: 32px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.admin-tab-panel.hidden {
  display: none;
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  transition: opacity 0.2s ease;
  align-items: stretch;
}

.health-updated {
  margin-top: -8px;
  margin-bottom: 12px;
  font-size: 0.8125rem;
  color: var(--text-dim);
}

.health-grid-metrics {
  display: contents;
}

.health-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  min-height: 172px;
  display: flex;
  flex-direction: column;
  gap: 0;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.health-card:hover {
  box-shadow: var(--shadow-sm);
}

.health-card-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-height: 2.25rem;
  margin-bottom: 10px;
}

.health-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 3.5rem;
}

.health-card-footer {
  margin-top: auto;
  padding-top: 12px;
  min-height: 40px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
}

.health-card-footer[aria-hidden="true"] {
  visibility: hidden;
  pointer-events: none;
}

.health-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.health-card-actions .btn {
  flex: 1;
  min-width: 0;
  justify-content: center;
  text-align: center;
}

.health-card-integration .health-card-footer {
  visibility: visible;
  pointer-events: auto;
}

.integration-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 3px;
}

.integration-dot-ok {
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.55);
}

.integration-dot-bad {
  background: #ef4444;
  animation: integration-pulse 1.2s ease-in-out infinite;
}

@keyframes integration-pulse {
  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 4px rgba(239, 68, 68, 0.45);
  }
  50% {
    opacity: 0.35;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.95);
  }
}

.health-card.health-ok {
  border-color: rgba(34, 197, 94, 0.35);
}

.health-card.health-warn {
  border-color: rgba(245, 158, 11, 0.45);
}

.health-card.health-bad {
  border-color: rgba(239, 68, 68, 0.45);
}

.health-card-integration.health-bad {
  border-color: rgba(239, 68, 68, 0.55);
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.1), 0 4px 20px rgba(239, 68, 68, 0.12);
}

.health-card-integration.health-bad .health-value {
  color: #f87171;
}

.health-card-integration.health-bad .health-detail {
  color: #fca5a5;
}

.health-label {
  font-size: 0.6875rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  line-height: 1.35;
  font-weight: 600;
}

.health-value {
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.3;
  word-break: break-word;
}

.health-detail {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.health-detail-empty {
  opacity: 0;
}

.health-card-footer .admin-message {
  margin-top: 0;
  font-size: 0.75rem;
}

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

@media (max-width: 520px) {
  .health-grid {
    grid-template-columns: 1fr;
  }

  .health-card {
    min-height: 0;
  }
}

.integrations-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.integrations-group-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  margin: 4px 0 0;
}

.integrations-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}

.integrations-full {
  grid-column: 1 / -1;
}

.integrations-form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 4px;
  align-items: center;
  justify-content: space-between;
}

.integrations-form-actions-main {
  display: flex;
  gap: 10px;
  margin-left: auto;
}

.integrations-confirm {
  color: var(--amber, #fbbf24);
  font-size: 0.875rem;
  margin: 8px 0 0;
  padding: 10px 12px;
  background: rgba(245, 158, 11, 0.1);
  border-radius: var(--radius-md);
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.btn-confirm {
  background: #d97706 !important;
  border-color: #d97706 !important;
}

.btn-confirm:hover:not(:disabled) {
  background: #b45309 !important;
}

.integrations-modal-desc {
  margin-top: 0;
  margin-bottom: 12px;
}

.admin-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.admin-modal.hidden {
  display: none;
}

.admin-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.admin-modal-panel {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: min(90vh, 720px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}

.admin-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.admin-modal-header h3 {
  margin: 0;
  font-size: 1.125rem;
}

.admin-modal-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.admin-modal-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
}

.admin-modal-actions {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.integrations-source {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: -4px;
}

@media (max-width: 700px) {
  .integrations-grid {
    grid-template-columns: 1fr;
  }
}

.today-content .summary-cards {
  margin-bottom: 16px;
}

.today-loading {
  margin-bottom: 16px;
}

.today-progress {
  margin-bottom: 10px;
}

.today-loading-track {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.today-loading-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--cyan));
  transition: width 0.35s ease;
}

.today-content.is-loading {
  opacity: 0.45;
  pointer-events: none;
}

.today-load-error {
  margin-bottom: 12px;
}

.card-skeleton .card-value {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-height: 2.75rem;
}

.skeleton-line {
  display: block;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 0%,
    rgba(255, 255, 255, 0.12) 50%,
    rgba(255, 255, 255, 0.05) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.6s ease-in-out infinite;
}

.skeleton-value {
  width: 58%;
  height: 1.375rem;
  border-radius: 8px;
}

.skeleton-delta {
  width: 36%;
  height: 0.875rem;
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.card-skeleton {
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.08);
}

.today-empty-banner {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 16px 20px;
  margin-bottom: 20px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 12px;
}

.today-empty-banner-icon {
  font-size: 1.75rem;
  line-height: 1;
  flex-shrink: 0;
}

.today-empty-banner strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 6px;
  color: var(--text);
}

.today-empty-banner p {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.card-idle {
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.08);
  opacity: 0.55;
}

.card-value-idle {
  color: var(--text-muted);
  font-size: 1.375rem;
  opacity: 0.45;
}

.today-cards-idle {
  pointer-events: none;
  user-select: none;
}

#tabToday.is-awaiting-load #loadTodayBtn {
  animation: today-btn-pulse 2.2s ease-in-out infinite;
}

@keyframes today-btn-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.45);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
  }
}

#tabToday.is-loading-data #loadTodayBtn {
  animation: none;
}

.issue-badge {
  display: inline-block;
  padding: 3px 8px;
  margin: 2px 4px 2px 0;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  white-space: nowrap;
}

.issue-badge.issue-bad {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.issue-badge.issue-warn {
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
}

.issue-badge.issue-info {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

tr.problem-row td {
  background: rgba(239, 68, 68, 0.06);
}

tr.problem-row-warn td {
  background: rgba(245, 158, 11, 0.06);
}

tr.problem-row-ok td {
  background: transparent;
}

.problem-data-row {
  cursor: pointer;
}

.problem-data-row:hover td {
  background: rgba(59, 130, 246, 0.08);
}

tr.problem-row.problem-data-row:hover td {
  background: rgba(239, 68, 68, 0.1);
}

tr.problem-row-warn.problem-data-row:hover td {
  background: rgba(245, 158, 11, 0.1);
}

.site-drilldown-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--accent, #60a5fa);
  cursor: pointer;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.site-drilldown-link:hover {
  color: #93c5fd;
}

.issue-badge.issue-ok {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
}

.problems-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  margin-bottom: 16px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.problems-filter-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.problems-filter-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.problems-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.problem-chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.problem-chip:hover {
  border-color: rgba(96, 165, 250, 0.4);
  color: var(--text);
}

.problem-chip.active {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(96, 165, 250, 0.45);
  color: #93c5fd;
}

.problems-search {
  flex: 1 1 180px;
  min-width: 0;
  max-width: 280px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
}

.problems-cards {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.problems-cards-empty {
  margin: 0;
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.problem-card {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color 0.15s;
}

.problem-card:hover {
  border-color: rgba(96, 165, 250, 0.45);
}

.problem-card-warn {
  border-left: 3px solid rgba(245, 158, 11, 0.7);
}

.problem-card-ok {
  border-left: 3px solid rgba(34, 197, 94, 0.5);
}

.problem-card-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  margin: 0 0 10px;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.problem-card-metrics {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 400;
}

.problem-card-issues {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.problem-card-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
  margin: 0;
}

.problem-card-stats > div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.8125rem;
}

.problem-card-stats dt {
  margin: 0;
  color: var(--text-dim);
}

.problem-card-stats dd {
  margin: 0;
  font-weight: 600;
}

.site-drilldown-panel {
  max-width: 720px;
  width: calc(100% - 32px);
}

.site-drilldown-body {
  padding: 0 20px 8px;
  max-height: min(70vh, 560px);
  overflow-y: auto;
}

.site-drilldown-url {
  margin: 0 0 12px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  word-break: break-all;
}

.site-drilldown-issues {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.site-drilldown-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.site-drilldown-section h4 {
  margin: 0 0 10px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.site-drilldown-dl {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.site-drilldown-dl > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.875rem;
}

.site-drilldown-dl > div.full {
  flex-direction: column;
  align-items: stretch;
}

.site-drilldown-dl dt {
  margin: 0;
  color: var(--text-muted);
  flex-shrink: 0;
}

.site-drilldown-dl dd {
  margin: 0;
  text-align: right;
  word-break: break-word;
}

.site-drilldown-dl > div.full dd {
  text-align: left;
}

.site-drilldown-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.muted {
  color: var(--text-dim);
  font-weight: 400;
}

#tabProblems.is-scanning .problems-cards {
  opacity: 0.55;
  pointer-events: none;
}

.num-negative {
  color: #f87171;
  font-weight: 600;
}

.role-select {
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font-family: inherit;
  font-size: 0.8125rem;
}

/* ── Filters toolbar ── */
.filters-toolbar {
  margin-bottom: 16px;
  padding: 20px 24px;
  background: var(--surface);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.filters-main {
  display: flex;
  align-items: stretch;
  gap: 24px;
}

.filters-left {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  min-height: 148px;
}

.filters-left-center {
  flex: 1;
  display: flex;
  align-items: center;
}

.filters-left-bottom {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.filters-side {
  flex: 0 0 360px;
  width: 360px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  justify-content: flex-start;
}

.custom-dates {
  display: flex;
  gap: 16px;
  flex-shrink: 0;
}

.custom-dates.hidden {
  display: none;
}

.filter-group-date {
  flex: 0 0 170px;
  width: 170px;
  min-width: 170px;
  max-width: 170px;
}

.filter-group-country {
  width: 100%;
}

.banner-danger {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.banner-danger a {
  color: #fecaca;
}

.compare-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  margin-top: 10px;
}

.compare-toggle input {
  accent-color: var(--accent, #5b8def);
  flex-shrink: 0;
}

.period-block {
  width: 100%;
}

.delta-badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 999px;
  line-height: 1.2;
  max-width: 100%;
}

.metric-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  min-width: 3.5rem;
}

.metric-cell .metric-value {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  line-height: 1.2;
}

.metric-cell .delta-badge {
  font-size: 0.625rem;
  padding: 1px 5px;
}

.data-table td.num.col-vis-gsc,
.data-table th.col-vis-gsc {
  min-width: 5.25rem;
}

.card-value-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.card-value-wrap .card-value-main {
  line-height: 1.1;
}

.card-value-wrap .delta-badge {
  font-size: 0.75rem;
}

.delta-up {
  color: #3dd68c;
  background: rgba(61, 214, 140, 0.12);
}

.delta-down {
  color: #f87171;
  background: rgba(248, 113, 113, 0.12);
}

.delta-neutral {
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
}

.filters-side .filter-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}

.filters-side .filter-actions .btn {
  width: 100%;
  min-width: 0;
  white-space: nowrap;
}

.filter-hint-row {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.chart-section {
  margin-bottom: 24px;
}

.period-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

.period-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.period-buttons {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.period-btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.period-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.period-btn.active {
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-strong);
}

.chart-panel {
  background: var(--surface);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  transition: padding 0.3s ease;
}

.chart-panel.is-collapsed {
  padding-bottom: 16px;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 0;
  flex-shrink: 0;
}

.chart-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.chart-toggle-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-strong);
}

.chart-toggle-icon {
  transition: transform 0.3s ease;
}

.chart-panel.is-collapsed .chart-toggle-icon {
  transform: rotate(-90deg);
}

.chart-body {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.35s ease, opacity 0.25s ease, margin-top 0.35s ease;
  margin-top: 12px;
}

.chart-panel.is-collapsed .chart-body {
  grid-template-rows: 0fr;
  opacity: 0;
  margin-top: 0;
}

.chart-body-inner {
  overflow: hidden;
  min-height: 0;
}

.chart-wrap {
  position: relative;
  height: var(--chart-height);
  max-height: var(--chart-height);
  flex: none;
}

.chart-panel.is-collapsed .chart-wrap {
  height: 0;
  max-height: 0;
}

.chart-title {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.chart-legend-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
}

.legend-line {
  display: inline-block;
  width: 22px;
  height: 3px;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend-line-clicks {
  background: #5b8def;
}

.legend-line-impressions {
  background: #22d3ee;
}

.legend-line-position {
  background: transparent;
  border-top: 3px dashed #3dd68c;
  height: 0;
  margin-top: 1px;
}

.legend-axis {
  font-size: 0.6875rem;
  font-weight: 400;
  color: var(--text-dim);
  margin-left: 2px;
}

.legend-chip-clicks { border-color: rgba(91, 141, 239, 0.35); }
.legend-chip-impressions { border-color: rgba(34, 211, 238, 0.35); }
.legend-chip-position { border-color: rgba(61, 214, 140, 0.35); }

.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.chart-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 0.8125rem;
  text-align: center;
  padding: 16px;
}

.chart-placeholder.hidden {
  display: none;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.filter-group label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.filter-group input[type="date"],
.filter-group select,
.country-search,
.search-box input {
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.filter-group input[type="date"]:focus,
.filter-group select:focus,
.country-search:focus,
.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.filter-group input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
}

.filter-group select {
  cursor: pointer;
}

.country-search {
  font-size: 0.8125rem;
}

.filter-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.filter-info {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-info::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}

/* ── Summary cards ── */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.card {
  background: var(--surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
  min-width: 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
}

.card-sites::after { background: var(--purple); }
.card-impressions::after { background: var(--cyan); }
.card-clicks::after { background: var(--primary); }
.card-ctr::after { background: var(--amber); }
.card-position::after { background: var(--success); }

/* ── Keitaro ── */
.keitaro-summary {
  margin-bottom: 24px;
}

.section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.keitaro-label::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
  flex-shrink: 0;
}

.keitaro-period-hint {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted, #94a3b8);
  letter-spacing: 0.01em;
}

.summary-cards-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.summary-cards-grid-6 {
  grid-template-columns: repeat(6, 1fr);
}

.keitaro-summary .summary-cards-grid {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.card-keitaro-clicks .card-value,
.card-keitaro-unique .card-value,
.card-keitaro-conv .card-value,
.card-keitaro-ftd .card-value,
.card-keitaro-revenue .card-value,
.card-keitaro-profit .card-value {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.card-keitaro-clicks::after { background: #f59e0b; }
.card-keitaro-unique::after { background: #38bdf8; }
.card-keitaro-conv::after { background: #a78bfa; }
.card-keitaro-ftd::after { background: #f472b6; }
.card-keitaro-revenue::after { background: #3dd68c; }
.card-keitaro-cr::after { background: var(--cyan); }
.card-keitaro-roi::after { background: var(--primary); }
.card-keitaro-profit::after { background: var(--primary); }

.chart-panel-keitaro {
  border-color: rgba(245, 158, 11, 0.2);
}

.legend-line-kt-clicks { background: #f59e0b; }
.legend-line-kt-conv { background: #a78bfa; }
.legend-line-kt-revenue {
  background: transparent;
  border-top: 3px dashed #3dd68c;
  height: 0;
  margin-top: 1px;
}

.legend-chip-kt-clicks { border-color: rgba(245, 158, 11, 0.35); }
.legend-chip-kt-conv { border-color: rgba(167, 139, 250, 0.35); }
.legend-chip-kt-revenue { border-color: rgba(61, 214, 140, 0.35); }

.col-campaign {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.col-keitaro.hidden,
.col-domain-cost.hidden,
.col-link-cost.hidden {
  display: none;
}

th.col-keitaro,
td.col-keitaro {
  color: #fbbf24;
}

th.col-domain-cost,
td.col-domain-cost {
  color: #60a5fa;
}

th.col-link-cost,
td.col-link-cost {
  color: #c084fc;
}

.domain-cost-empty,
.link-cost-empty {
  color: var(--text-dim);
}

.keitaro-empty {
  color: var(--text-dim);
}

.warning-banner {
  padding: 14px 20px;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.25);
  border-radius: var(--radius-lg);
  color: var(--amber);
  margin-top: 16px;
  font-size: 0.875rem;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.card-icon {
  font-size: 1rem;
  opacity: 0.7;
}

.card-value {
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.card-sites .card-value { color: var(--purple); }

.card-value-sites {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.sites-launched {
  font-size: 0.75rem;
  font-weight: 600;
  color: #c4b5fd;
  letter-spacing: 0;
  line-height: 1.2;
}

.card-impressions .card-value { color: var(--cyan); }
.card-clicks .card-value { color: var(--primary); }
.card-ctr .card-value { color: var(--amber); }
.card-position .card-value { color: var(--success); }

/* ── Progress ── */
.progress-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.progress-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.dashboard > *:not(.hidden) {
  animation: fadeIn 0.35s ease;
}

/* ── Table ── */
.table-container {
  background: var(--surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.table-header h2 {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.table-header-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.column-filter {
  position: relative;
}

.column-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 8px);
  background: var(--surface, rgba(255, 255, 255, 0.04));
  color: var(--text-muted, #9aa4b2);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.column-filter-btn:hover,
.column-filter-btn[aria-expanded="true"] {
  color: var(--text, #e6edf3);
  border-color: rgba(91, 141, 239, 0.45);
  background: rgba(91, 141, 239, 0.08);
}

.column-filter-chevron {
  font-size: 0.7rem;
  opacity: 0.7;
}

.column-filter-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  min-width: 280px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 12px);
  background: var(--surface-elevated, #161b22);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.column-filter-title {
  margin: 0 0 10px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.column-filter-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.column-filter-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text, #e6edf3);
  font-size: 0.875rem;
  line-height: 1.35;
  transition: background 0.12s;
}

.column-filter-option:hover {
  background: rgba(255, 255, 255, 0.04);
}

.column-filter-option input {
  margin-top: 2px;
  accent-color: var(--primary, #5b8def);
  flex-shrink: 0;
}

.col-hidden {
  display: none !important;
}

.search-box {
  position: relative;
  flex-shrink: 0;
}

.search-box input {
  width: 300px;
  padding-left: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238b93a7' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242 1.006a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
}

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

#dataTable {
  width: 100%;
  table-layout: fixed;
}

#dataTable col.col-site {
  width: 14%;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

thead {
  background: rgba(0, 0, 0, 0.2);
}

th {
  padding: 10px 12px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  vertical-align: bottom;
  transition: color 0.15s;
}

th.col-site { text-align: left; }
th.col-num { text-align: right; }
th.col-status { text-align: center; }
th.col-country { text-align: left; }

th:hover { color: var(--text-muted); }

th.sorted-asc,
th.sorted-desc {
  color: var(--primary);
}

.sort-icon {
  opacity: 0.35;
  font-size: 0.65rem;
}

th.sorted-asc .sort-icon::after { content: " ↑"; opacity: 1; }
th.sorted-desc .sort-icon::after { content: " ↓"; opacity: 1; }

td {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  vertical-align: middle;
}

tbody tr {
  transition: background 0.12s ease;
}

tbody tr:hover td {
  background: var(--surface-hover);
}

.site-url {
  font-family: "SF Mono", "Fira Code", Monaco, monospace;
  font-size: 0.8125rem;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #c9d1d9;
}

tfoot .table-totals-row td {
  position: sticky;
  bottom: 0;
  background: var(--surface-elevated, #1a2332);
  border-top: 2px solid var(--border, rgba(255, 255, 255, 0.12));
  font-weight: 600;
  padding-top: 12px;
  padding-bottom: 12px;
}

tfoot .totals-label {
  font-family: inherit;
  font-weight: 700;
  color: var(--text, #e6edf3);
}

tfoot .table-totals-row:hover td {
  background: var(--surface-elevated, #1a2332);
}

.num {
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-weight: 500;
  vertical-align: top;
}

.num .metric-cell {
  margin-left: auto;
}

.col-status {
  text-align: center;
  white-space: nowrap;
}

.col-country {
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-ok {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(61, 214, 140, 0.2);
}

.badge-error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid rgba(240, 113, 120, 0.2);
}

.country-tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.country-tag.empty {
  color: var(--text-dim);
  background: transparent;
  border-color: transparent;
}

.table-info {
  padding: 14px 24px;
  font-size: 0.8125rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}

/* ── Summary reports ── */
.summary-reports {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 20px;
}

.summary-table-container .table-header {
  border-bottom: 1px solid var(--border);
}

.summary-loading {
  padding: 12px 20px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.12);
}

.summary-loading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.summary-loading-percent {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 600;
}

.summary-loading-track {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.summary-loading-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--cyan));
  will-change: width;
}

.summary-table-wrapper {
  overflow-x: auto;
  scrollbar-width: thin;
  transition: opacity 0.45s ease;
}

.summary-table-wrapper.is-loading {
  opacity: 0.55;
  pointer-events: none;
}

.summary-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  table-layout: auto;
}

.summary-table th,
.summary-table td {
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.8125rem;
  white-space: nowrap;
}

.summary-table th {
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  cursor: default;
  text-align: center;
}

.summary-geo-empty {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  padding: 18px 14px !important;
}

.summary-empty-state {
  font-style: normal;
}

.summary-empty-state .summary-empty-text {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.summary-empty-state .btn {
  min-width: 180px;
}

.summary-th-geo,
.summary-metric-label,
.summary-geo-name {
  text-align: left;
  font-weight: 600;
  background: rgba(91, 141, 239, 0.12);
  color: var(--text, #e6edf3);
}

.summary-th-month {
  background: rgba(251, 191, 36, 0.12);
  color: #fbbf24;
}

.summary-th-total {
  background: rgba(251, 191, 36, 0.18);
  color: #fbbf24;
  font-weight: 700;
}

.summary-th-spend {
  background: rgba(248, 113, 113, 0.14);
  color: #fca5a5;
}

.summary-th-income {
  background: rgba(61, 214, 140, 0.14);
  color: #3dd68c;
}

.summary-th-profit {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
}

.summary-num {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.summary-total-cell {
  font-weight: 700;
  background: rgba(251, 191, 36, 0.06);
}

.summary-row-sites td {
  background: rgba(61, 214, 140, 0.06);
}

.summary-row-sites .summary-metric-label {
  background: rgba(61, 214, 140, 0.14);
}

.summary-sites-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  line-height: 1.2;
}

.summary-sites-new {
  font-size: 0.6875rem;
  font-weight: 500;
  color: #3dd68c;
  white-space: nowrap;
}

.summary-row-income td {
  background: rgba(61, 214, 140, 0.06);
}

.summary-row-income .summary-metric-label {
  background: rgba(61, 214, 140, 0.14);
}

.summary-row-spent td {
  background: rgba(251, 146, 60, 0.08);
}

.summary-row-spent .summary-metric-label {
  background: rgba(251, 146, 60, 0.16);
}

.summary-spend-cell {
  background: rgba(248, 113, 113, 0.08);
}

.summary-income-cell {
  background: rgba(61, 214, 140, 0.08);
}

.summary-profit-cell.is-negative {
  color: #f87171;
}

.summary-table-geo {
  min-width: 480px;
}

.error-banner {
  padding: 16px 20px;
  background: var(--error-bg);
  border: 1px solid rgba(240, 113, 120, 0.25);
  border-radius: var(--radius-lg);
  color: var(--error);
  margin-top: 16px;
  font-size: 0.875rem;
}

.hidden {
  display: none !important;
}

/* ── Responsive ── */
@media (max-width: 1100px) {
  .summary-cards,
  .summary-cards-grid,
  .summary-cards-grid-6 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .keitaro-summary .summary-cards-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .app {
    padding: 16px;
  }

  .header {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }

  .header-left {
    flex-direction: column;
  }

  .period-buttons {
    width: 100%;
  }

  .period-btn {
    flex: 1;
    text-align: center;
    padding: 8px 10px;
    font-size: 0.75rem;
  }

  .filters-main {
    flex-direction: column;
  }

  .filters-left {
    min-height: 0;
  }

  .filters-left-center {
    align-items: flex-start;
  }

  .filters-side {
    width: 100%;
    flex: 1 1 auto;
  }

  .filters-side .filter-actions {
    grid-template-columns: 1fr;
  }

  .custom-dates {
    flex-direction: column;
    width: 100%;
  }

  .filter-group-date {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  .summary-cards,
  .summary-cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .keitaro-summary .summary-cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .keitaro-summary .card {
    padding: 14px 12px;
  }

  .keitaro-summary .card-value {
    font-size: clamp(1rem, 4.8vw, 1.45rem);
    letter-spacing: -0.02em;
  }

  .keitaro-summary .card-label {
    font-size: 0.625rem;
    letter-spacing: 0.04em;
  }

  .keitaro-summary .card-top {
    gap: 6px;
    min-width: 0;
  }

  .card-value-sites .sites-launched {
    font-size: 0.6875rem;
  }

  .summary-table-container .table-header {
    position: sticky;
    top: 0;
    z-index: 6;
    background: var(--surface-elevated, #161b22);
    box-shadow: 0 1px 0 var(--border);
  }

  .summary-table-container .table-header-tools .btn {
    width: 100%;
  }

  #dataTable {
    min-width: 1040px;
    table-layout: auto;
  }

  #dataTable th {
    white-space: normal;
    font-size: 0.625rem;
    padding: 8px 6px;
    line-height: 1.25;
    vertical-align: bottom;
    hyphens: auto;
  }

  #dataTable td {
    font-size: 0.75rem;
    padding: 8px 6px;
  }

  #dataTable th .sort-icon {
    display: none;
  }

  .table-header {
    flex-direction: column;
  }

  .table-header-tools {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .column-filter-panel {
    left: 0;
    right: auto;
    width: 100%;
  }

  .search-box input {
    width: 100%;
  }

  .header-right {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }
}

@media (max-width: 480px) {
  .summary-cards,
  .summary-cards-grid {
    grid-template-columns: 1fr;
  }

  .keitaro-summary .summary-cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ── App version footer ── */
.app-footer {
  margin-top: auto;
  flex-shrink: 0;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  min-height: 48px;
  display: flex;
  align-items: center;
}

.app-footer-admin {
  margin-top: auto;
}

.app-footer-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  width: 100%;
  min-height: 1.25rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.25rem;
}

.app-footer-released {
  color: var(--text-muted);
  opacity: 0.85;
  min-height: 1.25rem;
}

.app-footer-sep {
  opacity: 0.5;
  user-select: none;
}

.app-footer-sep.hidden {
  display: none;
}

.app-footer-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.8125rem;
  color: #93c5fd;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.app-footer-link:hover {
  color: #bfdbfe;
}

.changelog-modal-panel {
  max-width: 520px;
  max-height: min(85vh, 640px);
  display: flex;
  flex-direction: column;
}

.changelog-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  margin: 0 0 16px;
  padding-right: 4px;
}

.changelog-entry {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.changelog-entry:first-child {
  padding-top: 0;
}

.changelog-entry:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.changelog-entry-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.changelog-entry-head strong {
  font-size: 0.9375rem;
  color: var(--text);
}

.changelog-entry-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.changelog-entry-title {
  margin: 0 0 8px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.changelog-entry-list {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--text-muted);
}

.changelog-entry-list li + li {
  margin-top: 4px;
}
