:root {
  --ink: #28263a;
  --muted: #747187;
  --bg: #f5f4f9;
  --surface: #ffffff;
  --line: #e0ddea;
  --brand: #242343;
  --brand-2: #5a538c;
  --accent: #d8bd67;
  --moon: #f2e8bb;
  --moon-soft: #eeeaf7;
  --danger: #b64b50;
  --danger-bg: #fbeaec;
  --warning: #916613;
  --warning-bg: #fff4d8;
  --success: #287457;
  --success-bg: #e7f5ee;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(36, 35, 67, .09);
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; color: var(--ink); background: var(--bg); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.5; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, .button { min-height: 42px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 22px 16px; display: flex; flex-direction: column; color: #f5f3fb; background: linear-gradient(180deg, #242343 0%, #302d58 100%); z-index: 50; overflow: hidden; }
.sidebar::after { content: ""; position: absolute; width: 190px; height: 190px; right: -118px; bottom: 78px; border: 1px solid rgba(242, 232, 187, .16); border-radius: 50%; box-shadow: 0 0 0 28px rgba(201, 195, 223, .035), 0 0 0 58px rgba(201, 195, 223, .025); pointer-events: none; }
.brand { display: flex; gap: 12px; align-items: center; padding: 4px 8px 25px; text-decoration: none; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.36); border-radius: 50%; color: #514a7c; background: radial-gradient(circle at 38% 35%, #fffdf5, var(--moon)); box-shadow: 0 0 22px rgba(242,232,187,.18); font-size: 1.75rem; font-weight: 800; line-height: 1; }
.brand strong, .brand small, .user-chip strong, .user-chip small { display: block; }
.brand small, .user-chip small { color: #c2bdd7; font-size: .75rem; }
.main-nav { display: grid; gap: 5px; }
.nav-link { display: flex; gap: 11px; align-items: center; padding: 10px 12px; border-radius: 10px; color: #d4d0e3; text-decoration: none; font-size: .93rem; font-weight: 650; }
.nav-link:hover, .nav-link.active { color: #fff; background: rgba(255,255,255,.11); }
.nav-icon { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 8px; background: rgba(255,255,255,.08); font-size: .72rem; }
.sidebar-footer { margin-top: auto; padding: 16px 8px 2px; border-top: 1px solid rgba(255,255,255,.12); }
.user-chip { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; font-size: .87rem; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: var(--brand); background: var(--moon); font-weight: 800; }
.text-link { color: #d4d0e3; font-size: .84rem; }

.page-shell { min-width: 0; }
.topbar { min-height: 94px; display: flex; align-items: center; gap: 16px; padding: 19px clamp(20px, 4vw, 48px); background: rgba(255,255,255,.9); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; backdrop-filter: blur(12px); }
.topbar h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.55rem, 3vw, 2rem); line-height: 1.1; }
.eyebrow { margin: 0 0 3px; color: var(--muted); font-size: .75rem; text-transform: capitalize; }
.topbar-action { margin-left: auto; }
.menu-button { display: none; }
.page-content { padding: 30px clamp(20px, 4vw, 48px) 56px; max-width: 1600px; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; border: 1px solid transparent; border-radius: 10px; text-decoration: none; cursor: pointer; font-weight: 750; font-size: .9rem; }
.button-primary { color: #fff; background: var(--brand); }
.button-primary:hover { background: var(--brand-2); }
.button-secondary { color: var(--brand); background: #fff; border-color: var(--line); }
.button-danger { color: var(--danger); background: var(--danger-bg); }
.button-small { min-height: 34px; padding: 6px 10px; font-size: .78rem; }
.icon-button { border: 0; background: transparent; cursor: pointer; }
.link { color: var(--brand-2); font-weight: 700; }

.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 0 0 15px; }
.section-heading h2, .card h2, .card h3 { margin: 0; }
.section-heading p { margin: 4px 0 0; color: var(--muted); }
.stack { display: grid; gap: 20px; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 20px; }
.card-header { padding: 17px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.metric-card { padding: 18px 20px; position: relative; overflow: hidden; }
.metric-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--brand-2); }
.metric-label { color: var(--muted); font-size: .82rem; font-weight: 700; }
.metric-value { display: block; margin-top: 3px; font-family: Georgia, serif; font-size: 2rem; line-height: 1; }
.metric-note { display: block; margin-top: 8px; color: var(--muted); font-size: .77rem; }

.task-list, .activity-list { list-style: none; margin: 0; padding: 0; }
.task-item { display: grid; grid-template-columns: 11px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.task-item:last-child { border-bottom: 0; }
.task-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.task-dot.overdue { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-bg); }
.task-copy strong, .task-copy small { display: block; }
.task-copy small { margin-top: 2px; color: var(--muted); font-size: .78rem; }
.empty-state { padding: 38px 20px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--ink); }

.badge { display: inline-flex; align-items: center; min-height: 25px; padding: 3px 9px; border-radius: 999px; white-space: nowrap; font-size: .72rem; font-weight: 800; }
.badge-priority-high { color: #97393e; background: #f8dddf; }
.badge-priority-medium { color: #7b5610; background: #fae9bd; }
.badge-priority-low { color: #27654d; background: #dff0e8; }
.status-pending { color: #57615f; background: #e9edec; }
.status-contacted { color: #315f8a; background: #e2edf7; }
.status-replied { color: #6b4c8f; background: #eee6f7; }
.status-conversation { color: #805c11; background: #fae9bd; }
.status-proposal { color: #8b4c23; background: #f7e3d5; }
.status-won { color: #27654d; background: #dff0e8; }
.status-rejected { color: #97393e; background: #f8dddf; }

.filter-bar { padding: 16px; display: grid; grid-template-columns: minmax(220px, 2fr) repeat(5, minmax(120px, 1fr)) auto; gap: 10px; align-items: end; }
.field { display: grid; gap: 6px; }
.field label { color: #4b4860; font-size: .78rem; font-weight: 800; }
.field input, .field select, .field textarea { width: 100%; min-height: 42px; padding: 9px 11px; color: var(--ink); background: #fff; border: 1px solid #d5d0e1; border-radius: 9px; outline: none; }
.field textarea { min-height: 105px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(90, 83, 140, .14); }
.field small, .help-text { color: var(--muted); font-size: .75rem; }
.field-full { grid-column: 1 / -1; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.form-actions { display: flex; gap: 10px; align-items: center; padding-top: 5px; }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 880px; }
.data-table th { padding: 12px 15px; color: var(--muted); background: #faf9fc; border-bottom: 1px solid var(--line); text-align: left; font-size: .72rem; letter-spacing: .025em; text-transform: uppercase; }
.data-table td { padding: 14px 15px; border-bottom: 1px solid var(--line); font-size: .87rem; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fbfaff; }
.business-name { font-weight: 800; text-decoration: none; }
.business-name:hover { color: var(--brand-2); text-decoration: underline; }
.date-overdue { color: var(--danger); font-weight: 800; }
.date-today { color: var(--warning); font-weight: 800; }

.kanban-board { display: grid; grid-template-columns: repeat(7, minmax(260px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 14px; align-items: start; }
.kanban-column { min-height: 250px; border-radius: var(--radius); background: #eceaf2; border: 1px solid transparent; transition: .16s ease; }
.kanban-column.drag-over { border-color: var(--brand-2); background: #e6e2f1; }
.kanban-column-header { position: sticky; top: 95px; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 13px; background: #eceaf2; border-radius: var(--radius) var(--radius) 0 0; }
.kanban-column-header h2 { margin: 0; font-size: .88rem; }
.column-count { min-width: 25px; height: 25px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); background: rgba(255,255,255,.75); font-size: .72rem; font-weight: 800; }
.kanban-cards { display: grid; gap: 10px; padding: 0 10px 10px; min-height: 190px; }
.kanban-card { padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: 11px; box-shadow: 0 4px 12px rgba(36, 35, 67, .07); cursor: grab; }
.kanban-card.dragging { opacity: .45; }
.kanban-card.saving { opacity: .62; pointer-events: none; }
.kanban-card h3 { margin: 0 0 4px; font-size: .95rem; }
.kanban-card p { margin: 0; color: var(--muted); font-size: .76rem; }
.kanban-card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 11px 0; }
.kanban-dates { display: grid; gap: 3px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: .72rem; }
.mobile-status { display: none; margin-top: 10px; width: 100%; }

.detail-hero { padding: 22px; display: flex; justify-content: space-between; gap: 20px; align-items: start; }
.detail-hero h2 { margin: 0 0 5px; font-family: Georgia, serif; font-size: 1.65rem; }
.detail-hero p { margin: 0; color: var(--muted); }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px 22px; }
.detail-item dt { color: var(--muted); font-size: .74rem; font-weight: 800; text-transform: uppercase; }
.detail-item dd { margin: 3px 0 0; overflow-wrap: anywhere; }
.activity-item { padding: 16px 0; border-bottom: 1px solid var(--line); }
.activity-item:last-child { border-bottom: 0; }
.activity-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.activity-head strong { font-size: .86rem; }
.activity-head time, .activity-user { color: var(--muted); font-size: .74rem; }
.activity-item p { margin: 0; white-space: pre-wrap; }

.funnel { display: grid; gap: 8px; max-width: 760px; margin: 0 auto; }
.funnel-row { min-height: 52px; margin-inline: auto; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; border-radius: 9px; color: #fff; background: var(--brand); }
.funnel-row:nth-child(2) { background: #36325f; }
.funnel-row:nth-child(3) { background: #4a4577; }
.funnel-row:nth-child(4) { background: #625b8f; }
.funnel-row:nth-child(5) { background: #7a72a4; }
.funnel-row:nth-child(6) { background: #5d658f; }

.alert { margin-bottom: 18px; padding: 12px 15px; border-radius: 10px; font-weight: 650; }
.alert-success { color: var(--success); background: var(--success-bg); }
.alert-error { color: var(--danger); background: var(--danger-bg); }
.alert-warning { color: var(--warning); background: var(--warning-bg); }
.error-list { margin: 0 0 18px; padding: 13px 16px 13px 34px; color: var(--danger); background: var(--danger-bg); border-radius: 10px; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 82% 20%, rgba(242,232,187,.92) 0 5%, rgba(242,232,187,.14) 5.2% 11%, transparent 11.2%), linear-gradient(140deg, #f2f0f7 0 58%, #242343 58%); }
.login-card { width: min(100%, 430px); padding: 32px; background: #fff; border-radius: 20px; box-shadow: 0 24px 70px rgba(31, 28, 65, .24); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.login-brand strong, .login-brand small { display: block; }
.login-brand small { color: var(--muted); font-size: .75rem; }
.login-card h1 { margin: 0 0 8px; font-family: Georgia, serif; font-size: 2rem; }
.login-card > p { margin: 0 0 24px; color: var(--muted); }
.login-card form { display: grid; gap: 16px; }
.login-card .button { width: 100%; }
.setup-note { margin-top: 18px; color: var(--muted); font-size: .8rem; text-align: center; }

.pagination { display: flex; justify-content: center; gap: 6px; padding: 18px; }
.pagination a, .pagination span { min-width: 36px; height: 36px; display: grid; place-items: center; padding: 0 9px; border-radius: 8px; text-decoration: none; }
.pagination .current { color: #fff; background: var(--brand); }
.sidebar-backdrop { display: none; }

@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-bar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filter-bar .field:first-child { grid-column: span 2; }
}

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-105%); width: 270px; transition: transform .2s ease; }
  .menu-open .sidebar { transform: translateX(0); }
  .menu-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(20, 18, 42, .48); }
  .menu-button { display: inline-grid; place-items: center; width: 42px; }
  .topbar { min-height: 78px; padding: 13px 16px; }
  .topbar-action { padding-inline: 11px; font-size: .8rem; }
  .eyebrow { display: none; }
  .page-content { padding: 20px 14px 45px; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .detail-hero { display: grid; }
  .kanban-column-header { top: 79px; }
  .mobile-status { display: block; }
  .kanban-card { cursor: default; }
}

@media (max-width: 600px) {
  .grid-4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric-card { padding: 15px; }
  .metric-value { font-size: 1.65rem; }
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .filter-bar .field:first-child { grid-column: 1 / -1; }
  .form-grid, .detail-list { grid-template-columns: 1fr; }
  .section-heading { align-items: start; flex-direction: column; }
  .task-item { grid-template-columns: 10px minmax(0, 1fr); }
  .task-item .button { grid-column: 2; justify-self: start; }
  .topbar h1 { font-size: 1.35rem; }
  .topbar-action { min-height: 38px; }
  .card-body { padding: 16px; }
  .login-card { padding: 25px 20px; }
}

