:root {
  color-scheme: dark;
  --bg-0: #080b1f;
  --bg-1: #11143a;
  --panel: rgba(24, 29, 68, 0.66);
  --panel-strong: rgba(27, 32, 75, 0.86);
  --line: rgba(255, 255, 255, 0.11);
  --text: #f7f8ff;
  --muted: #9da7d0;
  --muted-2: #6f7aae;
  --indigo: #6b66ff;
  --indigo-2: #8a7cff;
  --cyan: #35d7ff;
  --teal: #16d7aa;
  --rose: #ff6f98;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 4%, rgba(93, 77, 255, 0.32), transparent 34rem),
    radial-gradient(circle at 78% 20%, rgba(33, 188, 255, 0.14), transparent 28rem),
    linear-gradient(145deg, #12143a 0%, #080b1f 56%, #050718 100%);
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(circle at 52% 42%, black, transparent 74%);
  pointer-events: none;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
svg { display: block; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.loading {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(8, 11, 31, 0.86);
  transition: opacity .25s ease;
}

.loading-card, .login-card, .dialog-card {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.1), rgba(255,255,255,.045)), rgba(18, 23, 56, .9);
  box-shadow: 0 28px 90px rgba(0, 0, 0, .34);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.loading-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  border-radius: 18px;
  color: #dce2ff;
  font-weight: 760;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,.2);
  border-top-color: white;
  border-radius: 999px;
  animation: spin .8s linear infinite;
}

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

.login-view {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(360px, 100%);
  padding: 34px;
  border-radius: 24px;
  display: grid;
  justify-items: center;
  gap: 16px;
  text-align: center;
}

.login-card h1 { margin: 0; font-size: 32px; }
.login-card p { margin: 0 0 8px; color: var(--muted); }

.topbar {
  position: relative;
  z-index: 3;
  height: 74px;
  padding: 0 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,.09);
  background: rgba(19, 24, 54, .72);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.brand, .account, .avatar-button, .deploy-button, .primary-button, .secondary-button, .heading-row, .view-actions, .fab {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  font-weight: 800;
  font-size: 18px;
  white-space: nowrap;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(145deg, #705cff, #944cff);
  box-shadow: 0 10px 28px rgba(103, 82, 255, .32);
}

.brand-mark.large { width: 58px; height: 58px; border-radius: 17px; }
.brand-mark svg { width: 18px; height: 18px; fill: white; stroke: none; }
.brand-mark.large svg { width: 30px; height: 30px; }

.account {
  gap: 14px;
  padding-left: 24px;
  border-left: 1px solid rgba(255,255,255,.08);
  position: relative;
}

.avatar-button {
  gap: 11px;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 14px;
  padding: 6px;
}

.avatar-button:hover, .avatar-button.active { background: rgba(255,255,255,.055); }

.avatar-image, .avatar-fallback {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.72);
  box-shadow: 0 0 0 5px rgba(255,255,255,.04);
}

.avatar-fallback {
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #ffa97d, #ff80b3);
  color: #2f2446;
  font-weight: 900;
}

.avatar-copy { display: grid; gap: 3px; text-align: left; }
.avatar-copy strong { font-size: 15px; }
.avatar-copy span { color: #8994c1; font-size: 12px; font-weight: 760; }

.account-menu {
  position: absolute;
  top: calc(100% + 12px);
  right: 46px;
  z-index: 20;
  min-width: 148px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(15, 20, 50, .95);
  box-shadow: 0 20px 48px rgba(0,0,0,.34);
  backdrop-filter: blur(20px);
}
.account-menu[hidden] { display: none; }
.account-menu button { width: 100%; border: 0; border-radius: 10px; padding: 10px 11px; color: #e7eaff; background: transparent; text-align: left; font-weight: 760; }
.account-menu button:hover { background: rgba(255,255,255,.08); }

.console-shell { position: relative; z-index: 1; height: 100vh; }
.workspace { height: calc(100vh - 74px); display: grid; grid-template-columns: 292px 1fr; min-height: 0; }

.connector-panel {
  position: relative;
  padding: 28px;
  border-right: 1px solid var(--line);
  background: rgba(13,17,43,.16);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.panel-title, .section-title {
  color: var(--muted-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
}

.connector-list {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 86px;
}

.connector-item {
  min-height: 64px;
  width: 100%;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 18px;
  padding: 14px 13px;
  color: var(--text);
  background: transparent;
  text-align: left;
}
.connector-item:hover, .connector-item.active { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.11); }
.connector-icon { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; color: white; background: linear-gradient(145deg, rgba(102,98,255,.95), rgba(41,197,255,.78)); }
.connector-icon svg { width: 18px; height: 18px; }
.connector-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; font-weight: 800; }

.status-dot, .status-badge span {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #8a93b8;
  box-shadow: 0 0 0 4px rgba(255,255,255,.055);
}
.status-dot.online, .status-badge.online span { background: var(--teal); box-shadow: 0 0 0 4px rgba(22,215,170,.13), 0 0 18px rgba(22,215,170,.48); }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  color: #aab1d1;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  font-size: 13px;
  font-weight: 800;
}
.status-badge.online { color: #80ffe4; background: rgba(22,215,170,.12); border-color: rgba(22,215,170,.24); }

.deploy-button {
  position: absolute;
  left: 28px;
  right: 28px;
  bottom: 28px;
  justify-content: center;
  gap: 8px;
  height: 42px;
  border: 1px solid rgba(115,105,255,.34);
  color: #e1e5ff;
  background: rgba(105,96,255,.13);
  border-radius: 14px;
  font-weight: 800;
}

.content-panel {
  position: relative;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 28px;
}

.content-head { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.heading-row { gap: 12px; min-width: 0; }
.heading-row h1 { margin: 0; font-size: 30px; line-height: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.view-actions { gap: 8px; }

.icon-button, .back-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 13px;
  background: rgba(255,255,255,.05);
  color: #bec6ef;
}
.icon-button:hover, .back-button:hover { color: white; background: rgba(105,96,255,.16); border-color: rgba(130,125,255,.28); }
.icon-button svg, .back-button svg, .deploy-button svg, .fab svg, .dialog-close svg { width: 19px; height: 19px; }
.back-button { display: none; }

.service-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 340px));
  align-content: start;
  gap: 20px;
  padding: 0 98px 120px 0;
}

