/* ───────────────────────────────────────────────
   JPIS Portal
   Deep-indigo institutional minimalism, drawn from
   the eight-point star of the school crest.
   ─────────────────────────────────────────────── */

:root {
  --paper: #f6f3ec;
  --paper-deep: #efeae0;
  --surface: #fffefb;
  --ink: #16142c;
  --ink-soft: #4b4866;
  --ink-faint: #7d7a94;

  --indigo: #2b2489;
  --indigo-deep: #191357;
  --indigo-lift: #4a41c4;
  --gold: #a8792f;
  --teal: #2c6a63;
  --clay: #a2503c;

  --line: rgba(43, 36, 137, 0.13);
  --line-strong: rgba(43, 36, 137, 0.26);

  --radius: 20px;
  --radius-sm: 13px;
  --shadow-sm: 0 1px 2px rgba(25, 19, 87, 0.05), 0 6px 18px -12px rgba(25, 19, 87, 0.22);
  --shadow-lg: 0 24px 60px -34px rgba(25, 19, 87, 0.45), 0 2px 6px rgba(25, 19, 87, 0.05);

  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --ui: "Familjen Grotesk", "Helvetica Neue", Helvetica, sans-serif;

  --ease: cubic-bezier(0.22, 0.68, 0.24, 1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* ── atmosphere ───────────────────────────────── */

.glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(58rem 40rem at 82% -12%, rgba(74, 65, 196, 0.16), transparent 62%),
    radial-gradient(44rem 34rem at 4% 104%, rgba(168, 121, 47, 0.14), transparent 60%);
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.07'/%3E%3C/svg%3E");
}

/* ── view switching ───────────────────────────── */

.shell {
  display: none;
  position: relative;
  z-index: 2;
}

body[data-view="apps"] .shell-apps,
body[data-view="embedded"] .shell-embedded,
body[data-view="dash"] .shell-dash {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body[data-view="login"] .shell-login {
  display: grid;
}

/* ── shared type ──────────────────────────────── */

h1,
h2,
h3 {
  font-family: var(--display);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.08;
  margin: 0;
}

.eyebrow {
  margin: 0 0 0.9rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--indigo);
  opacity: 0.75;
}

em {
  font-style: italic;
  color: var(--indigo);
}

code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.86em;
  padding: 0.12em 0.4em;
  border-radius: 5px;
  background: rgba(43, 36, 137, 0.09);
  color: var(--indigo-deep);
}

:focus-visible {
  outline: 2px solid var(--indigo-lift);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ── top bar ──────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.05rem clamp(1.1rem, 4vw, 3.4rem);
  background: rgba(246, 243, 236, 0.86);
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: blur(14px) saturate(150%);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 3px;
  border-radius: 11px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.brand-words {
  display: grid;
  line-height: 1.15;
}

.brand-words strong {
  font-family: var(--display);
  font-size: 1.06rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.brand-words small {
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.admin-key {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.62rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--indigo);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.28s var(--ease), border-color 0.28s var(--ease), background 0.28s var(--ease);
}

.admin-key svg {
  width: 20px;
  height: 20px;
}

.admin-key-tip {
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: max-width 0.34s var(--ease), padding 0.34s var(--ease);
}

.admin-key:hover,
.admin-key:focus-visible {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: #fff;
}

.admin-key:hover .admin-key-tip,
.admin-key:focus-visible .admin-key-tip {
  max-width: 4rem;
  padding-right: 0.24rem;
}

/* ── launcher (main page) ─────────────────────── */

.launcher {
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(2.4rem, 6vw, 4.6rem) clamp(1.1rem, 4vw, 3.4rem) 3.2rem;
}

.launcher-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
  margin-bottom: clamp(2rem, 4vw, 3.2rem);
}

.launcher-head h1 {
  font-size: clamp(2.3rem, 5.4vw, 3.9rem);
  max-width: 22ch;
}

.search {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 260px;
  padding: 0.72rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.28s var(--ease), box-shadow 0.28s var(--ease);
}

.search:focus-within {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 4px rgba(74, 65, 196, 0.12);
}

.search svg {
  width: 18px;
  height: 18px;
  color: var(--ink-faint);
  flex: none;
}

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  outline: none;
}

