/* ── Reset & Variables ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #0f1117;
  --bg-secondary: #13161f;
  --card:         #1a1d27;
  --card-hover:   #1f2335;
  --border:       #2a2d3e;
  --border-light: #353850;
  --text:         #e2e4f0;
  --text-muted:   #7b80a0;
  --text-dim:     #525770;
  --accent:       #4f8ef7;
  --accent-hover: #6ba3ff;
  --accent-dim:   rgba(79,142,247,.12);

  /* Status colours */
  --pass:         #22c55e;
  --pass-bg:      rgba(34,197,94,.1);
  --fail:         #ef4444;
  --fail-bg:      rgba(239,68,68,.1);
  --warning:      #f59e0b;
  --warning-bg:   rgba(245,158,11,.1);
  --na:           #6b7280;
  --na-bg:        rgba(107,114,128,.1);
  --pending:      #374151;

  /* Tier colours */
  --basic:        #22c55e;
  --basic-bg:     rgba(34,197,94,.1);
  --growth:       #f97316;
  --growth-bg:    rgba(249,115,22,.1);
  --complete:     #a855f7;
  --complete-bg:  rgba(168,85,247,.1);

  --radius:       8px;
  --radius-sm:    5px;
  --sidebar-w:    280px;
  --header-h:     56px;
  --shadow:       0 2px 12px rgba(0,0,0,.35);
  --transition:   0.18s ease;
  --font:         'Inter', system-ui, -apple-system, sans-serif;
}

html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ── Typography ───────────────────────────────────────────────────────────── */
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── App Shell ────────────────────────────────────────────────────────────── */
.app-header {
  height: var(--header-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.app-header__logo {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.02em;
}

.app-header__logo span { color: var(--accent); }

.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - var(--header-h));
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar__header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar__title {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.sidebar__list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.sidebar__empty {
  color: var(--text-muted);
  font-size: .85rem;
  text-align: center;
  padding: 24px 12px;
}

/* Audit List Item */
.audit-item {
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
  border: 1px solid transparent;
  margin-bottom: 4px;
  position: relative;
}

.audit-item:hover { background: var(--card-hover); }

.audit-item--active {
  background: var(--accent-dim);
  border-color: rgba(79,142,247,.3);
}

.audit-item__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.audit-item__name {
  font-weight: 600;
  font-size: .875rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.audit-item__url {
  font-size: .75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.audit-item__meta {
  display: flex;
  justify-content: space-between;
  font-size: .7rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.audit-item__delete {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 2px;
  border-radius: 3px;
  transition: color var(--transition), background var(--transition);
}

.audit-item__delete:hover { color: var(--fail); background: var(--fail-bg); }

/* Mini progress */
.mini-progress {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.mini-progress__bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width .4s ease;
}

/* ── Main Content ─────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
}

/* ── Welcome ──────────────────────────────────────────────────────────────── */
.welcome {
  max-width: 520px;
  margin: 80px auto;
  text-align: center;
}

.welcome__icon { font-size: 3rem; margin-bottom: 16px; }

.welcome__title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.welcome__subtitle {
  color: var(--text-muted);
  margin-bottom: 32px;
}

.welcome__tiers {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.welcome__tier {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  min-width: 120px;
}

.welcome__tier-price { font-size: .9rem; font-weight: 600; color: var(--text); }
.welcome__tier-desc  { font-size: .75rem; color: var(--text-muted); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
  font-family: var(--font);
  line-height: 1.4;
  white-space: nowrap;
}

.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn--outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border-light);
}
.btn--outline:hover { background: var(--card); border-color: var(--accent); color: var(--accent); }

.btn--sm { padding: 5px 12px; font-size: .8rem; }

.btn--full { width: 100%; justify-content: center; }

/* ── Tier Badges ──────────────────────────────────────────────────────────── */
.tier-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.tier-badge--basic    { background: var(--basic-bg);    color: var(--basic); }
.tier-badge--growth   { background: var(--growth-bg);   color: var(--growth); }
.tier-badge--complete { background: var(--complete-bg); color: var(--complete); }

/* ── Status Badges ────────────────────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  flex-shrink: 0;
}

.status-badge--pass    { background: var(--pass-bg);    color: var(--pass); }
.status-badge--fail    { background: var(--fail-bg);    color: var(--fail); }
.status-badge--warning { background: var(--warning-bg); color: var(--warning); }
.status-badge--na      { background: var(--na-bg);      color: var(--na); }
.status-badge--pending { background: var(--pending);    color: var(--text-muted); }

/* ── Audit Header ─────────────────────────────────────────────────────────── */
.audit-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.audit-header__url {
  font-size: .8rem;
  color: var(--accent);
  margin-bottom: 2px;
}

.audit-header__name {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.audit-header__actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  align-items: flex-start;
}

/* ── Progress ─────────────────────────────────────────────────────────────── */
.progress-section {
  margin-bottom: 20px;
}

.progress-section__label {
  display: flex;
  justify-content: space-between;
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, #7eb4ff 100%);
  border-radius: 4px;
  transition: width .5s ease;
}

/* ── Toolbar ──────────────────────────────────────────────────────────────── */
.checklist-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 180px;
  padding: 7px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .875rem;
  font-family: var(--font);
  transition: border-color var(--transition);
}

.search-input::placeholder { color: var(--text-dim); }
.search-input:focus { outline: none; border-color: var(--accent); }

.filter-group {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 5px 11px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: .75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
}

.filter-btn:hover { border-color: var(--accent); color: var(--accent); }

.filter-btn--active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

/* ── Checklist Group ──────────────────────────────────────────────────────── */
.checklist-group {
  margin-bottom: 28px;
}

.checklist-group__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.checklist-group__title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}

.checklist-group__count {
  font-size: .75rem;
  color: var(--text-dim);
}

/* ── Checklist Item ───────────────────────────────────────────────────────── */
.checklist-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.checklist-item:hover { border-color: var(--border-light); }

.checklist-item--pass    { border-left: 3px solid var(--pass); }
.checklist-item--fail    { border-left: 3px solid var(--fail); }
.checklist-item--warning { border-left: 3px solid var(--warning); }
.checklist-item--na      { border-left: 3px solid var(--na); }
.checklist-item--pending { border-left: 3px solid var(--pending); }

.checklist-item__summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
}

.checklist-item__summary:hover .checklist-item__desc { color: var(--accent); }

.checklist-item__num {
  font-size: .7rem;
  font-weight: 700;
  color: var(--text-dim);
  background: var(--border);
  border-radius: 4px;
  padding: 2px 7px;
  flex-shrink: 0;
  min-width: 30px;
  text-align: center;
}

.checklist-item__main {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.checklist-item__desc {
  font-size: .875rem;
  color: var(--text);
  transition: color var(--transition);
  flex: 1;
}

.checklist-item__chevron {
  color: var(--text-dim);
  font-size: .75rem;
  transition: transform var(--transition);
  flex-shrink: 0;
}

.checklist-item--expanded .checklist-item__chevron {
  transform: rotate(90deg);
}

/* Detail panel */
.checklist-item__detail {
  display: none;
  padding: 0 14px 14px 14px;
  border-top: 1px solid var(--border);
}

.checklist-item--expanded .checklist-item__detail { display: block; }

.checklist-item__info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
  margin-top: 12px;
}

@media (max-width: 680px) {
  .checklist-item__info { grid-template-columns: 1fr; }
}

.info-block strong {
  display: block;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.info-block p {
  font-size: .85rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.checklist-item__controls { display: flex; flex-direction: column; gap: 10px; }

/* Status buttons */
.status-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.status-btn {
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: transparent;
  color: var(--text-muted);
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
}

.status-btn--pass:hover,   .status-btn--pass.status-btn--active   { background: var(--pass-bg);    border-color: var(--pass);    color: var(--pass); }
.status-btn--fail:hover,   .status-btn--fail.status-btn--active   { background: var(--fail-bg);    border-color: var(--fail);    color: var(--fail); }
.status-btn--warning:hover,.status-btn--warning.status-btn--active{ background: var(--warning-bg); border-color: var(--warning); color: var(--warning); }
.status-btn--na:hover,     .status-btn--na.status-btn--active     { background: var(--na-bg);      border-color: var(--na);      color: var(--na); }
.status-btn--reset { color: var(--text-dim); font-size: .75rem; }
.status-btn--reset:hover { color: var(--text-muted); border-color: var(--text-dim); }

/* Notes */
.notes-textarea {
  width: 100%;
  min-height: 70px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .85rem;
  font-family: var(--font);
  resize: vertical;
  transition: border-color var(--transition);
  line-height: 1.5;
}

.notes-textarea::placeholder { color: var(--text-dim); }
.notes-textarea:focus { outline: none; border-color: var(--accent); }

/* Save indicator */
.save-indicator {
  font-size: .72rem;
  min-height: 1em;
  transition: color var(--transition);
}

.save-indicator--saving { color: var(--text-muted); }
.save-indicator--saved  { color: var(--pass); }

/* ── Empty search ─────────────────────────────────────────────────────────── */
.empty-search {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
  font-size: .9rem;
}

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}

.modal__title {
  font-size: 1.05rem;
  font-weight: 600;
}

.modal__close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
  border-radius: 4px;
}

.modal__close:hover { color: var(--text); background: var(--border); }

.modal__form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.form-label {
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
}

.req { color: var(--fail); }

.form-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .875rem;
  font-family: var(--font);
  transition: border-color var(--transition);
}

