/* Portal — public app launcher. CSP-safe: no inline styles anywhere. */

:root {
  --bg: #0b0c10;
  --bg-glow-1: rgba(62, 230, 162, 0.10);
  --bg-glow-2: rgba(124, 156, 255, 0.12);
  --surface: rgba(255, 255, 255, 0.035);
  --surface-solid: #13151b;
  --surface-hover: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #eef0f4;
  --text-2: #b9bfca;
  --muted: #8a91a0;
  --accent: #3ee6a2;
  --accent-ink: #04150e;
  --up: #3ee6a2;
  --down: #8a91a0;
  --err: #ff8a8a;
  --err-bg: rgba(255, 110, 110, 0.1);
  --focus: #8eaeff;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 20px 50px -20px rgba(0, 0, 0, 0.6);
  --radius: 18px;
  --font: system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6f8;
    --bg-glow-1: rgba(10, 160, 110, 0.10);
    --bg-glow-2: rgba(80, 110, 230, 0.10);
    --surface: rgba(255, 255, 255, 0.75);
    --surface-solid: #ffffff;
    --surface-hover: #ffffff;
    --line: rgba(15, 25, 40, 0.08);
    --line-strong: rgba(15, 25, 40, 0.16);
    --text: #10151d;
    --text-2: #3a4350;
    --muted: #5f6876;
    --accent: #0a7d55;
    --accent-ink: #ffffff;
    --up: #10a36d;
    --down: #8d95a2;
    --err: #c0303a;
    --err-bg: rgba(200, 50, 60, 0.08);
    --focus: #3561d6;
    --shadow: 0 1px 2px rgba(15, 25, 40, 0.05), 0 18px 40px -22px rgba(15, 25, 40, 0.25);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font: 16px/1.5 var(--font);
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(60vmax 50vmax at 0% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(60vmax 50vmax at 100% 0%, var(--bg-glow-2), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.muted { color: var(--muted); }
.vh { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; left: -9999px; }

/* ---------- boot ---------- */
.boot { position: fixed; inset: 0; display: grid; place-items: center; opacity: 0; transition: opacity 0.3s; }
.boot.show { opacity: 1; }
.spin {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
.spin.sm { width: 16px; height: 16px; border-width: 2px; border-color: color-mix(in srgb, var(--accent-ink) 30%, transparent); border-top-color: var(--accent-ink); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- marks ---------- */
.logo svg, .brand-mark { fill: var(--text); }
.logo svg rect, .brand-mark rect { fill: currentColor; }
.logo { color: var(--text); }
.logo svg .b, .brand-mark .b { opacity: 0.45; }
.logo svg .c, .brand-mark .c { fill: var(--accent); }

/* ---------- login ---------- */
.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
}
.login-card {
  width: 100%;
  max-width: 400px;
  padding: 34px 30px 30px;
  display: flex;
  flex-direction: column;
  animation: rise 0.5s var(--ease) both;
}
.logo {
  width: 56px;
  height: 56px;
  margin-bottom: 24px;
  padding: 11px;
  border-radius: 16px;
  background: radial-gradient(120% 120% at 15% 5%, #1b2a2a, #11141b 55%, #0b0c10);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset, 0 12px 30px -12px rgba(0, 0, 0, 0.6);
  color: #eef0f4;
}
.logo svg { width: 100%; height: 100%; display: block; }
.logo svg .c { fill: #3ee6a2; }
.login-card h1 { margin: 0 0 6px; font-size: 26px; line-height: 1.15; letter-spacing: -0.025em; font-weight: 650; }
.sub { margin: 0 0 26px; color: var(--muted); font-size: 15px; }
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field > span:first-child { font-size: 13px; font-weight: 550; color: var(--text-2); }
.input-wrap { position: relative; display: block; }
input[type="text"], input[type="password"] {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  font: 16px var(--font);
  color: var(--text);
  background: var(--surface-solid);
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
#token { font-family: var(--mono); font-size: 15px; padding-right: 50px; letter-spacing: 0.01em; }
input:focus { border-color: var(--focus); box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 22%, transparent); }
input[aria-invalid="true"] { border-color: var(--err); }
.reveal {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.reveal:hover { color: var(--text); background: var(--surface-hover); }
.reveal svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.reveal[aria-pressed="true"] { color: var(--accent); }
.err {
  margin: 0 0 14px;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--err-bg);
  color: var(--err);
  font-size: 14px;
  animation: shake 0.32s var(--ease);
}
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.go {
  position: relative;
  margin-top: 6px;
  height: 52px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-ink);
  font: 600 16px var(--font);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.1s, filter 0.15s, box-shadow 0.2s;
  box-shadow: 0 10px 30px -12px color-mix(in srgb, var(--accent) 70%, transparent);
}
.go:hover { filter: brightness(1.06); }
.go:active { transform: scale(0.985); }
.go:disabled { cursor: progress; }
.go .arrow { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.2s var(--ease); }
.go:hover .arrow { transform: translateX(3px); }
.go .spin { display: none; }
.go.busy .spin { display: block; }
.go.busy .arrow, .go.busy .go-label { display: none; }

/* ---------- home ---------- */
.home {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 max(20px, env(safe-area-inset-right)) max(40px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: max(18px, env(safe-area-inset-top)) 0 18px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; letter-spacing: -0.01em; min-width: 0; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark { width: 22px; height: 22px; flex: none; color: var(--text); }
.signout {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font: 500 14px var(--font);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.signout:hover { color: var(--text); background: var(--surface); border-color: var(--line); }

.hello { padding: clamp(20px, 6vh, 56px) 0 clamp(22px, 4vh, 34px); animation: rise 0.5s var(--ease) both; }
.when { margin: 0 0 6px; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.summary { margin: 10px 0 0; color: var(--muted); font-size: 15px; min-height: 1.5em; }
.hello h1 { margin: 0; font-size: clamp(30px, 6vw, 46px); line-height: 1.08; letter-spacing: -0.035em; font-weight: 650; }

.tiles {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.tile {
  --c: #7c9cff;
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 168px;
  padding: 18px;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  background:
    radial-gradient(120% 90% at 0% 0%, color-mix(in srgb, var(--c) 15%, transparent), transparent 62%),
    var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow: hidden;
  transition: transform 0.22s var(--ease), border-color 0.22s, background-color 0.22s, box-shadow 0.22s;
  animation: rise 0.5s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 35ms + 60ms);
}
.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 45%, transparent);
  opacity: 0;
  transition: opacity 0.22s;
}
.tile:hover { transform: translateY(-3px); background-color: var(--surface-hover); }
.tile:hover::after { opacity: 1; }
.tile:active { transform: translateY(-1px) scale(0.99); }
.tile:focus-visible { outline-offset: 2px; }
.tile-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; }
.ico {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  font-size: 26px;
  line-height: 1;
  background: color-mix(in srgb, var(--c) 18%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 28%, transparent);
  overflow: hidden;
}
.ico.letter { font-size: 21px; font-weight: 700; color: var(--c); }
.ico img { width: 28px; height: 28px; object-fit: contain; }
.go-arrow { width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: 0.6; transition: transform 0.22s var(--ease), opacity 0.22s, stroke 0.22s; }
.tile:hover .go-arrow { transform: translate(2px, -2px); opacity: 1; stroke: var(--c); }
.name { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.25; }
.desc {
  margin-top: 4px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.state { margin-top: auto; padding-top: 14px; display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); }
.state i { width: 7px; height: 7px; border-radius: 50%; background: var(--up); box-shadow: 0 0 0 3px color-mix(in srgb, var(--up) 18%, transparent); }
.tile.down .state i { background: transparent; box-shadow: inset 0 0 0 1.5px var(--down); }
.tile.down .ico { filter: grayscale(0.7); opacity: 0.75; }

.empty { text-align: center; padding: 48px 20px; border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.empty p { margin: 0 0 4px; }
.home-err { margin-top: 16px; }
.foot { margin-top: 36px; text-align: center; color: var(--muted); font-size: 12.5px; min-height: 1em; }
.noscript { text-align: center; padding: 40px; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------- phones ---------- */
@media (max-width: 560px) {
  .tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tile { min-height: 150px; padding: 14px; border-radius: 16px; }
  .ico { width: 42px; height: 42px; font-size: 23px; border-radius: 12px; }
  .tile-top { margin-bottom: 12px; }
  .name { font-size: 15.5px; }
  .desc { font-size: 13px; }
  .login-card { padding: 28px 22px 24px; border-radius: 22px; }
}
@media (max-width: 340px) {
  .tiles { grid-template-columns: 1fr; }
}

@media (hover: none) {
  .tile:hover { transform: none; }
  .tile:hover::after { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
