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

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

:root {
  --bg: #f0f2f7;
  --card: #ffffff;
  --border: #e4e9f2;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text: #111827;
  --muted: #6b7280;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 8px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.1);
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ── NAV ─────────────────────────────────────────────────────────── */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1e1b4b;
  padding: 0 28px;
  height: 58px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,.18);
}
.nav-brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: #fff;
  letter-spacing: -.3px;
}
.nav-brand span { color: #818cf8; }
.nav-links { display: flex; gap: 4px; }
.nav-btn {
  background: none;
  border: none;
  padding: 7px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 500;
  color: rgba(255,255,255,.65);
  transition: background .15s, color .15s;
  font-family: inherit;
}
.nav-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-btn.active { background: var(--primary); color: #fff; }

/* ── VIEWS ───────────────────────────────────────────────────────── */
.view { display: none; padding: 28px 24px; max-width: 1140px; margin: 0 auto; }
.view.active { display: block; }

/* ── CARD ────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.card h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card h2::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 18px;
  background: var(--primary);
  border-radius: 2px;
}
.card h3 { font-size: .9rem; font-weight: 600; margin: 20px 0 10px; color: var(--muted); }

/* ── FORM ────────────────────────────────────────────────────────── */
.form-row {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  flex: 1;
  min-width: 150px;
}
input[type=text], input[type=number], input[type=email], select {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .88rem;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border .15s, box-shadow .15s;
  width: 100%;
  font-family: inherit;
}
input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
input[type=range] {
  padding: 0;
  height: 4px;
  accent-color: var(--primary);
  margin-top: 8px;
  cursor: pointer;
}

.checkbox-label {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: .83rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}
.checkbox-label input { width: auto; accent-color: var(--primary); }

/* ── TOGGLE ──────────────────────────────────────────────────────── */
.mode-toggle {
  display: flex;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.toggle-btn {
  border: none;
  padding: 8px 22px;
  background: transparent;
  cursor: pointer;
  font-size: .84rem;
  font-weight: 500;
  color: var(--muted);
  transition: background .15s, color .15s;
  font-family: inherit;
}
.toggle-btn.active { background: var(--primary); color: #fff; }

/* ── BUTTONS ─────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
  font-family: inherit;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: scale(.98); }

.btn-secondary {
  background: #fff;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  padding: 8px 18px;
  border-radius: 8px;
  font-size: .83rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  font-family: inherit;
  white-space: nowrap;
}
.btn-secondary:hover { background: var(--primary-light); }

.btn-danger { background: var(--danger); color: #fff; border: none; padding: 6px 12px; border-radius: 7px; font-size: .8rem; cursor: pointer; font-family: inherit; }
.btn-sm { padding: 5px 10px; font-size: .78rem; border-radius: 6px; cursor: pointer; border: 1.5px solid var(--border); background: #fff; color: var(--text); font-family: inherit; }
.btn-sm:hover { background: var(--bg); }

.form-actions { display: flex; gap: 12px; margin-top: 8px; flex-wrap: wrap; }

/* ── QUOTA BAR ───────────────────────────────────────────────────── */
.quota-bar-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 14px;
  flex-wrap: wrap;
}
.quota-label { font-size: .8rem; color: var(--muted); font-weight: 500; }
.quota-bar { flex: 1; min-width: 100px; max-width: 240px; height: 7px; background: var(--border); border-radius: 99px; overflow: hidden; }
.quota-fill { height: 100%; background: linear-gradient(90deg, var(--primary), #818cf8); border-radius: 99px; transition: width .4s; }
.quota-source { font-size: .8rem; color: var(--muted); margin-left: auto; }

.quota-bar-large-wrap { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.quota-bar-large { flex: 1; height: 14px; background: var(--border); border-radius: 99px; overflow: hidden; }

/* ── ALERT ───────────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 8px; font-size: .85rem; margin-bottom: 16px; background: #fef3c7; border: 1px solid #fcd34d; color: #92400e; }
.hidden { display: none !important; }

/* ── PROGRESS ────────────────────────────────────────────────────── */
.progress-wrap { display: flex; align-items: center; gap: 12px; margin-top: 20px; padding: 14px 16px; background: var(--primary-light); border-radius: 8px; }
.spinner { width: 20px; height: 20px; border: 3px solid #c7d2fe; border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress-stats { font-size: .83rem; color: var(--muted); margin-top: 8px; padding: 0 4px; }

/* ── TABLE ───────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: 8px; border: 1px solid var(--border); margin-top: 16px; }
table { width: 100%; border-collapse: collapse; font-size: .83rem; }
thead tr { background: #f8fafc; }
th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .4px;
}
th:hover { color: var(--primary); }
td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbff; }

/* ── BADGES & TAGS ───────────────────────────────────────────────── */
.badge { display: inline-block; background: var(--primary); color: #fff; font-size: .72rem; padding: 2px 9px; border-radius: 99px; font-weight: 600; }
.badge-success { background: var(--success); }
.badge-warning { background: var(--warning); color: #fff; }
.badge-danger { background: var(--danger); }

.tag-no-site { display: inline-block; background: #fee2e2; color: #b91c1c; font-size: .72rem; padding: 2px 8px; border-radius: 5px; font-weight: 600; }
.tag-has-site { display: inline-block; background: #d1fae5; color: #065f46; font-size: .72rem; padding: 2px 8px; border-radius: 5px; font-weight: 600; }
.tag-dup { background: #fef9c3; color: #854d0e; font-size: .72rem; padding: 2px 8px; border-radius: 5px; font-weight: 600; display: inline-block; }

/* ── RESULTS TOOLBAR ─────────────────────────────────────────────── */
.results-toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 4px; }
.results-toolbar h2 { flex: none; margin-bottom: 0; }
.results-toolbar h2::before { display: none; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.filters input, .filters select { max-width: 170px; }
.export-btns { display: flex; gap: 8px; }

/* ── QUOTA DASHBOARD ─────────────────────────────────────────────── */
.quota-dashboard { display: flex; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.quota-stat {
  background: linear-gradient(135deg, var(--primary-light), #fff);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
  flex: 1;
}
.stat-label { font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--primary); }

/* ── COPY BUTTON ─────────────────────────────────────────────────── */
.copy-btn { background: none; border: none; cursor: pointer; font-size: .75rem; color: var(--primary); padding: 2px 6px; border-radius: 4px; }
.copy-btn:hover { background: var(--primary-light); }

/* ── BRIEF CARDS ─────────────────────────────────────────────────── */
.brief-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: #fafbff;
  transition: box-shadow .15s;
}
.brief-card:hover { box-shadow: var(--shadow-md); background: #fff; }
.brief-card-info { flex: 1; min-width: 0; }
.brief-card-name { font-weight: 700; font-size: .9rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brief-card-meta { font-size: .75rem; color: var(--muted); margin-top: 3px; }
.brief-card-actions { display: flex; flex-direction: column; gap: 7px; align-items: flex-end; flex-shrink: 0; }
.brief-card-row { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; }
.brief-model-select {
  padding: 5px 8px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: .78rem;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  cursor: pointer;
  outline: none;
}
.brief-model-select:focus { border-color: var(--primary); }
.brief-empty { text-align: center; color: var(--muted); padding: 32px 0; font-size: .88rem; }

/* ── RESPONSIVE ──────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .nav { padding: 0 14px; }
  .view { padding: 14px 12px; }
  .card { padding: 16px; }
  .results-toolbar { flex-direction: column; align-items: flex-start; }
  .quota-dashboard { flex-direction: column; }
  .nav-brand span { display: none; }
}
