:root {
  color-scheme: dark;
  --bg: #07080a;
  --panel: #111418;
  --panel-2: #181c22;
  --line: #343a43;
  --text: #eef1f4;
  --muted: #9aa3ad;
  --silver: #c7ced6;
  --green: #53d18a;
  --red: #ff6b72;
  --amber: #f2bd5e;
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea {
  font: inherit;
}

button {
  border: 1px solid #737b85;
  background: linear-gradient(180deg, #e4e7eb, #9aa1aa);
  color: #0b0d10;
  border-radius: 6px;
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  filter: brightness(1.08);
}

button.ghost,
nav button {
  background: transparent;
  color: var(--silver);
}

button.danger {
  border-color: #ff8a8f;
  background: #461519;
  color: #ffd7da;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #090b0f;
  color: var(--text);
  min-height: 38px;
  padding: 0 10px;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #090b0f;
  color: var(--text);
  padding: 10px;
  resize: vertical;
}

.hidden {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.08), transparent 32%),
    radial-gradient(circle at 70% 10%, rgba(170,185,200,0.10), transparent 28%),
    var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  background: rgba(17, 20, 24, 0.94);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.45);
}

.brand-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-row > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.brand-row.compact {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.brand-row h1,
.topbar h2,
.section-head h3,
.risk-note h3 {
  margin: 0;
  letter-spacing: 0;
}

.brand-row p,
.brand-row small,
.topbar p,
.risk-note p {
  color: var(--muted);
  margin: 4px 0 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border: 1px solid #d8dde3;
  border-radius: 50%;
  background: linear-gradient(135deg, #f4f6f8, #747b84 55%, #15181c);
  flex: 0 0 auto;
}

.bob-avatar {
  display: block;
  object-fit: cover;
  border: 1px solid #d8dde3;
  background: #10141a;
  flex: 0 0 auto;
}

.bob-avatar.small {
  width: 38px;
  height: 38px;
  border-radius: 50%;
}

.bob-login-card {
  margin-top: 18px;
  border: 1px solid var(--line);
  background: #0b0e12;
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.bob-login-card p {
  color: var(--silver);
  margin: 0;
  line-height: 1.45;
}

.bob-portrait {
  display: block;
  width: 100%;
  max-width: 170px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  object-position: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #090b0f;
}

.login-form {
  margin-top: 24px;
  display: grid;
  gap: 14px;
}

.login-form label {
  display: grid;
  gap: 6px;
  color: var(--silver);
}

.error-text {
  color: var(--red);
  min-height: 20px;
  margin: 0;
}

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

.sidebar {
  border-right: 1px solid var(--line);
  background: #0c0f13;
  display: flex;
  flex-direction: column;
}

nav {
  padding: 14px;
  display: grid;
  gap: 8px;
}

nav button {
  text-align: left;
  border-color: transparent;
}

nav button.active {
  border-color: var(--line);
  background: var(--panel-2);
  color: var(--text);
}

#logoutBtn {
  margin: auto 14px 14px;
}

.workspace {
  min-width: 0;
}

.topbar {
  min-height: 84px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 18px 24px;
  background: linear-gradient(180deg, #15191f, #0e1014);
}

.toolbar,
.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.view {
  display: none;
  padding: 22px 24px 36px;
}

.view.active {
  display: block;
}

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

.bob-hero {
  border: 1px solid var(--line);
  background: linear-gradient(135deg, #15191f, #0b0d10);
  border-radius: 8px;
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  padding: 16px;
  margin-bottom: 16px;
}

.bob-hero h3 {
  margin: 0 0 8px;
  letter-spacing: 0;
}

.bob-hero p {
  margin: 0;
  color: var(--silver);
  line-height: 1.5;
}

.metrics article,
.band {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
}

.metrics article {
  min-height: 86px;
  padding: 16px;
  display: grid;
  align-content: space-between;
}

.metrics span {
  color: var(--muted);
}

.metrics strong {
  font-size: 24px;
  letter-spacing: 0;
}

.band {
  margin-bottom: 16px;
  overflow: hidden;
}

.band.split {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr);
  gap: 20px;
  padding: 18px;
}

.section-head {
  min-height: 58px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.inline-form input {
  width: 130px;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid #252a31;
  text-align: left;
  white-space: nowrap;
}

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

td {
  color: var(--silver);
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

.muted {
  color: var(--muted);
}

.spark {
  width: 120px;
  height: 34px;
  display: block;
}

.settings-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.setting-row {
  display: grid;
  grid-template-columns: 220px minmax(140px, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.risk-note {
  border-left: 1px solid var(--line);
  padding-left: 20px;
}

.bob-chat-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
  gap: 16px;
}

.bob-chat-panel,
.bob-task-panel {
  min-height: 420px;
}

.bob-messages {
  min-height: 300px;
  max-height: 54vh;
  overflow: auto;
  padding: 14px;
  display: grid;
  align-content: start;
  gap: 10px;
}

.bob-message {
  border: 1px solid #293039;
  background: #0c1015;
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.bob-message.user {
  margin-left: 10%;
  background: #161b21;
}

.bob-message.assistant {
  margin-right: 10%;
}

.bob-message strong {
  display: block;
  color: var(--silver);
  margin-bottom: 4px;
}

.bob-form {
  border-top: 1px solid var(--line);
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.bob-tasks {
  padding: 14px;
  display: grid;
  gap: 10px;
}

.bob-task {
  border: 1px solid #293039;
  background: #0c1015;
  border-radius: 8px;
  padding: 10px 12px;
}

.bob-task strong {
  display: block;
  margin-bottom: 4px;
}

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

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    min-width: 0;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    min-width: 0;
    max-width: 100vw;
    overflow: hidden;
  }

  nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 10px;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  nav button {
    flex: 0 0 auto;
    min-width: 86px;
    font-size: 14px;
    text-align: center;
    padding: 0 8px;
  }

  #logoutBtn {
    margin: 0 14px 14px;
  }

  .workspace {
    min-width: 0;
    max-width: 100vw;
  }

  .metrics,
  .band.split,
  .bob-chat-layout,
  .bob-hero {
    grid-template-columns: 1fr;
  }

  .bob-hero .bob-portrait {
    max-width: 118px;
  }

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

  .risk-note {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 18px 0 0;
  }

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