:root {
  --accent: #37474f;
  --accent-soft: #eceff1;
  --danger: #c62828;

  --bg: #f5f6f7;
  --surface: #ffffff;
  --border: #e2e5e9;
  --text: #1c1e21;
  --text-muted: #6b7078;

  --radius: 16px;
  --shadow: 0 1px 2px rgb(20 24 30 / 6%), 0 3px 10px rgb(20 24 30 / 5%);

  color-scheme: light;
}

/* Escuro: segue o sistema. */
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #90a4ae;
    --accent-soft: #1f2628;
    --danger: #ef5350;

    --bg: #111214;
    --surface: #1b1d20;
    --border: #2b2e33;
    --text: #e8e9ec;
    --text-muted: #9a9ea6;

    --shadow: 0 1px 2px rgb(0 0 0 / 35%), 0 3px 10px rgb(0 0 0 / 25%);

    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, "Noto Color Emoji", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }
.muted { color: var(--text-muted); }

button { font: inherit; color: inherit; }

/* ── Entrada ─────────────────────────────────────────────────── */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.login__card {
  width: 100%;
  max-width: 380px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 24px;
  box-shadow: var(--shadow);
}

.login__logo,
.topbar__logo {
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
  background: #37474f;
}

.login__logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  font-size: 40px;
  border-radius: 20px;
}

.login__card h1 { margin: 0 0 8px; font-size: 1.5rem; }
.login__card p { margin: 0 0 24px; }
.login__button { display: flex; justify-content: center; min-height: 44px; }

.alert {
  margin: 16px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  text-align: left;
}

.alert--error {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}

/* ── Apps ────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 1.1rem;
}

.topbar__logo {
  width: 32px;
  height: 32px;
  font-size: 18px;
  border-radius: 9px;
}

.topbar__user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex: none;
}

.link-btn {
  flex: none;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  font-size: 0.9rem;
}

.link-btn:hover { background: var(--accent-soft); }

.content {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px calc(32px + env(safe-area-inset-bottom));
}

.greeting { margin: 0 0 20px; font-size: 1.5rem; }

.apps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.app {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 100%;
  padding: 14px 16px;
  color: inherit;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.app:hover,
.app:focus-visible {
  border-color: var(--app-color);
  transform: translateY(-1px);
  outline: none;
}

.app__icon {
  flex: none;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 14px;
  font-size: 28px;
  background: color-mix(in srgb, var(--app-color) 16%, transparent);
}

.app__icon img { width: 100%; height: 100%; object-fit: cover; }

.app__text { display: grid; gap: 2px; min-width: 0; flex: 1; }
.app__name { font-weight: 600; font-size: 1.05rem; }
.app__description { color: var(--text-muted); font-size: 0.9rem; }

.app__chevron { color: var(--text-muted); font-size: 1.6rem; line-height: 1; }

@media (max-width: 420px) {
  .topbar__name { display: none; }
}
