:root {
  color-scheme: dark;
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1d212b;
  --border: #232735;
  --border-strong: #30364a;
  --text: #e8eaf0;
  --muted: #8b90a0;
  --muted-2: #a9aebe;
  --accent: #7c6cf0;
  --accent-2: #9b8cff;
  --green: #3ddc85;
  --red: #ff5c5c;
  --amber: #f0b85f;
  --blue: #61a8ff;
  --sidebar: 220px;
  --radius: 12px;
  --shadow: 0 18px 60px rgb(0 0 0 / 34%);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: linear-gradient(180deg, #10131a 0%, var(--bg) 42%, #101215 100%);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
textarea:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: .55;
}

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

.login-screen,
.boot-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-card,
.boot-card {
  width: min(100%, 430px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgb(29 33 43 / 96%), rgb(23 26 33 / 98%));
  box-shadow: var(--shadow);
  padding: 28px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid rgb(124 108 240 / 45%);
  border-radius: 10px;
  background: rgb(124 108 240 / 12%);
  color: var(--accent-2);
  font-weight: 800;
}

.login-card h1,
.boot-card h1 {
  margin: 18px 0 8px;
  font-size: 1.55rem;
  line-height: 1.2;
}

.login-card p,
.boot-card p {
  margin: 0 0 22px;
  color: var(--muted);
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 15px;
}

.field span {
  color: var(--muted-2);
  font-size: .86rem;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #11141b;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.textarea {
  min-height: 54px;
  max-height: 180px;
  resize: none;
  line-height: 1.45;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: rgb(124 108 240 / 82%);
  box-shadow: 0 0 0 3px rgb(124 108 240 / 16%);
  background: #141823;
}

.error-text {
  min-height: 20px;
  color: #ff8a8a;
  font-size: .9rem;
}

.primary-btn,
.ghost-btn,
.danger-btn,
.subtle-btn,
.chip-btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 13px;
  color: var(--text);
  background: transparent;
  transition: transform .14s ease, border-color .14s ease, background .14s ease, color .14s ease;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), #5d9dff);
  box-shadow: 0 10px 28px rgb(124 108 240 / 22%);
  font-weight: 700;
}

.ghost-btn {
  border-color: var(--border);
  background: #121620;
}

.subtle-btn {
  border-color: var(--border);
  background: rgb(255 255 255 / 3%);
  color: var(--muted-2);
}

.danger-btn {
  border-color: rgb(255 92 92 / 35%);
  background: rgb(255 92 92 / 10%);
  color: #ffb0b0;
}

.chip-btn {
  padding: 8px 11px;
  border-color: var(--border);
  background: #121620;
  color: var(--muted-2);
  font-size: .86rem;
}

.primary-btn:hover,
.ghost-btn:hover,
.danger-btn:hover,
.subtle-btn:hover,
.chip-btn:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
}

.app-shell {
  min-height: 100vh;
  padding-left: var(--sidebar);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  border-right: 1px solid var(--border);
  background: rgb(15 17 21 / 92%);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  z-index: 20;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 6px 16px;
}

.sidebar-brand strong {
  display: block;
  font-size: 1.04rem;
}

.sidebar-brand small {
  color: var(--muted);
}

.live-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 6px 18px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted-2);
  background: #121620;
  font-size: .84rem;
}

.dot,
.live-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 50%;
  background: #5f6574;
  box-shadow: 0 0 0 3px rgb(95 101 116 / 12%);
}

.dot.up,
.live-dot.is-live {
  background: var(--green);
  box-shadow: 0 0 0 3px rgb(61 220 133 / 14%), 0 0 16px rgb(61 220 133 / 28%);
}

.dot.down {
  background: var(--red);
  box-shadow: 0 0 0 3px rgb(255 92 92 / 14%);
}

.nav {
  display: grid;
  gap: 5px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 11px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted-2);
  transition: background .14s ease, border-color .14s ease, color .14s ease;
}

.nav-glyph {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgb(255 255 255 / 4%);
  color: var(--muted);
  font-size: .8rem;
  font-weight: 800;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text);
  background: rgb(124 108 240 / 10%);
  border-color: rgb(124 108 240 / 26%);
}

.nav-link.active .nav-glyph {
  color: white;
  background: var(--accent);
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 6px 0;
  border-top: 1px solid var(--border);
}

