:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #eef3f7;
  --ink: #14212b;
  --muted: #667789;
  --line: #d9e1e8;
  --primary: #146b63;
  --primary-strong: #0f4f49;
  --accent: #b54d2e;
  --blue: #2f5d8c;
  --yellow: #f3bd4d;
  --danger: #b83a3a;
  --shadow: 0 10px 28px rgba(20, 33, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #111b24;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.auth-brand {
  border-bottom: 0;
  padding-bottom: 16px;
  color: var(--ink);
}

.auth-brand p {
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 9px;
}

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

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

.sidebar {
  background: #15222d;
  color: #f9fbfc;
  padding: 22px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #f3bd4d;
  color: #15222d;
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
}

.brand p {
  color: #b8c4ce;
  font-size: 12px;
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.nav button {
  border: 0;
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  color: #d7e1e8;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
}

.nav button.active,
.nav button:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

.main {
  min-width: 0;
  background: var(--bg);
  padding: 26px 30px 40px;
}

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

.eyebrow {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 700;
}

.topbar h2 {
  font-size: 28px;
  margin-top: 3px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

.user-pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}

.button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  min-height: 38px;
}

.button:hover {
  border-color: #9fb0bf;
}

.button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

.button.primary:hover {
  background: var(--primary-strong);
}

.button.ghost {
  background: transparent;
}

.button.small {
  padding: 6px 9px;
  min-height: 30px;
  font-size: 13px;
}

.notice {
  background: #fff6df;
  border: 1px solid #ead29b;
  color: #5c4311;
  border-radius: 8px;
  padding: 11px 12px;
  margin-bottom: 14px;
}

.hidden {
  display: none;
}

.content {
  display: grid;
  gap: 16px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 16px;
}

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

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.panel-header h3 {
  margin: 0;
  font-size: 16px;
}

.panel-body {
  padding: 14px;
}

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

.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.item h4 {
  margin: 0 0 6px;
  font-size: 15px;
}

.item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.next-action {
  margin-top: 9px !important;
  color: #274456 !important;
  background: #f5f8fa;
  border-left: 3px solid var(--primary);
  border-radius: 6px;
  padding: 8px 9px;
}

.company-card {
  display: grid;
  gap: 12px;
}

.company-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

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

.company-intel-grid > div,
.analysis-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
}

.company-intel-grid h5,
.analysis-box h5 {
  margin: 0 0 7px;
  color: #405466;
  font-size: 12px;
  text-transform: uppercase;
}

.mini-offer {
  display: grid;
  gap: 3px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 7px;
  margin-bottom: 7px;
}

.mini-offer:last-child {
  border-bottom: 0;
  margin-bottom: 0;
  padding-bottom: 0;
}

.mini-offer strong {
  font-size: 13px;
}

.mini-offer span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.signal-row {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-top: 10px;
}

.signal-row h4 {
  margin: 0 0 5px;
  font-size: 14px;
}

.signal-row p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  border: 1px solid #cdd9e2;
  border-radius: 8px;
  color: #304658;
  background: #f5f8fa;
  padding: 3px 7px;
  font-size: 12px;
}

.tag.high {
  background: #fff1e9;
  border-color: #efc0a7;
  color: #85361a;
}

.tag.ok {
  background: #eaf7f3;
  border-color: #a8d6ca;
  color: #146b63;
}

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

.compact-form {
  margin-top: 10px;
}

.form-row {
  display: grid;
  gap: 5px;
}

.form-row.full {
  grid-column: 1 / -1;
}

label {
  font-size: 12px;
  font-weight: 700;
  color: #405466;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  background: #111b24;
  color: #e7f0f6;
  border-radius: 8px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.45;
}

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

.table th,
.table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

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

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

.pipeline-board,
.task-board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(260px, 1fr);
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.pipeline-column {
  min-width: 260px;
}

.pipeline-card {
  min-height: 180px;
}

.column-title {
  font-size: 13px;
  font-weight: 800;
  color: #405466;
  text-transform: uppercase;
  margin: 0 0 8px;
}

.draft-body {
  white-space: pre-wrap;
  color: #2c3d4b;
}

.chat-panel {
  min-height: calc(100vh - 150px);
}

.chat-layout {
  display: grid;
  grid-template-rows: minmax(300px, 1fr) auto;
  gap: 12px;
}

.chat-messages {
  display: grid;
  align-content: start;
  gap: 10px;
  max-height: 58vh;
  overflow: auto;
  padding-right: 4px;
}

.chat-message {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
}

.chat-message.user {
  background: #eaf7f3;
  border-color: #a8d6ca;
}

.chat-message.assistant {
  background: #f8fafc;
}

.chat-message strong {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
}

.chat-message p {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.45;
}

.chat-form {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.user-row select,
.user-row input {
  min-height: 34px;
}

a {
  color: var(--blue);
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .metrics,
  .grid-2,
  .grid-3,
  .company-intel-grid,
  .kanban,
  .form-grid {
    grid-template-columns: 1fr;
  }

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