/* =========================================================
   Modern Social Detroit — SEO Audit Dashboard Styles
   Precision Health Leads Brand Theme
   Light mode default · Dark mode optional
   ========================================================= */

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

/* ── Light Mode (default — Precision Health Leads inspired) ── */
:root, [data-theme="light"] {
  --bg:           #f5f7fb;
  --surface:      #ffffff;
  --surface2:     #eef4f8;
  --border:       #d8e4ee;
  --text:         #102331;
  --text-muted:   #5f7385;
  --accent:       #1ec8e8;
  --accent-gold:  #ff9f43;
  --green:        #16b884;
  --amber:        #e6a817;
  --red:          #ef5350;
  --orange:       #ff8a3d;
  --gray:         #7b8794;
  --radius:       14px;
  --radius-sm:    10px;
  --shadow:       0 4px 20px rgba(10, 38, 64, .07);
  font-family: 'Manrope', system-ui, sans-serif;
}

/* ── Dark Mode (optional — deep PHL navy) ─────────────────── */
[data-theme="dark"] {
  --bg:           #071b2a;
  --surface:      #0d2233;
  --surface2:     #11293d;
  --border:       #1e3c54;
  --text:         #f2fbff;
  --text-muted:   #9ab2c2;
  --accent:       #20c7e8;
  --accent-gold:  #ff9f43;
  --green:        #32d7a1;
  --amber:        #ffb347;
  --red:          #ff6a67;
  --orange:       #ff8a3d;
  --gray:         #7d8d9a;
  --radius:       14px;
  --radius-sm:    10px;
  --shadow:       0 14px 32px rgba(0,0,0,.32);
}

body {
  background: radial-gradient(circle at top right, rgba(30,200,232,.06), transparent 30%),
              var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
  transition: background 0.2s, color 0.2s;
}

/* ── Page Wrapper ── */
.page-wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 48px);
}

