/* Console — login + authenticated workspace */

.page-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background:
    radial-gradient(ellipse 80% 60% at 80% 10%, var(--accent-soft), transparent),
    radial-gradient(ellipse 60% 50% at 10% 90%, var(--violet-soft), transparent),
    linear-gradient(165deg, #f8fafc, #eef2ff);
}

.login-shell {
  width: 100%;
  max-width: 430px;
}

.login-card {
  padding: 2rem 2.15rem;
}

.login-brand {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.35rem;
}

.login-brand .logo-mark {
  background: linear-gradient(145deg, var(--accent-hover), var(--violet));
  color: #fff;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  flex-shrink: 0;
}

.login-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 800;
}

.login-sub {
  margin: 0.35rem 0 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-hint {
  margin: 1.15rem 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--muted);
}

/* App shell */
.app-shell {
  display: grid;
  grid-template-columns: 268px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #0f172a 0%, #111827 60%);
  color: #e2e8f0;
  padding: 1.35rem 1.1rem;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.05rem;
  margin-bottom: 1.75rem;
}

.sidebar-brand .logo-mark {
  background: linear-gradient(145deg, var(--accent-hover), var(--violet));
  color: #fff;
  border-radius: var(--radius-sm);
  width: 2.35rem;
  height: 2.35rem;
  display: grid;
  place-items: center;
  font-size: 1rem;
}

.console-home {
  color: #94a3b8;
  font-size: 0.82rem;
  margin-bottom: 1rem;
}

.console-home a {
  color: #cbd5e1;
  text-decoration: none;
}

.console-home a:hover {
  color: #fff;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.68rem 0.85rem;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: #94a3b8;
  font: inherit;
  font-size: 0.93rem;
  text-align: left;
  cursor: pointer;
  transition:
    background 0.12s,
    color 0.12s;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #f8fafc;
}

.nav-item.active {
  background: rgba(13, 148, 136, 0.22);
  color: #fff;
}

a.nav-item {
  text-decoration: none;
}

.nav-icon {
  opacity: 0.85;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  margin-bottom: 0.65rem;
  color: #cbd5e1;
}

.user-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-hover);
  box-shadow: 0 0 12px var(--accent-glow);
}

.logout-form {
  margin: 0;
}

.page-dashboard .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.main {
  padding: 2rem 2.5rem 3rem;
  overflow-x: hidden;
}

.main-header {
  margin-bottom: 1.65rem;
}

.main-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 800;
}

.main-desc {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.98rem;
}

.panel {
  animation: fadeIn 0.22s ease;
}

.panel[hidden] {
  display: none !important;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.grid-stack {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  padding: 1.35rem;
}

.card-elevated {
  background: var(--paper);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}

.card-title {
  margin: 0;
  font-size: 1.05rem;
  font-family: var(--font-display);
}

.card-lead {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.code-block {
  margin: 0.75rem 0 0;
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--mist);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  overflow: auto;
  max-height: 140px;
}

.code-block.empty {
  color: var(--muted);
}

.tips {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.tips li + li {
  margin-top: 0.45rem;
}

.market-banner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  padding: 1.25rem 1.35rem;
  border-radius: var(--radius);
  background: linear-gradient(120deg, var(--accent-soft), var(--violet-soft));
  border: 1px solid var(--line);
  margin-bottom: 1.35rem;
}

.market-banner h3 {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
}

.market-banner p {
  margin: 0;
  color: var(--muted);
  max-width: 42rem;
}

.subscription-strip {
  margin: -0.5rem 0 1rem;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 0.88rem;
}

.agent-market-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.agent-card {
  padding: 1.15rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  text-align: left;
  cursor: pointer;
  transition:
    box-shadow 0.15s,
    transform 0.1s;
  font: inherit;
}

.agent-card:hover:not(:disabled) {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.agent-card:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.agent-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.agent-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.agent-card h4 {
  margin: 0;
  font-size: 1rem;
}

.agent-card .tagline {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.agent-card .desc {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
  flex: 1;
}

.agent-card-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-sm);
  background: var(--mist);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: var(--accent);
}

.chat-agent-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 1rem;
  background: var(--mist);
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}

.chat-agent-bar strong {
  font-family: var(--font-display);
}

.chat-layout {
  display: flex;
  flex-direction: column;
  max-width: 880px;
  padding: 0;
  overflow: hidden;
  border-radius: var(--radius);
}

.chat-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.chat-transcript {
  min-height: 300px;
  max-height: 48vh;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  background: linear-gradient(180deg, #fafbfc, #fff);
}

.chat-bubble {
  max-width: 92%;
  padding: 0.85rem 1.05rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  line-height: 1.5;
}

.chat-bubble.user {
  align-self: flex-end;
  background: linear-gradient(165deg, var(--accent-hover), var(--accent));
  color: #fff;
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.chat-bubble .citations {
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  font-size: 0.82rem;
  color: var(--muted);
}

.chat-form {
  padding: 1rem 1.25rem 1.35rem;
  border-top: 1px solid var(--line);
  background: var(--mist);
}

.chat-actions {
  margin-top: 0.65rem;
  display: flex;
  justify-content: flex-end;
}

.upload-form {
  display: grid;
  gap: 1rem;
  max-width: 520px;
}

.table-wrap {
  overflow: auto;
  margin-top: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.table th,
.table td {
  padding: 0.68rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.table th {
  background: var(--mist);
  font-weight: 650;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.table .center {
  text-align: center;
}

.col-actions {
  width: 200px;
  text-align: right;
}

.row-actions {
  display: flex;
  gap: 0.35rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.toast-stack {
  position: fixed;
  bottom: 1.35rem;
  right: 1.35rem;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(380px, calc(100vw - 2rem));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 0.85rem 1.05rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  animation: slideUp 0.22s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.toast-success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.toast-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.dialog {
  border: none;
  padding: 0;
  max-width: calc(100vw - 2rem);
  width: 520px;
  background: transparent;
}

.dialog.sheet-wide {
  width: min(640px, 94vw);
}

.dialog::backdrop {
  background: rgba(15, 23, 42, 0.48);
}

.dialog-inner {
  padding: 1.35rem;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.dialog-head h3 {
  margin: 0;
  font-family: var(--font-display);
}

.chunks-body {
  margin-top: 0.75rem;
  overflow-y: auto;
  flex: 1;
}

.chunk-card {
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--mist);
  margin-bottom: 0.65rem;
  font-size: 0.85rem;
}

.chunk-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
  font-family: var(--font-mono);
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
    flex: 1 1 auto;
  }

  .sidebar-footer {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .user-chip {
    margin-bottom: 0;
  }

  .main {
    padding: 1.25rem;
  }

  .chat-transcript {
    max-height: 42vh;
  }
}

.team-role-fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

.team-role-checkbox-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1.25rem;
}

.team-role-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--ink-soft);
}

.team-role-label input {
  width: auto;
  margin: 0;
}