.search input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: clamp(0.9rem, 1.6vw, 1.25rem);
}

.app-card,
.app-rows li,
.admin-rows li {
  --accent: var(--indigo);
  --accent-wash: rgba(43, 36, 137, 0.1);
  --accent-wash: color-mix(in srgb, var(--accent) 12%, transparent);
}

.app-card {
  position: relative;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  min-height: 172px;
  padding: 1.25rem 1.3rem 1.15rem;
  text-align: left;
  font: inherit;
  color: inherit;
  background:
    linear-gradient(148deg, color-mix(in srgb, var(--accent) 72%, #171438), color-mix(in srgb, var(--accent) 88%, #2b2489) 62%, color-mix(in srgb, var(--accent) 66%, #655fd4));
  border: 1px solid color-mix(in srgb, var(--accent) 74%, #ffffff 26%);
  border-radius: var(--radius);
  box-shadow: 0 14px 30px color-mix(in srgb, var(--accent) 18%, transparent), inset 0 1px rgba(255, 255, 255, 0.12);
  cursor: pointer;
  overflow: hidden;
  animation: rise 0.6s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 55ms);
  transition: transform 0.34s var(--ease), box-shadow 0.34s var(--ease), border-color 0.34s var(--ease);
}

.app-card::after {
  content: "";
  position: absolute;
  inset: auto -40% -60% auto;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.2), transparent 68%);
  opacity: 0.42;
  transition: opacity 0.4s var(--ease);
  pointer-events: none;
}

.app-card:hover,
.app-card:focus-visible {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--accent) 55%, #ffffff 45%);
  box-shadow: 0 22px 44px color-mix(in srgb, var(--accent) 28%, transparent), inset 0 1px rgba(255, 255, 255, 0.16);
}

.app-card:hover::after,
.app-card:focus-visible::after {
  opacity: 1;
}

.app-card:active {
  transform: translateY(-1px) scale(0.995);
}

.app-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  flex: none;
}

.app-icon svg {
  width: 23px;
  height: 23px;
}

.app-card .app-body {
  display: block;
}

.app-card .app-name {
  display: block;
  font-family: var(--display);
  font-size: 1.18rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: #f8f7ff;
}

.app-card .app-desc {
  display: block;
  margin-top: 0.32rem;
  font-size: 0.88rem;
  color: rgba(245, 243, 255, 0.76);
}

.app-card .meta {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.76rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: rgba(245, 243, 255, 0.68);
}

.app-card .meta i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #e4be74;
  opacity: 1;
}

.app-card .go {
  position: absolute;
  top: 1.3rem;
  right: 1.25rem;
  width: 18px;
  height: 18px;
  color: #fff;
  opacity: 0;
  transform: translateX(-5px);
  transition: opacity 0.32s var(--ease), transform 0.32s var(--ease);
}

.app-card .go svg {
  width: 100%;
  height: 100%;
}

.app-card:hover .go,
.app-card:focus-visible .go {
  opacity: 0.72;
  transform: none;
}

.app-card .card-watermark {
  position: absolute;
  right: -34px;
  bottom: -44px;
  width: 154px;
  height: 154px;
  color: #fff;
  opacity: 0.09;
  transform: rotate(-8deg);
  transition: opacity 0.34s var(--ease), transform 0.34s var(--ease);
  pointer-events: none;
}

.app-card .card-watermark svg {
  width: 100%;
  height: 100%;
  stroke-width: 0.9;
}

.app-card:hover .card-watermark,
.app-card:focus-visible .card-watermark {
  opacity: 0.15;
  transform: rotate(-3deg) scale(1.04);
}

