@import url("https://api.fonts.coollabs.io/css2?family=Manrope:wght@400;500;600;700&display=swap");

:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-soft: #eef2f5;
  --text: #15212a;
  --muted: #5c6b75;
  --accent: #1f8d65;
  --accent-dark: #176b4c;
  --danger: #c34b4b;
  --border: #d7e0e7;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 14px 34px rgba(16, 24, 32, 0.12);
  --content-width: 1120px;
  --page-bg: radial-gradient(circle at 20% 0%, #ffffff 0%, #e6edf2 60%);
  --header-bg: rgba(255, 255, 255, 0.9);
  --nav-hover-bg: rgba(21, 33, 42, 0.06);
  --nav-active-bg: rgba(31, 141, 101, 0.3);
  --nav-active-border: rgba(31, 141, 101, 0.65);
  --panel-border-soft: rgba(21, 33, 42, 0.08);
  --icon-border: rgba(21, 33, 42, 0.12);
  --icon-bg: rgba(21, 33, 42, 0.05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1419;
    --panel: #151c22;
    --panel-soft: #1b242c;
    --text: #f0f4f7;
    --muted: #a3b1bb;
    --accent: #4bd29c;
    --accent-dark: #35b281;
    --danger: #e15d5d;
    --border: #24303a;
    --shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
    --page-bg: radial-gradient(circle at 20% 0%, #1a2530 0%, #0d1419 55%);
    --header-bg: rgba(13, 20, 25, 0.85);
    --nav-hover-bg: rgba(255, 255, 255, 0.05);
    --nav-active-bg: rgba(75, 210, 156, 0.22);
    --nav-active-border: rgba(75, 210, 156, 0.45);
    --panel-border-soft: rgba(255, 255, 255, 0.03);
    --icon-border: rgba(255, 255, 255, 0.08);
    --icon-bg: rgba(255, 255, 255, 0.06);
    color-scheme: dark;
  }
}

html[data-theme="light"] {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-soft: #eef2f5;
  --text: #15212a;
  --muted: #5c6b75;
  --accent: #1f8d65;
  --accent-dark: #176b4c;
  --danger: #c34b4b;
  --border: #d7e0e7;
  --shadow: 0 14px 34px rgba(16, 24, 32, 0.12);
  --page-bg: radial-gradient(circle at 20% 0%, #ffffff 0%, #e6edf2 60%);
  --header-bg: rgba(255, 255, 255, 0.9);
  --nav-hover-bg: rgba(21, 33, 42, 0.06);
  --nav-active-bg: rgba(31, 141, 101, 0.3);
  --nav-active-border: rgba(31, 141, 101, 0.65);
  --panel-border-soft: rgba(21, 33, 42, 0.08);
  --icon-border: rgba(21, 33, 42, 0.12);
  --icon-bg: rgba(21, 33, 42, 0.05);
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0d1419;
  --panel: #151c22;
  --panel-soft: #1b242c;
  --text: #f0f4f7;
  --muted: #a3b1bb;
  --accent: #4bd29c;
  --accent-dark: #35b281;
  --danger: #e15d5d;
  --border: #24303a;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
  --page-bg: radial-gradient(circle at 20% 0%, #1a2530 0%, #0d1419 55%);
  --header-bg: rgba(13, 20, 25, 0.85);
  --nav-hover-bg: rgba(255, 255, 255, 0.05);
  --nav-active-bg: rgba(75, 210, 156, 0.22);
  --nav-active-border: rgba(75, 210, 156, 0.45);
  --panel-border-soft: rgba(255, 255, 255, 0.03);
  --icon-border: rgba(255, 255, 255, 0.08);
  --icon-bg: rgba(255, 255, 255, 0.06);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", "Segoe UI", sans-serif;
  background: var(--page-bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.55;
}

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

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 28px;
  gap: 24px;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  backdrop-filter: blur(8px);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.6px;
  font-size: 1.05rem;
}

.nav-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  flex: 1;
  justify-content: center;
}

.nav-links a {
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.92rem;
}

.nav-links a:hover {
  color: var(--text);
  background: var(--nav-hover-bg);
}

.nav-links a.is-active {
  color: var(--text);
  background: var(--nav-active-bg);
  box-shadow: inset 0 0 0 1px var(--nav-active-border);
}

.user-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.88rem;
  color: var(--muted);
  margin-left: auto;
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-label {
  display: inline-flex;
  align-items: center;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.theme-options {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.theme-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.theme-button svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-button:hover {
  color: var(--text);
  background: var(--nav-hover-bg);
}

.theme-button.is-active {
  color: var(--text);
  background: var(--nav-active-bg);
  border-color: var(--nav-active-border);
}

.theme-button:focus-visible {
  outline: 2px solid var(--nav-active-border);
  outline-offset: 2px;
}

.user-meta span {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content {
  flex: 1;
  padding: clamp(24px, 4vw, 40px);
  max-width: var(--content-width);
  width: 100%;
  margin: 0 auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(20px, 3vw, 28px);
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.panel h1,
.panel h2 {
  margin-top: 0;
  letter-spacing: -0.02em;
}

.panel h1 {
  font-size: clamp(1.8rem, 2.8vw, 2.3rem);
}

.panel h2 {
  font-size: clamp(1.25rem, 2vw, 1.6rem);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--accent);
  color: #04110c;
  font-weight: 600;
  border: none;
  cursor: pointer;
  min-height: 40px;
}

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

.link-button {
  background: transparent;
  border: 1px solid rgba(75, 210, 156, 0.35);
  color: var(--accent);
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
}

.link-button:hover {
  border-color: rgba(75, 210, 156, 0.65);
  color: var(--accent-dark);
  background: rgba(75, 210, 156, 0.12);
}

.link-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.link-button.danger {
  border-color: rgba(195, 75, 75, 0.4);
  color: var(--danger);
}

.link-button.danger:hover {
  border-color: rgba(195, 75, 75, 0.7);
  color: var(--danger);
  background: rgba(195, 75, 75, 0.12);
}

.link-button.danger:focus-visible {
  outline-color: var(--danger);
}

.text-link {
  color: var(--accent);
}

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

.form-grid .primary-button {
  justify-self: start;
}

.form-inline {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: end;
}

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

input,
select {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--text);
  font-family: inherit;
}

input:focus,
select:focus {
  outline: 2px solid rgba(75, 210, 156, 0.5);
  outline-offset: 1px;
}

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

.app-card-form {
  display: block;
}

.app-card {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.2s ease, border-color 0.2s ease;
  min-height: 160px;
}

.app-card-button {
  width: 100%;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.app-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}

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

.app-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--icon-border);
  background: var(--icon-bg);
  object-fit: cover;
}

.app-card h2 {
  margin: 0;
  font-size: 1.1rem;
}

.app-card p {
  color: var(--muted);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

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

.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: var(--panel-soft);
  border: 1px solid var(--panel-border-soft);
}

.list-row > div:first-child {
  flex: 1;
  min-width: 0;
}

.app-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.app-url {
  word-break: break-word;
}

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

.list-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex-shrink: 0;
}

.list-actions form {
  margin: 0;
}

.pill {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.pill-green {
  background: rgba(75, 210, 156, 0.15);
  color: var(--accent);
  border-color: rgba(75, 210, 156, 0.4);
}

.pill-gray {
  background: rgba(154, 167, 177, 0.15);
  color: var(--muted);
  border-color: rgba(154, 167, 177, 0.4);
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

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

.checkbox-item {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--panel-soft);
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--panel-border-soft);
}

.checkbox-item input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.checkbox-item span {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.checkbox-item:has(input:checked) {
  border-color: rgba(75, 210, 156, 0.5);
  box-shadow: inset 0 0 0 1px rgba(75, 210, 156, 0.2);
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.permissions-filter {
  align-items: center;
  gap: 20px;
  margin-bottom: 10px;
}

.permissions-form {
  display: grid;
  gap: 20px;
}

.permissions-form .checkbox-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.permissions-form .primary-button {
  justify-self: end;
  padding: 10px 22px;
}

.site-footer {
  padding: 16px 32px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

@media (max-width: 720px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
  }

  .nav-links {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
  }

  .nav-links::-webkit-scrollbar {
    display: none;
  }

  .user-meta {
    width: 100%;
    justify-content: flex-start;
    gap: 8px 12px;
  }

  .theme-toggle {
    order: 1;
  }

  .user-meta form {
    order: 2;
    margin-left: auto;
  }

  .user-meta span {
    order: 3;
    flex-basis: 100%;
    max-width: none;
  }

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

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

  .list-actions .pill {
    margin-left: auto;
  }

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

  .app-card p {
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .permissions-form .primary-button {
    justify-self: stretch;
  }
}

@media (max-width: 560px) {
  .nav-links {
    gap: 6px;
  }

  .nav-links a {
    font-size: 0.88rem;
    padding: 6px 10px;
  }

  .form-grid .primary-button {
    width: 100%;
  }
}
