:root {
  --bg: #0f172a;
  --panel: #111c33;
  --panel-2: #16233d;
  --text: #eef4ff;
  --muted: #9fb0cc;
  --line: rgba(255,255,255,.11);
  --accent: #6ea8ff;
  --danger: #ff7a7a;
  --warning: #ffd166;
  --ok: #8be28b;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #1f355f, var(--bg) 42%);
  color: var(--text);
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }

.login-body { display: grid; place-items: center; padding: 24px; }
.login-shell { width: min(440px, 100%); }
.login-card, .panel {
  background: rgba(17, 28, 51, .92);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px;
  box-shadow: 0 20px 70px rgba(0,0,0,.35);
}
.brand-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(135deg, #66d9ff, #7c7cff);
  color: #07111f;
  font-size: 30px;
  font-weight: 800;
}
h1, h2, h3, p { margin-top: 0; }
.muted { color: var(--muted); }
.login-form { display: grid; gap: 12px; margin-top: 22px; }
label { color: var(--muted); font-size: 14px; }
input {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #091225;
  color: var(--text);
  font-size: 16px;
}
button, .button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  background: var(--accent);
  color: #06101f;
  font-weight: 800;
  cursor: pointer;
}
.button.secondary { background: rgba(255,255,255,.1); color: var(--text); border: 1px solid var(--line); }
.alert { padding: 12px 14px; border-radius: 12px; margin: 14px 0; border: 1px solid var(--line); }
.alert-error, .alert-danger { background: rgba(255, 122, 122, .14); color: #ffd1d1; }
.alert-success { background: rgba(139, 226, 139, .14); color: #d8ffd8; }
.alert-info, .alert-message { background: rgba(110, 168, 255, .14); color: #dbeaff; }

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 22px min(4vw, 42px);
  border-bottom: 1px solid var(--line);
  background: rgba(8, 14, 28, .55);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { margin-bottom: 4px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.user-pill, .badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 12px;
  background: rgba(255,255,255,.06);
}
.dashboard { padding: 28px min(4vw, 42px) 60px; }
.dashboard.narrow { max-width: 900px; margin: 0 auto; }
.category-section { margin-bottom: 32px; }
.category-section h2 { color: #dfe9ff; margin-bottom: 14px; }
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.app-card {
  display: flex;
  gap: 14px;
  min-height: 150px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.035));
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}
.app-card:hover { transform: translateY(-2px); border-color: rgba(110,168,255,.55); }
.app-card.greyed_out, .app-card.disabled, .app-card.hidden_or_blocked {
  opacity: .48;
  filter: grayscale(.35);
  cursor: not-allowed;
}
.app-card.limited { border-color: rgba(255, 209, 102, .5); }
.app-icon {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  display: grid;
  place-items: center;
  font-size: 34px;
}
.app-icon img {
  width: 56px;
  height: 56px;
  display: block;
  object-fit: contain;
  border-radius: 12px;
}
.app-icon span { line-height: 1; }
.app-info h3 { margin-bottom: 6px; }
.app-info p { color: var(--muted); font-size: 14px; line-height: 1.35; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.badge.state { color: #dce8ff; }
.badge.resource { color: #cbd7ee; }
.badge.missing { color: #ffd1d1; border-color: rgba(255,122,122,.35); }
.flash-wrap { padding: 0 min(4vw, 42px); }
.empty-state { border: 1px dashed var(--line); border-radius: 20px; padding: 28px; color: var(--muted); }
.details-list { display: grid; grid-template-columns: 140px 1fr; gap: 10px 18px; }
dt { color: var(--muted); }
dd { margin: 0; }

@media (max-width: 680px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .top-actions { width: 100%; justify-content: space-between; }
  .app-grid { grid-template-columns: 1fr; }
}

/* Cleanup pass: system status strip + clearer disabled app cards */
.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px min(4vw, 42px) 0;
}
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 11px;
  background: rgba(255,255,255,.055);
  color: var(--muted);
  font-size: 13px;
}
.status-chip.available { border-color: rgba(139,226,139,.25); }
.status-chip.offline { border-color: rgba(255,122,122,.25); }
.status-chip.limited { border-color: rgba(255,209,102,.32); }
.status-light {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(255,122,122,.12);
}
.status-light.ok {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(139,226,139,.12);
}
.status-label { color: var(--text); font-weight: 700; }
.status-state { text-transform: capitalize; }
.app-card.unclickable {
  pointer-events: none;
}
.app-card.greyed_out .missing-note,
.app-card.disabled .missing-note {
  margin: 10px 0 0;
  color: #ffd1d1;
  font-size: 13px;
  line-height: 1.35;
}

/* Icon update: image icons with emoji fallback */
.icon-fallback {
  display: none;
  width: 56px;
  height: 56px;
  place-items: center;
  font-size: 34px;
  line-height: 1;
}
.icon-fallback.visible {
  display: inline-grid;
}

/* Final icon/calendar shell fixes */
.app-icon {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  overflow: visible;
}
.app-icon-img,
.app-icon img {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  object-fit: contain;
}
.icon-fallback { background: transparent !important; }