@media (min-width: 760px) {
  .app-card.size-wide,
  .app-card.size-large {
    grid-column: span 2;
  }

  .app-card.size-large {
    min-height: 248px;
    padding: 1.5rem 1.55rem 1.35rem;
  }

  .app-card.size-wide .card-watermark,
  .app-card.size-large .card-watermark {
    right: -46px;
    bottom: -62px;
    width: 220px;
    height: 220px;
  }

  .app-card.size-large .app-icon {
    width: 54px;
    height: 54px;
    border-radius: 16px;
  }

  .app-card.size-large .app-icon svg {
    width: 27px;
    height: 27px;
  }

  .app-card.size-large .app-name {
    font-size: 1.42rem;
  }
}

.empty {
  margin: 3rem auto 0;
  max-width: 30ch;
  text-align: center;
  color: var(--ink-faint);
  font-size: 0.95rem;
}

.foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.4rem clamp(1.1rem, 4vw, 3.4rem);
  border-top: 1px solid var(--line);
  font-size: 0.78rem;
  color: var(--ink-faint);
}

/* ── embedded app workspace ───────────────────── */

body[data-view="embedded"] {
  overflow: hidden;
}

.shell-embedded {
  height: 100vh;
  background: var(--paper-deep);
}

.embedded-topbar {
  position: relative;
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 1rem;
  min-height: 72px;
  padding: 0.75rem clamp(0.85rem, 2.5vw, 1.6rem);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 254, 251, 0.94);
  backdrop-filter: blur(16px) saturate(150%);
  box-shadow: 0 8px 28px -24px rgba(25, 19, 87, 0.65);
}

.embedded-back,
.embedded-external {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  width: fit-content;
  min-height: 42px;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--indigo);
  font: 600 0.82rem/1 var(--ui);
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.24s var(--ease), border-color 0.24s var(--ease), background 0.24s var(--ease);
}

.embedded-back:hover,
.embedded-back:focus-visible,
.embedded-external:hover,
.embedded-external:focus-visible {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: #fff;
}

.embedded-back svg,
.embedded-external svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.embedded-external {
  justify-self: end;
}

.embedded-identity {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  min-width: 0;
}

.embedded-app-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--indigo);
  color: #fff;
  box-shadow: 0 8px 18px -10px rgba(25, 19, 87, 0.8);
}

.embedded-app-icon svg {
  width: 20px;
  height: 20px;
}

.embedded-title-wrap {
  display: grid;
  min-width: 0;
}

.embedded-title-wrap strong,
.embedded-title-wrap small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.embedded-title-wrap strong {
  font-family: var(--display);
  font-size: 1rem;
  line-height: 1.2;
}

.embedded-title-wrap small {
  color: var(--ink-faint);
  font-size: 0.7rem;
}

.embedded-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 0.75rem;
}

.embedded-frame {
  width: 100%;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity 0.35s var(--ease);
}

.embedded-frame.loaded {
  opacity: 1;
}

.embedded-loading {
  position: absolute;
  inset: 0.75rem;
  z-index: 2;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink-soft);
  text-align: center;
}

.embedded-loading[hidden] {
  display: none;
}

.embedded-loading-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 0.6rem;
  border-radius: 17px;
  background: var(--indigo);
  color: #fff;
  animation: embedded-pulse 1.2s ease-in-out infinite alternate;
}

.embedded-loading-mark svg {
  width: 27px;
  height: 27px;
}

.embedded-loading strong {
  font-family: var(--display);
  font-size: 1.15rem;
  color: var(--ink);
}

.embedded-loading small {
  color: var(--ink-faint);
}

@keyframes embedded-pulse {
  from { transform: scale(0.94); opacity: 0.78; }
  to { transform: scale(1); opacity: 1; }
}

/* toast */

