/* Levix control room
   One dependency-free stylesheet for the dashboard, sign-in, setup and QR pages.
   The interface stays useful offline and keeps the dark/light preference local. */

:root {
  color-scheme: dark;

  --blue: #176bfa;
  --blue-deep: #0b50d0;
  --blue-bright: #5a94ff;
  --cyan: #21cef3;
  --cyan-soft: #8be8fb;
  --grad: linear-gradient(120deg,
      var(--blue) 0%,
      #087ff2 58%,
      var(--cyan) 115%);

  --bg: #07101f;
  --bg-soft: #0a1629;
  --panel: #0d1a30;
  --panel-raised: #11213b;
  --panel-hover: #142845;
  --line: #223657;
  --line-soft: #192b48;

  --text: #f2f6ff;
  --muted: #a4b5cf;
  --faint: #7086a8;

  --ok: #3bd68b;
  --warn: #f2b84b;
  --danger: #ff6b78;
  --info: var(--blue-bright);

  --radius: 18px;
  --radius-sm: 11px;
  --radius-xs: 8px;
  --shadow: 0 22px 70px rgba(0, 5, 18, 0.3);
  --shadow-soft: 0 12px 34px rgba(0, 5, 18, 0.16);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --body:
    Aptos, "Segoe UI Variable Text", "Segoe UI", "Noto Sans Arabic", Tahoma,
    sans-serif;
  --display:
    ui-rounded, "SF Pro Rounded", "Segoe UI Variable Display", "Avenir Next",
    var(--body);

  /* Gateway tokens */
  --gateway-story-bg:
    linear-gradient(145deg, rgba(10, 33, 72, 0.96), rgba(5, 20, 44, 0.98)),
    #07162f;
  --gateway-story-border: #203a60;
  --gateway-story-grid: rgba(94, 155, 232, 0.075);
  --gateway-story-ring: rgba(60, 179, 255, 0.18);
  --gateway-panel-bg:
    radial-gradient(circle at 95% 4%,
      rgba(23, 107, 250, 0.1),
      transparent 24rem),
    #091222;
  --gateway-card-bg: #0d1a30;
  --gateway-card-border: #243857;
  --gateway-card-shadow: 0 28px 80px rgba(0, 4, 14, 0.34);
  --gateway-input-bg: #091529;
  --gateway-input-border: #263d61;
  --gateway-input-text: #f2f6ff;
  --gateway-ring-border: rgba(72, 192, 255, 0.44);
  --gateway-ring-dot: var(--cyan);
  --gateway-ring-glow: rgba(33, 206, 243, 0.8);
  --gateway-eyebrow: var(--cyan-soft);
  --gateway-auth-eyebrow: #70a3ff;
  --gateway-text-sub: #94a8c4;
  --gateway-link: #70a3ff;
  --gateway-error-text: #ff9ca5;
  --gateway-qr-frame-border: #ffffff;
}

:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f3f7fd;
  --bg-soft: #eef4fc;
  --panel: #ffffff;
  --panel-raised: #ffffff;
  --panel-hover: #edf4ff;
  --line: #cfdced;
  --line-soft: #e3ebf6;

  --text: #10203a;
  --muted: #576b89;
  --faint: #5e7391;
  --blue-bright: #155fdc;
  --shadow: 0 22px 65px rgba(38, 71, 117, 0.13);
  --shadow-soft: 0 10px 30px rgba(38, 71, 117, 0.09);

  /* Gateway tokens */
  --gateway-story-bg:
    linear-gradient(145deg, rgba(230, 240, 255, 0.96), rgba(240, 246, 255, 0.98)),
    #eaf2fd;
  --gateway-story-border: #cfdced;
  --gateway-story-grid: rgba(23, 107, 250, 0.07);
  --gateway-story-ring: rgba(23, 107, 250, 0.16);
  --gateway-panel-bg:
    radial-gradient(circle at 95% 4%,
      rgba(23, 107, 250, 0.06),
      transparent 24rem),
    #f3f7fd;
  --gateway-card-bg: #ffffff;
  --gateway-card-border: #cfdced;
  --gateway-card-shadow: 0 22px 65px rgba(38, 71, 117, 0.13);
  --gateway-input-bg: #ffffff;
  --gateway-input-border: #cfdced;
  --gateway-input-text: #10203a;
  --gateway-ring-border: rgba(23, 107, 250, 0.35);
  --gateway-ring-dot: var(--blue);
  --gateway-ring-glow: rgba(23, 107, 250, 0.4);
  --gateway-eyebrow: var(--blue-bright);
  --gateway-auth-eyebrow: var(--blue-bright);
  --gateway-text-sub: var(--muted);
  --gateway-link: var(--blue-bright);
  --gateway-error-text: #c0262d;
  --gateway-qr-frame-border: #cfdced;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
}