.service-card {
  position: relative;
  min-height: 258px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.035)), rgba(29,34,76,.75);
  box-shadow: 0 18px 54px rgba(0,0,0,.22);
}

.service-preview {
  position: relative;
  height: 168px;
  border-radius: 15px;
  overflow: hidden;
  border: 1px solid rgba(72,216,255,.45);
  background: var(--preview-bg);
}
.service-preview::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255,255,255,.14), rgba(4,8,29,.54)); }
.service-icon { position: absolute; z-index: 2; left: 20px; top: 20px; width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; color: white; background: var(--icon-bg); border: 2px solid rgba(255,255,255,.72); }
.service-icon svg { width: 22px; height: 22px; }
.preview-line, .preview-tile { position: absolute; z-index: 1; display: block; border-radius: 999px; background: rgba(230,245,255,.72); }
.preview-line.one { left: 64px; top: 32px; width: 58%; height: 13px; }
.preview-line.two { left: 64px; top: 58px; width: 78%; height: 7px; }
.preview-line.three { left: 64px; top: 78px; width: 38%; height: 7px; }
.preview-tile { bottom: 28px; width: 28%; height: 40px; background: rgba(235,248,255,.34); }
.preview-tile.a { left: 22px; } .preview-tile.b { left: 36%; } .preview-tile.c { right: 22px; }