.toast {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: 1.6rem;
  transform: translate(-50%, 140%);
  max-width: min(90vw, 27rem);
  padding: 0.72rem 1.05rem;
  border-radius: 999px;
  background: var(--indigo-deep);
  color: #f1efff;
  font-size: 0.86rem;
  box-shadow: var(--shadow-lg);
  transition: transform 0.44s var(--ease), opacity 0.3s var(--ease);
  opacity: 0;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

/* ── login ────────────────────────────────────── */

.shell-login {
  grid-template-columns: 1fr;
  min-height: 100vh;
}

@media (min-width: 900px) {
  .shell-login {
    grid-template-columns: 0.92fr 1.08fr;
  }
}

.login-aside {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: clamp(2rem, 5vw, 3.6rem);
  background: linear-gradient(158deg, var(--indigo-deep), var(--indigo) 58%, #372f9f);
  color: #eeecff;
}

.login-aside .star-motif {
  position: absolute;
  top: -14%;
  right: -26%;
  width: 30rem;
  height: 30rem;
  color: #fff;
  opacity: 0.1;
  pointer-events: none;
  animation: turn 130s linear infinite;
}

.login-aside .star-motif svg {
  width: 100%;
  height: 100%;
}

.login-emblem {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(190px, 24vw, 280px);
  aspect-ratio: 1;
  isolation: isolate;
}

.login-emblem::before,
.login-emblem::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.login-emblem::before {
  inset: 0;
  background: repeating-conic-gradient(
    from 0deg,
    rgba(255, 255, 255, 0.88) 0deg 7deg,
    transparent 7deg 22.5deg
  );
  -webkit-mask: radial-gradient(circle, transparent 0 57%, #000 58% 70%, transparent 71%);
  mask: radial-gradient(circle, transparent 0 57%, #000 58% 70%, transparent 71%);
  filter: drop-shadow(0 12px 24px rgba(9, 5, 48, 0.24));
  animation: turn 24s linear infinite;
}

.login-emblem::after {
  inset: 19%;
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow:
    0 0 0 12px rgba(255, 255, 255, 0.035),
    0 0 48px rgba(255, 255, 255, 0.12);
}

.login-mark {
  position: relative;
  z-index: 1;
  width: 104px;
  height: 104px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 29px;
  background: #fff;
  box-shadow: var(--shadow-lg);
  transform: rotate(-3deg);
}

.login-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.1rem;
  padding: clamp(2.2rem, 5vw, 4rem) clamp(1.2rem, 5vw, 4.4rem);
  animation: rise 0.55s var(--ease) both;
}

.login-panel h2 {
  font-size: clamp(1.85rem, 3.6vw, 2.5rem);
}

.login-lede {
  margin: 0;
  max-width: 44ch;
  color: var(--ink-soft);
}

.ghost-back {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.8rem;
  padding: 0.42rem 0.85rem 0.42rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--indigo);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.26s var(--ease), border-color 0.26s var(--ease);
}

.ghost-back:hover {
  background: var(--surface);
  border-color: var(--line-strong);
}

.ghost-back svg {
  width: 17px;
  height: 17px;
}

.flip {
  transform: scaleX(-1);
}

#email-form,
#code-form {
  display: grid;
  gap: 1rem;
  max-width: 25rem;
  margin-top: 0.8rem;
}

.field {
  display: grid;
  gap: 0.4rem;
}

.field label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.field input {
  width: 100%;
  padding: 0.78rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  color: inherit;
  transition: border-color 0.24s var(--ease), box-shadow 0.24s var(--ease);
}

.field input:focus {
  outline: none;
  border-color: var(--indigo-lift);
  box-shadow: 0 0 0 4px rgba(74, 65, 196, 0.13);
}

.field input[aria-invalid="true"] {
  border-color: var(--clay);
  box-shadow: 0 0 0 4px rgba(162, 80, 60, 0.11);
}

.field small {
  font-size: 0.78rem;
  color: var(--ink-faint);
}

.primary {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.4rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--indigo);
  color: #fff;
  font: inherit;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 12px 26px -16px rgba(25, 19, 87, 0.8);
  transition: transform 0.24s var(--ease), background 0.24s var(--ease);
}

.primary:hover {
  background: var(--indigo-deep);
  transform: translateY(-1px);
}

.primary[aria-busy="true"] {
  pointer-events: none;
  background: var(--indigo-deep);
}

.primary .spinner {
  display: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: turn 0.8s linear infinite;
}

.primary[aria-busy="true"] .spinner {
  display: block;
}

.form-msg {
  margin: 0;
  font-size: 0.86rem;
  padding: 0.6rem 0.85rem;
  border-radius: 11px;
}