.form-input:focus { outline: none; border-color: var(--accent); }

select.form-input { cursor: pointer; }
select.form-input option { background: var(--card); }

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 10px 18px;
  font-size: .85rem;
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .25s ease, transform .25s ease;
  max-width: 320px;
}

.toast--visible { opacity: 1; transform: translateY(0); }
.toast--success { border-left: 3px solid var(--pass); }
.toast--error   { border-left: 3px solid var(--fail); }
.toast--info    { border-left: 3px solid var(--accent); }

/* ── Agent Panel ──────────────────────────────────────────────────────────── */
.agent-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.agent-panel__icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.agent-panel__text {
  flex: 1;
  min-width: 180px;
}

.agent-panel__title {
  font-size: .875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.agent-panel__desc {
  font-size: .78rem;
  color: var(--text-muted);
}

.agent-panel__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.agent-status {
  font-size: .78rem;
  color: var(--text-muted);
  min-width: 0;
}

.agent-status--running { color: var(--warning); }
.agent-status--done    { color: var(--pass); }
.agent-status--error   { color: var(--fail); }

/* Spinner */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid var(--border-light);
  border-top-color: var(--warning);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
  margin-right: 5px;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-body { flex-direction: column; height: auto; overflow: visible; }

  .sidebar {
    width: 100%;
    max-height: 240px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .main-content { padding: 16px; }

  .audit-header { flex-direction: column; }

  .checklist-toolbar { flex-direction: column; align-items: stretch; }

  .filter-group { justify-content: flex-start; }
}

@media (max-width: 480px) {
  .modal { margin: 12px; }
  .status-buttons { gap: 4px; }
  .status-btn { padding: 4px 10px; font-size: .75rem; }
}