.service-info { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 14px 8px 8px; align-items: start; }
.service-title { margin: 0; font-size: 21px; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.service-url, .service-status { color: #c3c9ed; font-size: 13px; margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.service-status { color: #78ffe4; }

.more-button { width: 34px; height: 34px; display: grid; place-items: center; border: 0; background: transparent; color: #d3d8fa; border-radius: 10px; }
.more-button:hover { background: rgba(255,255,255,.08); }
.more-button svg { width: 19px; height: 19px; fill: currentColor; stroke: none; }

.service-menu {
  position: absolute;
  right: 12px;
  bottom: 56px;
  z-index: 8;
  display: none;
  min-width: 132px;
  padding: 7px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  background: rgba(15,20,50,.95);
  box-shadow: 0 18px 44px rgba(0,0,0,.34);
}
.service-card.menu-open .service-menu { display: block; }
.service-menu button { width: 100%; border: 0; border-radius: 9px; padding: 9px 10px; color: white; background: transparent; text-align: left; }
.service-menu button:hover { background: rgba(255,255,255,.08); }

.session-section { flex: 0 0 auto; max-height: 140px; overflow: hidden; border-top: 1px solid rgba(255,255,255,.08); padding-top: 14px; }
.session-list { margin-top: 8px; display: grid; gap: 8px; max-height: 96px; overflow-y: auto; }
.session-item { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid rgba(255,255,255,.08); border-radius: 14px; background: rgba(255,255,255,.045); }
.session-main { min-width: 0; display: flex; align-items: center; gap: 12px; }
.session-icon { flex: 0 0 auto; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: #88f7ff; background: rgba(72,112,255,.18); }
.session-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.session-copy { min-width: 0; display: grid; gap: 3px; }
.session-item strong, .session-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-item strong { color: white; font-size: 13px; }
.session-item span { color: var(--muted); font-size: 12px; }
.session-actions { display: flex; gap: 8px; }
.session-actions .primary-button, .session-actions .secondary-button { min-height: 34px; padding: 0 12px; border-radius: 10px; font-size: 12px; }

.fab {
  position: absolute;
  right: 28px;
  bottom: 28px;
  z-index: 7;
  gap: 8px;
  min-width: 128px;
  height: 56px;
  justify-content: center;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 18px;
  color: white;
  font-weight: 850;
  background: linear-gradient(145deg, #6960ff, #8d69ff);
  box-shadow: 0 18px 48px rgba(105,96,255,.34);
}

.primary-button, .secondary-button {
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: 13px;
  padding: 0 18px;
  border: 1px solid transparent;
  font-weight: 850;
  color: white;
}
.primary-button { background: linear-gradient(145deg, #6960ff, #8d69ff); }
.secondary-button { background: rgba(255,255,255,.07); color: #d7ddff; border-color: rgba(255,255,255,.09); }

.app-dialog { border: 0; padding: 0; background: transparent; color: var(--text); }
.app-dialog::backdrop { background: rgba(4,7,24,.72); backdrop-filter: blur(8px); }
.dialog-card { position: relative; width: min(430px, calc(100vw - 32px)); padding: 28px; border-radius: 22px; display: grid; gap: 16px; }
.dialog-card h2 { margin: 0; font-size: 24px; }
.dialog-card label { display: grid; gap: 8px; color: #c9d0f5; font-size: 13px; font-weight: 800; }
.dialog-card input, .dialog-card textarea, .dialog-card select {
  width: 100%;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 13px;
  padding: 12px 14px;
  color: white;
  background: rgba(8,12,36,.68);
  outline: none;
}
.dialog-card input:focus, .dialog-card textarea:focus, .dialog-card select:focus { border-color: rgba(107,102,255,.7); box-shadow: 0 0 0 3px rgba(107,102,255,.18); }
.dialog-close { position: absolute; right: 18px; top: 18px; width: 38px; height: 38px; display: grid; place-items: center; border: 0; border-radius: 12px; color: #c6cdef; background: rgba(255,255,255,.06); }
.dialog-actions { display: grid; grid-template-columns: 1fr 1.2fr; gap: 12px; margin-top: 6px; }
.field-label-row { display: flex; justify-content: space-between; gap: 12px; }
.field-label-row small { color: var(--muted-2); font-weight: 700; }

.toast-container { position: fixed; right: 24px; bottom: 24px; z-index: 100; display: grid; gap: 10px; }
.toast { padding: 13px 16px; border: 1px solid rgba(255,255,255,.12); border-radius: 14px; background: rgba(20,25,58,.94); color: white; box-shadow: 0 18px 42px rgba(0,0,0,.32); }

.empty-state { grid-column: 1 / -1; display: grid; place-items: center; min-height: 240px; border: 1px dashed rgba(255,255,255,.14); border-radius: 22px; color: var(--muted); text-align: center; }
.empty-state.compact { min-height: 86px; border-radius: 16px; }
.empty-state strong { display: block; margin-bottom: 6px; color: white; font-size: 18px; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(129,140,248,.28); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(129,140,248,.44); }

@media (orientation: portrait) {
  body { overflow: hidden; }
  .topbar { height: 82px; padding: 0 18px; }
  .workspace { height: calc(100vh - 82px); display: block; }
  .connector-panel, .content-panel { position: absolute; inset: 0; border-right: 0; }
  .connector-panel { padding: 28px 18px; }
  .content-panel { display: none; padding: 22px 18px; }
  .workspace.services-open .connector-panel { display: none; }
  .workspace.services-open .content-panel { display: flex; }
  .back-button { display: grid; }
  .heading-row { flex: 1; }
  .heading-row h1 { font-size: 26px; }
  .content-head { align-items: center; margin-bottom: 18px; }
  .service-grid { grid-template-columns: minmax(0, 1fr); padding: 0 0 104px; gap: 18px; }
  .service-card { min-height: 252px; }
  .fab { right: 18px; bottom: 18px; height: 52px; }
  .session-section { display: none; }
  .account { gap: 8px; padding-left: 10px; }
  .avatar-copy strong { font-size: 13px; }
  .avatar-copy span { font-size: 11px; }
  .logout-button { display: none; }
}

@media (max-width: 520px) {
  .brand { font-size: 16px; }
  .brand-mark { width: 32px; height: 32px; }
  .avatar-image, .avatar-fallback { width: 34px; height: 34px; }
  .content-head { gap: 10px; }
  .view-actions { gap: 6px; }
  .icon-button, .back-button { width: 40px; height: 40px; }
}