.form-msg.error {
  color: #7d3627;
  background: rgba(162, 80, 60, 0.1);
  border: 1px solid rgba(162, 80, 60, 0.22);
}

.form-msg.ok {
  color: #1f5049;
  background: rgba(44, 106, 99, 0.1);
  border: 1px solid rgba(44, 106, 99, 0.22);
}

/* ── dashboard ────────────────────────────────── */

.dash-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.who {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--indigo);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  flex: none;
}

.who-copy {
  display: grid;
  line-height: 1.2;
}

.who-copy strong {
  font-size: 0.88rem;
  font-weight: 600;
}

.who-copy small {
  font-size: 0.74rem;
  color: var(--ink-faint);
}

.quiet {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.83rem;
  cursor: pointer;
  transition: color 0.24s var(--ease), border-color 0.24s var(--ease);
}

.quiet:hover {
  color: var(--indigo);
  border-color: var(--line-strong);
}

.quiet svg {
  width: 16px;
  height: 16px;
}

.dash {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 3.4rem) clamp(1.1rem, 4vw, 3.4rem) 3.6rem;
  display: grid;
  gap: clamp(1.2rem, 2.4vw, 1.8rem);
}

.dash-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.4rem;
  flex-wrap: wrap;
}

.dash-head h1 {
  font-size: clamp(2rem, 4.4vw, 2.9rem);
}

.quiet-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--indigo);
  font-size: 0.87rem;
  font-weight: 500;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.24s var(--ease);
}

.quiet-link:hover {
  border-color: var(--line-strong);
}

.quiet-link svg {
  width: 16px;
  height: 16px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: clamp(0.8rem, 1.6vw, 1.1rem);
}

.stats article {
  padding: 1.15rem 1.3rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  animation: rise 0.55s var(--ease) both;
}

.stats article:nth-child(2) {
  animation-delay: 70ms;
}

.stats article:nth-child(3) {
  animation-delay: 140ms;
}

.stats p {
  margin: 0;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.stats strong {
  display: block;
  margin: 0.5rem 0 0.15rem;
  font-family: var(--display);
  font-size: clamp(2rem, 3.6vw, 2.5rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--indigo-deep);
}

.stats small {
  font-size: 0.81rem;
  color: var(--ink-soft);
}

.card {
  padding: clamp(1.2rem, 2.4vw, 1.7rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  animation: rise 0.6s var(--ease) both;
  animation-delay: 120ms;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.15rem;
}

.card-head h2 {
  font-size: 1.35rem;
  font-weight: 600;
}

.card-head p {
  margin: 0.35rem 0 0;
  max-width: 48ch;
  font-size: 0.87rem;
  color: var(--ink-soft);
}

.count {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(43, 36, 137, 0.05);
  font-size: 0.77rem;
  font-weight: 600;
  color: var(--indigo);
  white-space: nowrap;
}

.app-rows,
.admin-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
}

.app-rows li,
.admin-rows li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.9rem;
  padding: 0.85rem 0;
  border-top: 1px solid var(--line);
}

.app-rows li:first-child,
.admin-rows li:first-child {
  border-top: 0;
}

.row-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--accent-wash);
  color: var(--accent);
  flex: none;
}

.row-icon svg {
  width: 19px;
  height: 19px;
}

.row-copy strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
}

.row-copy span {
  font-size: 0.81rem;
  color: var(--ink-faint);
}

.row-side {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.chip {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 0.24rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}

.chip.on {
  color: #1f5049;
  background: rgba(44, 106, 99, 0.11);
}

.chip.off {
  color: var(--ink-faint);
  background: rgba(22, 20, 44, 0.06);
}

.switch {
  position: relative;
  width: 42px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(22, 20, 44, 0.08);
  cursor: pointer;
  flex: none;
  transition: background 0.3s var(--ease), border-color 0.3s var(--ease);
}

.switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(25, 19, 87, 0.3);
  transition: transform 0.3s var(--ease);
}

.switch[aria-checked="true"] {
  background: var(--indigo);
  border-color: var(--indigo);
}

.switch[aria-checked="true"]::before {
  transform: translateX(18px);
}

