:root {
  color-scheme: dark;
  --red: #D20035;
  --red-dark: #A4002A;
  --ink: #0D0F12;
  --surface: #171A1F;
  --surface-2: #1D2127;
  --border: rgba(139, 125, 130, .32);
  --muted: #B9B3B5;
  --white: #FFFFFF;
  --radius: 18px;
  font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--white);
  background:
    radial-gradient(circle at 12% 4%, rgba(210, 0, 53, .15), transparent 30rem),
    radial-gradient(circle at 88% 70%, rgba(139, 125, 130, .07), transparent 34rem),
    linear-gradient(145deg, #111318, #0B0D10 58%, #121014);
}

a { color: inherit; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 70px;
  padding: 10px clamp(18px, 4vw, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: rgba(13, 15, 18, .9);
  border-bottom: 1px solid rgba(210, 0, 53, .35);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
  backdrop-filter: blur(16px) saturate(130%);
}

.brand img { display: block; width: 96px; height: auto; }
.top-actions { display: flex; align-items: center; gap: 14px; }
.theme-toggle {
  width: 38px;
  height: 38px;
  padding: 0;
  position: relative;
  display: grid;
  place-items: center;
  color: #D6D1D2;
  background: rgba(29, 33, 39, .82);
  border: 1px solid var(--border);
  border-radius: 11px;
  cursor: pointer;
  transition: color .18s ease, border-color .18s ease, background .18s ease, transform .18s ease;
}
.theme-toggle:hover { color: var(--white); border-color: var(--red); transform: translateY(-1px); }
.theme-icon { position: absolute; line-height: 1; transition: opacity .18s ease, transform .18s ease; }
.theme-icon-sun { opacity: 1; transform: rotate(0) scale(1); }
.theme-icon-moon { opacity: 0; transform: rotate(-25deg) scale(.72); }
[data-theme="light"] .theme-icon-sun { opacity: 0; transform: rotate(25deg) scale(.72); }
[data-theme="light"] .theme-icon-moon { opacity: 1; transform: rotate(0) scale(1); }
.user-name { color: var(--muted); font-size: .9rem; }
.avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--white);
  background: linear-gradient(145deg, var(--red), var(--red-dark));
  font-weight: 750;
  box-shadow: 0 0 0 3px rgba(210, 0, 53, .14);
}
.logout-link {
  padding: 9px 13px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  transition: .18s ease;
}
.logout-link:hover { color: var(--white); border-color: var(--red); }

