:root {
  --bg: #04080b;
  --panel: #0a1628;
  --panel-2: #102034;
  --line: rgba(49, 195, 237, 0.16);
  --line-strong: rgba(49, 195, 237, 0.34);
  --text: #e2f0fb;
  --muted: #87a7bd;
  --dim: #4d6a80;
  --cyan: #31c3ed;
  --green: #10b981;
  --red: #ef4444;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "DM Sans", system-ui, sans-serif;
}

a { color: inherit; text-decoration: none; }

.shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line-strong);
  background: rgba(49, 195, 237, 0.11);
  color: var(--cyan);
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 900;
  letter-spacing: 0;
}

.brand strong,
.top h1,
.auth-form h1 {
  font-family: "Barlow Condensed", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0;
}

.brand strong { display: block; font-size: 23px; line-height: 1; }
.brand small { display: block; color: var(--muted); margin-top: 3px; }

.role { color: var(--green) !important; text-transform: uppercase; font-weight: 800; }

.logout,
.auth-form button,
.text-button {
  border: 1px solid var(--line-strong);
  background: rgba(49, 195, 237, 0.12);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.logout:hover,
.auth-form button:hover { border-color: var(--cyan); }

.main {
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  min-height: 58px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(4, 8, 11, 0.92);
  position: relative;
  z-index: 10;
}

.top-brand {
  padding: 0;
  border: 0;
  min-width: 228px;
  flex: 0 0 auto;
}

.top-brand .brand-mark {
  width: 34px;
  height: 34px;
}

.top-brand strong {
  font-size: 24px;
}

.top-brand small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.top-nav a {
  color: var(--muted);
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 800;
  font-size: 13px;
}

.top-nav a:hover,
.top-nav a.active {
  color: var(--text);
  background: rgba(49, 195, 237, 0.08);
  border-color: var(--line);
}

.top-account {
  margin-left: auto;
  position: relative;
  flex: 0 0 auto;
}

.account-trigger {
  max-width: min(310px, 38vw);
  border: 1px solid var(--line);
  background: rgba(10, 22, 40, 0.9);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 11px;
  font: inherit;
  cursor: pointer;
  display: grid;
  justify-items: end;
  gap: 2px;
}

.account-trigger span,
.account-menu span,
.account-menu strong {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-trigger span {
  font-weight: 800;
  font-size: 13px;
}

.account-trigger small {
  color: var(--green);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.account-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(320px, calc(100vw - 24px));
  border: 1px solid var(--line-strong);
  background: #07111f;
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.45);
}

.account-menu.open {
  display: grid;
  gap: 9px;
}

.account-menu strong {
  font-size: 14px;
}

.account-menu span {
  color: var(--muted);
  font-size: 12px;
}

.content {
  min-height: 0;
  flex: 1;
  background: var(--bg);
}

.app-frame {
  display: block;
  width: 100%;
  height: calc(100vh - 58px);
  border: 0;
  background: var(--bg);
}

.locked-view,
.tool-grid {
  max-width: 920px;
  margin: 0 auto;
  padding: 42px 24px;
}

.locked-view h1 {
  margin: 0 0 10px;
  font-size: 30px;
}

.locked-view p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.tool-card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 18px;
}

.tool-card span {
  display: block;
  font-weight: 900;
  margin-bottom: 7px;
}

.tool-card small {
  color: var(--muted);
  line-height: 1.45;
}

.login-page {
  min-height: 100vh;
  background: radial-gradient(circle at top left, rgba(49, 195, 237, 0.12), transparent 38%), var(--bg);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  background: rgba(10, 22, 40, 0.96);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.login-brand {
  padding: 0 0 18px;
  border-bottom: 0;
}

.auth-form {
  display: grid;
  gap: 13px;
}

.auth-form h1 {
  margin: 0;
  font-size: 34px;
}

.auth-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-form input {
  width: 100%;
  border: 1px solid var(--line);
  background: #06111d;
  color: var(--text);
  border-radius: 8px;
  padding: 12px;
  font: inherit;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--cyan);
}

.text-button {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.auth-message {
  min-height: 20px;
  margin: 14px 0 0;
  color: var(--muted);
}

.auth-message[data-tone="error"] { color: var(--red); }
.auth-message[data-tone="success"] { color: var(--green); }

.reset-form,
.magic-form,
.update-form,
body[data-mode="reset"] .login-form,
body[data-mode="magic"] .login-form,
body[data-mode="update"] .login-form {
  display: none;
}

body[data-mode="reset"] .reset-form,
body[data-mode="magic"] .magic-form,
body[data-mode="update"] .update-form {
  display: grid;
}

@media (max-width: 820px) {
  .top {
    flex-wrap: wrap;
    min-height: 110px;
    align-content: center;
    gap: 8px;
  }

  .top-brand {
    min-width: 0;
    flex: 1 1 auto;
  }

  .top-nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
  }

  .account-trigger {
    max-width: 46vw;
  }

  .app-frame {
    height: calc(100vh - 110px);
  }
}