.admin-rows .role {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--indigo);
  padding: 0.24rem 0.6rem;
  border-radius: 999px;
  background: rgba(43, 36, 137, 0.08);
  white-space: nowrap;
}

.admin-rows .role.protected {
  color: #76501f;
  background: rgba(168, 121, 47, 0.12);
}

/* ── motion ───────────────────────────────────── */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

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

/* ── responsive ───────────────────────────────── */

@media (max-width: 720px) {
  .embedded-topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    min-height: 64px;
    gap: 0.6rem;
  }

  .embedded-back,
  .embedded-external {
    width: 42px;
    min-height: 42px;
    justify-content: center;
    padding: 0;
  }

  .embedded-back span,
  .embedded-external span,
  .embedded-title-wrap small {
    display: none;
  }

  .embedded-identity {
    justify-content: flex-start;
  }

  .embedded-app-icon {
    width: 34px;
    height: 34px;
  }

  .embedded-stage {
    padding: 0;
  }

  .embedded-frame,
  .embedded-loading {
    border: 0;
    border-radius: 0;
  }

  .embedded-loading {
    inset: 0;
  }

  .launcher-head {
    align-items: stretch;
  }

  .search {
    width: 100%;
  }

  .who-copy {
    display: none;
  }

  .app-rows li,
  .admin-rows li {
    grid-template-columns: auto 1fr;
    row-gap: 0.6rem;
  }

  .row-side {
    grid-column: 1 / -1;
    justify-content: space-between;
  }

  .admin-rows .role,
  .admin-rows .remove {
    grid-column: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── login steps ──────────────────────────────── */

.step {
  display: none;
}

.shell-login[data-step="email"] .step-email,
.shell-login[data-step="code"] .step-code {
  display: block;
  animation: rise 0.45s var(--ease) both;
}

.inline-icon {
  width: 17px;
  height: 17px;
  vertical-align: -3px;
  margin-right: 0.2rem;
  color: var(--indigo);
}

.otp {
  font-family: var(--display);
  font-size: 1.6rem;
  font-weight: 500;
  letter-spacing: 0.42em;
  text-align: center;
  padding-left: 0.42em;
}

.otp::placeholder {
  color: var(--ink-faint);
  opacity: 0.45;
  letter-spacing: 0.42em;
}

.step-links {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 1.2rem 0 0;
  font-size: 0.85rem;
  color: var(--ink-faint);
}

.link {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: var(--indigo);
  cursor: pointer;
  border-bottom: 1px solid var(--line-strong);
}

.link:hover {
  border-color: var(--indigo);
}

/* ── loading ──────────────────────────────────── */

.skeleton {
  min-height: 172px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(100deg, var(--surface) 30%, var(--paper-deep) 50%, var(--surface) 70%);
  background-size: 300% 100%;
  animation: sweep 1.5s var(--ease) infinite;
}

.skeleton:nth-child(2) {
  animation-delay: 0.15s;
}

.skeleton:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes sweep {
  from {
    background-position: 140% 0;
  }
  to {
    background-position: -40% 0;
  }
}

.empty.small {
  margin: 1.2rem 0 0;
  max-width: none;
  text-align: left;
  font-size: 0.88rem;
}

/* ── app form ─────────────────────────────────── */

.app-form {
  display: grid;
  gap: 1rem;
  max-width: 46rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
}

.label-text {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.field-note {
  margin: 0.18rem 0 0;
  font-size: 0.8rem;
  color: var(--ink-faint);
}

.size-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
  padding-top: 0.45rem;
}

.size-option {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 0.65rem;
  min-height: 68px;
  padding: 0.62rem;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  color: var(--ink-soft);
  text-align: left;
  cursor: pointer;
  transition: transform 0.22s var(--ease), border-color 0.22s var(--ease), background 0.22s var(--ease), box-shadow 0.22s var(--ease);
}

.size-option:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.size-option.on {
  border-color: var(--indigo);
  background: rgba(43, 36, 137, 0.06);
  box-shadow: inset 0 0 0 1px var(--indigo);
}

.size-option > span:last-child {
  display: grid;
  min-width: 0;
}

.size-option strong {
  font-size: 0.82rem;
  color: var(--ink);
}

.size-option small {
  overflow: hidden;
  font-size: 0.68rem;
  color: var(--ink-faint);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.size-preview {
  display: grid;
  align-items: end;
  width: 44px;
  height: 34px;
  padding: 5px;
  border-radius: 7px;
  background: linear-gradient(145deg, var(--indigo-deep), var(--indigo-lift));
  box-shadow: 0 5px 10px rgba(25, 19, 87, 0.18);
}

.size-preview i {
  width: 45%;
  height: 3px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.68);
}

.size-preview.wide {
  width: 48px;
  height: 28px;
}

.size-preview.large {
  width: 48px;
  height: 40px;
}

.size-chip {
  padding: 0.25rem 0.52rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-faint);
  font-size: 0.68rem;
  font-weight: 600;
}

