:root {
  --navy: #0b1f3a;
  --navy-2: #133056;
  --accent: #1bb6c1;
  --accent-2: #128e97;
  --bg: #f3f6fb;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --danger: #e11d48;
  --warn: #d97706;
  --ok: #059669;
  --sidebar: 248px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14.5px/1.45 "Plus Jakarta Sans", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--accent-2); }

.login-screen {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background:
    radial-gradient(900px 400px at 10% -10%, rgba(27, 182, 193, 0.18), transparent 50%),
    linear-gradient(160deg, #071525, #0b1f3a 45%, #102a4c);
}
.login-screen[hidden],
.app[hidden] {
  display: none;
}
.login-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 16px;
  padding: 28px;
}
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.login-brand strong, .brand strong { display: block; font-size: 14px; }
.login-brand span, .brand span { color: var(--muted); font-size: 12px; }
.login-card h1 { margin: 0 0 6px; font-size: 24px; }
.login-copy { margin: 0 0 22px; color: var(--muted); }
.login-card label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
.login-card input, .field input, .field select, .field textarea, .topbar input {
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--text);
}
.hint { margin: 14px 0 0; font-size: 12px; color: var(--muted); }
.form-error { color: var(--danger); font-size: 13px; margin: 0 0 10px; }

.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--accent); color: #062027;
  display: grid; place-items: center;
  font-weight: 700; font-size: 18px; flex-shrink: 0;
}

