:root {
  color-scheme: dark;
  --bg: #111318;
  --panel: #181c23;
  --panel-strong: #202734;
  --border: #303846;
  --text: #eef2f8;
  --muted: #a6b0bf;
  --accent: #23c483;
  --accent-strong: #67e0ae;
  --danger: #ff6b6b;
  --blue: #60a5fa;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body.auth-required {
  overflow: hidden;
}

button,
a {
  font: inherit;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    linear-gradient(135deg, rgba(35, 196, 131, 0.14), transparent 32%),
    linear-gradient(315deg, rgba(96, 165, 250, 0.16), transparent 34%),
    #0d1016;
}

.auth-screen[hidden] {
  display: none;
}

.auth-card {
  display: grid;
  gap: 17px;
  width: min(100%, 390px);
  padding: 26px;
  border: 1px solid rgba(238, 242, 248, 0.12);
  border-radius: 8px;
  background: rgba(24, 28, 35, 0.94);
  box-shadow: var(--shadow);
}

.auth-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 1px solid rgba(35, 196, 131, 0.5);
  border-radius: 8px;
  background: rgba(35, 196, 131, 0.13);
  color: var(--accent-strong);
  font-size: 18px;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 17px;
  line-height: 1.2;
}

.password-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.password-field input {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: 0;
  background: #10141c;
  color: var(--text);
  font: inherit;
}

.password-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(35, 196, 131, 0.16);
}

.auth-error {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
}

.primary-button {
  height: 46px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #07120d;
  font-weight: 800;
  cursor: pointer;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.auth-card.is-loading .primary-button {
  opacity: 0.72;
  pointer-events: none;
}

.app {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100%;
  transition: grid-template-columns 160ms ease;
}

body.sidebar-collapsed .app {
  grid-template-columns: 76px minmax(0, 1fr);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: 100vh;
  padding: 18px;
  background: #151922;
  border-right: 1px solid var(--border);
}

.brand {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 40px;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(35, 196, 131, 0.55);
  border-radius: 8px;
  background: rgba(35, 196, 131, 0.12);
  color: var(--accent-strong);
  font-weight: 800;
}

.brand p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.service-list {
  display: grid;
  gap: 8px;
}

.service-button {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.service-button:hover {
  background: rgba(255, 255, 255, 0.05);
}

.service-button[aria-current="page"] {
  background: var(--panel-strong);
  border-color: rgba(35, 196, 131, 0.45);
  box-shadow: inset 3px 0 0 var(--accent);
}

.service-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--accent-strong);
}

.service-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.service-name {
  overflow: hidden;
  font-size: 14px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.service-description,
.service-url {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.service-url {
  font-size: 11px;
}

.hint {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  padding: 14px 18px;
  background: rgba(17, 19, 24, 0.92);
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h2 {
  overflow-wrap: anywhere;
  font-size: 22px;
  line-height: 1.18;
}

.actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.icon-button:hover {
  border-color: rgba(35, 196, 131, 0.55);
}

.icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.collapse-button svg {
  transition: transform 160ms ease;
}

body.sidebar-collapsed .collapse-button svg {
  transform: rotate(180deg);
}

body.sidebar-collapsed .sidebar {
  align-items: center;
  padding-inline: 13px;
}

body.sidebar-collapsed .brand {
  grid-template-columns: 48px;
}

body.sidebar-collapsed .brand > div:nth-child(2),
body.sidebar-collapsed .hint,
body.sidebar-collapsed .service-name,
body.sidebar-collapsed .service-description,
body.sidebar-collapsed .service-url {
  display: none;
}

body.sidebar-collapsed .collapse-button {
  width: 48px;
}

body.sidebar-collapsed .service-list {
  justify-items: center;
  width: 48px;
  grid-template-columns: 48px;
}

body.sidebar-collapsed .service-button {
  grid-template-columns: 1fr;
  justify-items: center;
  justify-self: center;
  width: 48px;
  max-width: 48px;
  height: 48px;
  min-height: 48px;
  padding: 4px;
  aspect-ratio: 1;
}

body.sidebar-collapsed .service-icon {
  width: 38px;
  height: 38px;
}

body.sidebar-collapsed .service-button[aria-current="page"] {
  box-shadow: none;
}

.frame-shell {
  position: relative;
  min-width: 0;
  min-height: 0;
  margin: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0b0d12;
  box-shadow: var(--shadow);
}

iframe {
  display: none;
  width: 100%;
  height: 100%;
  min-height: calc(100vh - 106px);
  border: 0;
  background: #ffffff;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.empty-state h3 {
  color: var(--text);
  font-size: 24px;
}

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

body.has-selection iframe {
  display: block;
}

body.has-selection .empty-state {
  display: none;
}

@media (max-width: 760px) {
  .app,
  body.sidebar-collapsed .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .service-list {
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  }

  .service-button {
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 7px;
  }

  body.sidebar-collapsed .service-list {
    grid-template-columns: repeat(auto-fit, minmax(52px, 1fr));
    width: 100%;
  }

  body.sidebar-collapsed .service-button {
    grid-template-columns: 1fr;
  }

  .topbar {
    min-height: 70px;
  }

  h2 {
    font-size: 18px;
  }

  iframe {
    min-height: 70vh;
  }
}
