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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  line-height: 1.5;
}

/* ── Header ── */
.header {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
}

.logo-domain {
  color: #2563eb;
}

.header-actions {
  display: flex;
  gap: 6px;
}

/* ── Container ── */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px;
}

main.container {
  padding-top: 20px;
  padding-bottom: 40px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 8px;
  padding: 8px 14px;
  border: none;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

.btn-primary {
  background: #2563eb;
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #1d4ed8;
}

.btn-outline {
  background: #fff;
  color: #334155;
  border: 1px solid #cbd5e1;
}

.btn-outline:hover:not(:disabled) {
  background: #f8fafc;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.75rem;
}

/* ── Status bar ── */
.status-bar {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-weight: 500;
  font-size: 0.875rem;
}

.status-ok {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.status-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

/* ── Metric cards ── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px 18px;
}

.metric-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.metric-value {
  font-size: 1.5rem;
  font-weight: 700;
}

/* ── Card ── */
.card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 14px;
}

.card h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
}

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

.card-header h2 {
  margin-bottom: 0;
}

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  text-align: left;
  padding: 8px 10px;
  font-weight: 600;
  color: #64748b;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 2px solid #e2e8f0;
}

tbody td {
  padding: 10px 10px;
  border-bottom: 1px solid #f1f5f9;
}

tbody tr:hover {
  background: #f8fafc;
}

/* ── Rank change chips ── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
}

.chip-up {
  background: #dcfce7;
  color: #166534;
}

.chip-down {
  background: #fee2e2;
  color: #991b1b;
}

.chip-neutral {
  background: #f1f5f9;
  color: #64748b;
}

.rank-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.rank-na {
  color: #94a3b8;
}

/* ── Alerts ── */
.alert-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.875rem;
}

.alert-item:last-child {
  border-bottom: none;
}

.alert-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  background: #fee2e2;
  color: #dc2626;
}

.alert-body {
  flex: 1;
}

.alert-date {
  font-size: 0.75rem;
  color: #94a3b8;
}

/* ── Forms ── */
.inline-form {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

input[type="text"] {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.8125rem;
  min-width: 180px;
  transition: border-color 0.15s;
}

input[type="text"]:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* ── Empty states ── */
.empty-state {
  text-align: center;
  color: #94a3b8;
  padding: 24px 0;
  font-size: 0.875rem;
}

/* ── Settings ── */
.settings-toggle {
  font-weight: 600;
  cursor: pointer;
  font-size: 0.875rem;
  color: #64748b;
}

.settings-body {
  padding-top: 12px;
}

.settings-section h3 {
  font-size: 0.875rem;
  margin-bottom: 8px;
}

.gsc-link-output a {
  color: #2563eb;
  font-size: 0.875rem;
}