.user-meta {
  margin-bottom: 12px;
}

.user-meta strong {
  display: block;
  overflow-wrap: anywhere;
}

.user-meta span {
  color: var(--muted);
  font-size: .86rem;
}

.main {
  min-height: 100vh;
  padding: 22px 28px 34px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.45rem, 2.2vw, 2.15rem);
  line-height: 1.12;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.banner {
  position: sticky;
  top: 14px;
  z-index: 15;
  margin-bottom: 16px;
  border: 1px solid rgb(240 184 95 / 36%);
  border-radius: var(--radius);
  background: rgb(240 184 95 / 12%);
  color: #ffd89d;
  padding: 11px 13px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 20%);
}

.view {
  animation: fade-in .18s ease both;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.stat-card,
.panel,
.table-wrap,
.empty-state,
.access-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgb(23 26 33 / 88%);
  box-shadow: 0 12px 30px rgb(0 0 0 / 14%);
}

.stat-card {
  padding: 17px;
}

.stat-card span {
  color: var(--muted);
  font-size: .86rem;
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-size: 1.85rem;
  line-height: 1;
}

.stat-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.ops-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, .8fr);
  gap: 16px;
}

.telemetry-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.panel {
  padding: 16px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-header h2,
.panel-header h3 {
  margin: 0;
  font-size: 1rem;
}

.muted,
.panel-header span {
  color: var(--muted);
}

.container-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 11px;
}

.container-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px;
  background: #121620;
}

.container-card-top,
.status-line {
  display: flex;
  align-items: center;
  gap: 9px;
}

.container-card strong,
.status-line strong {
  overflow-wrap: anywhere;
}

.container-card code,
.proposal-card code,
.mono,
.log-pane,
.message-content {
  font-family: ui-monospace, Consolas, "SFMono-Regular", Menlo, monospace;
}

.container-card code,
.proposal-card code {
  display: inline-block;
  max-width: 100%;
  color: #c6ccda;
  overflow-wrap: anywhere;
}

.container-status {
  margin: 10px 0 0 19px;
  color: var(--muted-2);
  overflow-wrap: anywhere;
}

.event-list {
  display: grid;
  gap: 10px;
  max-height: 390px;
  overflow: auto;
  padding-right: 4px;
}

.event-item {
  display: grid;
  gap: 4px;
  border-left: 2px solid rgb(124 108 240 / 64%);
  padding-left: 10px;
}

.event-item strong {
  font-size: .9rem;
}

.event-item time {
  color: var(--muted);
  font-size: .78rem;
}

.log-pane {
  min-height: 170px;
  max-height: 330px;
  overflow: auto;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: #0c0f14;
  color: #d8dce8;
  font-size: .84rem;
  line-height: 1.48;
}

.console-layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  min-height: calc(100vh - 112px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: rgb(23 26 33 / 88%);
}

.session-rail {
  border-right: 1px solid var(--border);
  background: rgb(18 22 32 / 82%);
  padding: 14px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.rail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.rail-header h2 {
  margin: 0;
  font-size: 1rem;
}

.session-list {
  display: grid;
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}

.session-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #11151e;
  transition: border-color .14s ease, background .14s ease;
}

.session-item.active {
  border-color: rgb(124 108 240 / 52%);
  background: rgb(124 108 240 / 10%);
}

.session-select {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 11px 11px 6px;
}

.session-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.session-select small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: .78rem;
}

.session-actions {
  display: flex;
  gap: 6px;
  padding: 0 8px 8px;
}

.mini-btn {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgb(255 255 255 / 3%);
  color: var(--muted-2);
  padding: 5px 8px;
  font-size: .76rem;
}

.mini-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

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

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.chat-header h2 {
  margin: 0;
  font-size: 1.08rem;
  overflow-wrap: anywhere;
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 13px;
  min-height: 0;
  overflow: auto;
  padding: 18px;
  scroll-behavior: smooth;
}

.bubble {
  max-width: min(780px, 86%);
  display: grid;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 13px;
  background: #11151e;
}

.bubble.user {
  align-self: flex-end;
  background: rgb(124 108 240 / 18%);
  border-color: rgb(124 108 240 / 34%);
}

.bubble.assistant {
  align-self: flex-start;
}

.bubble.system {
  align-self: center;
  max-width: min(720px, 92%);
  background: rgb(61 220 133 / 8%);
  border-color: rgb(61 220 133 / 24%);
}

