:root {
  --bg: #f7f8fb;
  --bg-alt: #edf1f7;
  --card: #ffffff;
  --card-muted: #f5f7fb;
  --card-glow: rgba(37, 99, 235, 0.08);
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --secondary: #0f766e;
  --warning: #f59e0b;
  --error: #ef4444;
  --success: #22c55e;
  --text: #0f172a;
  --text-muted: #5b6472;
  --border: rgba(15, 23, 42, 0.12);
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 10px 24px rgba(15, 23, 42, 0.06);
  --font-display: "Geist", "Avenir Next", sans-serif;
  --font-body: "Geist", "Avenir Next", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background: radial-gradient(circle at top, #ffffff 0%, var(--bg) 45%, var(--bg-alt) 100%);
  position: relative;
  overflow-x: hidden;
  line-height: 1.5;
}

body.drawer-open {
  overflow: hidden;
}

body.auth-locked {
  overflow: hidden;
}

body.auth-locked .ambient,
body.auth-locked .app {
  visibility: hidden;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-title {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.auth-input {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 12px;
  padding: 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.auth-input:focus {
  border-color: rgba(37, 99, 235, 0.4);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.auth-error {
  margin: 0;
  color: #b91c1c;
  font-size: 13px;
}

.ambient {
  position: fixed;
  inset: -25% 0 0 0;
  background: radial-gradient(circle at 12% 20%, rgba(37, 99, 235, 0.14), transparent 55%),
    radial-gradient(circle at 85% 10%, rgba(16, 185, 129, 0.12), transparent 45%),
    radial-gradient(circle at 20% 80%, rgba(14, 116, 144, 0.1), transparent 55%);
  z-index: 0;
  pointer-events: none;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  padding: 36px 24px 90px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  animation: fadeInUp 0.7s ease both;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-icon {
  font-size: 24px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.18), rgba(14, 116, 144, 0.12));
  padding: 12px 14px;
  border-radius: 14px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent-strong);
  border: 1px solid rgba(37, 99, 235, 0.2);
}

.brand-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
}

.brand-subtitle {
  color: var(--text-muted);
  font-size: 14px;
}

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

.card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 20px 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.filters {
  position: sticky;
  top: 20px;
  z-index: 5;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.filter-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: none;
  font-weight: 600;
}

.filter-item select,
.filter-item input {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 12px;
  padding: 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.filter-item input::placeholder {
  color: rgba(15, 23, 42, 0.4);
}

.filter-item select:focus,
.filter-item input:focus {
  border-color: rgba(37, 99, 235, 0.4);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, border 0.2s ease;
  background: none;
  text-decoration: none;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.25);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  border: 1px solid rgba(15, 23, 42, 0.12);
  box-shadow: var(--shadow-soft);
}

.btn.danger {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn.small {
  padding: 6px 12px;
  font-size: 12px;
}

.btn.with-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-icon {
  display: inline-flex;
  width: 14px;
  height: 14px;
}

.btn-icon svg {
  width: 100%;
  height: 100%;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.12);
}

.btn.ghost:hover {
  border-color: rgba(37, 99, 235, 0.2);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
}

.section-header h2 {
  font-family: var(--font-display);
  margin: 0;
  font-size: 20px;
}

.section-header.compact {
  margin-bottom: 12px;
}

.section-subtitle {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.section-subtitle.subtitle-meta {
  margin-top: 2px;
  font-size: 12px;
}

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

.badge {
  background: rgba(37, 99, 235, 0.12);
  color: var(--accent);
  border: 1px solid rgba(37, 99, 235, 0.2);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

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

.updates-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.empty-state {
  padding: 18px;
  border-radius: 16px;
  border: 1px dashed rgba(15, 23, 42, 0.2);
  background: rgba(248, 250, 252, 0.9);
  color: var(--text-muted);
  text-align: center;
  box-shadow: var(--shadow-soft);
  animation: rise 0.4s ease both;
}

.empty-state .empty-title {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.empty-state .empty-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.projects-grid .empty-state {
  grid-column: 1 / -1;
}

.update-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(248, 250, 252, 0.9);
  border: 1px solid rgba(15, 23, 42, 0.06);
  box-shadow: var(--shadow-soft);
  animation: rise 0.4s ease both;
}

.update-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(255, 255, 255, 0.95);
}

.update-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.update-card-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.update-card .update-dot {
  margin-top: 0;
}

.update-project {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.update-chip {
  background: rgba(15, 23, 42, 0.06);
  color: var(--text-muted);
  border: 1px solid rgba(15, 23, 42, 0.12);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.update-snippet {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.update-card .update-meta {
  margin-top: 0;
}

.update-card-actions {
  flex-shrink: 0;
}

.update-card-actions .btn {
  white-space: nowrap;
}

.update-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 6px;
}

.update-title {
  font-weight: 600;
}

.update-meta {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 4px;
}

.update-actions a {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
}

.update-actions a:hover,
.details-list a:hover {
  text-decoration: underline;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.projects-footer {
  display: flex;
  justify-content: center;
}

.projects-footer .load-more-btn {
  margin-top: 16px;
  padding: 12px 26px;
  font-size: 14px;
}

.project-card {
  background: #ffffff;
  border-radius: 20px;
  padding: 18px;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  animation: rise 0.5s ease both;
  animation-delay: var(--delay, 0ms);
  box-shadow: var(--shadow-soft);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border 0.2s ease;
}

.project-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, var(--card-glow), transparent 55%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.project-card:hover::after {
  opacity: 1;
}

.project-card:hover {
  transform: translateY(-2px);
  border-color: rgba(37, 99, 235, 0.2);
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.12);
}

.project-card.active {
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.25) inset, 0 16px 32px rgba(15, 23, 42, 0.12);
}

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

.project-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.status-active {
  background: var(--accent);
}

.status-pending {
  background: var(--warning);
}

.status-loss {
  background: var(--error);
}

.status-win {
  background: var(--success);
}

.status-unknown {
  background: rgba(15, 23, 42, 0.25);
}

.card-meta {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text-muted);
}

.card-meta strong {
  color: var(--text);
}

.latest-update-label {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  background: rgba(37, 99, 235, 0.1);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
}

.card-footer {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-muted);
  font-size: 12px;
}

.update-badge {
  background: rgba(16, 185, 129, 0.18);
  color: var(--secondary);
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.card-details {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  display: none;
  gap: 12px;
  flex-direction: column;
}

.card-details.active {
  display: flex;
}

.details-section {
  background: #f8fafc;
  border-radius: 12px;
  padding: 12px;
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.details-section h4 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 14px;
}

.details-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.details-list a {
  color: var(--accent);
  text-decoration: none;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: clamp(320px, 40vw, 560px);
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
  z-index: 25;
  transition: transform 0.35s ease, opacity 0.35s ease;
  display: flex;
}

.drawer.open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.drawer-content {
  background: #ffffff;
  border-left: 1px solid var(--border);
  box-shadow: -24px 0 50px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  width: 100%;
  height: 100%;
}

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

.drawer-kicker {
  margin: 0 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.drawer-header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
}

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

.drawer-meta {
  display: block;
}

.overview-card {
  border-radius: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(248, 250, 252, 0.9);
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 10px;
}

.overview-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  align-items: center;
}

.overview-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
}

.overview-value {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.overview-muted {
  color: var(--text-muted);
  font-weight: 500;
}

.link-button {
  border: none;
  background: none;
  padding: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

.link-button:hover,
.source-action:hover {
  text-decoration: underline;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 24px;
  min-height: 0;
}

.drawer-card {
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.drawer-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(248, 250, 252, 0.9);
}

.drawer-accordion {
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  flex-shrink: 0;
}

.drawer-accordion summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.drawer-accordion summary::-webkit-details-marker {
  display: none;
}

.drawer-accordion summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid rgba(15, 23, 42, 0.45);
  border-bottom: 2px solid rgba(15, 23, 42, 0.45);
  transform: rotate(45deg);
  margin-left: 8px;
  transition: transform 0.2s ease;
}

.drawer-accordion[open] summary {
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(248, 250, 252, 0.9);
}

.drawer-accordion[open] summary::after {
  transform: rotate(225deg);
}

.accordion-meta {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.05);
}

.accordion-body {
  padding: 0 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.accordion-text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

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

.source-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.06);
  background: rgba(248, 250, 252, 0.9);
}