.app { display: flex; min-height: 100%; }
.sidebar {
  width: var(--sidebar);
  background: var(--navy);
  color: #dbe7f3;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; gap: 12px; align-items: center;
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand span { color: #8aa0b8; }
nav { padding: 12px 10px; flex: 1; overflow: auto; }
nav a {
  display: flex; align-items: center; gap: 10px;
  color: #c5d4e4; text-decoration: none;
  padding: 9px 10px; border-radius: 8px; margin-bottom: 2px;
}
nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
nav a.active { background: rgba(27, 182, 193, .16); color: #fff; }
nav svg { width: 18px; height: 18px; opacity: .9; }
.nav-label {
  display: block; padding: 14px 12px 6px;
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #7b93ab;
}
.sidebar-foot {
  padding: 14px 16px 18px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 13px;
}
.sidebar-foot strong { display: block; color: #fff; }
.sidebar-foot span { color: #8aa0b8; font-size: 12px; }
.sidebar-foot button {
  margin-top: 10px; background: transparent; color: #9fb3c8;
  border: 1px solid rgba(255,255,255,.12); border-radius: 8px; padding: 6px 10px; width: 100%;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 22px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.search-wrap { position: relative; flex: 1; max-width: 520px; }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); overflow: hidden; z-index: 30;
}
.search-results button {
  display: block; width: 100%; text-align: left;
  border: 0; background: #fff; padding: 10px 12px; border-bottom: 1px solid var(--line);
}
.search-results button:hover { background: #f8fafc; }
.search-results small { display: block; color: var(--muted); }

.view { padding: 22px; flex: 1; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 22px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 600; }
.kpi .value { font-size: 22px; font-weight: 700; margin-top: 6px; }
.kpi .delta { font-size: 12px; color: var(--muted); margin-top: 4px; }

.grid-2 { display: grid; grid-template-columns: 1.4fr .8fr; gap: 12px; margin-bottom: 12px; }
.grid-2.even { grid-template-columns: 1fr 1fr; }

.bar-row { display: grid; grid-template-columns: 110px 1fr 80px; gap: 8px; align-items: center; margin: 8px 0; font-size: 13px; }
.bar { height: 8px; background: #e8eef5; border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.muted { color: var(--muted); }
.right { text-align: right; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:hover td { background: #f8fafc; }
.table-wrap { overflow: auto; }

.pill {
  display: inline-flex; align-items: center;
  padding: 3px 8px; border-radius: 99px; font-size: 12px; font-weight: 600;
  background: #eef2f7; color: #334155;
}
.pill.new, .pill.qualification, .pill.draft, .pill.planning { background: #e8f1ff; color: #1d4ed8; }
.pill.contacted, .pill.discovery, .pill.sent, .pill.in_progress, .pill.open { background: #e6f7f8; color: #0e7490; }
.pill.qualified, .pill.proposal, .pill.qa, .pill.waiting { background: #fef3c7; color: #b45309; }
.pill.negotiation, .pill.high, .pill.overdue { background: #ffedd5; color: #c2410c; }
.pill.won, .pill.paid, .pill.active, .pill.resolved, .pill.done, .pill.delivered { background: #dcfce7; color: #166534; }
.pill.lost, .pill.unqualified, .pill.closed, .pill.urgent { background: #ffe4e6; color: #be123c; }
.pill.medium, .pill.onboarding { background: #f1f5f9; color: #475569; }
.pill.sent, .pill.demo, .pill.review { background: #e6f7f8; color: #0e7490; }
.pill.accepted, .pill.billable { background: #dcfce7; color: #166534; }
.pill.rejected, .pill.expired { background: #ffe4e6; color: #be123c; }
.pill.call, .pill.workshop, .pill.onsite { background: #e8f1ff; color: #1d4ed8; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 99px;
  padding: 6px 10px; color: var(--muted);
}
.chip.active { border-color: var(--navy); color: var(--navy); background: #eef3f9; }

.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 8px 12px; color: var(--text);
}
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.primary:hover { background: var(--navy-2); }
.btn.ghost { background: transparent; }
.btn.danger { background: #fff; color: var(--danger); border-color: #fecdd3; }
.btn.block { width: 100%; }
.btn.small { padding: 5px 8px; font-size: 12px; }
.icon-btn { border: 0; background: transparent; font-size: 18px; padding: 6px; color: var(--text); display: grid; place-items: center; position: relative; }
.menu-btn { display: none; }
.notif-wrap { position: relative; }
.notif-panel {
  position: absolute; right: 0; top: calc(100% + 8px); width: min(360px, 90vw);
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  z-index: 40; overflow: hidden; max-height: 420px; overflow-y: auto;
}
.notif-panel button {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--text);
}
.notif-panel button:hover { background: var(--bg); }
.notif-panel small { display: block; color: var(--muted); }
.badge {
  position: absolute; top: 0; right: 0; min-width: 16px; height: 16px;
  background: var(--danger); color: #fff; border-radius: 99px;
  font-size: 10px; display: grid; place-items: center; padding: 0 4px;
}

.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head { font-size: 12px; color: var(--muted); text-align: center; font-weight: 600; padding: 4px; }
.cal-day {
  min-height: 92px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px; font-size: 12px;
}
.cal-day.out { opacity: .45; }
.cal-day.today { border-color: var(--accent); }
.cal-day strong { display: block; margin-bottom: 4px; }
.cal-item {
  display: block; width: 100%; border: 0; background: #e6f7f8; color: #0e7490;
  border-radius: 6px; padding: 3px 5px; margin-bottom: 3px; text-align: left; font-size: 11px;
}
.cal-item.task { background: #fef3c7; color: #b45309; }

html.dark {
  --bg: #0b1220;
  --surface: #152033;
  --text: #e8eef6;
  --muted: #8ea0b5;
  --line: #243044;
}
html.dark .card,
html.dark .modal,
html.dark .topbar,
html.dark .search-results,
html.dark .search-results button,
html.dark .deal-card,
html.dark .chip { background: var(--surface); color: var(--text); }
html.dark .kanban-col { background: #10192a; }
html.dark tr:hover td { background: #1b2a40; }
html.dark .btn { background: var(--surface); color: var(--text); border-color: var(--line); }
html.dark .btn.primary { background: var(--accent); color: #062027; border-color: var(--accent); }
html.dark .linkish { color: var(--accent); }
html.dark .login-card { background: var(--surface); color: var(--text); }

.kanban {
  display: grid;
  grid-template-columns: repeat(6, minmax(200px, 1fr));
  gap: 10px; overflow-x: auto; padding-bottom: 8px;
}
.kanban-col {
  background: #eef2f7; border-radius: 12px; padding: 10px; min-height: 240px;
}
.kanban-col h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #475569; }
.deal-card {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px; margin-bottom: 8px; cursor: grab;
}
.deal-card strong { display: block; font-size: 13px; }
.deal-card span { color: var(--muted); font-size: 12px; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.feed time { display: block; color: var(--muted); font-size: 12px; }

.progress {
  height: 6px; background: #e8eef5; border-radius: 99px; overflow: hidden; margin-top: 6px;
}
.progress > span { display: block; height: 100%; background: var(--accent); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: grid; place-items: center; z-index: 50; padding: 16px;
}
.modal {
  width: min(560px, 100%); background: #fff; border-radius: 14px;
  padding: 20px; max-height: 90vh; overflow: auto;
}
.modal h2 { margin: 0 0 14px; font-size: 18px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: flex; flex-direction: column; font-size: 12px; font-weight: 600; color: var(--muted); }
.field.full { grid-column: 1 / -1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: grid; gap: 8px; }
.toast {
  background: var(--navy); color: #fff; padding: 10px 14px; border-radius: 10px;
  min-width: 220px;
}

.empty { padding: 28px; text-align: center; color: var(--muted); }

.linkish { border: 0; background: none; color: var(--navy); font-weight: 600; padding: 0; text-align: left; }
.row-actions { display: flex; gap: 6px; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-2.even { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: repeat(6, 220px); }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: .2s; }
  .sidebar.open { transform: none; }
  .menu-btn { display: block; }
  .fields { grid-template-columns: 1fr; }
}
