:root {
  --ink: #1c2230;
  --muted: #6b7280;
  --line: #e3e6ec;
  --bg: #f6f7f9;
  --accent: #0b5fff;
  --card: #ffffff;
  --field-bg: #ffffff;
  --th-bg: #fafbfc;
  --shadow: rgba(0, 0, 0, .06);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --ink: #e6e9ef;
  --muted: #9aa3b2;
  --line: #2a3140;
  --bg: #0f141b;
  --accent: #5b94ff;
  --card: #1a212c;
  --field-bg: #131a24;
  --th-bg: #161d28;
  --shadow: rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1.4rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 1.1rem; text-decoration: none; color: var(--ink); letter-spacing: .04em; }
.brand span { color: var(--accent); }
.topbar nav a { margin-left: 1.1rem; text-decoration: none; color: var(--muted); }
.topbar nav a:hover { color: var(--ink); }
.theme-toggle {
  margin-left: 1.1rem;
  padding: .3rem .55rem;
  font-size: 1rem;
  line-height: 1;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--muted); filter: none; }

main { max-width: 1040px; margin: 1.6rem auto; padding: 0 1.2rem; }

.filters { display: flex; gap: .6rem; align-items: center; margin-bottom: 1rem; }
.filters input[type=text] { flex: 1; }
.filters .clear { color: var(--muted); text-decoration: none; font-size: .9rem; }

input, select, textarea {
  font: inherit;
  padding: .5rem .6rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--field-bg);
  color: var(--ink);
}
textarea { width: 100%; resize: vertical; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .9rem; }
button {
  font: inherit;
  padding: .5rem .9rem;
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button:hover { filter: brightness(1.05); }
button.danger { background: #c0392b; }

table.opps { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.opps th, .opps td { text-align: left; padding: .65rem .8rem; border-bottom: 1px solid var(--line); font-size: .92rem; vertical-align: middle; }
.opps th { background: var(--th-bg); color: var(--muted); font-weight: 600; }
.opps tr:last-child td { border-bottom: 0; }
.opps a { color: var(--accent); text-decoration: none; }
.opps a:hover { text-decoration: underline; }
.nowrap { white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 2rem; }
form.inline { margin: 0; }

/* status pill-ish select coloring */
.status { border-width: 1px; font-size: .82rem; padding: .25rem .4rem; }
.status-NEW { color: #2563eb; }
.status-DRAFTED { color: #7c3aed; }
.status-SENT { color: #0891b2; }
.status-FUP1, .status-FUP2 { color: #d97706; }
.status-REPLIED { color: #0d9488; }
.status-WON { color: #15803d; font-weight: 700; }
.status-LOST { color: #b91c1c; }

/* brighter status colors for dark-mode contrast */
:root[data-theme="dark"] .status-NEW { color: #6ea8ff; }
:root[data-theme="dark"] .status-DRAFTED { color: #b794ff; }
:root[data-theme="dark"] .status-SENT { color: #34c5e6; }
:root[data-theme="dark"] .status-FUP1, :root[data-theme="dark"] .status-FUP2 { color: #f3b34d; }
:root[data-theme="dark"] .status-REPLIED { color: #2dd4bf; }
:root[data-theme="dark"] .status-WON { color: #4ade80; }
:root[data-theme="dark"] .status-LOST { color: #f87171; }

/* record form */
form.record { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1.2rem; }
form.record label { display: block; margin-bottom: .9rem; font-size: .85rem; color: var(--muted); }
form.record label input, form.record label select { display: block; width: 100%; margin-top: .25rem; color: var(--ink); }
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; }
.actions { display: flex; gap: .8rem; align-items: center; margin-top: .4rem; }
.btn-link { color: var(--muted); text-decoration: none; }
form.delete { margin-top: 1rem; }

/* login */
.login-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 2rem; width: 320px; box-shadow: 0 8px 30px var(--shadow); }
.login-card h1 { margin: 0 0 1.2rem; font-size: 1.2rem; letter-spacing: .04em; }
.login-card h1 span { color: var(--accent); }
.login-card label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 1rem; }
.login-card input { display: block; width: 100%; margin-top: .3rem; }
.login-card button { width: 100%; }
.error { color: #b91c1c; font-size: .9rem; margin: 0 0 .8rem; }
:root[data-theme="dark"] .error { color: #f87171; }

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