:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --surface: #ffffff;
  --ink: #171717;
  --muted: #6f6a60;
  --line: #ded8cb;
  --strong-line: #c9c0af;
  --focus: #0f766e;
  --shadow: 0 18px 42px rgba(48, 43, 35, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100svh;
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.08) 0 1px, transparent 1px 100%),
    linear-gradient(180deg, rgba(15, 118, 110, 0.06) 0 1px, transparent 1px 100%),
    var(--bg);
  background-size: 44px 44px;
  color: var(--ink);
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

.shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100svh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
  height: 100svh;
  padding: 28px 22px;
  border-right: 1px solid var(--line);
  background: rgba(247, 245, 239, 0.9);
  backdrop-filter: blur(18px);
}

.brand {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: center;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #171717;
  color: #fffdf7;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 17px;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.category-nav {
  display: grid;
  gap: 7px;
}

.category-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.category-button:hover,
.category-button[data-active="true"] {
  border-color: var(--strong-line);
  background: #fffdf8;
  color: var(--ink);
}

.category-button b {
  min-width: 26px;
  border-radius: 999px;
  background: rgba(23, 23, 23, 0.08);
  padding: 2px 7px;
  font-size: 12px;
  text-align: center;
}

.side-status {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: auto;
}

.side-status span {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.side-status b {
  display: block;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.1;
}

.workspace {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 34px 34px 56px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
}

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

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

h1 {
  font-size: clamp(34px, 5vw, 64px);
  line-height: 0.95;
  letter-spacing: 0;
}

.search {
  position: relative;
  flex: 0 1 380px;
  min-width: 280px;
}

.search input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--strong-line);
  border-radius: 8px;
  padding: 0 16px 0 42px;
  background: #fffdf8;
  color: var(--ink);
  outline: none;
}

.search input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  width: 15px;
  height: 15px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  transform: translateY(-55%);
}

.search-icon::after {
  content: "";
  position: absolute;
  right: -7px;
  bottom: -5px;
  width: 8px;
  height: 2px;
  border-radius: 999px;
  background: var(--muted);
  transform: rotate(45deg);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.access-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 18px;
}

.scope-tabs {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  border: 1px solid var(--strong-line);
  border-radius: 8px;
  padding: 4px;
  background: rgba(255, 253, 248, 0.9);
}

.scope-tab {
  min-width: 104px;
  height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.scope-tab[data-active="true"] {
  background: var(--ink);
  color: #fffdf8;
}

.auth-actions {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.metrics div {
  min-height: 92px;
  padding: 18px;
  background: rgba(255, 253, 248, 0.9);
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metrics strong {
  display: block;
  margin-top: 12px;
  font-size: 30px;
  line-height: 1;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin: 30px 0 14px;
}

.section-head h2 {
  font-size: 22px;
}

.section-head p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
}

.ghost-button {
  min-width: 76px;
  height: 38px;
  border: 1px solid var(--strong-line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  cursor: pointer;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 14px;
}

.app-card {
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 16px;
  min-height: 238px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 1px 0 rgba(23, 23, 23, 0.03);
  opacity: 0;
  transform: translateY(8px);
  animation: card-in 360ms ease forwards;
  animation-delay: var(--delay);
}

.app-card:hover {
  border-color: color-mix(in srgb, var(--accent), var(--strong-line) 46%);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.app-main {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 14px;
}

.app-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent), white 82%);
  color: color-mix(in srgb, var(--accent), black 30%);
  font-size: 13px;
  font-weight: 800;
  overflow: hidden;
}

.app-copy {
  min-width: 0;
}

.app-title-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

h3 {
  min-width: 0;
  font-size: 18px;
  line-height: 1.2;
}

.status {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: rgba(22, 163, 74, 0.1);
  color: #166534;
  font-size: 12px;
  font-weight: 700;
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
}

.status.configured {
  background: rgba(100, 116, 139, 0.12);
  color: #475569;
}

.app-copy p {
  margin-top: 9px;
  color: #48443d;
  font-size: 14px;
  line-height: 1.55;
}

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

.app-meta {
  margin-top: 12px;
}

.app-meta span,
.tag-row span {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  border: 1px solid rgba(23, 23, 23, 0.08);
  border-radius: 999px;
  padding: 0 9px;
  background: rgba(23, 23, 23, 0.035);
  color: var(--muted);
  font-size: 12px;
}

.open-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  height: 42px;
  border-radius: 8px;
  background: var(--ink);
  color: #fffdf8;
  text-decoration: none;
  font-weight: 750;
}

.open-link:hover {
  background: var(--accent);
}

.open-link:focus-visible,
.ghost-button:focus-visible,
.category-button:focus-visible,
.scope-tab:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.25);
  outline-offset: 2px;
}

.empty {
  margin-top: 28px;
  border: 1px dashed var(--strong-line);
  border-radius: 8px;
  padding: 32px;
  background: rgba(255, 253, 248, 0.82);
  color: var(--muted);
  text-align: center;
}

.login-dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--strong-line);
  border-radius: 8px;
  padding: 0;
  background: #fffdf8;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.login-dialog::backdrop {
  background: rgba(23, 23, 23, 0.38);
}

.login-panel {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.login-panel h2 {
  font-size: 22px;
}

.login-panel p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
}

.login-panel label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.login-panel input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--strong-line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.login-panel input:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.form-error {
  color: #b91c1c !important;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.dialog-submit {
  border: 0;
  cursor: pointer;
}

@keyframes card-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 860px) {
  .shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .category-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .category-button {
    flex: 0 0 auto;
    width: auto;
    gap: 10px;
  }

  .side-status {
    display: none;
  }

  .workspace {
    padding: 24px 16px 42px;
  }

  .topbar {
    display: grid;
    align-items: start;
  }

  .search {
    min-width: 0;
    width: 100%;
  }

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

  .access-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .auth-actions {
    justify-content: space-between;
  }

  .metrics div {
    min-height: 76px;
  }

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
