:root {
  color-scheme: light dark;
  --surface: rgba(15, 23, 42, 0.92);
  --surface-alt: rgba(30, 41, 59, 0.85);
  --bg: linear-gradient(160deg, #0f172a, #1e293b 45%, #111827 100%);
  --text: #e2e8f0;
  --muted: rgba(226, 232, 240, 0.7);
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --border: rgba(148, 163, 184, 0.35);
  --danger: #f87171;
  --success: #4ade80;
  --font: "Inter", "Segoe UI", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: clamp(0.5rem, 2vw, 1.5rem);
}

.app-shell {
  width: min(1120px, 100%);
  display: grid;
  grid-template-areas:
    "header"
    "actions"
    "main"
    "notifications"
    "footer";
  gap: clamp(0.75rem, 2vw, 1.4rem);
}

.app-header {
  grid-area: header;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  padding: clamp(1rem, 2vw, 1.75rem);
  border-radius: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.brand-mark {
  font-size: clamp(2.2rem, 4vw, 3rem);
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.4rem, 3vw, 1.9rem);
}

.tagline {
  margin: 0.2rem 0 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.session-status {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.95rem;
  min-width: 160px;
  align-items: flex-end;
}

.action-strip {
  grid-area: actions;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
}

.action-strip button,
.action-strip a {
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 0.65rem 1.5rem;
  background: rgba(56, 189, 248, 0.14);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

.action-strip button:focus-visible,
.action-strip a:focus-visible,
.action-strip button:hover,
.action-strip a:hover {
  outline: none;
  transform: translateY(-1px);
  background: rgba(56, 189, 248, 0.22);
}

.app-main {
  grid-area: main;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: clamp(1rem, 2vw, 1.5rem);
}

.card {
  background: var(--surface-alt);
  border-radius: 24px;
  padding: clamp(1.5rem, 2.5vw, 2rem);
  border: 1px solid var(--border);
  box-shadow: 0 24px 60px rgba(8, 15, 30, 0.45);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 200px;
}

.card header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

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

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

.profile-overview {
  display: grid;
  gap: 0.6rem;
}

.profile-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.95rem;
}

.profile-row .label {
  color: var(--muted);
}

.profile-row .value {
  font-weight: 500;
}

.card form {
  display: grid;
  gap: 1rem;
}

.feature-list {
  margin: 0;
  padding-left: 1rem;
  color: var(--muted);
  display: grid;
  gap: 0.4rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field label {
  font-size: 0.9rem;
  color: var(--muted);
}

.field input,
.field textarea,
.field select {
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.75);
  color: var(--text);
  padding: 0.75rem 1rem;
  font-size: 1rem;
  resize: vertical;
}

.field input:focus-visible,
.field textarea:focus-visible,
.field select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.sign-in-options {
  justify-content: flex-start;
}

.sign-in-options .button-primary {
  min-width: 220px;
}

.auth-divider {
  margin: 0.5rem 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(148, 163, 184, 0.35);
}

.auth-form {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.auth-form h3 {
  margin: 0;
  font-size: 1rem;
}

.auth-register {
  margin-top: 1rem;
}

.auth-register summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
  list-style: none;
}

.auth-register summary::-webkit-details-marker {
  display: none;
}

.auth-register summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 0.35rem;
  transition: transform 160ms ease;
}

.auth-register[open] summary::before {
  transform: rotate(90deg);
}

.auth-register form {
  margin-top: 0.75rem;
}

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

.warning-text {
  background: rgba(248, 113, 113, 0.15);
  border: 1px solid rgba(248, 113, 113, 0.45);
  color: var(--danger);
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  font-size: 0.95rem;
}

.button-primary,
.button-secondary,
.button-danger {
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.6rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.button-primary {
  background: var(--accent);
  color: #0f172a;
}

.button-primary:hover,
.button-primary:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(56, 189, 248, 0.25);
}

.button-primary.is-disabled,
.button-primary:disabled {
  background: rgba(148, 163, 184, 0.35);
  color: rgba(15, 23, 42, 0.6);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.button-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.button-danger {
  background: var(--danger);
  color: #0f172a;
}

.app-list {
  display: grid;
  gap: 0.75rem;
}

.app-row {
  padding: 1rem;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.7);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.app-row header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.app-row .app-id {
  font-size: 0.8rem;
  color: var(--muted);
}

.app-row .scope-line,
.app-row .app-meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.22);
  font-size: 0.85rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.empty-state {
  border: 1px dashed rgba(148, 163, 184, 0.4);
  border-radius: 18px;
  padding: 1.4rem;
  text-align: center;
  color: var(--muted);
}

.notifications {
  grid-area: notifications;
  min-height: 40px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.85rem 1.2rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(16px);
  font-size: 0.95rem;
  transition: opacity 220ms ease;
}

.toast.fade {
  opacity: 0;
}

.toast.success {
  border-color: rgba(74, 222, 128, 0.35);
  color: var(--success);
}

.toast.error {
  border-color: rgba(248, 113, 113, 0.35);
  color: var(--danger);
}

.app-footer {
  grid-area: footer;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
  padding: 1rem;
}

.app-footer a {
  color: var(--accent);
}

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

.table th,
.table td {
  text-align: left;
  padding: 0.65rem 0.4rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  font-size: 0.9rem;
}

.table th {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.8rem;
}

@media (max-width: 720px) {
  body {
    padding: 0.5rem;
  }

  .app-shell {
    gap: 0.9rem;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .session-status {
    width: 100%;
    align-items: flex-start;
    font-size: 1rem;
  }

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

  .action-strip {
    position: sticky;
    bottom: 0.5rem;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(16px);
    padding: 0.6rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    justify-content: space-around;
    z-index: 10;
  }

  .action-strip button,
  .action-strip a {
    flex: 1;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }
}