html {
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
input,
select,
textarea,
summary {
  -webkit-tap-highlight-color: transparent;
}

::selection {
  background: color-mix(in srgb, var(--cyan) 28%, transparent);
  color: var(--text);
}

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

a {
  color: var(--blue-bright);
  text-decoration: none;
}

svg {
  display: block;
}

code,
kbd {
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: color-mix(in srgb, var(--blue) 8%, var(--bg-soft));
  color: color-mix(in srgb, var(--text) 92%, var(--cyan));
  font-family: var(--mono);
  font-size: 0.84em;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* --- dashboard shell --------------------------------------------------- */

.dashboard-page {
  min-width: 320px;
  background:
    radial-gradient(circle at 78% 0%,
      color-mix(in srgb, var(--blue) 9%, transparent),
      transparent 32rem),
    var(--bg);
}

.dashboard-page::before {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  content: "";
  opacity: 0.26;
  background-image: radial-gradient(circle,
      color-mix(in srgb, var(--faint) 24%, transparent) 0.75px,
      transparent 0.85px);
  background-size: 22px 22px;
  mask-image: linear-gradient(to bottom, black, transparent 72%);
}

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid #203555;
  background:
    radial-gradient(circle at 15% 6%,
      rgba(25, 118, 255, 0.2),
      transparent 17rem),
    linear-gradient(180deg, #08152b 0%, #071226 100%);
  color: #f4f7ff;
  scrollbar-width: thin;
  scrollbar-color: #294362 transparent;
}

.brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 86px;
  margin: 0 14px;
  padding: 18px 10px;
  border-bottom: 1px solid rgba(151, 180, 220, 0.16);
  color: #f4f7ff;
}

.brand img {
  width: 43px;
  height: 43px;
  flex: none;
  filter: drop-shadow(0 8px 16px rgba(0, 102, 245, 0.24));
}

.brand-copy {
  min-width: 0;
}

.brand-name {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 760;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.brand-tag {
  margin-top: 4px;
  color: #7891b4;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1;
  text-transform: uppercase;
}

.brand-pulse {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 15px;
  margin-left: auto;
}

.brand-pulse i {
  display: block;
  width: 2px;
  height: 5px;
  border-radius: 999px;
  background: var(--cyan);
  box-shadow: 0 0 10px rgba(33, 206, 243, 0.65);
  animation: pulse-bars 1.5s ease-in-out infinite;
}

.brand-pulse i:nth-child(2) {
  height: 12px;
  animation-delay: 0.18s;
}

.brand-pulse i:nth-child(3) {
  height: 8px;
  animation-delay: 0.36s;
}

@keyframes pulse-bars {

  0%,
  100% {
    opacity: 0.4;
    transform: scaleY(0.65);
  }

  50% {
    opacity: 1;
    transform: scaleY(1);
  }
}

.nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 3px;
  padding: 12px 13px;
}

.nav-label {
  padding: 18px 11px 7px;
  color: #607a9f;
  font-size: 0.64rem;
  font-weight: 720;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 43px;
  padding: 10px 12px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 12px 12px 12px 5px;
  color: #91a6c5;
  font-size: 0.9rem;
  font-weight: 570;
  transition:
    color 160ms ease,
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.nav a::after {
  position: absolute;
  right: 11px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow:
    0 0 0 4px rgba(33, 206, 243, 0.1),
    0 0 14px rgba(33, 206, 243, 0.6);
  content: "";
  opacity: 0;
  transform: scale(0.3);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.nav a:hover {
  border-color: rgba(112, 154, 211, 0.15);
  background: rgba(111, 155, 216, 0.08);
  color: #e9f1ff;
  transform: translateX(2px);
}

.nav a.active {
  border-color: rgba(83, 142, 232, 0.24);
  background: linear-gradient(105deg,
      rgba(23, 107, 250, 0.2),
      rgba(33, 206, 243, 0.06));
  color: #ffffff;
  box-shadow: inset 3px 0 0 var(--cyan);
}

.nav a.active::after {
  opacity: 1;
  transform: scale(1);
}

.nav svg {
  width: 18px;
  height: 18px;
  flex: none;
  opacity: 0.84;
}

.nav a.active svg {
  color: var(--cyan-soft);
  opacity: 1;
}

.sidebar-foot {
  margin-top: auto;
  padding: 15px 17px 18px;
  border-top: 1px solid rgba(151, 180, 220, 0.14);
}

.local-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 11px;
  border: 1px solid rgba(122, 161, 213, 0.14);
  border-radius: 12px 12px 12px 5px;
  background: rgba(9, 31, 61, 0.74);
  color: #7189ac;
  font-size: 0.69rem;
  line-height: 1.35;
}

.local-note strong {
  display: block;
  color: #bfd0e8;
  font-size: 0.73rem;
  font-weight: 680;
}

.local-note-icon {
  position: relative;
  width: 21px;
  height: 21px;
  flex: none;
  border: 1px solid rgba(59, 214, 139, 0.38);
  border-radius: 50%;
}

.local-note-icon::after {
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 10px rgba(59, 214, 139, 0.65);
  content: "";
}

.sidebar-credit {
  display: grid;
  gap: 3px;
  color: #5f789d;
  font-size: 0.8rem;
}

.sidebar-credit.c1 {
  display: flex;
  align-items: center;
  gap: 5px;
}

.sidebar-credit a {
  width: fit-content;
  color: #006aff;
  transition: color 150ms ease;
}

.sidebar-credit a:hover {
  color: #ffffff;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  border: 0;
  background: rgba(2, 8, 19, 0.72);
  backdrop-filter: blur(4px);
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  min-height: 74px;
  gap: 13px;
  padding: 12px clamp(18px, 2.4vw, 34px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 76%, transparent);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  box-shadow: 0 7px 24px rgba(0, 6, 18, 0.06);
  backdrop-filter: blur(18px) saturate(130%);
}

.page-heading {
  display: grid;
  gap: 1px;
}

.page-heading>span {
  color: var(--faint);
  font-size: 0.61rem;
  font-weight: 720;
  letter-spacing: 0.13em;
  line-height: 1;
  text-transform: uppercase;
}

.topbar h1 {
  font-family: var(--display);
  font-size: 1.08rem;
  font-weight: 730;
  letter-spacing: -0.025em;
  line-height: 1.25;
}

.topbar>.spacer,
.card-head .spacer {
  flex: 1;
}

.topbar-actions,
.icon-cluster {
  display: flex;
  align-items: center;
}

.topbar-actions {
  gap: 11px;
}

.icon-cluster {
  gap: 5px;
  padding: 3px;
  border: 1px solid var(--line-soft);
  border-radius: 13px;
  background: color-mix(in srgb, var(--panel) 64%, transparent);
}

.content {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: clamp(24px, 3.4vw, 48px);
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: view-in 260ms cubic-bezier(0.22, 0.8, 0.32, 1);
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(7px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- overview hero ----------------------------------------------------- */

.overview-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(300px, 0.82fr);
  min-height: 355px;
  margin-bottom: clamp(34px, 5vw, 56px);
  overflow: hidden;
  border: 1px solid #1e3e6c;
  border-radius: 28px 28px 28px 10px;
  background:
    linear-gradient(105deg,
      rgba(4, 20, 48, 0.98) 0 52%,
      rgba(6, 35, 73, 0.94) 100%),
    #07172f;
  box-shadow: 0 28px 80px rgba(0, 20, 57, 0.26);
  color: #f7faff;
  isolation: isolate;
}

.overview-hero::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(113, 161, 226, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(113, 161, 226, 0.07) 1px, transparent 1px);
  background-size: 42px 42px;
  content: "";
  mask-image: linear-gradient(90deg, transparent 8%, black 70%, transparent);
}

.overview-hero::after {
  position: absolute;
  right: 32%;
  bottom: -88px;
  z-index: -1;
  width: 190px;
  height: 190px;
  border: 1px solid rgba(49, 182, 255, 0.18);
  border-radius: 50% 50% 50% 14px;
  content: "";
  transform: rotate(16deg);
}

.hero-copy {
  display: flex;
  justify-content: center;
  flex-direction: column;
  padding: clamp(34px, 5vw, 66px);
}

.eyebrow {
  display: inline-block;
  width: fit-content;
  margin-bottom: 8px;
  color: var(--blue-bright);
  font-size: 0.66rem;
  font-weight: 760;
  letter-spacing: 0.14em;
  line-height: 1.2;
  text-transform: uppercase;
}

.hero-copy .eyebrow {
  color: var(--cyan-soft);
}

.hero-copy h2 {
  max-width: 680px;
  font-family: var(--display);
  font-size: clamp(2.25rem, 4.1vw, 4.2rem);
  font-weight: 710;
  letter-spacing: -0.062em;
  line-height: 0.98;
}

.hero-copy h2 em {
  color: var(--cyan-soft);
  font-style: normal;
  font-weight: 560;
}

.hero-copy>p {
  max-width: 590px;
  margin-top: 20px;
  color: #a9bdd9;
  font-size: clamp(0.94rem, 1.3vw, 1.04rem);
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 27px;
}

.hero-actions .btn {
  border-color: rgba(255, 255, 255, 0.13);
}

.hero-actions .btn svg,
.auth-submit svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  transition: transform 160ms ease;
}

.hero-actions .btn:hover svg,
.auth-submit:hover svg {
  transform: translateX(3px);
}

.text-link {
  color: #bad0ed;
  font-size: 0.87rem;
  font-weight: 650;
  transition: color 160ms ease;
}

.text-link:hover {
  color: #ffffff;
}

.signal-stage {
  position: relative;
  min-height: 330px;
}

.signal-core {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  display: grid;
  width: clamp(118px, 11vw, 160px);
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid rgba(148, 207, 255, 0.26);
  border-radius: 50% 50% 50% 22%;
  background: rgba(8, 30, 66, 0.7);
  box-shadow:
    inset 0 0 0 12px rgba(78, 148, 244, 0.05),
    0 0 70px rgba(0, 139, 255, 0.22);
  transform: translate(-50%, -58%) rotate(-5deg);
  backdrop-filter: blur(10px);
}

.signal-core img {
  width: 60%;
  height: 60%;
  transform: rotate(5deg);
  filter: drop-shadow(0 12px 20px rgba(0, 90, 255, 0.3));
}

.signal-orbit {
  position: absolute;
  top: 50%;
  left: 50%;
  border: 1px solid rgba(101, 185, 255, 0.22);
  border-radius: 50%;
  transform: translate(-50%, -58%);
}

.orbit-one {
  width: clamp(210px, 19vw, 290px);
  aspect-ratio: 1;
  border-top-color: var(--cyan);
  border-right-color: rgba(101, 185, 255, 0.08);
  animation: orbit 15s linear infinite;
}

.orbit-two {
  width: clamp(280px, 27vw, 400px);
  aspect-ratio: 1;
  border-style: dashed;
  border-left-color: rgba(33, 206, 243, 0.54);
  animation: orbit-reverse 24s linear infinite;
}

@keyframes orbit {
  from {
    transform: translate(-50%, -58%) rotate(0deg);
  }

  to {
    transform: translate(-50%, -58%) rotate(360deg);
  }
}

@keyframes orbit-reverse {
  from {
    transform: translate(-50%, -58%) rotate(360deg);
  }

  to {
    transform: translate(-50%, -58%) rotate(0deg);
  }
}

.signal-node {
  position: absolute;
  z-index: 3;
  width: 9px;
  height: 9px;
  border: 2px solid #0b2247;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow:
    0 0 0 6px rgba(33, 206, 243, 0.08),
    0 0 22px rgba(33, 206, 243, 0.7);
}

.node-one {
  top: 21%;
  left: 30%;
}

.node-two {
  top: 46%;
  right: 18%;
}

.node-three {
  bottom: 23%;
  left: 27%;
}

.signal-label {
  position: absolute;
  right: clamp(18px, 3vw, 44px);
  bottom: 26px;
  z-index: 4;
  display: grid;
  gap: 1px;
  padding-left: 12px;
  border-left: 2px solid var(--cyan);
  color: #7596bd;
  font-size: 0.63rem;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
}

.signal-label strong {
  color: #c8d8eb;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.04em;
}

/* --- shared pieces ----------------------------------------------------- */

.section-head {
  max-width: 770px;
  margin-bottom: 23px;
}

.section-head h2 {
  font-family: var(--display);
  font-size: clamp(1.7rem, 2.6vw, 2.35rem);
  font-weight: 720;
  letter-spacing: -0.045em;
  line-height: 1.1;
}

.section-head p {
  max-width: 680px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.93rem;
}

.section-head-split {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  max-width: none;
}

.section-note {
  flex: none;
  padding-bottom: 3px;
  color: var(--faint);
  font-size: 0.74rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 31px;
  gap: 8px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--panel) 76%, transparent);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 680;
  white-space: nowrap;
}

