:root {
  color-scheme: dark;
  --bg: #05070b;
  --panel: #12161f;
  --line: #232b37;
  --line2: #3a4453;
  --text: #f3f6fb;
  --muted: #97a1b2;
  --faint: #6c7688;
  --red: #e01b24;
  --red2: #ff3b43;
  --gold: #e3c47f;
  --green: #34d17d;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 10px 34px rgba(0,0,0,.32);
  --shadow-lg: 0 28px 80px rgba(0,0,0,.5);
  --ring: 0 0 0 3px rgba(224,27,36,.32);
  --ease: cubic-bezier(.4, 0, .2, 1);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.011em;
  background: linear-gradient(180deg, #0a0d13, var(--bg));
  color: var(--text);
}
* { scrollbar-width: thin; scrollbar-color: #2c3340 transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: #2c3340; border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: #3b4453; background-clip: padding-box; }
button, input { font: inherit; letter-spacing: inherit; }
button {
  height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, var(--red2), var(--red));
  color: #fff;
  font-weight: 700;
  padding: 0 16px;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255,255,255,.08) inset, 0 6px 16px rgba(224,27,36,.24);
  transition: filter .16s var(--ease), transform .06s var(--ease), background .16s var(--ease), border-color .16s var(--ease);
}
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button.secondary { background: linear-gradient(180deg, #232a35, #1a212b); border: 1px solid #333c49; color: #e9edf4; box-shadow: 0 1px 0 rgba(255,255,255,.04) inset; }
button.secondary:hover { background: linear-gradient(180deg, #2b3340, #212836); border-color: #45505f; filter: none; }
button.ghost { background: transparent; border: 1px solid #363f4d; color: #cfd6e1; box-shadow: none; }
button.ghost:hover { background: rgba(255,255,255,.04); border-color: #4a5568; filter: none; }
button:disabled { opacity: .5; cursor: not-allowed; filter: none; box-shadow: none; transform: none; }
button:focus-visible { outline: none; box-shadow: var(--ring); }
input {
  width: 100%;
  height: 42px;
  border: 1px solid #2b3340;
  border-radius: var(--radius-sm);
  background: #0a0e14;
  color: var(--text);
  outline: none;
  padding: 0 13px;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
input::placeholder { color: var(--faint); }
input:hover { border-color: #3a4453; }
input:focus { border-color: var(--red2); box-shadow: var(--ring); }
label { display: grid; gap: 8px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.hidden { display: none !important; }

.masterLogin {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 460px at 50% -8%, rgba(224,27,36,.2), transparent 60%),
    linear-gradient(180deg, #0a0d13, var(--bg));
}
.loginBox {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(23,29,39,.97), rgba(10,13,18,.98));
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,.03) inset;
  padding: 34px;
}
.loginMark {
  width: 60px;
  height: 60px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -.02em;
  background: linear-gradient(150deg, var(--red2), #96121a);
  box-shadow: 0 14px 34px rgba(224,27,36,.36), 0 0 0 1px rgba(255,255,255,.06) inset;
  margin-bottom: 20px;
}
.loginBox h1 { margin: 0 0 22px; font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.loginGrid { display: grid; gap: 14px; }
.loginActions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.loginActions button { flex: 1 1 auto; }
.message { margin-top: 14px; color: var(--muted); line-height: 1.5; font-size: 13.5px; }
.message:not(:empty) { padding: 11px 13px; border-radius: var(--radius-sm); background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.06); }
.message.error { color: #ffb3b3; background: rgba(224,27,36,.1); border-color: rgba(224,27,36,.32); }

.masterShell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
}
.masterShell.sidebarCollapsed { grid-template-columns: 78px minmax(0, 1fr); }
.masterSidebar {
  height: 100vh;
  position: sticky;
  top: 0;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(11,14,20,.96), rgba(7,9,13,.98));
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.sidebarToggle { width: 100%; }
.brand { display: flex; gap: 12px; align-items: center; padding: 2px 4px 14px; min-width: 0; border-bottom: 1px solid rgba(255,255,255,.05); }
.mark {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  letter-spacing: -.02em;
  background: linear-gradient(150deg, var(--red2), #96121a);
  box-shadow: 0 10px 26px rgba(224,27,36,.32), 0 0 0 1px rgba(255,255,255,.06) inset;
}
.brandCopy { min-width: 0; }
.brandTitle { font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.brandSub { margin-top: 2px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.portalNav { display: grid; gap: 4px; }
.portalButton {
  height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #b9c1cd;
  font-weight: 600;
  text-align: left;
  padding: 0 14px;
  box-shadow: none;
  transition: background .14s var(--ease), color .14s var(--ease), border-color .14s var(--ease);
}
.portalButton:hover { background: rgba(255,255,255,.045); color: #eef1f6; filter: none; }
.portalButton.active {
  background: linear-gradient(90deg, rgba(224,27,36,.18), rgba(224,27,36,.05));
  border-color: rgba(224,27,36,.4);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--red2);
}
.masterFoot {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,.05);
}
.masterMain {
  min-width: 0;
  height: 100vh;
  background: #05070b;
  position: relative;
  overflow: hidden;
  padding: 12px;
}
.portalLoader {
  position: absolute;
  inset: 12px;
  z-index: 2;
  display: grid;
  place-items: center;
  gap: 14px;
  grid-auto-flow: row;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  background: #070a0f;
  border-radius: var(--radius);
}
.portalLoader::before {
  content: "";
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.12);
  border-top-color: var(--red2);
  animation: masterSpin .8s linear infinite;
}
@keyframes masterSpin { to { transform: rotate(360deg); } }
#portalFrame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 0 0 1px var(--line), var(--shadow);
}
.sidebarCollapsed .brandCopy,
.sidebarCollapsed .portalButton span,
.sidebarCollapsed .masterFoot button:not(#logoutBtn) { display: none; }
.sidebarCollapsed .masterSidebar { padding-left: 10px; padding-right: 10px; }
.sidebarCollapsed .portalButton { padding: 0; text-align: center; }
.sidebarCollapsed .portalButton::first-letter { font-size: 0; }
.sidebarCollapsed .portalButton::after {
  content: attr(data-short);
  display: block;
  text-align: center;
}

@media (max-width: 900px) {
  .masterShell, .masterShell.sidebarCollapsed { grid-template-columns: 1fr; }
  .masterSidebar {
    height: auto;
    position: relative;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .portalNav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .portalButton { text-align: center; padding: 0 8px; }
  .masterMain { height: calc(100vh - 210px); }
}
