:root {
  color-scheme: light dark;
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4d;
  --text: #e7edf5;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at top, #1e293b 0%, var(--bg) 55%);
  color: var(--text);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--border);
}

header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
}

.panel-center {
  text-align: center;
  max-width: 420px;
  margin: 4rem auto;
}

.panel p {
  color: var(--muted);
  line-height: 1.5;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
}

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

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

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

.user-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.app-card {
  position: relative;
  display: block;
  padding: 1.25rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}

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

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

.app-card p {
  margin: 0;
  font-size: 0.85rem;
}

.region-badge {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
}

.error-box {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: #7f1d1d;
  color: #fecaca;
  font-size: 0.9rem;
}

.sso-reset-btn {
  margin-top: 0.85rem;
}

.admin-panel {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.admin-panel.collapsed > :not(h2) {
  display: none;
}

.admin-hint {
  margin-top: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.admin-form {
  display: grid;
  gap: 0.85rem;
  margin: 1rem 0;
}

.admin-form label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.admin-form input {
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
  font-size: 0.95rem;
}

.admin-form-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

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

.admin-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.admin-row-detail {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.admin-row-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

button.danger {
  color: #fecaca;
  border-color: #7f1d1d;
}

.success-box {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: #14532d;
  color: #bbf7d0;
  font-size: 0.9rem;
}

.loading-panel {
  max-width: 420px;
  margin: 4rem auto;
  text-align: center;
}

.loading-brand {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.loading-message {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.loading-step {
  margin: 0.85rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.25rem;
}

.progress-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #60a5fa);
  transition: width 0.45s ease;
}

.progress-fill.indeterminate {
  width: 35%;
  animation: progress-slide 1.4s ease-in-out infinite;
}

@keyframes progress-slide {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(320%);
  }
}

.apps-grid.is-loading {
  min-height: 8rem;
}

.app-card.skeleton {
  pointer-events: none;
  border-color: transparent;
  background: rgba(255, 255, 255, 0.04);
}

.skeleton-line {
  height: 0.85rem;
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.06) 25%,
    rgba(255, 255, 255, 0.12) 50%,
    rgba(255, 255, 255, 0.06) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
}

.skeleton-line.title {
  width: 55%;
  height: 1rem;
  margin-bottom: 0.65rem;
}

.skeleton-line.desc {
  width: 85%;
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}
