/* Autopilot Audit Lab — Autopilot V4 house-style theme.
   Warm beige/off-white app background, left sidebar, white cards, subtle
   borders, compact enterprise-dashboard spacing, dark primary buttons,
   restrained severity colors. No gradients, no marketing chrome. */

:root {
  --bg-app: #f4efe6;
  --bg-sidebar: #efe8db;
  --bg-card: #ffffff;
  --border: #e2dbca;
  --border-soft: #ece5d6;
  --text-primary: #23201a;
  --text-secondary: #6f6656;
  --text-muted: #928872;
  --accent: #262420;
  --accent-hover: #3a362e;
  --accent-contrast: #ffffff;

  --critical: #b3261e;
  --critical-bg: #fbeae8;
  --critical-border: #f0cec9;
  --warning: #96660b;
  --warning-bg: #faf1de;
  --warning-border: #edddb4;
  --passed: #1a7f4b;
  --passed-bg: #e6f4ec;
  --passed-border: #bfe3cf;
  --info: #2f5f8a;
  --info-bg: #eaf1f8;
  --info-border: #c9dcec;

  --radius-sm: 6px;
  --radius-md: 10px;
  --sidebar-width: 208px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
    "PingFang SC", "Microsoft JhengHei", "Microsoft YaHei", Roboto, Arial,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg-app);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: var(--info);
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0 0.35rem;
}

.brand-name {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.brand-tagline {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.nav-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 0.35rem;
  margin-bottom: 0.35rem;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nav-list a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  position: relative;
}

.nav-list a:hover {
  background: rgba(0, 0, 0, 0.05);
}

.nav-list a.active {
  background: var(--bg-card);
  border-left-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.sidebar-footer {
  margin-top: auto;
  font-size: 0.68rem;
  color: var(--text-muted);
  padding: 0 0.35rem;
}

/* Main column */

.main-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-app);
  gap: 1rem;
}

.topbar-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.sidebar-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.55rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.lang-form {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.lang-form label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.lang-form select {
  font-family: var(--font);
  font-size: 0.82rem;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
}

.content {
  flex: 1;
  padding: 1.5rem clamp(24px, 3vw, 32px) 2rem;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

.page-section {
  margin-bottom: 1.6rem;
  scroll-margin-top: 1rem;
}

.section-heading {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 0.9rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
  color: var(--text-primary);
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.3rem;
  margin-bottom: 1.1rem;
}

.card:last-child {
  margin-bottom: 0;
}

.card h2 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 0.85rem;
}

.card-about {
  border-top: 3px solid var(--info);
}

.card-about h2 {
  font-size: 1.02rem;
}

/* Audit form */

.audit-form-row {
  display: flex;
  gap: 0.55rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.field-group {
  flex: 1;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.field-group input[type="text"],
.field-group input[type="url"] {
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fffdf9;
  color: var(--text-primary);
}

.field-group input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn-primary {
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.6rem 1.1rem;
  background: var(--accent);
  color: var(--accent-contrast);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.65;
  cursor: default;
}

.btn-secondary {
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.45rem 0.75rem;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.btn-secondary:hover {
  background: #f6f2ea;
}

.btn-secondary.copied {
  background: var(--passed-bg);
  border-color: var(--passed-border);
  color: var(--passed);
}

/* Error banner */

.error-banner {
  background: var(--critical-bg);
  border: 1px solid var(--critical-border);
  color: var(--critical);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  margin-bottom: 1.1rem;
  font-size: 0.85rem;
}

/* Summary */

.summary-meta {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 0.6rem;
}

.summary-meta a {
  color: var(--text-primary);
  font-weight: 600;
  text-decoration: none;
}

.readiness-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

.readiness-pill {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--passed-bg);
  color: var(--passed);
  border: 1px solid var(--passed-border);
}

.readiness-pill.rd-needs-work,
.readiness-pill.rd-critical {
  background: var(--critical-bg);
  color: var(--critical);
  border-color: var(--critical-border);
}

.readiness-pill.rd-needs-improvement {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: var(--warning-border);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.7rem;
}

.stat-tile {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.8rem;
  background: #fffdf9;
  border-top: 3px solid var(--border);
}

.stat-tile[data-severity] {
  cursor: pointer;
  user-select: none;
  transition: box-shadow 0.12s ease, transform 0.08s ease, background 0.12s ease;
}

.stat-tile[data-severity]:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.stat-tile[data-severity]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.stat-tile[data-severity].active {
  box-shadow: inset 0 0 0 2px currentColor, 0 2px 6px rgba(0, 0, 0, 0.1);
}

.stat-tile.stat-critical.active {
  background: var(--critical-bg);
  color: var(--critical);
}

.stat-tile.stat-warning.active {
  background: var(--warning-bg);
  color: var(--warning);
}

.stat-tile.stat-passed.active {
  background: var(--passed-bg);
  color: var(--passed);
}

.stat-tile.stat-info.active {
  background: var(--info-bg);
  color: var(--info);
}

.stat-tile.active .stat-number,
.stat-tile.active .stat-label {
  color: inherit;
}

.filter-status-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.6rem;
  min-height: 1.6rem;
}

.filter-empty-state {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: #f8f4ec;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.7rem;
}

@keyframes finding-flash {
  0% {
    background: #fdf1cf;
    box-shadow: 0 0 0 2px #e7c876;
  }
  100% {
    background: #fffdf9;
    box-shadow: none;
  }
}

.finding-card.flash-highlight {
  animation: finding-flash 1.6s ease-out;
}

.stat-tile.stat-critical {
  border-top-color: var(--critical);
}

.stat-tile.stat-warning {
  border-top-color: var(--warning);
}

.stat-tile.stat-passed {
  border-top-color: var(--passed);
}

.stat-tile.stat-info {
  border-top-color: var(--info);
}

.stat-number {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.1;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.15rem;
}

.disclaimer-box {
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: #f8f4ec;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  margin-top: 0.9rem;
}

/* Report controls */

.report-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.9rem;
}

/* Category accordions */

.category-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

details.category-card {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  overflow: hidden;
}

details.category-card > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-weight: 600;
  font-size: 0.88rem;
}

