:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --border: #e2e8f0;
  --shadow: 0 20px 45px rgba(37, 99, 235, 0.12);
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
}

* {
  box-sizing: border-box;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
}

.hidden {
  display: none !important;
}

.block {
  width: 100%;
}

.primary {
  background: var(--primary);
  color: #fff;
  border-radius: 12px;
  border: none;
  padding: 12px 20px;
  font-weight: 600;
  transition: background 0.2s ease;
}

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

.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 18px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.ghost:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.page {
  min-height: 100vh;
}

/* Landing */

.landing {
  padding: 40px clamp(5vw, 10vw, 160px) 80px;
}

.hero-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 60px;
}

.brand,
.sidebar-logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.hero-nav {
  display: flex;
  gap: 24px;
  color: var(--muted);
  font-weight: 500;
}

.hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 48px;
  align-items: start;
}

.hero-copy h1 {
  font-size: clamp(32px, 4vw, 48px);
  margin-bottom: 16px;
}

.hero-copy p {
  font-size: 18px;
  color: var(--muted);
  margin-bottom: 24px;
  max-width: 540px;
}

.hero-list {
  list-style: none;
  padding: 0;
  margin: 0 0 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hero-list li {
  position: relative;
  padding-left: 28px;
  color: var(--muted);
}

.hero-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
}

.hero-pricing {
  background: rgba(37, 99, 235, 0.08);
  border-radius: 18px;
  padding: 20px 30px;
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
}

.hero-pricing strong {
  font-size: 24px;
  color: var(--primary);
}

.hero-pricing span {
  color: var(--muted);
}

.auth-card {
  background: var(--surface);
  border-radius: 24px;
  padding: 32px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 320px;
}

.auth-card h2 {
  margin: 0;
  font-size: 22px;
}

.auth-toggle {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  background: var(--surface-muted);
  padding: 6px;
  border-radius: 12px;
}

.auth-toggle button {
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  transition: all 0.2s ease;
}

.auth-toggle button.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.15);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

input {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  transition: border 0.2s ease;
}

input:focus {
  border-color: var(--primary);
  outline: none;
}

.hero-stats {
  margin-top: 64px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.stat-card h3 {
  margin: 0 0 12px;
}

.stat-card p {
  margin: 0;
  color: var(--muted);
}

/* Dashboard */

.dashboard {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-label {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.sidebar-subtext {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.project-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}

.project-list li {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  color: var(--muted);
  transition: all 0.2s ease;
}

.project-list li:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.project-list li.active {
  background: rgba(37, 99, 235, 0.12);
  color: var(--primary);
  font-weight: 600;
}

.main-content {
  padding: 40px 56px 64px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}

.main-header h1 {
  margin: 0 0 8px;
  font-size: 28px;
}

.main-header p {
  margin: 0;
  color: var(--muted);
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.tabs {
  display: inline-flex;
  background: var(--surface);
  border-radius: 14px;
  padding: 6px;
  border: 1px solid var(--border);
  gap: 6px;
}

.tab {
  padding: 10px 18px;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font-weight: 500;
  transition: all 0.2s ease;
}

.tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.18);
}

.panel {
  background: var(--surface);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(226, 232, 240, 0.6);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.panel h2 {
  margin: 0;
}

.insights-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.insights-list li {
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--muted);
  line-height: 1.4;
}

.table-wrapper {
  overflow-x: auto;
}

.table-wrapper table {
  width: 100%;
  border-collapse: collapse;
}

.table-wrapper th,
.table-wrapper td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 14px;
}

.table-wrapper th {
  color: var(--muted);
  font-weight: 600;
}

.sync-output {
  background: var(--surface-muted);
  border-radius: 14px;
  padding: 18px;
  margin: 18px 0 0;
  color: var(--muted);
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* Modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(3px);
  z-index: 90;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 99;
}

.modal-card {
  width: min(760px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 24px;
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.2);
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  margin: 0;
}

.modal-header button {
  background: transparent;
  border: none;
  font-size: 20px;
  color: var(--muted);
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.modal-section {
  display: grid;
  gap: 14px;
}

.oauth-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.status-connected {
  background: rgba(34, 197, 94, 0.15);
  color: #047857;
}

.status-disconnected {
  background: rgba(148, 163, 184, 0.2);
  color: var(--muted);
}

.hint {
  margin: -6px 0 0;
  font-size: 13px;
  color: var(--muted);
}

input[readonly] {
  background: rgba(241, 245, 249, 0.6);
  color: var(--muted);
}

.modal-section h3 {
  margin: 0;
  font-size: 16px;
  color: var(--text);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

@media (max-width: 960px) {
  .dashboard {
    grid-template-columns: 1fr;
  }

  .sidebar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    border-right: none;
    padding: 20px;
    overflow-x: auto;
  }

  .sidebar-section {
    min-width: 180px;
  }

  .primary.block {
    max-width: 200px;
  }

  .main-content {
    padding: 28px 20px 48px;
  }
}

@media (max-width: 760px) {
  .hero-header {
    flex-direction: column;
    gap: 16px;
  }

  .hero-nav {
    gap: 16px;
  }

  .hero {
    grid-template-columns: 1fr;
  }

  .main-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .tabs {
    width: 100%;
  }
}