.pill .dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--faint);
}

.pill.on {
  border-color: color-mix(in srgb, var(--ok) 35%, transparent);
  background: color-mix(in srgb, var(--ok) 8%, var(--panel));
  color: var(--ok);
}

.pill.on .dot {
  background: var(--ok);
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--ok) 15%, transparent),
    0 0 12px color-mix(in srgb, var(--ok) 55%, transparent);
}

.pill.off {
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
  background: color-mix(in srgb, var(--danger) 7%, var(--panel));
  color: var(--danger);
}

.pill.off .dot {
  background: var(--danger);
}

.pill.warn {
  border-color: color-mix(in srgb, var(--warn) 35%, transparent);
  background: color-mix(in srgb, var(--warn) 7%, var(--panel));
  color: var(--warn);
}

.pill.warn .dot {
  background: var(--warn);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--warn) 14%, transparent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 39px;
  gap: 8px;
  padding: 8px 15px;
  border: 1px solid var(--line);
  border-radius: 11px 11px 11px 5px;
  background: var(--panel-raised);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 650;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 0 color-mix(in srgb, #ffffff 5%, transparent) inset;
  transition:
    transform 150ms ease,
    background 150ms ease,
    border-color 150ms ease,
    box-shadow 150ms ease,
    opacity 150ms ease;
}