.bubble-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: .78rem;
}

.message-content {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.48;
  color: #f1f3f8;
}

.message-content code {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #0c0f14;
  color: #dce1ee;
  padding: 1px 5px;
  font-size: .9em;
}

.message-code {
  margin: 8px 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0c0f14;
  padding: 10px;
  white-space: pre;
}

.message-code code {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

.proposal-card {
  border: 1px solid rgb(124 108 240 / 34%);
  border-radius: 10px;
  background: rgb(124 108 240 / 9%);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.proposal-card h3 {
  margin: 0;
  font-size: .93rem;
}

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

.thinking {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted-2);
}

.thinking i {
  width: 7px;
  height: 7px;
  display: inline-block;
  border-radius: 50%;
  background: var(--accent-2);
  animation: blink 1s infinite ease-in-out;
}

.thinking i:nth-child(2) {
  animation-delay: .15s;
}

.thinking i:nth-child(3) {
  animation-delay: .3s;
}

@keyframes blink {
  0%,
  80%,
  100% {
    opacity: .28;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

.chat-composer {
  border-top: 1px solid var(--border);
  padding: 13px;
  background: rgb(15 18 26 / 92%);
}

.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.composer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.table-wrap {
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
  background: rgb(255 255 255 / 2%);
}

.topbar .live-pill {
  margin: 0;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table code {
  font-family: ui-monospace, Consolas, "SFMono-Regular", Menlo, monospace;
  color: #dce1ee;
  overflow-wrap: anywhere;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.section-stack {
  display: grid;
  gap: 16px;
}

.empty-state,
.access-card {
  padding: 26px;
  text-align: center;
  color: var(--muted);
}

.empty-state strong,
.access-card strong {
  display: block;
  margin-bottom: 7px;
  color: var(--text);
}

.users-layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.create-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgb(23 26 33 / 88%);
  padding: 16px;
}

.create-card h2 {
  margin: 0 0 14px;
  font-size: 1rem;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted-2);
}

.toggle input {
  width: 38px;
  height: 20px;
  accent-color: var(--accent);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgb(0 0 0 / 34%);
}

.log-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 40;
  width: min(620px, 100vw);
  border-left: 1px solid var(--border);
  background: #11141b;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  animation: slide-in .16s ease both;
}

@keyframes slide-in {
  from {
    transform: translateX(24px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding: 16px;
}

.drawer-header h2 {
  margin: 0;
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.drawer-body {
  min-height: 0;
  overflow: auto;
  padding: 16px;
}

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100vw - 32px));
}

.toast {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #171a21;
  color: var(--text);
  padding: 12px 13px;
  box-shadow: var(--shadow);
  animation: toast-in .16s ease both;
}

.toast.error {
  border-color: rgb(255 92 92 / 38%);
}

.toast.success {
  border-color: rgb(61 220 133 / 34%);
}

.toast.warn {
  border-color: rgb(240 184 95 / 42%);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.loading-line {
  height: 11px;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #191e29, #252c3c, #191e29);
  background-size: 240% 100%;
  animation: shimmer 1.2s infinite linear;
}

.loading-stack {
  display: grid;
  gap: 10px;
}

@keyframes shimmer {
  to {
    background-position: -240% 0;
  }
}

@media (max-width: 1040px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ops-grid,
  .telemetry-grid,
  .users-layout {
    grid-template-columns: 1fr;
  }

  .console-layout {
    grid-template-columns: 240px minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding-left: 0;
    padding-top: 86px;
  }

  .sidebar {
    width: 100%;
    height: 86px;
    inset: 0 0 auto 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    padding: 10px 12px;
  }

  .sidebar-brand,
  .live-pill,
  .sidebar-footer {
    display: none;
  }

  .nav {
    display: flex;
    overflow-x: auto;
    gap: 8px;
  }

  .nav-link {
    flex: 0 0 auto;
  }

  .main {
    padding: 18px 14px 28px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }

  .console-layout {
    grid-template-columns: 1fr;
  }

  .session-rail {
    max-height: 260px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .bubble {
    max-width: 94%;
  }

  .composer-row {
    grid-template-columns: 1fr;
  }

  .data-table {
    min-width: 720px;
  }

  .table-wrap {
    overflow-x: auto;
  }
}
