:root {
  color-scheme: dark;
  --bg: #080b10;
  --panel: #101722;
  --panel-2: #141e2b;
  --line: #233247;
  --text: #eef5ff;
  --muted: #9fb0c3;
  --blue: #2f8cff;
  --green: #21d07a;
  --red: #ff5570;
  --yellow: #f2c94c;
  --violet: #9a6cff;
  --shadow: 0 22px 70px rgba(0, 0, 0, .38);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  background: radial-gradient(circle at 70% 0%, rgba(47, 140, 255, .16), transparent 30%), var(--bg);
  color: var(--text);
  font-family: Inter, Segoe UI, Arial, sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  background: var(--blue);
  color: white;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, border-color .16s ease;
}

button:hover {
  transform: translateY(-1px);
}

.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  background: transparent;
}

.sidebar {
  min-height: 100vh;
  max-height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: rgba(11, 16, 24, .86);
  backdrop-filter: blur(18px);
  padding: 20px 14px;
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 20px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--blue), var(--green));
  color: #021018;
  font-weight: 900;
}

.brand span,
.tenant-switch span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

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

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  border: 1px solid transparent;
}

.nav-item.active,
.nav-item:hover {
  color: var(--text);
  background: rgba(47, 140, 255, .10);
  border-color: rgba(47, 140, 255, .24);
}

.nav-icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, .07);
}

.shell {
  min-width: 0;
}

.topbar {
  min-height: 76px;
  display: grid;
  grid-template-columns: 190px minmax(240px, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 11, 16, .66);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 4;
}

.search {
  height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .05);
}

.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.status-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.pill.good {
  border-color: rgba(33, 208, 122, .35);
  color: #9ff4c8;
}

.pill.warn {
  border-color: rgba(242, 201, 76, .38);
  color: #ffe08a;
}

.pill.danger {
  border-color: rgba(255, 85, 112, .38);
  color: #ff9dad;
}

.content {
  padding: 24px;
}

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

.page-head h1 {
  margin: 0 0 8px;
  font-size: clamp(26px, 3vw, 42px);
  letter-spacing: 0;
}

.page-head p {
  margin: 0;
  color: var(--muted);
  max-width: 780px;
  line-height: 1.55;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi,
.panel,
.table-wrap,
.kanban-column,
.chat-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .025));
  box-shadow: var(--shadow);
}

.kpi {
  padding: 16px;
  min-height: 120px;
}

.kpi span {
  color: var(--muted);
  font-size: 13px;
}

.kpi strong {
  display: block;
  margin-top: 12px;
  font-size: 28px;
}

.kpi small {
  display: block;
  margin-top: 10px;
  color: var(--green);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.25fr .75fr;
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.panel {
  padding: 16px;
  min-width: 0;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.chart {
  height: 230px;
  display: flex;
  align-items: end;
  gap: 10px;
  padding-top: 20px;
}

.bar {
  flex: 1;
  min-width: 18px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--blue), var(--green));
}

.event-list,
.alert-list {
  display: grid;
  gap: 10px;
}

.event,
.alert,
.kanban-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, .04);
}

.event strong,
.alert strong,
.kanban-card strong {
  display: block;
  margin-bottom: 6px;
}

.event span,
.alert span,
.kanban-card span {
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  color: #dbe7f5;
}

.actions {
  display: flex;
  gap: 7px;
}

.actions button {
  padding: 7px 9px;
}

.kanban {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 14px;
  overflow-x: auto;
}

.kanban-column {
  padding: 12px;
  min-height: 320px;
}

.kanban-column h2 {
  margin: 0 0 12px;
  font-size: 15px;
  color: var(--muted);
}

.kanban-card {
  margin-bottom: 10px;
}

.brain-button {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 60px;
  height: 60px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--violet), var(--blue));
  font-weight: 900;
  box-shadow: 0 18px 45px rgba(47, 140, 255, .35);
  z-index: 8;
}

.chat-layout {
  display: grid;
  grid-template-columns: 260px 1fr 280px;
  gap: 16px;
}

.chat-panel {
  padding: 14px;
  min-height: 520px;
}

.messages {
  height: 390px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 6px;
}

.message {
  max-width: 82%;
  padding: 12px;
  border-radius: 8px;
  background: rgba(47, 140, 255, .13);
  border: 1px solid rgba(47, 140, 255, .26);
}

.message.ai {
  align-self: flex-start;
}

.message.user {
  align-self: flex-end;
  background: rgba(33, 208, 122, .12);
  border-color: rgba(33, 208, 122, .24);
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 12px;
}

.composer input,
.form-grid input,
.form-grid select,
.form-grid textarea,
.sql-box {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, .06);
  color: var(--text);
  padding: 11px 12px;
  outline: 0;
}

dialog {
  width: min(780px, calc(100vw - 26px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(0, 0, 0, .62);
}

dialog header,
dialog footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

dialog footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}

.form-grid label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.span-2 {
  grid-column: 1 / -1;
}

.sql-box {
  min-height: 180px;
  resize: vertical;
  font-family: Consolas, monospace;
}

@media (max-width: 1100px) {
  body {
    grid-template-columns: 88px 1fr;
  }

  .brand div:not(.brand-mark),
  .nav-label {
    display: none;
  }

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

  .status-strip {
    justify-content: flex-start;
  }

  .kpi-grid,
  .grid-2,
  .grid-3,
  .chat-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  body {
    display: block;
  }

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

  nav {
    display: flex;
    overflow-x: auto;
  }

  .nav-item {
    width: auto;
    white-space: nowrap;
  }

  .content {
    padding: 16px;
  }

  .page-head {
    display: grid;
  }

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