.btn:hover {
  border-color: color-mix(in srgb, var(--blue-bright) 62%, var(--line));
  background: var(--panel-hover);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  border-color: color-mix(in srgb, var(--cyan) 25%, var(--blue));
  background: var(--grad);
  color: #ffffff;
  box-shadow:
    0 9px 24px rgba(11, 95, 230, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-primary:hover {
  border-color: color-mix(in srgb, var(--cyan) 50%, var(--blue));
  background: linear-gradient(120deg, #2878ff, #0c8cf3 62%, #23d4f7 120%);
  box-shadow:
    0 12px 28px rgba(11, 95, 230, 0.29),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.btn-danger {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
  background: color-mix(in srgb, var(--danger) 5%, var(--panel-raised));
  color: var(--danger);
}

.btn-danger:hover {
  border-color: color-mix(in srgb, var(--danger) 70%, var(--line));
  background: color-mix(in srgb, var(--danger) 11%, var(--panel));
}

.btn-sm {
  min-height: 32px;
  padding: 6px 11px;
  font-size: 0.77rem;
}

.btn-icon {
  width: 35px;
  min-height: 35px;
  padding: 8px;
  border-color: transparent;
  border-radius: 9px;
  background: transparent;
}

.btn-icon svg,
.logout-btn svg,
.qr-back svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.theme-toggle .moon-icon {
  display: none;
}

:root[data-theme="light"] .theme-toggle .sun-icon {
  display: none;
}

:root[data-theme="light"] .theme-toggle .moon-icon {
  display: block;
}

#refresh-btn:active svg {
  transform: rotate(35deg);
}

.menu-btn {
  display: none;
}

.logout-btn {
  border-color: var(--line-soft);
  background: transparent;
  color: var(--muted);
}

.logout-btn:hover {
  color: var(--text);
}

.card {
  position: relative;
  padding: clamp(19px, 2.1vw, 26px);
  border: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) var(--radius) 7px;
  background: color-mix(in srgb, var(--panel) 95%, transparent);
  box-shadow: var(--shadow-soft);
}

.card+.card,
#settings-list .card:first-child {
  margin-top: 18px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.card-head .eyebrow {
  margin-bottom: 4px;
}

.card-head h2 {
  font-family: var(--display);
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.022em;
}

.hint {
  color: var(--muted);
  font-size: 0.82rem;
}

.inline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.form-actions,
.action-cluster {
  margin-top: 15px;
}

.callout {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 17px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--blue) 18%, var(--line-soft));
  border-radius: 12px 12px 12px 5px;
  background: color-mix(in srgb, var(--blue) 5%, var(--bg-soft));
  color: var(--muted);
  font-size: 0.8rem;
}

.callout-icon {
  display: grid;
  width: 20px;
  height: 20px;
  flex: none;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--blue-bright) 48%, transparent);
  border-radius: 50%;
  color: var(--blue-bright);
  font-family: var(--mono);
  font-size: 0.67rem;
  font-weight: 700;
}

.session-card::before {
  position: absolute;
  top: -1px;
  left: 24px;
  width: 84px;
  height: 2px;
  border-radius: 0 0 4px 4px;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
  content: "";
}

.session-detail {
  color: var(--text);
  font-size: 0.93rem;
}

.compact-card {
  max-width: 900px;
}

.prefix-control input {
  max-width: 84px;
  text-align: center;
  font-family: var(--mono);
  font-weight: 720;
}

/* --- stats and runtime ------------------------------------------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat {
  position: relative;
  min-height: 155px;
  padding: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px 16px 16px 6px;
  background: var(--panel);
  box-shadow: 0 8px 28px rgba(0, 7, 20, 0.09);
  transition:
    transform 170ms ease,
    border-color 170ms ease,
    box-shadow 170ms ease;
}

.stat::after {
  position: absolute;
  right: -26px;
  bottom: -34px;
  width: 82px;
  height: 82px;
  border: 1px solid color-mix(in srgb, var(--blue) 16%, transparent);
  border-radius: 50% 50% 50% 16px;
  content: "";
  transform: rotate(25deg);
}

.stat:hover {
  border-color: color-mix(in srgb, var(--blue-bright) 42%, var(--line));
  box-shadow: 0 14px 34px rgba(0, 40, 100, 0.12);
  transform: translateY(-2px);
}

.stat-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-icon {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--blue-bright) 30%, var(--line));
  border-radius: 9px 9px 9px 4px;
  background: color-mix(in srgb, var(--blue) 8%, var(--bg-soft));
  color: var(--blue-bright);
}

.stat-icon svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.stat .label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
}

.stat .value {
  margin-top: 14px;
  font-family: var(--display);
  font-size: clamp(1.9rem, 2.4vw, 2.45rem);
  font-variant-numeric: tabular-nums;
  font-weight: 720;
  letter-spacing: -0.06em;
  line-height: 1;
}

.stat-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  color: var(--faint);
  font-size: 0.63rem;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.stat-foot i {
  display: block;
  width: 18px;
  height: 1px;
  background: color-mix(in srgb, var(--cyan) 60%, var(--line));
}

.runtime-card {
  overflow: hidden;
}

.runtime-card::after {
  position: absolute;
  top: 0;
  right: 0;
  width: 190px;
  height: 100%;
  pointer-events: none;
  background: radial-gradient(circle at 100% 0,
      color-mix(in srgb, var(--blue) 10%, transparent),
      transparent 70%);
  content: "";
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 13px 13px 13px 5px;
  background: var(--line-soft);
}

.runtime-item {
  min-width: 0;
  padding: 14px 16px;
  background: var(--bg-soft);
}

.runtime-label {
  color: var(--faint);
  font-size: 0.64rem;
  font-weight: 720;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.runtime-value {
  margin-top: 4px;
  overflow: hidden;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.84rem;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- forms ------------------------------------------------------------- */

label.field {
  display: block;
  margin-bottom: 15px;
}

label.field>span,
.setting-label {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 650;
}

label.field>small {
  display: block;
  margin-top: 6px;
  color: var(--faint);
  font-size: 0.72rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm) var(--radius-sm) var(--radius-sm) 5px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 0.87rem;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

input::placeholder,
textarea::placeholder {
  color: color-mix(in srgb, var(--faint) 75%, transparent);
}

