:root {
  --bg: #f6f5fa;
  --surface: #ffffff;
  --text: #1b1f24;
  --text-muted: #5b6472;
  --border: #e5e2ee;

  --brand-700: #431d63;
  --brand-600: #5b2d90;
  --brand-500: #7241ac;
  --brand-400: #8b5cc7;
  --brand-100: #efe8f8;
  --accent-contrast: #ffffff;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(27, 20, 40, 0.06);
  --shadow-md: 0 10px 30px rgba(67, 29, 99, 0.12);

  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Header ---------- */

.site-header {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--brand-700) 0%, var(--brand-600) 55%, var(--brand-500) 100%);
  color: var(--accent-contrast);
  padding: 40px 0 56px;
}

.header-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0.9;
}

.header-bg svg {
  width: 100%;
  height: 100%;
}

.header-row {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logomark {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.15));
}

.site-header h1 {
  margin: 0 0 4px;
  font-size: 1.8rem;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 0;
  opacity: 0.88;
  font-size: 0.95rem;
}

.user-area {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
}

.user-area[hidden] {
  display: none;
}

.text-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: var(--accent-contrast);
  border-radius: 999px;
  padding: 7px 16px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s ease;
}

.text-btn:hover { background: rgba(255, 255, 255, 0.18); }

/* ---------- Login gate ---------- */

.login-gate {
  margin-top: -34px;
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 40px 44px;
  text-align: center;
  max-width: 380px;
  width: 100%;
}

.login-card h2 {
  margin: 0 0 8px;
  font-size: 1.3rem;
}

.login-card p {
  margin: 0 0 20px;
  color: var(--text-muted);
}

.primary-btn {
  background: linear-gradient(135deg, var(--brand-600), var(--brand-500));
  color: var(--accent-contrast);
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 32px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(91, 45, 144, 0.28);
}

.error-text {
  color: #b3261e;
  margin: 16px 0 0;
  font-size: 0.9rem;
}

/* ---------- Tiles ---------- */

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
  margin: 44px 0 48px;
}

.tile-grid[hidden] {
  display: none;
}

.tile {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--tile-color, var(--brand-500));
}

.tile-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-100); /* fallback for browsers without color-mix() */
  background: color-mix(in srgb, var(--tile-color, var(--brand-600)) 14%, white);
  color: var(--tile-color, var(--brand-600));
  margin-bottom: 16px;
}

.tile-icon svg {
  width: 24px;
  height: 24px;
}

.tile-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tile h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.tile-arrow {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: var(--text-muted);
  opacity: 0;
  transform: translate(-2px, 2px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.tile:hover .tile-arrow {
  opacity: 1;
  transform: translate(0, 0);
}

.tile p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 0 44px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.footer-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logomark-small {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  opacity: 0.7;
}

.footer-row p {
  margin: 0;
}

@media (max-width: 560px) {
  .login-card { padding: 32px 24px; }
  .site-header { padding: 32px 0 48px; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1d2025;
    --text: #eef0f2;
    --text-muted: #9aa2ad;
    --border: #2c3038;
    --brand-100: #2a1f38;
  }

  .tile-icon {
    background: color-mix(in srgb, var(--tile-color, var(--brand-500)) 22%, #1d2025);
  }
}
.login-gate[hidden] {
  display: none;
}
