:root {
  --ink: #070d14;
  --ink-2: #101d2d;
  --panel: rgba(16, 29, 45, 0.7);
  --paper: #101d2d;
  --line: rgba(255, 255, 255, 0.06);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --gold: #f2c42d;
  --gold-2: #fbbf24;
  --danger: #f87171;
  --ok: #34d399;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  --glow: 0 0 20px rgba(242, 196, 45, 0.2);
  --glass-border: 1px solid rgba(255, 255, 255, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "DM Sans", "Inter", sans-serif;
  background: #04080c;
  background-image:
    radial-gradient(circle at 0% 0%, #101d2d 0%, transparent 50%),
    radial-gradient(circle at 100% 100%, rgba(242, 196, 45, 0.05) 0%, transparent 50%);
  background-attachment: fixed;
  overflow-x: hidden;
}

h1, h2, h3, .eyebrow, strong, .primary, label {
  font-family: "Outfit", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
  transition: all 0.2s ease;
}

.hidden {
  display: none !important;
}

@keyframes slideUpFade {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulseGlow {
  0% {
    box-shadow: 0 0 0 0 rgba(242, 196, 45, 0.4);
  }

  70% {
    box-shadow: 0 0 0 10px rgba(242, 196, 45, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(242, 196, 45, 0);
  }
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) 480px;
  background: linear-gradient(135deg, #050a0f 0%, #0a131d 50%, #04080c 100%);
  position: relative;
}

.login-shell::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  opacity: 0.5;
}

.login-brand {
  padding: clamp(32px, 6vw, 86px);
  color: white;
  display: grid;
  align-content: center;
  gap: 44px;
  position: relative;
  z-index: 1;
}

.login-brand::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 800px;
  height: 800px;
  background: radial-gradient(circle, rgba(242, 196, 45, 0.08) 0%, transparent 60%);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.login-brand img {
  width: min(430px, 82vw);
  border-radius: 6px;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.5));
  animation: slideUpFade 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  margin-bottom: 2rem;
}

.hero-title {
  max-width: 100%;
  margin: 0 0 16px 0;
  line-height: 1.1;
  letter-spacing: -0.02em;
  animation: slideUpFade 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
}

.hero-light {
  display: block;
  font-size: clamp(28px, 3.5vw, 44px);
  color: #94a3b8;
  font-weight: 300;
  margin-bottom: 2px;
}

.hero-gradient {
  display: block;
  font-size: clamp(38px, 5.5vw, 70px);
  background: linear-gradient(135deg, var(--gold) 0%, #f97316 40%, #db2777 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 20px rgba(242, 196, 45, 0.3));
  font-weight: 900;
}

.login-brand p {
  max-width: 680px;
  color: #cbd5e1;
  font-size: 1.125rem;
  line-height: 1.6;
  animation: slideUpFade 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
}

.eyebrow {
  color: var(--gold);
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: .2em;
  font-size: 13px;
}

.login-panel {
  margin: 40px;
  padding: 48px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.4));
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  align-self: center;
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.15), 0 30px 60px rgba(0,0,0,0.8);
  position: relative;
  z-index: 1;
  animation: slideUpFade 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
}

.login-panel h2 {
  margin: 0 0 32px;
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

label {
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.4);
  color: var(--text);
  border-radius: 8px;
  padding: 16px;
  outline: none;
  transition: all 0.3s ease;
  font-size: 16px;
  font-family: inherit;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
  background: rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 0 4px rgba(242, 196, 45, .15);
}

