:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #111827;
  --muted: #64748b;
  --line: rgba(15, 23, 42, 0.12);
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --shadow: 0 20px 60px rgba(15, 23, 42, 0.10);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

body.dark {
  --bg: #07111f;
  --card: #0f1b2d;
  --text: #f8fafc;
  --muted: #aab6c8;
  --line: rgba(255, 255, 255, 0.12);
  --primary: #60a5fa;
  --primary-dark: #3b82f6;
  --shadow: 0 22px 80px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hero {
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.24), transparent 36%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(226, 232, 240, 0.55));
  border-bottom: 1px solid var(--line);
}

body.dark .hero {
  background:
    radial-gradient(circle at top left, rgba(96, 165, 250, 0.24), transparent 36%),
    linear-gradient(135deg, rgba(15, 27, 45, 0.95), rgba(2, 6, 23, 0.95));
}

.topbar,
.hero-content,
main,
footer {
  width: min(1180px, calc(100% - 32px));
  margin-inline: auto;
}

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  box-shadow: 0 12px 26px rgba(37, 99, 235, 0.25);
}

.nav-actions,
.hero-buttons,
.form-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.primary-btn,
.ghost-btn,
.icon-btn {
  border: 0;
  border-radius: 999px;
  min-height: 42px;
  padding: 0 18px;
  font-weight: 700;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.primary-btn {
  background: var(--primary);
  color: white;
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.22);
}

.primary-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.ghost-btn {
  color: var(--text);
  background: rgba(148, 163, 184, 0.16);
  border: 1px solid var(--line);
}

.ghost-btn:hover {
  transform: translateY(-1px);
  background: rgba(148, 163, 184, 0.22);
}

.big {
  min-height: 48px;
  padding-inline: 22px;
}

.hero-content {
  padding: 72px 0 48px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 36px;
  align-items: center;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(2.3rem, 6vw, 5.2rem);
  line-height: 0.95;
  letter-spacing: -0.07em;
  margin-bottom: 22px;
  max-width: 850px;
}

.hero-text {
  color: var(--muted);
  max-width: 650px;
  font-size: 1.1rem;
  line-height: 1.7;
  margin-bottom: 28px;
}

.hero-card {
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.62);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  padding: 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  position: relative;
}

body.dark .hero-card {
  background: rgba(15, 27, 45, 0.66);
}

.hero-card::after {
  content: "";
  position: absolute;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.14);
  right: -70px;
  top: -70px;
}

.stat-number {
  font-size: 5rem;
  font-weight: 900;
  letter-spacing: -0.08em;
  z-index: 1;
}

.stat-label {
  color: var(--muted);
  font-weight: 800;
  z-index: 1;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  z-index: 1;
}

.mini-grid span {
  height: 76px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.16), rgba(124, 58, 237, 0.16));
  border: 1px solid var(--line);
}

main {
  padding: 30px 0 72px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 14px;
  margin-bottom: 28px;
}

.search-wrap,
select {
  min-height: 52px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.04);
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
}

.search-wrap span {
  color: var(--muted);
  font-size: 1.25rem;
}

.search-wrap input,
select {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

select {
  padding: 0 16px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-end;
  margin-bottom: 20px;
}

.section-title h2 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  letter-spacing: -0.05em;
}

.danger-link {
  color: var(--danger);
  border: 0;
  background: transparent;
  font-weight: 800;
  padding: 8px;
}

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

.project-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: 0 12px 34px rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
  min-height: 430px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.project-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.card-top {
  display: block;
  text-align: center;
  margin-bottom: 16px;
}

.project-logo {
  width: 100%;
  aspect-ratio: 1 / 1;
  height: auto;
  border-radius: 24px;
  object-fit: contain;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.12), rgba(124, 58, 237, 0.12));
  padding: 14px;
  display: block;
  margin: 0 auto 14px;
}

.default-logo {
  display: grid;
  place-items: center;
  color: white;
  font-weight: 900;
  font-size: clamp(2.4rem, 8vw, 4.2rem);
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  padding: 0;
}

.card-title {
  min-width: 0;
}

.card-title h3 {
  margin: 0 0 8px;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
  font-size: 1.2rem;
  line-height: 1.25;
}

.category-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.11);
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 800;
}

.project-desc {
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 18px;
  flex: 1;
  overflow-wrap: anywhere;
}

.card-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.visit-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: white;
  background: var(--primary);
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  font-weight: 800;
}

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

.small-actions button {
  border: 1px solid var(--line);
  background: rgba(148, 163, 184, 0.12);
  color: var(--text);
  border-radius: 12px;
  min-height: 38px;
  padding: 0 12px;
  font-weight: 800;
}

.small-actions button:last-child {
  color: var(--danger);
}

.empty-state {
  display: none;
  text-align: center;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius-xl);
  padding: 44px 18px;
}

.empty-state.show {
  display: block;
}

.empty-state img {
  width: min(210px, 70%);
  margin-bottom: 16px;
}

.empty-state p {
  color: var(--muted);
}

.project-modal {
  width: min(640px, calc(100% - 24px));
  border: 0;
  border-radius: 28px;
  padding: 0;
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
}

.project-modal::backdrop {
  background: rgba(2, 6, 23, 0.62);
  backdrop-filter: blur(6px);
}

.project-modal form {
  padding: 24px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}

.modal-head h2 {
  margin-bottom: 0;
}

.icon-btn {
  width: 42px;
  padding: 0;
  font-size: 1.6rem;
  background: rgba(148, 163, 184, 0.16);
  color: var(--text);
}

label {
  display: grid;
  gap: 8px;
  font-weight: 800;
  margin-bottom: 14px;
}

label span {
  color: var(--danger);
}

input,
textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--text);
  padding: 13px 14px;
  outline: 0;
}

textarea {
  resize: vertical;
}

small {
  color: var(--muted);
  font-weight: 600;
}

.logo-preview-wrap {
  display: none;
  align-items: center;
  gap: 14px;
  margin: 12px 0 20px;
}

.logo-preview-wrap.show {
  display: flex;
}

.logo-preview {
  width: 86px;
  height: 86px;
  border-radius: 20px;
  object-fit: cover;
  border: 1px solid var(--line);
  background: var(--bg);
}

.form-actions {
  justify-content: flex-end;
  padding-top: 8px;
}

footer {
  color: var(--muted);
  padding-bottom: 24px;
  text-align: center;
}

@media (max-width: 900px) {
  .hero-content,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .hero-card {
    min-height: 230px;
  }

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

@media (max-width: 640px) {
  .hero {
    padding: 16px;
  }

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

  .nav-actions,
  .hero-buttons {
    width: 100%;
  }

  .nav-actions button,
  .hero-buttons button {
    flex: 1;
  }

  .hero-content {
    padding: 48px 0 34px;
  }

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

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

  .card-actions {
    align-items: stretch;
  }

  .visit-link,
  .small-actions {
    width: 100%;
    justify-content: center;
  }
}

[hidden] {
  display: none !important;
}

.cloud-status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 18px 0 0;
  padding: 9px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(148, 163, 184, 0.12);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.cloud-status::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #16a34a;
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.13);
}

.cloud-status[data-state="loading"]::before {
  background: #f59e0b;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.14);
  animation: pulse-dot 1.1s ease-in-out infinite;
}

.cloud-status[data-state="error"] {
  color: var(--danger);
  background: rgba(220, 38, 38, 0.08);
}

.cloud-status[data-state="error"]::before {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.12);
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
  transform: none !important;
}

.project-url {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  margin-bottom: 14px;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}
