:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #15171a;
  --muted: #667085;
  --border: #d9dee7;
  --primary: #2563eb;
  --primary-contrast: #ffffff;
  --success: #0f766e;
  --warning: #a16207;
  --danger: #b42318;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101216;
  --surface: #181b20;
  --surface-2: #22262d;
  --text: #f2f4f7;
  --muted: #a4acb9;
  --border: #2b3038;
  --primary: #6ea8fe;
  --primary-contrast: #08111f;
  --success: #5eead4;
  --warning: #facc15;
  --danger: #f97066;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

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

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

a {
  color: inherit;
}

.site-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(16px);
}

.brand {
  font-weight: 850;
  text-decoration: none;
}

.nav-actions,
.nav-link,
.button,
.icon-button,
.menu-panel a,
.menu-panel button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.nav-actions {
  gap: 8px;
}

.nav-link,
.button,
.icon-button {
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}

.nav-link,
.button {
  padding: 0 12px;
}

.icon-button {
  width: 36px;
  justify-content: center;
  padding: 0;
}

.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-contrast);
}

.user-menu {
  position: relative;
}

.menu-panel {
  position: absolute;
  top: 42px;
  right: 0;
  display: none;
  width: min(320px, calc(100vw - 32px));
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.user-menu[open] .menu-panel {
  display: grid;
  gap: 6px;
}

.menu-panel small {
  margin-bottom: 6px;
  color: var(--muted);
}

.menu-panel a,
.menu-panel button {
  min-height: 38px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.menu-panel a:hover,
.menu-panel button:hover {
  background: var(--surface-2);
}

.page {
  width: 100%;
  margin: 0 auto;
  padding: 28px 32px 56px;
}

.page.wide {
  width: 100%;
}

.section-head {
  max-width: 1180px;
  margin: 0 auto 14px;
}

.section-head p,
.admin-head p {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

.section-head h1 {
  font-size: clamp(1.55rem, 3vw, 2.35rem);
  line-height: 1.12;
}

.catalog-shell,
.app-admin-list {
  display: grid;
  gap: 12px;
}

.catalog-shell {
  max-width: 1180px;
  margin: 0 auto;
}

.app-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.app-section summary {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 14px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 850;
}

.app-section summary::marker {
  color: var(--muted);
}

.app-section summary b {
  display: inline-grid;
  min-width: 28px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.78rem;
}

.app-grid {
  display: grid;
  gap: 8px;
  padding: 0 10px 10px;
}

.app-card,
.panel,
.app-edit {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.app-card {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  box-shadow: none;
}

.app-card.locked {
  box-shadow: none;
}

.app-icon {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  color: var(--primary);
  background: var(--surface-2);
}

.app-icon.small {
  width: 36px;
  height: 36px;
}

.card-title-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.app-card h2 {
  font-size: 1rem;
}

.app-card p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.app-card small,
td small,
.meta-lines small,
.check-row small {
  display: block;
  color: var(--muted);
  line-height: 1.4;
}

.badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  background: var(--surface-2);
}

.badge svg {
  width: 14px;
  height: 14px;
}

.badge.public {
  color: var(--success);
}

.badge.request {
  color: var(--primary);
}

.badge.hidden {
  color: var(--warning);
}

.badge.private {
  color: var(--danger);
}

.muted {
  color: var(--muted);
}

.notice {
  margin-bottom: 18px;
  padding: 13px 14px;
  border: 1px solid color-mix(in srgb, var(--success) 40%, var(--border));
  border-radius: 8px;
  color: var(--success);
  background: color-mix(in srgb, var(--success) 10%, var(--surface));
}

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

.panel {
  padding: 20px;
}

label span,
legend {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 750;
}

input {
  width: 100%;
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

textarea {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  resize: vertical;
}

.form-actions,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.admin-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 22px;
  align-items: start;
}

.admin-side {
  position: sticky;
  top: 84px;
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.admin-side h1 {
  margin: 4px 6px 12px;
  font-size: 1.15rem;
}

.admin-side a {
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 750;
  text-decoration: none;
}

.admin-side a.active,
.admin-side a:hover {
  background: var(--surface-2);
  color: var(--text);
}

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

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

.search-field {
  display: block;
  margin-bottom: 14px;
}

.user-sections {
  display: grid;
  gap: 12px;
}

.user-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.user-section summary {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 850;
}

.user-section summary b {
  display: inline-grid;
  min-width: 28px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.78rem;
}

.user-section .table-wrap {
  border-inline: 0;
  border-bottom: 0;
  border-radius: 0 0 8px 8px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

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

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

tr:last-child td {
  border-bottom: 0;
}

.modal {
  width: min(720px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.48);
}

.switch {
  display: flex;
  gap: 10px;
  align-items: center;
}

.switch input,
.check-row input {
  width: auto;
  min-height: auto;
}

.switch span {
  margin: 0;
  color: var(--text);
}

.checks {
  display: grid;
  gap: 8px;
}

.check-row {
  display: grid;
  grid-template-columns: auto 36px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.app-edit {
  display: grid;
  grid-template-columns: 56px 1fr 160px;
  gap: 14px;
  align-items: end;
  padding: 16px;
}

.wide-field,
.mode-group,
.meta-lines {
  grid-column: 2 / -1;
}

.mode-group {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 0;
  border: 0;
}

.mode-group label {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.mode-group input {
  width: auto;
  min-height: auto;
}

.mode-group span {
  margin: 0;
  color: var(--text);
}

.meta-lines {
  display: grid;
  gap: 2px;
}

@media (max-width: 760px) {
  .site-nav {
    padding-inline: 16px;
  }

  .nav-link span {
    display: none;
  }

  .app-card,
  .app-edit {
    grid-template-columns: 48px 1fr;
  }

  .card-action,
  .wide-field,
  .mode-group,
  .meta-lines,
  .app-edit .button {
    grid-column: 1 / -1;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .admin-side {
    position: static;
    grid-auto-flow: column;
    overflow-x: auto;
  }

  .admin-side h1 {
    display: none;
  }

  .mode-group {
    grid-template-columns: 1fr;
  }
}