input:hover,
select:hover,
textarea:hover {
  border-color: color-mix(in srgb, var(--blue-bright) 34%, var(--line));
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--blue-bright);
  background: color-mix(in srgb, var(--blue) 3%, var(--bg-soft));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 13%, transparent);
}

textarea {
  min-height: 230px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.65;
}

select {
  cursor: pointer;
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  user-select: none;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch .track {
  position: relative;
  width: 41px;
  height: 23px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-soft);
  transition:
    background 180ms ease,
    border-color 180ms ease;
}

.switch .track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  content: "";
  transition:
    transform 180ms ease,
    background 180ms ease;
}

.switch input:checked+.track {
  border-color: var(--blue);
  background: var(--blue);
}

.switch input:checked+.track::after {
  background: #ffffff;
  transform: translateX(18px);
}

.switch input:focus-visible+.track {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.search-field {
  position: relative;
  display: block;
  width: min(280px, 100%);
}

.search-field svg {
  position: absolute;
  top: 50%;
  left: 12px;
  z-index: 2;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--faint);
  stroke-linecap: round;
  stroke-width: 1.7;
  transform: translateY(-50%);
}

.search-field input[type="text"] {
  max-width: none;
  padding-left: 36px;
}

.password-grid {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(190px, 1fr) auto;
  align-items: end;
  gap: 12px;
  max-width: 850px;
}

.password-grid .field {
  margin-bottom: 0;
}

.security-card>.hint {
  max-width: 820px;
  margin-top: 14px;
}

.memory-editor {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}

/* --- tables ------------------------------------------------------------ */

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.toolbar>.spacer {
  flex: 1;
}

.toolbar select {
  width: auto;
  min-width: 142px;
}

.data-tabs {
  width: fit-content;
  max-width: 100%;
  padding: 4px;
  border: 1px solid var(--line-soft);
  border-radius: 13px;
  background: var(--bg-soft);
}

.data-tabs .btn {
  border-color: transparent;
  border-radius: 9px;
  background: transparent;
  box-shadow: none;
}

.data-tabs .btn-primary {
  background: var(--panel-raised);
  color: var(--text);
  box-shadow: 0 5px 14px rgba(0, 5, 20, 0.12);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px 14px 14px 5px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-soft);
  color: var(--faint);
  font-size: 0.65rem;
  font-weight: 740;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

tbody tr {
  transition: background 140ms ease;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: color-mix(in srgb, var(--blue) 4%, var(--panel));
}

td.wrap {
  min-width: 220px;
  white-space: normal;
}

.schedule-state {
  display: grid;
  min-width: 150px;
  gap: 6px;
  white-space: normal;
}

.schedule-detail,
.schedule-error {
  color: var(--faint);
  font-size: 0.72rem;
  line-height: 1.45;
}

.schedule-error {
  max-width: 260px;
  color: var(--danger);
  overflow-wrap: anywhere;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tag,
.source {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 23px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1;
  text-transform: uppercase;
}

.tag.ok {
  border-color: color-mix(in srgb, var(--ok) 36%, transparent);
  background: color-mix(in srgb, var(--ok) 6%, transparent);
  color: var(--ok);
}

.tag.warn {
  border-color: color-mix(in srgb, var(--warn) 36%, transparent);
  background: color-mix(in srgb, var(--warn) 6%, transparent);
  color: var(--warn);
}

.tag.danger {
  border-color: color-mix(in srgb, var(--danger) 36%, transparent);
  background: color-mix(in srgb, var(--danger) 6%, transparent);
  color: var(--danger);
}

.tag.info,
.source.dashboard {
  border-color: color-mix(in srgb, var(--blue-bright) 38%, transparent);
  background: color-mix(in srgb, var(--blue) 6%, transparent);
  color: var(--blue-bright);
}

.empty,
.loading {
  padding: 38px 24px;
  color: var(--faint);
  font-size: 0.83rem;
  text-align: center;
}

.loading::before {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 9px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--cyan) 10%, transparent);
  content: "";
  animation: loading-pulse 1s ease-in-out infinite;
}

@keyframes loading-pulse {
  50% {
    opacity: 0.35;
    transform: scale(0.7);
  }
}

/* --- commands, groups and settings ------------------------------------ */

.cmd-name {
  font-family: var(--mono);
  font-weight: 700;
}

.alias-input {
  min-width: 190px;
  font-family: var(--mono);
  font-size: 0.78rem;
}

.locked {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--faint);
  font-size: 0.75rem;
}

.group-card {
  box-shadow: none;
}

.group-card+.group-card {
  margin-top: 12px;
}

.group-card summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 28px;
  color: var(--text);
  font-weight: 650;
  cursor: pointer;
  list-style: none;
}

.group-card summary::-webkit-details-marker {
  display: none;
}

.group-card summary .chev {
  margin-left: auto;
  color: var(--faint);
  font-size: 1.2rem;
  transition: transform 160ms ease;
}

.group-card[open] {
  border-color: color-mix(in srgb, var(--blue-bright) 30%, var(--line));
  box-shadow: var(--shadow-soft);
}

.group-card[open] summary .chev {
  transform: rotate(90deg);
}

.group-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 22px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
}

.group-body h3 {
  margin-bottom: 10px;
  color: var(--faint);
  font-size: 0.65rem;
  font-weight: 740;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.role-control #role-number {
  max-width: 230px;
}

.role-control #role-kind {
  max-width: 150px;
}

.setting-item {
  padding: 17px 0;
  border-bottom: 1px solid var(--line-soft);
}

.setting-item:first-child {
  padding-top: 0;
}

.setting-item:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.setting-label-row {
  margin-bottom: 7px;
}

.setting-label-row .setting-label {
  margin-bottom: 0;
}

.setting-item>.inline:not(.setting-label-row) {
  max-width: 720px;
}

.setting-item>.inline:not(.setting-label-row)>input,
.setting-item>.inline:not(.setting-label-row)>select {
  flex: 1 1 300px;
}

.setting-hint {
  max-width: 780px;
  margin-top: 7px;
}

/* --- QR --------------------------------------------------------------- */

.qr-box {
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  text-align: center;
}

.qr-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 270px;
  min-height: 270px;
  padding: 10px;
  border: 8px solid #ffffff;
  border-radius: 18px 18px 18px 7px;
  background: #ffffff;
  line-height: 0;
  box-shadow: 0 15px 38px rgba(0, 7, 24, 0.2);
}