details.category-card > summary::-webkit-details-marker {
  display: none;
}

.cat-summary-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.cat-chevron {
  display: inline-block;
  transition: transform 0.15s ease;
  color: var(--text-muted);
  font-size: 0.75rem;
}

details.category-card[open] .cat-chevron {
  transform: rotate(90deg);
}

.cat-pills {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.pill {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  border: 1px solid transparent;
}

.pill-critical {
  background: var(--critical-bg);
  color: var(--critical);
  border-color: var(--critical-border);
}

.pill-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: var(--warning-border);
}

.pill-passed {
  background: var(--passed-bg);
  color: var(--passed);
  border-color: var(--passed-border);
}

.pill-info {
  background: var(--info-bg);
  color: var(--info);
  border-color: var(--info-border);
}

.pill-muted {
  background: #f1ede2;
  color: var(--text-muted);
  border-color: var(--border-soft);
}

.category-body {
  border-top: 1px solid var(--border-soft);
  padding: 0.9rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.category-empty {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.finding-card {
  border: 1px solid var(--border-soft);
  border-left: 4px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  background: #fffdf9;
}

.finding-card.sev-critical {
  border-left-color: var(--critical);
}

.finding-card.sev-warning {
  border-left-color: var(--warning);
}

.finding-card.sev-passed {
  border-left-color: var(--passed);
}

.finding-card.sev-info {
  border-left-color: var(--info);
}

.finding-title-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.finding-title {
  font-size: 0.87rem;
  font-weight: 600;
}

.finding-field {
  margin-bottom: 0.4rem;
  font-size: 0.83rem;
}

.finding-field:last-child {
  margin-bottom: 0;
}

.finding-field-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.1rem;
}

.finding-confidence {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.finding-scope {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--info);
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}

.finding-urls {
  padding-top: 0.15rem;
  border-top: 1px dashed var(--border-soft);
}

.finding-url-link {
  font-size: 0.78rem;
  color: var(--info);
  word-break: break-all;
  text-decoration: none;
}

.finding-url-link:hover {
  text-decoration: underline;
}

/* About */

.about-body {
  font-size: 0.87rem;
  color: var(--text-primary);
  margin-bottom: 0.8rem;
}

.about-list {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.83rem;
  color: var(--text-secondary);
}

.about-list li {
  margin-bottom: 0.35rem;
}

.empty-state {
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 0.5rem 0;
}

footer.app-footer {
  padding: 1.25rem clamp(24px, 3vw, 32px) 2rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
}

/* Responsive
   Desktop  (> 1024px): full-width Autopilot workspace, sidebar in-flow,
             4-column stat grid, wide fluid content up to 1600px.
   Tablet   (641px-1024px): sidebar stays in-flow (not collapsed), cards
             and stat tiles narrow to 2 columns, tighter gutters.
   Mobile   (<= 640px): sidebar collapses behind the menu button as an
             overlay, single-column near-full-width content. */

@media (max-width: 1024px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .content {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  .sidebar {
    width: 176px;
  }
}

@media (max-width: 640px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 0.15s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.12);
  }

  .app-shell.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .app-shell.sidebar-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(20, 18, 12, 0.28);
    z-index: 15;
  }

  .sidebar-toggle {
    display: inline-block;
  }

  .content,
  footer.app-footer {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .audit-form-row {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-primary {
    width: 100%;
  }

  .report-controls {
    flex-direction: column;
  }

  .report-controls .btn-secondary {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .stat-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
}