/* ── Topbar ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px clamp(16px, 4vw, 48px);
  background: linear-gradient(90deg, #083447 0%, #0a4a63 55%, #0d5d7a 100%);
  border-bottom: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(12px);
  transition: background 0.2s;
}

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #ffb347;
  margin-bottom: 2px;
}

.topbar-title {
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(90deg, #ffffff 0%, #9cecff 45%, #20c7e8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Sync pill ── */
.sync-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  white-space: nowrap;
  color: rgba(255,255,255,.8);
}
.sync-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gray);
  flex-shrink: 0;
}
.sync-live    .sync-dot { background: #32d7a1; box-shadow: 0 0 6px #32d7a1; animation: pulse 2s ease-in-out infinite; }
.sync-loading .sync-dot { background: #ffb347; animation: pulse 0.6s ease-in-out infinite; }
.sync-error   .sync-dot { background: #ef5350; }

@keyframes pulse { 0%,100%{ opacity:1 } 50%{ opacity:.4 } }
@keyframes spin   { to { transform: rotate(360deg); } }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity .15s, transform .1s, box-shadow .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:not(:disabled):hover { opacity: .88; }
.btn:not(:disabled):active { transform: scale(.97); }

.btn-primary   { background: linear-gradient(90deg, #ffb347 0%, #ff8a3d 100%); color: #082130; font-weight: 700; box-shadow: 0 6px 18px rgba(255,159,67,.28); }
.btn-secondary { background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.2); }
.btn-full      { width: 100%; justify-content: center; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  color: rgba(255,255,255,.8);
  cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}
.icon-btn:hover {
  color: #fff;
  background: rgba(30,200,232,.2);
  border-color: rgba(30,200,232,.5);
}

.agency-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(255,179,71,.18);
  border: 1px solid rgba(255,179,71,.4);
  color: #fff5e8;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  transition: background .15s;
}
.agency-pill:hover { background: rgba(255,179,71,.28); }

/* ── Settings drawer buttons override ── */
.drawer .btn-primary   { background: linear-gradient(90deg, #ffb347 0%, #ff8a3d 100%); color: #082130; }
.drawer .btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }

/* ── Stats row ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  padding-top: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  transition: background 0.2s, border-color 0.2s, transform .15s ease, box-shadow .15s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(10,38,64,.11); }

[data-theme="dark"] .stat-card:hover { box-shadow: 0 8px 28px rgba(0,0,0,.38); }

.stat-label  { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); margin-bottom: 6px; }
.stat-value  { font-size: 28px; font-weight: 800; color: var(--text); margin-bottom: 10px; font-variant-numeric: tabular-nums; }
.overdue-val { color: var(--red); }
.priority-val { color: var(--orange); }

.mini-bar-wrap { height: 4px; border-radius: 2px; background: var(--surface2); overflow: hidden; }
.mini-bar      { height: 100%; border-radius: 2px; transition: width .6s cubic-bezier(.4,0,.2,1); }

/* ── Charts row ── */
.charts-row {
  display: grid;
  grid-template-columns: 260px 1fr 1fr;
  gap: 14px;
  padding-top: 14px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: background 0.2s, border-color 0.2s, transform .15s ease;
}
.panel:hover { transform: translateY(-2px); }

.panel-eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* donut */
.donut-wrap { position: relative; width: 160px; height: 160px; margin: 0 auto 14px; }
.donut-legend { display: flex; flex-direction: column; gap: 7px; }
.legend-item  { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.legend-dot   { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

/* section bars */
.section-bar-row   { margin-bottom: 10px; }
.section-bar-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.section-bar-track { height: 5px; border-radius: 3px; background: var(--surface2); overflow: hidden; }
.section-bar-fill  { height: 100%; background: linear-gradient(90deg, var(--accent), #0f9fcb); border-radius: 3px; transition: width .7s cubic-bezier(.4,0,.2,1); }

/* line chart */
.line-wrap { height: 160px; position: relative; }

/* ── Filter bar ── */
.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding-top: 14px;
  flex-wrap: wrap;
}

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

.filter-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}

.filter-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  min-width: 140px;
}
.filter-select:focus, .filter-select:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30,200,232,.12);
}

.filter-result {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  align-self: center;
}

/* ── Table panel ── */
.table-panel {
  margin-top: 14px;
  margin-bottom: 0;
}

.table-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.task-count { font-size: 12px; color: var(--text-muted); font-weight: 600; }

.table-container { overflow-x: auto; }
.tasks-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tasks-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.tasks-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.tasks-table tr:last-child td { border-bottom: none; }
.task-row:hover td { background: color-mix(in srgb, var(--accent) 5%, var(--surface2)); }
.row-expanded td  { background: var(--surface2); }

.expand-cell { width: 36px; }
.expand-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color .15s, background .15s, transform .2s;
}
.expand-btn:hover { color: var(--accent); background: var(--surface2); }
.expand-btn.btn-rotated svg { transform: rotate(180deg); }

.detail-cell {
  background: var(--surface2) !important;
  padding: 10px 16px !important;
  font-size: 12px;
  color: var(--text-muted);
}
.detail-body { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.detail-label { font-weight: 700; color: var(--text-muted); }

.empty-state {
  color: var(--text-muted);
  padding: 40px 24px !important;
  text-align: center;
  line-height: 1.8;
}
.empty-icon { font-size: 32px; margin-bottom: 10px; }
.error-state { color: var(--red); }

/* Status badges */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-done        { background: rgba(22,184,132,.14); color: var(--green); }
.badge-working     { background: rgba(255,179,71,.16);  color: var(--amber); }
.badge-stuck       { background: rgba(239,83,80,.14);   color: var(--red); }
.badge-not-started { background: rgba(123,135,148,.14); color: var(--gray); }

/* Priority badges */
.prio-critical { background: rgba(239,83,80,.18);   color: var(--red);    font-weight: 800; }
.prio-high     { background: rgba(255,138,61,.15);  color: var(--orange); }
.prio-medium   { background: rgba(230,168,23,.14);  color: var(--amber); }
.prio-low      { background: rgba(22,184,132,.13);  color: var(--green); }

.badge-overdue {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  background: rgba(239,83,80,.18);
  color: var(--red);
  margin-left: 6px;
}

.due-overdue { color: var(--red); font-weight: 700; }
.due-soon    { color: var(--amber); font-weight: 600; }

.section-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface2));
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* ── Avatar initials ── */
.avatar-group { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  cursor: default;
  letter-spacing: .02em;
}
.avatar-empty { color: var(--text-muted); font-size: 13px; }

/* ── Settings Drawer ── */
.drawer-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  backdrop-filter: blur(3px);
}
.drawer-overlay.open { display: block; }