.qr-frame canvas,
.qr-frame img {
  display: block;
  max-width: 100%;
}

.steps {
  max-width: 420px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 0.83rem;
  text-align: start;
}

.steps li {
  margin: 8px 0;
  margin-inline-start: 21px;
  padding-inline-start: 4px;
}

.steps li::marker {
  color: var(--blue-bright);
  font-family: var(--mono);
}

.pair-chooser {
  margin: 16px 0 8px;
}

.pair-methods {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin: 8px 0 12px;
}

.pair-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.pair-phone-wrap {
  display: grid;
  gap: 6px;
  max-width: 360px;
  margin-bottom: 12px;
}

.pair-phone-wrap[hidden] {
  display: none;
}

.pairing-code {
  font-family: var(--mono);
  font-size: 2rem;
  letter-spacing: 0.18em;
  font-weight: 700;
  padding: 18px 24px;
  border-radius: 14px;
  background: var(--panel-raised);
  color: var(--text);
  border: 1px solid var(--line);
}

.steps li span {
  color: var(--text);
  font-weight: 650;
}

/* --- toasts ------------------------------------------------------------ */

.toasts {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 10px;
}

.toast {
  max-width: 360px;
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--blue-bright);
  border-radius: 12px 12px 12px 5px;
  background: var(--panel-raised);
  color: var(--text);
  font-size: 0.83rem;
  box-shadow: var(--shadow);
  animation: toast-in 220ms cubic-bezier(0.2, 0.8, 0.3, 1);
}

.toast.ok {
  border-left-color: var(--ok);
}