/* Chrome pinta los campos autocompletados con fondo claro; lo forzamos al tema oscuro. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px #0a1420 inset;
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: background-color 9999s ease-in-out 0s;
}

form {
  display: grid;
  gap: 24px;
}

.primary,
.ghost,
.send,
.icon-button {
  border: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 700;
}

.primary {
  color: #000;
  background: var(--gold);
  padding: 16px 24px;
  font-size: 16px;
  box-shadow: 0 0 25px rgba(242, 196, 45, 0.5);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.primary:hover {
  background: var(--gold-2);
  transform: translateY(-2px);
  box-shadow: 0 0 40px rgba(242, 196, 45, 0.8);
}

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

.form-error {
  color: var(--danger);
  min-height: 22px;
  font-size: 14px;
  font-weight: 600;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  background: rgba(10, 19, 30, 0.8);
  backdrop-filter: blur(20px);
  border-right: var(--glass-border);
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 10;
}

.sidebar-logo {
  padding: 32px 24px 24px;
}

.sidebar-logo img {
  width: 200px;
  max-width: 100%;
  display: block;
  border-radius: 6px;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4));
  transition: transform 0.3s ease;
}

.sidebar-logo img:hover {
  transform: scale(1.02);
}

nav {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 10px 16px;
}

.nav-item {
  height: 48px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  text-align: left;
  font-weight: 600;
  font-size: 15px;
  transition: all 0.2s ease;
}

.nav-item i {
  transition: color 0.2s ease;
}

.nav-item:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
  color: #000;
  background: var(--gold);
  box-shadow: 0 4px 12px rgba(242, 196, 45, 0.2);
}

.nav-item.active i {
  color: #000;
}

.profile-strip {
  min-height: 84px;
  display: grid;
  grid-template-columns: 46px 1fr 42px;
  align-items: center;
  gap: 14px;
  padding: 20px 24px;
  background: rgba(0, 0, 0, 0.2);
  border-top: var(--glass-border);
}

.avatar {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--ink-2) 0%, #1e3a5f 100%);
  border: var(--glass-border);
  color: var(--gold);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 16px;
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.1);
}

.profile-strip strong {
  font-size: 15px;
  display: block;
  margin-bottom: 2px;
}

.profile-strip span {
  display: block;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.icon-button {
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  transform: translateY(-1px);
}

.icon-button.danger {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.2);
}

.icon-button.danger:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.workspace {
  min-width: 0;
  background: transparent;
  position: relative;
}

.topbar {
  min-height: 88px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  background: rgba(10, 19, 30, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 16px 40px;
  border-bottom: var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.status-pill {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: var(--glass-border);
  font-weight: 700;
  font-size: 14px;
}

.status-pill span {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold);
}

.status-pill.ok span {
  background: var(--ok);
  box-shadow: 0 0 10px var(--ok);
}

.status-pill.bad span {
  background: var(--danger);
  box-shadow: 0 0 10px var(--danger);
  animation: pulseGlow 2s infinite;
}

.view-grid {
  padding: 40px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 32px;
  animation: slideUpFade 0.4s ease-out forwards;
}

.metric-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 20px;
}

.metric,
.panel {
  background: var(--panel);
  backdrop-filter: blur(16px);
  border: var(--glass-border);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.metric::before,
.panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
}

.metric:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  background: rgba(20, 35, 55, 0.8);
}

.metric {
  padding: 24px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric strong {
  display: block;
  margin-top: 12px;
  font-size: clamp(20px, 1.5vw, 26px);
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  line-height: 1.1;
}

.metric small {
  font-weight: 800;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
  padding: 4px 8px;
  border-radius: 6px;
}

.metric small.positive {
  color: var(--ok);
  background: rgba(16, 185, 129, 0.1);
}

.metric small.negative {
  color: var(--danger);
  background: rgba(248, 113, 113, 0.1);
}

.metric small.neutral {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
}

.forecast-card {
  border: 1px solid rgba(242, 196, 45, .3);
  background: linear-gradient(135deg, rgba(30, 40, 50, 0.8) 0%, rgba(50, 40, 20, 0.8) 100%);
}

.forecast-card strong {
  color: var(--gold);
  text-shadow: 0 0 15px rgba(242, 196, 45, 0.3);
}

.forecast-unavailable {
  border: 1px dashed rgba(148, 163, 184, 0.35);
  background: linear-gradient(135deg, rgba(20, 30, 42, 0.85), rgba(30, 36, 46, 0.75));
}

.forecast-unavailable strong {
  color: var(--muted);
  white-space: normal;
}

.forecast-unavailable small {
  line-height: 1.35;
}

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

.panel.wide {
  grid-column: 1 / -1;
}

.panel h2 {
  margin: 0 0 24px;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.panel-heading h2 {
  margin: 0;
}

.data-list {
  display: grid;
  gap: 12px;
}

.data-list div {
  padding: 16px;
  border: var(--glass-border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  transition: all 0.2s ease;
}

.data-list div:hover {
  background: rgba(255, 255, 255, 0.05);
  transform: translateX(4px);
}

.chat-main {
  min-height: calc(100vh - 168px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 24px 32px;
  gap: 16px;
}

#chatView > .panel:last-child {
  height: calc(100vh - 168px);
  display: flex;
  flex-direction: column;
}

.chat-header {
  padding-bottom: 8px;
  border-bottom: var(--glass-border);
  display: flex;
  justify-content: flex-end;
}

.chat-select {
  width: 250px;
  background: rgba(0, 0, 0, 0.4);
  color: var(--gold);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  transition: all 0.3s;
}

.chat-select:focus,
.chat-select:hover {
  border-color: var(--gold);
  background: rgba(0, 0, 0, 0.6);
  box-shadow: 0 0 10px rgba(242, 196, 45, 0.1);
}

.chat-select option {
  background: var(--panel);
  color: #fff;
}

.messages {
  display: grid;
  align-content: start;
  gap: 24px;
  overflow: auto;
  max-height: calc(100vh - 360px);
  padding-right: 12px;
}

.messages::-webkit-scrollbar {
  width: 6px;
}

.messages::-webkit-scrollbar-track {
  background: transparent;
}

.messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.message {
  max-width: 85%;
  padding: 20px 24px;
  border-radius: 16px;
  line-height: 1.6;
  font-size: 16px;
  position: relative;
  animation: slideUpFade 0.3s ease-out forwards;
}

.message.user {
  justify-self: end;
  background: linear-gradient(135deg, #1e3a5f 0%, #122435 100%);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.message.assistant {
  justify-self: start;
  background: rgba(15, 25, 35, 0.8);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(242, 196, 45, 0.3);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3), inset 0 2px 20px rgba(242, 196, 45, 0.05);
  border-bottom-left-radius: 4px;
}

.message.assistant::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--gold);
  border-radius: 4px 0 0 4px;
  box-shadow: 0 0 10px var(--gold);
}

.msg-label {
  color: var(--muted);
  display: block;
  margin-bottom: 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 800;
}

.markdown-body {
  color: var(--text);
}

.markdown-body p {
  margin: 0 0 16px;
}

.markdown-body p:last-child {
  margin: 0;
}

.markdown-body strong {
  color: #fff;
  font-weight: 700;
}

.markdown-body table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 20px;
  margin-bottom: 20px;
  font-size: 14px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  display: block;
  overflow-x: auto;
  white-space: nowrap;
}

.markdown-body th,
.markdown-body td {
  border-bottom: var(--glass-border);
  border-right: var(--glass-border);
  padding: 14px 16px;
  text-align: left;
}

.markdown-body th {
  background: rgba(0, 0, 0, 0.4);
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 12px;
}

.markdown-body tr {
  background: rgba(255, 255, 255, 0.02);
  transition: background 0.2s ease;
}

.markdown-body tr:hover {
  background: rgba(255, 255, 255, 0.06);
}

.markdown-body tr td:last-child,
.markdown-body tr th:last-child {
  border-right: none;
}

.markdown-body tr:last-child td {
  border-bottom: none;
}

.chat-input {
  margin-top: 24px;
  display: grid;
  grid-template-columns: 1fr 56px;
  gap: 16px;
  position: relative;
}

.chat-input input {
  padding: 20px 24px;
  font-size: 16px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
}

.chat-input input:focus {
  background: rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 0 2px rgba(242, 196, 45, 0.2);
}

.chat-input input::placeholder {
  color: var(--muted);
}

button.primary {
  background: var(--gold);
  color: #04080c;
  border: none;
  font-weight: 800;
  box-shadow: 0 0 15px rgba(242, 196, 45, 0.3);
}

button.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 20px rgba(242, 196, 45, 0.5);
  filter: brightness(1.1);
}

button.danger {
  background: #ef4444;
  color: #fff;
  border: none;
  font-weight: 800;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.3);
}

button.danger:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
  filter: brightness(1.1);
}

button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

button.ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.send {
  background: var(--gold);
  color: #000;
  border-radius: 12px;
  transition: all 0.3s ease;
}

.send:hover {
  transform: scale(1.05);
  box-shadow: 0 0 15px rgba(242, 196, 45, 0.4);
}

.send i {
  width: 22px;
  height: 22px;
}

.result-panel,
pre {
  white-space: pre-wrap;
  overflow: auto;
  background: rgba(0, 0, 0, 0.3);
  color: #60a5fa;
  border-radius: 12px;
  max-height: 480px;
  padding: 20px;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 14px;
  border: var(--glass-border);
}

.result-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 16px;
  background: transparent;
  padding-right: 12px;
  border: none;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
}

.result-panel::-webkit-scrollbar {
  width: 6px;
}

.result-panel::-webkit-scrollbar-track {
  background: transparent;
}

.result-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.sql-wrapper {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
}

.sql-box {
  background: #050a0f;
  color: #38bdf8;
  border-radius: 12px;
  padding: 20px;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 13px;
  border: 1px solid rgba(56, 189, 248, 0.2);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
  flex: 0 0 auto;
  margin-top: 8px;
  white-space: pre-wrap;
}

.table {
  display: grid;
  gap: 12px;
}

.stack-form {
  align-content: start;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.check input {
  width: auto;
  cursor: pointer;
}

.message.status .status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-style: italic;
}

.message.status .status-line svg {
  width: 16px;
  height: 16px;
  animation: statusSpin 1.2s linear infinite;
}

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

/* Aviso de sistema en el chat (ej. cambio de conexión) */
.chat-notice {
  display: flex;
  justify-content: center;
  margin: 18px 0;
}