.page { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 54px 0 80px; }
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 480px);
  align-items: end;
  gap: 36px;
  margin-bottom: 30px;
}
.eyebrow { margin: 0 0 8px; color: #F45A7E; font-size: .72rem; font-weight: 750; letter-spacing: .16em; }
.hero h1 { margin: 0; font-size: clamp(2rem, 4vw, 3.25rem); letter-spacing: -.045em; }
.hero p:not(.eyebrow) { margin: 10px 0 0; color: var(--muted); font-size: 1.05rem; }

.search-box {
  min-height: 52px;
  padding: 0 15px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  background: rgba(29, 33, 39, .94);
  border: 1px solid var(--border);
  border-radius: 15px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .2);
  transition: .18s ease;
}
.search-box:focus-within { border-color: var(--red); box-shadow: 0 0 0 3px rgba(210, 0, 53, .16); }
.search-box > span { color: #D6D1D2; font-size: 1.55rem; transform: rotate(-18deg); }
.search-box input { width: 100%; border: 0; outline: 0; color: var(--white); background: transparent; }
.search-box input::placeholder { color: #AAA3A6; }
kbd { padding: 3px 7px; color: var(--muted); background: #111318; border: 1px solid var(--border); border-radius: 6px; }

.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 50px;
  overflow: hidden;
  background: rgba(23, 26, 31, .68);
  border: 1px solid rgba(139, 125, 130, .2);
  border-radius: 16px;
}
.summary div { padding: 17px 22px; display: flex; align-items: baseline; gap: 10px; }
.summary div + div { border-left: 1px solid rgba(139, 125, 130, .2); }
.summary strong { color: var(--white); font-size: 1.2rem; }
.summary span { color: var(--muted); font-size: .86rem; }

.catalog-section { margin: 0 0 42px; scroll-margin-top: 92px; }
.section-header {
  min-height: 45px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid rgba(139, 125, 130, .24);
}
.section-header > div { display: flex; align-items: center; gap: 10px; }
.section-marker { width: 3px; height: 28px; background: var(--red); border-radius: 3px; box-shadow: 0 0 16px rgba(210, 0, 53, .35); }
.section-header h2 { margin: 0; font-size: 1.02rem; letter-spacing: .055em; text-transform: uppercase; }
.section-header p { margin: 0; color: var(--muted); font-size: .82rem; }
.group-count { min-width: 25px; padding: 3px 7px; text-align: center; color: #E9E5E6; background: #252930; border-radius: 999px; font-size: .72rem; }

.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.app-card {
  position: relative;
  min-width: 0;
  min-height: 174px;
  overflow: hidden;
  background: linear-gradient(145deg, rgba(31, 35, 42, .98), rgba(22, 25, 30, .98));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: inset 0 1px rgba(255, 255, 255, .035), 0 12px 30px rgba(0, 0, 0, .22);
  animation: card-in .34s cubic-bezier(.2, .75, .25, 1) both;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.app-card:hover, .app-card:focus-within {
  transform: translateY(-4px);
  border-color: rgba(210, 0, 53, .78);
  box-shadow: 0 20px 42px rgba(0, 0, 0, .36), 0 0 0 1px rgba(210, 0, 53, .12);
}
.app-link {
  min-height: 174px;
  padding: 21px 38px 21px 18px;
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  align-items: center;
  gap: 13px;
  text-decoration: none;
}
.icon-wrap {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
}
.icon-wrap img { max-width: 100%; max-height: 100%; object-fit: contain; filter: drop-shadow(0 9px 13px rgba(0, 0, 0, .3)); }
.icon-fallback {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  color: var(--white);
  background: linear-gradient(145deg, var(--red), var(--red-dark));
  border-radius: 18px;
  font-weight: 800;
  letter-spacing: -.02em;
}
.app-copy { min-width: 0; display: grid; gap: 7px; }
.app-copy strong {
  max-width: 100%;
  line-height: 1.18;
  font-size: .96rem;
  overflow-wrap: break-word;
  hyphens: auto;
}
.app-copy small { color: var(--muted); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.launch-icon {
  position: absolute;
  right: 18px;
  bottom: 16px;
  color: #8E878A;
  font-size: 1.1rem;
}
.favorite-button {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 34px;
  height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  color: #777176;
  background: rgba(13, 15, 18, .66);
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: .16s ease;
}
.favorite-button:hover { color: var(--white); border-color: rgba(210, 0, 53, .5); }
.favorite-button.is-favorite { color: #FF537B; background: rgba(210, 0, 53, .15); }
.access-count { position: absolute; left: 21px; bottom: 10px; color: #8E878A; font-size: .67rem; }

.status-panel { margin-bottom: 24px; padding: 16px 18px; display: grid; gap: 4px; border-radius: 14px; }
.status-panel.error { color: #FFDCE4; background: rgba(210, 0, 53, .14); border: 1px solid rgba(210, 0, 53, .5); }
.empty-state { padding: 72px 20px; text-align: center; color: var(--muted); }
.empty-state > span { font-size: 3rem; }
.empty-state h2 { margin: 12px 0 6px; color: var(--white); }
.empty-state p { margin: 0; }
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  padding: 12px 16px;
  color: var(--white);
  background: #252930;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, .4);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

.login-shell { min-height: 100vh; padding: 24px; display: grid; place-items: center; }
.login-card {
  width: min(520px, 100%);
  padding: clamp(30px, 6vw, 54px);
  background: rgba(23, 26, 31, .9);
  border: 1px solid var(--border);
  border-top: 3px solid var(--red);
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .4);
}
.login-logo { width: 130px; margin-bottom: 40px; }
.login-card h1 { margin: 0; font-size: clamp(2rem, 7vw, 3rem); line-height: 1.02; letter-spacing: -.045em; }
.login-copy { margin: 18px 0 30px; color: var(--muted); line-height: 1.6; }
.primary-button,
.primary-button:link,
.primary-button:visited,
.primary-button:hover,
.primary-button:focus,
.primary-button:active,
.primary-button span {
  color: #FFFFFF !important;
}
.primary-button { padding: 14px 18px; display: flex; justify-content: space-between; background: var(--red); border-radius: 12px; text-decoration: none; font-weight: 700; }
.primary-button:hover,
.primary-button:focus { background: #E1003A; }
.login-note { margin: 20px 0 0; color: #8E878A; text-align: center; font-size: .77rem; }

/* Tema claro */
[data-theme="light"] {
  color-scheme: light;
  --ink: #231F20;
  --surface: #FFFFFF;
  --surface-2: #F7F4F5;
  --border: rgba(102, 102, 102, .24);
  --muted: #666666;
  --white: #231F20;
}

[data-theme="light"] body {
  color: #231F20;
  background:
    radial-gradient(circle at 10% 3%, rgba(210, 0, 53, .09), transparent 31rem),
    radial-gradient(circle at 90% 68%, rgba(139, 125, 130, .08), transparent 34rem),
    linear-gradient(145deg, #FFFFFF, #FAF8F9 58%, #F5F2F3);
}

[data-theme="dark"] .brand img,
[data-theme="dark"] .login-logo {
  filter: brightness(0) invert(1);
  opacity: .94;
}

[data-theme="light"] .topbar {
  background: rgba(255, 255, 255, .90);
  border-bottom-color: rgba(210, 0, 53, .28);
  box-shadow: 0 8px 26px rgba(35, 31, 32, .09);
}

[data-theme="light"] .theme-toggle {
  color: #4E494B;
  background: #F7F4F5;
}

[data-theme="light"] .theme-toggle:hover,
[data-theme="light"] .logout-link:hover { color: var(--red-dark); }

[data-theme="light"] .search-box {
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 12px 30px rgba(35, 31, 32, .09);
}
[data-theme="light"] .search-box > span { color: #666666; }
[data-theme="light"] .search-box input { color: #231F20; }
[data-theme="light"] .search-box input::placeholder { color: #80777A; }
[data-theme="light"] kbd { color: #666666; background: #F1EDEF; }

[data-theme="light"] .summary {
  background: rgba(255, 255, 255, .76);
  border-color: rgba(102, 102, 102, .18);
  box-shadow: 0 12px 34px rgba(35, 31, 32, .055);
}
[data-theme="light"] .summary div + div { border-color: rgba(102, 102, 102, .16); }
[data-theme="light"] .summary strong,
[data-theme="light"] .empty-state h2 { color: #231F20; }

[data-theme="light"] .section-header { border-bottom-color: rgba(102, 102, 102, .22); }
[data-theme="light"] .group-count { color: #5A5255; background: #EBE6E8; }

[data-theme="light"] .app-card {
  background: linear-gradient(145deg, rgba(255, 255, 255, .99), rgba(247, 244, 245, .99));
  border-color: rgba(102, 102, 102, .23);
  box-shadow: inset 0 1px rgba(255, 255, 255, .8), 0 12px 30px rgba(35, 31, 32, .10);
}
[data-theme="light"] .app-card:hover,
[data-theme="light"] .app-card:focus-within {
  border-color: rgba(210, 0, 53, .70);
  box-shadow: 0 20px 42px rgba(35, 31, 32, .14), 0 0 0 1px rgba(210, 0, 53, .10);
}
[data-theme="light"] .icon-wrap img { filter: drop-shadow(0 8px 11px rgba(35, 31, 32, .16)); }
[data-theme="light"] .favorite-button { color: #7A7174; background: rgba(241, 237, 239, .92); }
[data-theme="light"] .favorite-button:hover { color: var(--red-dark); }
[data-theme="light"] .favorite-button.is-favorite { color: var(--red); background: rgba(210, 0, 53, .10); }
[data-theme="light"] .launch-icon,
[data-theme="light"] .access-count { color: #756C6F; }

[data-theme="light"] .toast {
  color: #231F20;
  background: #FFFFFF;
  box-shadow: 0 16px 36px rgba(35, 31, 32, .18);
}

[data-theme="light"] .login-card {
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 30px 80px rgba(35, 31, 32, .16);
}

@keyframes card-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 760px) {
  .topbar { min-height: 62px; }
  .brand img { width: 82px; }
  .user-name { display: none; }
  .page { width: min(100% - 24px, 1180px); padding-top: 30px; }
  .hero { grid-template-columns: 1fr; gap: 22px; }
  .summary { grid-template-columns: 1fr; }
  .summary div + div { border-left: 0; border-top: 1px solid rgba(139, 125, 130, .2); }
  .section-header p { display: none; }
  .app-grid { grid-template-columns: 1fr; }
  .app-card, .app-link { min-height: 144px; }
  .app-link { padding: 17px 38px 17px 17px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