.toast.error {
  border-left-color: var(--danger);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(16px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

/* --- gateway: login, setup and QR ------------------------------------- */

.gateway-page {
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.gateway-shell {
  display: grid;
  grid-template-columns: minmax(350px, 0.82fr) minmax(480px, 1.18fr);
  min-height: 100vh;
}

.gateway-story {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: clamp(32px, 5vw, 72px);
  overflow: hidden;
  border-inline-end: 1px solid var(--gateway-story-border);
  background: var(--gateway-story-bg);
  isolation: isolate;
}

.gateway-story::before {
  position: absolute;
  inset: 0;
  z-index: -2;
  background-image:
    linear-gradient(var(--gateway-story-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--gateway-story-grid) 1px, transparent 1px);
  background-size: 48px 48px;
  content: "";
  mask-image: linear-gradient(140deg, black, transparent 78%);
}

.gateway-story::after {
  position: absolute;
  inset-inline-end: -220px;
  bottom: -240px;
  z-index: -1;
  width: 520px;
  height: 520px;
  border: 1px solid var(--gateway-story-ring);
  border-radius: 50% 50% 50% 20%;
  content: "";
  transform: rotate(17deg);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  gap: 12px;
  color: var(--text);
}

.brand-lockup img {
  width: 49px;
  height: 49px;
  filter: drop-shadow(0 10px 20px rgba(0, 102, 245, 0.3));
}

.brand-lockup>span {
  display: grid;
}

.brand-lockup strong {
  font-family: var(--display);
  font-size: 1.42rem;
  font-weight: 760;
  letter-spacing: -0.045em;
  line-height: 1.1;
}

.brand-lockup small {
  margin-top: 3px;
  color: var(--faint);
  font-size: 0.61rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.gateway-copy {
  position: relative;
  z-index: 2;
  max-width: 560px;
  margin: auto 0;
  padding: clamp(56px, 11vh, 110px) 0;
}

.gateway-copy .eyebrow {
  color: var(--gateway-eyebrow);
}

.gateway-copy h2 {
  font-family: var(--display);
  font-size: clamp(2.25rem, 4.2vw, 4.35rem);
  font-weight: 690;
  letter-spacing: -0.06em;
  line-height: 0.98;
}

.gateway-copy p {
  max-width: 480px;
  margin-top: 22px;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.75;
}

.gateway-mark {
  position: absolute;
  inset-inline-end: clamp(-72px, -4vw, -28px);
  bottom: clamp(88px, 14vh, 150px);
  z-index: 0;
  display: grid;
  width: clamp(190px, 20vw, 300px);
  aspect-ratio: 1;
  place-items: center;
  opacity: 0.34;
}

.gateway-mark img {
  width: 46%;
  filter: saturate(1.1) drop-shadow(0 15px 30px rgba(0, 119, 255, 0.28));
}

.gateway-ring {
  position: absolute;
  inset: 2px;
  border: 1px dashed var(--gateway-ring-border);
  border-radius: 50%;
  animation: orbit 28s linear infinite;
}

.gateway-ring::after {
  position: absolute;
  top: 11%;
  left: 14%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gateway-ring-dot);
  box-shadow: 0 0 15px var(--gateway-ring-glow);
  content: "";
}

.gateway-trust {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--faint);
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.gateway-trust>span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow:
    0 0 0 5px rgba(59, 214, 139, 0.09),
    0 0 13px rgba(59, 214, 139, 0.44);
}

.gateway-panel {
  display: grid;
  min-width: 0;
  place-items: center;
  padding: clamp(26px, 5vw, 72px);
  background: var(--gateway-panel-bg);
}

.gateway-panel-inner {
  width: min(100%, 480px);
}

.auth-card {
  padding: clamp(25px, 4vw, 38px);
  border-color: var(--gateway-card-border);
  background: var(--gateway-card-bg);
  box-shadow: var(--gateway-card-shadow);
  text-align: start;
}

.auth-head {
  margin-bottom: 27px;
}

.auth-head .eyebrow,
.qr-card-head .eyebrow {
  color: var(--gateway-auth-eyebrow);
}

.auth-card h1,
.qr-card h1 {
  font-family: var(--display);
  font-size: clamp(1.8rem, 3vw, 2.3rem);
  font-weight: 720;
  letter-spacing: -0.05em;
  line-height: 1.08;
}

.auth-card .sub {
  margin-top: 8px;
  color: var(--gateway-text-sub);
  font-size: 0.86rem;
}

.auth-card label.field>span {
  color: var(--text);
}

.auth-card input {
  border-color: var(--gateway-input-border);
  background: var(--gateway-input-bg);
  color: var(--gateway-input-text);
}

.auth-submit {
  width: 100%;
  min-height: 46px;
  margin-top: 4px;
  justify-content: space-between;
  padding-inline: 17px;
}

.error {
  margin-top: 14px;
  padding: 11px 13px;
  border: 1px solid color-mix(in srgb, var(--danger) 42%, transparent);
  border-radius: 11px 11px 11px 5px;
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  color: var(--gateway-error-text);
  font-size: 0.8rem;
  text-align: start;
}

.foot {
  margin-top: 20px;
  color: var(--faint);
  font-size: 0.7rem;
  text-align: center;
}

.qr-panel-inner {
  width: min(100%, 560px);
}

.qr-card-head {
  align-items: flex-start;
}

.qr-card .qr-box {
  padding: 8px 0 20px;
}

.qr-card .qr-frame {
  min-width: 286px;
  min-height: 286px;
  border: 8px solid var(--gateway-qr-frame-border);
  box-shadow: var(--shadow-soft);
}

.compact-callout {
  max-width: 430px;
  margin-top: 2px;
  text-align: start;
}

.qr-back {
  width: 100%;
}

.qr-success {
  padding: 58px 28px;
  color: var(--text);
  font-family: var(--display);
  font-weight: 700;
  line-height: 1.2;
}

/* --- responsive -------------------------------------------------------- */

@media (max-width: 1220px) {
  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stat {
    min-height: 142px;
  }

  .overview-hero {
    grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr);
  }
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    width: 268px;
    transform: translateX(-102%);
    transition: transform 220ms cubic-bezier(0.22, 0.8, 0.32, 1);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop.open {
    display: block;
  }

  .menu-btn {
    display: inline-flex;
  }

  .overview-hero {
    grid-template-columns: minmax(0, 1.1fr) minmax(230px, 0.9fr);
  }

  .hero-copy {
    padding: 38px;
  }

  .gateway-shell {
    grid-template-columns: minmax(290px, 0.72fr) minmax(440px, 1.28fr);
  }

  .gateway-story {
    padding: 34px;
  }

  .gateway-copy h2 {
    font-size: clamp(2.1rem, 4.5vw, 3.2rem);
  }

  .gateway-mark {
    opacity: 0.22;
  }
}

@media (max-width: 760px) {
  .topbar {
    min-height: 65px;
    padding: 10px 14px;
  }

  .content {
    padding: 22px 14px 34px;
  }

  .page-heading>span {
    display: none;
  }

  .overview-hero {
    display: block;
    min-height: 0;
    border-radius: 22px 22px 22px 8px;
  }

  .hero-copy {
    position: relative;
    z-index: 5;
    padding: 34px 25px 38px;
  }

  .hero-copy h2 {
    font-size: clamp(2.15rem, 10vw, 3.25rem);
  }

  .hero-copy>p {
    max-width: 520px;
  }

  .signal-stage {
    position: absolute;
    inset: 0 0 0 38%;
    min-height: 100%;
    opacity: 0.34;
  }

  .signal-core {
    width: 126px;
  }

  .signal-label {
    display: none;
  }

  .section-head-split {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .section-note {
    padding-bottom: 0;
  }

  .password-grid {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .gateway-shell {
    display: block;
  }

  .gateway-story {
    min-height: 255px;
    padding: 25px;
    border-inline-end: 0;
    border-bottom: 1px solid var(--gateway-story-border);
  }

  .gateway-copy {
    margin: 48px 0 0;
    padding: 0 0 18px;
  }

  .gateway-copy h2 {
    max-width: 520px;
    font-size: clamp(2rem, 8vw, 3rem);
  }

  .gateway-copy p {
    max-width: 560px;
    margin-top: 13px;
  }

  .gateway-mark {
    inset-inline-end: -35px;
    bottom: -62px;
    width: 220px;
  }

  .gateway-trust {
    display: none;
  }

  .gateway-panel {
    min-height: calc(100vh - 255px);
    padding: 30px 18px;
  }
}

@media (max-width: 560px) {
  .topbar {
    gap: 8px;
  }

  .page-heading {
    display: none;
  }

  .topbar>.spacer {
    display: none;
  }

  .topbar-actions {
    width: auto;
    min-width: 0;
    flex: 1;
    justify-content: flex-end;
    gap: 7px;
  }

  .topbar-actions .pill {
    margin-right: auto;
  }

  .logout-btn span {
    display: none;
  }

  .logout-btn {
    width: 35px;
    min-height: 35px;
    padding: 8px;
    border-color: var(--line-soft);
    border-radius: 9px;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat {
    min-height: 138px;
    padding: 14px;
  }

  .stat-icon {
    width: 25px;
    height: 25px;
  }

  .card {
    padding: 18px;
  }

  .section-head h2 {
    font-size: 1.65rem;
  }

  .hero-copy {
    padding: 31px 21px 34px;
  }

  .hero-actions {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .signal-stage {
    left: 25%;
  }

  .action-cluster .btn {
    flex: 1 1 calc(50% - 6px);
  }

  .toolbar .search-field,
  .toolbar select {
    width: 100%;
  }

  .toolbar>.spacer {
    display: none;
  }

  .data-tabs {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .data-tabs .btn {
    flex: none;
  }

  .role-control #role-number,
  .role-control #role-kind {
    max-width: none;
  }

  .role-control>input,
  .role-control>select,
  .role-control>button {
    width: 100%;
  }

  .toasts {
    right: 12px;
    bottom: 12px;
    left: 12px;
  }

  .toast {
    width: 100%;
    max-width: none;
  }

  .gateway-story {
    min-height: 225px;
  }

  .gateway-copy {
    margin-top: 38px;
  }

  .gateway-copy p {
    display: none;
  }

  .gateway-panel {
    min-height: calc(100vh - 225px);
    padding: 22px 12px;
  }

  .auth-card {
    padding: 23px 19px;
  }

  .qr-card-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .qr-card .qr-frame,
  .qr-frame {
    min-width: min(270px, 100%);
    min-height: 270px;
  }
}

@media (max-width: 390px) {
  .topbar-actions .pill {
    max-width: 102px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .stat {
    min-height: 128px;
  }

  .prefix-control>* {
    width: 100%;
    max-width: none;
  }

  .prefix-control input {
    max-width: none;
  }
}

@media (max-width: 340px) {
  .stats {
    grid-template-columns: 1fr;
  }
}

/* --- Language Switcher ---------------------------------------------------- */
.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  width: auto !important;
  font-weight: 600;
  font-size: 13px;
}

.lang-btn svg {
  width: 17px;
  height: 17px;
}

.lang-tag {
  font-family: var(--display);
  letter-spacing: 0.5px;
}

/* --- Settings Redesign Tabs ----------------------------------------------- */
.settings-nav-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 16px 0;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
  scrollbar-width: thin;
}

.settings-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 550;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s ease;
}

.settings-tab:hover {
  background: var(--panel-hover);
  color: var(--text);
  border-color: var(--blue-bright);
}

.settings-tab.active {
  background: var(--grad);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(23, 107, 250, 0.35);
}

.settings-tab svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  flex-shrink: 0;
}

/* --- AI Provider Selector Grid -------------------------------------------- */
.provider-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 16px 0;
}

.provider-card {
  display: flex;
  flex-direction: column;
  padding: 16px;
  background: var(--panel-raised);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.22s ease;
  position: relative;
  text-align: left;
}

html[dir="rtl"] .provider-card {
  text-align: right;
}

.provider-card:hover {
  background: var(--panel-hover);
  border-color: var(--blue-bright);
  transform: translateY(-2px);
}

.provider-card.active {
  border-color: var(--cyan);
  background: linear-gradient(135deg, rgba(23, 107, 250, 0.14) 0%, rgba(33, 206, 243, 0.08) 100%);
  box-shadow: 0 8px 24px rgba(23, 107, 250, 0.2);
}

.provider-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.provider-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.provider-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}