@media (max-width: 620px) {
  .size-picker {
    grid-template-columns: 1fr;
  }
}

.optional {
  margin-left: 0.35rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--ink-faint);
}

.picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding-top: 0.15rem;
}

.picker.icons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 0.5rem;
}

.swatch {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 0.22s var(--ease), transform 0.22s var(--ease), background 0.22s var(--ease);
}

.swatch svg {
  width: 19px;
  height: 19px;
}

.swatch:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.icon-swatch.on {
  border-color: var(--indigo);
  background: rgba(43, 36, 137, 0.08);
  color: var(--indigo);
}

.icon-swatch {
  width: auto;
  height: 58px;
  grid-template-columns: 22px 1fr;
  justify-content: start;
  gap: 0.45rem;
  padding: 0 0.6rem;
  color: var(--ink-soft);
}

.icon-swatch span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font: 600 0.7rem/1.1 var(--ui);
  text-align: left;
  white-space: nowrap;
}

.icon-swatch.on {
  box-shadow: inset 0 0 0 1px var(--indigo);
}

.accent-swatch {
  background: var(--accent);
  border-color: transparent;
  box-shadow: inset 0 0 0 2px var(--surface), inset 0 0 0 3px transparent;
}

.accent-swatch.on {
  box-shadow: inset 0 0 0 3px var(--surface), 0 0 0 2px var(--accent);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
  cursor: pointer;
}

.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--indigo);
}

/* ── row tools ────────────────────────────────── */

.row-tools {
  display: inline-flex;
  gap: 0.15rem;
}

.tool {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 9px;
  background: none;
  color: var(--ink-faint);
  cursor: pointer;
  transition: color 0.2s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease);
}

.tool svg {
  width: 17px;
  height: 17px;
  pointer-events: none;
}

.tool:hover:not(:disabled) {
  color: var(--indigo);
  background: rgba(43, 36, 137, 0.07);
  border-color: var(--line);
}

.tool.danger:hover:not(:disabled) {
  color: var(--clay);
  background: rgba(162, 80, 60, 0.09);
  border-color: rgba(162, 80, 60, 0.24);
}

.tool:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.flip-y {
  transform: scaleY(-1);
}

/* ── administrator editor ────────────────────── */

.admin-form {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  align-items: end;
  gap: 0.75rem 1rem;
  margin: 1.25rem 0 0.45rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(43, 36, 137, 0.035);
}

.admin-email-field {
  margin: 0;
}

.admin-form-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.primary.compact {
  width: auto;
  min-width: 160px;
  margin: 0;
  white-space: nowrap;
}

.admin-form-msg {
  grid-column: 1 / -1;
  margin: 0;
}

@media (max-width: 720px) {
  .admin-form {
    grid-template-columns: 1fr;
  }

  .admin-form-actions,
  .primary.compact {
    width: 100%;
  }
}

.mail-state {
  margin: 1.2rem 0 0;
  padding: 0.8rem 1rem;
  border-left: 2px solid var(--gold);
  border-radius: 0 11px 11px 0;
  background: rgba(168, 121, 47, 0.07);
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--ink-soft);
}

.dash-topbar {
  background: rgba(255, 255, 255, 0.9);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
}