.source-main {
  min-width: 0;
}

.source-domain {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.source-url {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-action {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.drawer-update-item {
  padding: 12px;
}

.drawer-update-content {
  min-width: 0;
}

.update-description {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.backdrop.drawer-backdrop {
  z-index: 15;
  backdrop-filter: blur(2px);
}

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

.modal-content {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  width: min(420px, 90vw);
  box-shadow: var(--shadow);
}

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

.modal-text {
  color: var(--text-muted);
  margin-bottom: 16px;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0.02em;
  font-weight: 600;
  color: var(--text-muted);
}

.modal-field input {
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #ffffff;
  color: var(--text);
  outline: none;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.modal-field input:focus {
  border-color: rgba(37, 99, 235, 0.4);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.field-hint {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0;
  text-transform: none;
}

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

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 10;
}

.hidden {
  display: none;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 14px 24px rgba(15, 23, 42, 0.25);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  z-index: 30;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

  .filter-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .filter-row {
    grid-template-columns: 1fr;
  }

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

  .update-item {
    grid-template-columns: auto 1fr;
  }

  .update-actions {
    grid-column: 1 / -1;
  }

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

  .update-card-actions {
    width: 100%;
  }

  .update-card-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .drawer {
    width: 100%;
  }

  .drawer-content {
    border-left: none;
  }

  .overview-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}
