/* Pebbles CRM. Light and dark via prefers-color-scheme; no external fonts, no third-party requests. */
:root {
  --bg: #f4f5f9; --panel: #ffffff; --panel-2: #f8fafc; --line: #e6e8ef; --ink: #0f172a; --ink-2: #475569; --muted: #94a3b8;
  --accent: #4f46e5; --accent-ink: #ffffff; --accent-soft: #eef2ff; --danger: #dc2626; --danger-soft: #fee2e2; --ok: #16a34a; --ok-soft: #dcfce7;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px -12px rgba(15, 23, 42, .18);
  --radius: 14px; --sidebar: 232px;
  --s-lead: #0ea5e9; --s-qualified: #8b5cf6; --s-proposal: #f59e0b; --s-negotiation: #f97316; --s-won: #16a34a; --s-lost: #94a3b8;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b1020; --panel: #121a2e; --panel-2: #0f1628; --line: #1f2a44; --ink: #e5e9f5; --ink-2: #aab4cc; --muted: #6b7794;
    --accent: #818cf8; --accent-ink: #0b1020; --accent-soft: #1b2142; --danger: #f87171; --danger-soft: #3b1420; --ok: #4ade80; --ok-soft: #122a1c;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 30px -14px rgba(0,0,0,.7); }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 24px; letter-spacing: -.02em; margin: 0; font-weight: 700; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 650; letter-spacing: -.01em; }
.muted { color: var(--ink-2); }
.dim { color: var(--muted); }
small, .small { font-size: 12.5px; }
[hidden] { display: none !important; }

/* Controls */
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: var(--muted); }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 9px 14px; font-weight: 600; transition: transform .05s, background .15s, border-color .15s; white-space: nowrap; }
button:hover { background: var(--panel-2); }
button:active { transform: translateY(1px); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary:hover { filter: brightness(1.07); background: var(--accent); }
button.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
button.ghost:hover { background: var(--accent-soft); color: var(--accent); }
button.danger { color: var(--danger); }
button.danger:hover { background: var(--danger-soft); border-color: var(--danger-soft); }
button.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
button:disabled { opacity: .55; cursor: default; }
button svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
button svg + * , button.primary svg { margin-right: 2px; }
.side .foot button svg { width: 18px; height: 18px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
form.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; align-items: end; }
form.grid .wide { grid-column: 1 / -1; }
.error { color: var(--danger); font-size: 13.5px; }

/* Auth screens */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 10% -10%, var(--accent-soft), transparent 60%), radial-gradient(900px 500px at 110% 110%, #fef3c7aa, transparent 60%); }
@media (prefers-color-scheme: dark) { .auth { background: radial-gradient(1200px 600px at 10% -10%, #1b2142, transparent 60%), radial-gradient(900px 500px at 110% 110%, #2a1f0a, transparent 60%); } }
.auth .box { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 32px; box-shadow: var(--shadow); }
.auth .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth .brand img { width: 40px; height: 40px; border-radius: 10px; }
.auth .brand strong { font-size: 18px; letter-spacing: -.02em; }
.auth form { display: grid; gap: 14px; }
.auth p { margin: 0 0 6px; color: var(--ink-2); font-size: 14px; }

/* App shell */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 18px 14px; border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; gap: 6px; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; }
.side .brand img { width: 30px; height: 30px; border-radius: 8px; }
.side .brand strong { font-size: 16px; letter-spacing: -.02em; }
.side a.nav { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--ink-2); font-weight: 550; }
.side a.nav svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side a.nav:hover { background: var(--panel-2); color: var(--ink); }
.side a.nav.active { background: var(--accent-soft); color: var(--accent); }
.side .spacer { flex: 1; }
.side .foot { padding: 8px 10px; display: flex; gap: 8px; align-items: center; }
.main { padding: 26px 32px 60px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.topbar .grow { flex: 1; }
.search { position: relative; max-width: 420px; flex: 1; }
.search input { padding-left: 36px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; stroke: var(--muted); fill: none; stroke-width: 2; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; bottom: 0; top: auto; height: auto; width: 100%; flex-direction: row; justify-content: space-around; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); z-index: 5; }
  .side .brand, .side .spacer, .side .nav span { display: none; }
  .side a.nav { padding: 10px 14px; }
  .side .foot { padding: 0; }
  .main { padding: 18px 16px 90px; }
}

/* Cards and tables */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stack > * + * { margin-top: 16px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .cols { grid-template-columns: 1fr; } }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .l { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.kpi .v { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.kpi .d { font-size: 12.5px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11.5px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .06em; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--panel-2); }
tbody tr.link { cursor: pointer; }
td .name { font-weight: 600; }
.table-wrap { overflow-x: auto; }
.empty { padding: 36px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink-2); font-weight: 600; margin-bottom: 4px; }

/* Avatars, pills */
.avatar { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-size: 12.5px; font-weight: 700; color: #fff; flex: none; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.row { display: flex; align-items: center; gap: 12px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--line); }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill[data-stage="lead"] { color: var(--s-lead); } .pill[data-stage="qualified"] { color: var(--s-qualified); } .pill[data-stage="proposal"] { color: var(--s-proposal); }
.pill[data-stage="negotiation"] { color: var(--s-negotiation); } .pill[data-stage="won"] { color: var(--s-won); } .pill[data-stage="lost"] { color: var(--s-lost); }
.kind { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); flex: none; }
.kind svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Pipeline board */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity; }
.col { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 240px; scroll-snap-align: start; transition: background .15s, border-color .15s; }
.col.over { border-color: var(--accent); background: var(--accent-soft); }
.col h3 { margin: 4px 6px 2px; font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.col h3 .dot { width: 8px; height: 8px; border-radius: 50%; }
.col h3 .n { margin-left: auto; color: var(--muted); font-weight: 600; }
.col .sum { margin: 0 6px 10px; font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.deal { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; margin-bottom: 8px; cursor: grab; box-shadow: 0 1px 2px rgba(15,23,42,.04); transition: box-shadow .15s, transform .15s; }
.deal:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.deal.dragging { opacity: .45; }
.deal .t { font-weight: 600; margin-bottom: 4px; line-height: 1.3; }
.deal .m { font-size: 12.5px; color: var(--ink-2); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.deal .v { font-weight: 700; color: var(--ink); }
.deal .actions { display: none; gap: 6px; margin-top: 8px; }
.deal:hover .actions, .deal:focus-within .actions { display: flex; }
.deal select { padding: 4px 8px; font-size: 12.5px; border-radius: 8px; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 30px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .h { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.timeline .h strong { font-weight: 600; }
.timeline .b { color: var(--ink-2); white-space: pre-wrap; }
ul.files { list-style: none; margin: 0; padding: 0; }
ul.files li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
ul.files li:last-child { border-bottom: 0; }
ul.files .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drop { border: 1.5px dashed var(--line); border-radius: 12px; padding: 16px; text-align: center; color: var(--muted); font-size: 13.5px; transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.notice { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: 10px; padding: 10px 12px; font-size: 13.5px; }
@media (prefers-color-scheme: dark) { .notice { background: #2a1f0a; border-color: #4a3410; color: #fcd34d; } }

/* Toast, modal */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); z-index: 20; max-width: 90vw; }
.toast.bad { background: var(--danger); color: #fff; }
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: grid; place-items: center; padding: 20px; z-index: 10; backdrop-filter: blur(2px); }
.modal .card { width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; }
.modal .head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal .head h2 { margin: 0; font-size: 17px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.pagehead .sub { color: var(--ink-2); font-size: 14px; margin-top: 2px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 13.5px; margin-bottom: 10px; }
.back:hover { color: var(--accent); }
.details dl { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; margin: 0; }
.details dt { color: var(--muted); font-size: 13px; }
.details dd { margin: 0; }
