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

:root {
  --bg:          #0f1117;
  --bg-alt:      #13161f;
  --surface:     #1a1f2e;
  --surface-2:   #1e2435;
  --border:      rgba(255, 255, 255, 0.07);
  --border-2:    rgba(255, 255, 255, 0.12);
  --accent:      #2dd4bf;
  --accent-dim:  rgba(45, 212, 191, 0.1);
  --text:        #e2e8f0;
  --text-muted:  #8892a4;
  --text-subtle: #4a5568;
  --nav-h:       58px;
  --radius:      12px;
  --font:        'Inter', system-ui, -apple-system, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* ── Loading ─────────────────────────────────────────────────────── */

#loadingScreen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Login ───────────────────────────────────────────────────────── */

#loginScreen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background-image:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(45, 212, 191, 0.06) 0%, transparent 70%),
    radial-gradient(circle at 1px 1px, rgba(255,255,255,0.03) 1px, transparent 0);
  background-size: 100% 100%, 28px 28px;
}

.login-card {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0;
}

.login-mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--accent-dim);
  border: 1px solid rgba(45, 212, 191, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  line-height: 1;
  margin-bottom: 24px;
  color: var(--accent);
}

.login-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
  margin-bottom: 8px;
}

.login-card p {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 32px;
}

#googleSignIn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 20px;
  background: #fff;
  color: #1a1a1a;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.12s, transform 0.1s, box-shadow 0.12s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

#googleSignIn:hover  { background: #f5f5f5; box-shadow: 0 2px 10px rgba(0,0,0,0.5); }
#googleSignIn:active { transform: scale(0.98); }

/* ── Header ──────────────────────────────────────────────────────── */

#portalScreen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#portalScreen header {
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(15, 17, 23, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.portal-logo {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-subtle);
}

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

#userAvatar {
  border-radius: 50%;
  border: 1.5px solid var(--border-2);
  display: block;
}

#userName {
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#signOutBtn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-subtle);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.76rem;
  font-family: var(--font);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

#signOutBtn:hover { border-color: var(--border-2); color: var(--text-muted); }

/* ── Main ────────────────────────────────────────────────────────── */

#portalScreen main {
  flex: 1;
  padding: 52px 24px 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.portal-greeting {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
  text-align: center;
}

.portal-subtitle {
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-subtle);
  margin-bottom: 48px;
  text-align: center;
}

/* ── App icon grid ───────────────────────────────────────────────── */

.app-grid {
  display: grid;
  grid-template-columns: repeat(4, 80px);
  gap: 36px 28px;
  justify-content: center;
}

/* ── App item ────────────────────────────────────────────────────── */

.app-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.app-icon-wrap {
  position: relative;
  width: 80px;
  height: 80px;
}

.app-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  border-radius: 20px;
  font-size: 2.2rem;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  user-select: none;
}

.app-icon:hover  { transform: scale(1.06); box-shadow: 0 8px 24px rgba(0,0,0,0.6); }
.app-icon:active { transform: scale(0.94); box-shadow: 0 2px 8px rgba(0,0,0,0.4); }

/* ── Info button ─────────────────────────────────────────────────── */

.app-info-btn {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1.5px solid var(--border-2);
  color: var(--text-subtle);
  font-size: 0.6rem;
  font-weight: 700;
  font-family: var(--font);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  letter-spacing: 0;
  line-height: 1;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.app-info-btn:hover,
.app-item.active .app-info-btn {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Tooltip ─────────────────────────────────────────────────────── */

.app-tooltip {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 0.76rem;
  color: var(--text-muted);
  width: 172px;
  text-align: center;
  line-height: 1.5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
  white-space: normal;
  z-index: 20;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.app-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--border-2);
}

.app-item.active .app-tooltip {
  opacity: 1;
  pointer-events: none;
  transform: translateX(-50%) translateY(0);
}

/* ── App label ───────────────────────────────────────────────────── */

.app-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text);
  text-align: center;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}

/* ── No access ───────────────────────────────────────────────────── */

#noAccessMsg {
  text-align: center;
  color: var(--text-muted);
  padding: 80px 16px;
  font-size: 0.9rem;
  line-height: 1.8;
}

/* ── Responsive ──────────────────────────────────────────────────── */

@media (max-width: 520px) {
  .app-grid {
    grid-template-columns: repeat(3, 80px);
    gap: 32px 24px;
  }
}

@media (max-width: 380px) {
  .app-grid {
    grid-template-columns: repeat(3, 72px);
    gap: 28px 16px;
  }
  .app-icon { width: 72px; height: 72px; border-radius: 18px; }
  .app-icon-wrap { width: 72px; height: 72px; }
}

@media (max-width: 480px) {
  #portalScreen header { padding: 0 16px; }
  #portalScreen main   { padding: 40px 16px 56px; }
  #userName            { display: none; }
}
