:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1c2530;
  --muted: #6b7787;
  --line: #e3e7ec;
  --accent: #2b6cb0;
  --accent-ink: #ffffff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
}

header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand { font-weight: 700; font-size: 1.1rem; color: var(--ink); text-decoration: none; }
nav { display: flex; gap: 1rem; flex-wrap: wrap; }
nav a { color: var(--accent); text-decoration: none; font-size: 0.95rem; }
nav a:hover { text-decoration: underline; }

main { max-width: 1100px; margin: 1.5rem auto; padding: 0 1.5rem; }

h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  margin-bottom: 1.25rem;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
tbody tr:hover { background: #fafbfc; }

.muted { color: var(--muted); }
.pill { display: inline-block; background: #eef1f5; color: var(--muted); border-radius: 6px; padding: 0.05rem 0.4rem; font-size: 0.8rem; margin-right: 0.4rem; }

.actions { list-style: none; padding: 0; margin: 0; }
.actions li { padding: 0.4rem 0; border-bottom: 1px solid var(--line); }
.actions li:last-child { border-bottom: none; }

.warmth { border-radius: 6px; padding: 0.05rem 0.5rem; font-size: 0.8rem; font-weight: 600; }
.warmth-cold { background: #e3eefc; color: #2b6cb0; }
.warmth-cool { background: #e6f4f1; color: #2c7a7b; }
.warmth-warm { background: #fdebd0; color: #b7791f; }
.warmth-hot  { background: #fbe3e3; color: #c53030; }

.status { background: #eef1f5; border-radius: 6px; padding: 0.05rem 0.5rem; font-size: 0.8rem; }

.flash { background: #e6f4ea; border: 1px solid #b7dfc2; color: #276749; border-radius: 8px; padding: 0.5rem 0.9rem; margin-bottom: 1rem; }
.flash p { margin: 0.15rem 0; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  font-size: 0.92rem;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: #245a91; }
.btn-link { color: var(--muted); text-decoration: none; padding: 0.5rem 0.4rem; }

.card-form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.25rem;
  max-width: 640px;
}
.card-form label { display: block; margin-bottom: 0.85rem; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.card-form input, .card-form select, .card-form textarea {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--ink);
}
.card-form .row { display: flex; gap: 1rem; }
.card-form .row label { flex: 1; }
.form-actions { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.5rem; }

td a { color: var(--accent); text-decoration: none; }
td a:hover { text-decoration: underline; }

/* Detail pages */
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.detail-head h1 { margin: 0; display: flex; align-items: center; gap: 0.6rem; }
.subtitle { color: var(--muted); margin: 0.25rem 0 0; }
.detail-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.detail-actions form { margin: 0; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.75rem 1.5rem; margin: 0; }
.facts dt { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; }
.facts dd { margin: 0.1rem 0 0; font-size: 0.98rem; }
.notes { margin: 1rem 0 0; padding-top: 0.85rem; border-top: 1px solid var(--line); white-space: pre-wrap; }

/* Destructive actions */
.btn-danger {
  background: #fff; color: #c53030; border: 1px solid #f0c2c2;
  border-radius: 8px; padding: 0.5rem 0.9rem; font-size: 0.92rem; cursor: pointer;
}
.btn-danger:hover { background: #fbe3e3; }
.row-actions { white-space: nowrap; }
.row-actions form { display: inline; margin: 0; }
.row-actions a { color: var(--accent); text-decoration: none; margin-right: 0.5rem; }
.link-danger { background: none; border: none; color: #c53030; cursor: pointer; font-size: 0.92rem; padding: 0; }
.link-danger:hover { text-decoration: underline; }

/* Pipeline: metric cards */
.metric-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.85rem; margin-bottom: 1.25rem; }
.metric { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 0.9rem 1rem; }
.metric-value { font-size: 1.45rem; font-weight: 700; }
.metric-label { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; margin-top: 0.15rem; }
.metric-alert { border-color: #f0c2c2; background: #fdf3f3; }
.metric-alert .metric-value { color: #c53030; }

/* Pipeline: deal funnel */
.funnel { display: flex; flex-direction: column; gap: 0.5rem; }
.funnel-row { display: grid; grid-template-columns: 90px 1fr 150px; align-items: center; gap: 0.75rem; }
.funnel-label { font-size: 0.88rem; font-weight: 600; }
.funnel-bar-wrap { background: #f0f2f5; border-radius: 6px; height: 1.4rem; overflow: hidden; }
.funnel-bar { height: 100%; min-width: 2px; border-radius: 6px; }
.funnel-meta { font-size: 0.88rem; text-align: right; }
.funnel-meta .muted { margin-left: 0.4rem; }
.funnel-row.terminal .funnel-label { color: var(--muted); }
.funnel-note { margin: 0.85rem 0 0; font-size: 0.82rem; }

.status-sourced   { background: #cfe0f7; }
.status-reviewing { background: #a9c7ef; }
.status-nda       { background: #86b0e6; }
.status-loi       { background: #f6c97a; }
.status-diligence { background: #f0a85f; }
.status-closed    { background: #7bc89a; }
.status-passed    { background: #d8dde3; }

/* Pipeline: follow-up list */
tr.stale { background: #fdf6ec; }
tr.stale:hover { background: #fbf0dd; }
.flag { display: inline-block; background: #fbe3e3; color: #c53030; border-radius: 5px; padding: 0.02rem 0.4rem; font-size: 0.72rem; font-weight: 600; margin-left: 0.35rem; }

/* Auth */
.user-box { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; font-size: 0.9rem; }
.user-box form { margin: 0; }
.login-wrap { max-width: 420px; margin: 3rem auto 0; }
.login-wrap .card-form { max-width: none; }

/* User management: inline add + reset forms */
.inline-form { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.6rem; }
.inline-form input[type="text"],
.inline-form input[type="password"],
.reset-form input[type="password"] {
  padding: 0.45rem 0.6rem; border: 1px solid var(--line); border-radius: 8px;
  font-size: 0.92rem; font-family: inherit; color: var(--ink);
}
.inline-form .checkbox { display: flex; align-items: center; gap: 0.3rem; color: var(--muted); font-size: 0.9rem; font-weight: 600; }
.reset-form { display: flex; gap: 0.4rem; align-items: center; }
.reset-form input[type="password"] { padding: 0.3rem 0.5rem; font-size: 0.85rem; }
.user-box a.muted { text-decoration: none; }
.user-box a.muted:hover { text-decoration: underline; }

@media (max-width: 640px) {
  .card-form .row { flex-direction: column; gap: 0; }
  .detail-head { flex-direction: column; }
  .funnel-row { grid-template-columns: 70px 1fr 90px; }
  .user-box { margin-left: 0; }
}