.provider-active-badge {
  display: none;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--ok);
  color: #07101f;
  font-weight: 700;
}

.provider-card.active .provider-active-badge {
  display: inline-block;
}

/* --- Presets & Capabilities ----------------------------------------------- */
.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 16px 0;
}

.preset-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(33, 206, 243, 0.12);
  border: 1px solid rgba(33, 206, 243, 0.35);
  border-radius: 999px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-chip:hover {
  background: rgba(33, 206, 243, 0.22);
  transform: translateY(-1px);
}

.capability-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  margin-inline-start: 8px;
}

.capability-badge.supported {
  background: rgba(59, 214, 139, 0.15);
  color: var(--ok);
  border: 1px solid rgba(59, 214, 139, 0.35);
}

.capability-badge.manual {
  background: rgba(242, 184, 75, 0.15);
  color: var(--warn);
  border: 1px solid rgba(242, 184, 75, 0.35);
}

/* --- Modal Dialog --------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 16, 31, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 16px;
}

.modal-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 620px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(10px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line-soft);
}

.modal-body {
  padding: 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  padding: 14px 22px;
  border-top: 1px solid var(--line-soft);
  background: var(--panel-raised);
}

/* --- RTL Support ---------------------------------------------------------- */
html[dir="rtl"] {
  font-family: var(--body);
  direction: rtl;
  text-align: right;
}

html[dir="rtl"] .sidebar {
  border-right: none;
  border-left: 1px solid var(--line-soft);
}

html[dir="rtl"] .nav a {
  padding: 10px 16px 10px 14px;
}

html[dir="rtl"] .nav a svg {
  margin-right: 0;
  margin-left: 12px;
}

html[dir="rtl"] .brand img {
  margin-right: 0;
  margin-left: 12px;
}

html[dir="rtl"] .topbar-actions {
  margin-left: 0;
  margin-right: auto;
}

html[dir="rtl"] .page-heading {
  margin-right: 0;
  margin-left: auto;
}

html[dir="rtl"] .inline {
  flex-direction: row;
}

html[dir="rtl"] .card-head {
  flex-direction: row;
}

html[dir="rtl"] .setting-label-row {
  flex-direction: row;
}

html[dir="rtl"] .modal-head {
  flex-direction: row;
}

html[dir="rtl"] .modal-foot {
  justify-content: flex-start;
}

html[dir="rtl"] .status-dot {
  margin-right: 0;
  margin-left: 8px;
}

html[dir="rtl"] .source {
  margin-left: 0;
  margin-right: 8px;
}

html[dir="rtl"] .btn svg {
  margin-right: 0;
  margin-left: 6px;
}

html[dir="rtl"] .logout-btn svg {
  margin-left: 0;
  margin-right: 6px;
  transform: rotate(180deg);
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
/* --- gateway: password visibility, reset link, screen guard ------------- */

.input-wrap {
  position: relative;
  /* The field is a password / Latin value, so keep it LTR even when the page
     is Arabic: the input's own padding and the eye button's `inset-inline-end`
     then resolve to the same physical end. */
  direction: ltr;
}

.input-wrap input {
  padding-inline-end: 52px;
}

.eye-btn {
  position: absolute;
  inset-inline-end: 2px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--faint);
  cursor: pointer;
}

.eye-btn:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--line) 55%, transparent);
}

.eye-btn:focus-visible {
  outline: 2px solid var(--blue-bright);
  outline-offset: -2px;
}

.eye-btn svg {
  width: 17px;
  height: 17px;
}

.auth-alt {
  margin-top: 14px;
  text-align: center;
}

.link-btn {
  padding: 0;
  border: none;
  background: none;
  color: var(--gateway-link);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.link-btn:hover {
  text-decoration: underline;
}

/* The password screens blur themselves whenever the page can't be watched —
   another tab, a minimised window, the task switcher. Best effort: the web
   platform cannot truly forbid screenshots, but this keeps the form out of
   task-switcher thumbnails and casual captures. Printing one of these pages
   gets a blank sheet instead. */
html.screen-guard .gateway-panel {
  filter: blur(18px);
}

@media print {

  .gateway-panel {
    display: none;
  }
}

.gateway-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.625rem;
  margin-bottom: 0.75rem;
  border-radius: 0.625rem;
  border: 1px solid var(--line);
  background: var(--panel-raised);
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
}
.gateway-back-btn[hidden] {
  display: none;
}
.gateway-back-btn:hover {
  background: var(--panel-hover);
  color: var(--blue-bright);
}
.gateway-back-btn svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}
/* Directional icons point the way the language reads: a right arrow in an
   English submit button, a left arrow on a back control. Arabic flips both. */
html[dir="rtl"] .gateway-back-btn svg,
html[dir="rtl"] .qr-back svg,
html[dir="rtl"] .auth-submit svg {
  transform: scaleX(-1);
}

html[dir="rtl"] .auth-submit:hover svg {
  transform: scaleX(-1) translateX(3px);
}