.chat-notice span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(242, 196, 45, 0.08);
  border: 1px solid rgba(242, 196, 45, 0.25);
  color: var(--gold);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.chat-notice svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.file-label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.file-label input[type="file"] {
  width: 100%;
  padding: 10px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  cursor: pointer;
}

.file-label input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 6px 14px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: inherit;
  cursor: pointer;
}

.table-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.1fr) minmax(160px, 1.4fr) auto auto auto max-content;
  gap: 16px;
  align-items: center;
  padding: 16px 20px;
  border: var(--glass-border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  transition: all 0.2s ease;
}

.table-row:hover {
  background: rgba(255, 255, 255, 0.06);
  transform: scale(1.01);
}

.message-table {
  margin-top: 20px;
  margin-bottom: 20px;
  display: grid;
  border: var(--glass-border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.message-table-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0;
  border-top: var(--glass-border);
  background: rgba(255, 255, 255, 0.02);
  transition: background 0.2s ease;
}

.message-table-row:not(:first-child):hover {
  background: rgba(255, 255, 255, 0.06);
}

.message-table-row:first-child {
  border-top: 0;
  background: rgba(0, 0, 0, 0.4);
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 12px;
}

.message-table-row span {
  padding: 14px 16px;
  overflow-wrap: anywhere;
  border-right: var(--glass-border);
}

.message-table-row span:last-child {
  border-right: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  justify-self: start;
}

.badge.admin,
.badge.default {
  background: rgba(242, 196, 45, 0.15);
  color: var(--gold);
  border: 1px solid rgba(242, 196, 45, 0.3);
}

.badge.ok {
  background: rgba(16, 185, 129, 0.15);
  color: var(--ok);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge.bad {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.rank-list {
  display: grid;
  gap: 12px;
}

.rank-item {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border: var(--glass-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  transition: all 0.2s ease;
}

.rank-item:hover {
  background: rgba(255, 255, 255, 0.05);
  transform: translateX(4px);
}

.rank-number {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(242, 196, 45, 0.1);
  color: var(--gold);
  font-weight: 800;
  font-size: 16px;
  border: 1px solid rgba(242, 196, 45, 0.3);
}

.rank-item span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

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

.health-card {
  border: var(--glass-border);
  border-top: 4px solid var(--ok);
  border-radius: 12px;
  padding: 24px;
  background: rgba(255, 255, 255, 0.02);
  transition: all 0.3s ease;
}

.health-card:hover {
  transform: translateY(-4px);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.health-card.bad {
  border-top-color: var(--danger);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.1);
}

.health-card.warn {
  border-top-color: var(--gold);
}

.health-card h3 {
  margin: 0 0 12px;
  font-size: 18px;
  color: #fff;
}

.health-card p {
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

svg.lucide {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal:not(.hidden) {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  width: 90%;
  max-width: 1200px;
  padding: 24px;
  position: relative;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal:not(.hidden) .modal-content {
  transform: scale(1);
}

.modal-header {
  padding: 24px 32px;
  border-bottom: var(--glass-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
}

.modal-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
}

.modal-body {
  padding: 32px;
  background: rgba(0, 0, 0, 0.4);
  height: 500px;
  display: flex;
}

.plotly-surface {
  flex: 1;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.dashboard-plot-shell {
  position: relative;
  height: 380px;
  width: 100%;
}

#chatArtifactPlot,
#dashboardTrendPlot {
  position: relative;
}

.plotly-surface .modebar {
  opacity: 0;
  transform: translateY(-4px);
  padding: 5px 7px !important;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  background: rgba(7, 13, 20, 0.86) !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.plotly-surface:hover .modebar,
.plotly-surface:focus-within .modebar {
  opacity: 1;
  transform: translateY(0);
}

.plotly-surface .modebar-btn path {
  fill: var(--muted) !important;
  transition: fill 0.15s ease;
}

.plotly-surface .modebar-btn:hover path {
  fill: var(--gold) !important;
}

@media (hover: none) {
  .plotly-surface .modebar {
    opacity: 0.78;
    transform: none;
  }
}

.plot-error {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 980px) {

  .login-shell,
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    border-right: none;
    border-bottom: var(--glass-border);
    position: static;
    height: auto;
  }

  nav {
    display: flex;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 12px;
    scrollbar-width: none;
  }

  nav::-webkit-scrollbar {
    display: none;
  }

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

  .view-grid {
    grid-template-columns: 1fr;
    padding: 24px;
  }

  .health-grid {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  }
}

@media (max-width: 768px) {
  .topbar {
    padding: 16px 24px;
  }

  .table-row {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 16px;
    align-items: start;
  }

  .table-row>* {
    display: block;
    width: 100%;
    text-align: left;
  }

  .table-row button {
    justify-content: center;
  }
}

@media (max-width: 560px) {
  .login-brand {
    padding: 32px 24px;
    text-align: center;
  }

  .login-brand h1 {
    font-size: 36px;
  }

  .login-panel {
    margin: 16px;
    padding: 32px 24px;
  }

  .view-grid {
    padding: 16px;
    gap: 16px;
  }

  .panel,
  .metric {
    padding: 20px;
  }

  .chat-main {
    padding: 16px;
  }

  .chat-input {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .chat-input input {
    padding: 16px;
  }

  .chat-input button {
    height: 50px;
    width: 100%;
  }
}