.drawer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 201;
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 0;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  max-width: 560px;
  margin: 0 auto;
}
.drawer.open { transform: translateY(0); }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.drawer-header h3 { font-size: 15px; font-weight: 700; }

.drawer .icon-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.drawer .icon-btn:hover { background: var(--border); color: var(--text); border-color: var(--border); }

.drawer-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field span { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.field input, .field select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30,200,232,.12);
}

.drawer-note {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.drawer-note code {
  background: var(--surface2);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .stats-row    { grid-template-columns: repeat(3, 1fr); }
  .charts-row   { grid-template-columns: 1fr 1fr; }
  .donut-panel  { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .stats-row  { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .topbar-title { font-size: 16px; }
  .agency-pill  { display: none; }
}

/* ══════════════════════════════════════════════════════════
   SEO AUDIT REPORT SECTION
   ══════════════════════════════════════════════════════════ */

.audit-section {
  margin-top: 40px;
  padding-top: 32px;
  border-top: 2px solid color-mix(in srgb, var(--accent) 25%, var(--border));
  padding-bottom: 48px;
}

.audit-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.audit-section-header .section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--accent-gold);
  margin-bottom: 4px;
}

.audit-section-header h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}

.audit-section-header p {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 56ch;
}

.audit-report-date {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
  align-self: flex-start;
  margin-top: 4px;
}

/* ── Baseline Snapshot KPIs ── */
.audit-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.audit-kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.audit-kpi:hover { transform: translateY(-2px); }

.audit-kpi-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.audit-kpi-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.audit-kpi-value.kpi-danger  { color: var(--red); }
.audit-kpi-value.kpi-warning { color: var(--amber); }
.audit-kpi-value.kpi-good    { color: var(--green); }
.audit-kpi-value.kpi-accent  { color: var(--accent); }

.audit-kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ── Report Cards ── */
.audit-report-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 768px) {
  .audit-report-cards { grid-template-columns: 1fr; }
  .audit-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

.audit-report-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.audit-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface2));
}

.audit-card-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.audit-card-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.icon-pdf  { background: rgba(239,83,80,.13); }
.icon-html { background: rgba(30,200,232,.14); }

.audit-card-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.audit-card-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

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

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  transition: color .15s, background .15s, border-color .15s;
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.btn-ghost.active { color: var(--accent); border-color: var(--accent); background: rgba(30,200,232,.08); }

.audit-card-viewer {
  display: none;
  flex-direction: column;
  flex: 1;
}
.audit-card-viewer.open { display: flex; }

.audit-viewer-iframe {
  width: 100%;
  border: none;
  background: #fff;
  min-height: 560px;
  flex: 1;
}

/* ── 90-Day Targets Table ── */
.audit-targets-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.audit-targets-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface2));
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
}

.audit-targets-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.audit-targets-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.audit-targets-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.audit-targets-table tr:last-child td { border-bottom: none; }
.audit-targets-table tr:hover td { background: color-mix(in srgb, var(--accent) 4%, var(--surface2)); }

.target-current {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.target-goal {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--green);
}

.target-arrow {
  color: var(--accent);
  font-size: 14px;
  padding: 0 4px;
}
