:root {
  color-scheme: light;
  --ink: #17202c;
  --muted: #657184;
  --line: #dfe4eb;
  --surface: #fff;
  --canvas: #f4f6f8;
  --nav: #172337;
  --nav-soft: #24334a;
  --primary: #e5542d;
  --primary-dark: #c83f1d;
  --blue: #3769db;
  --blue-soft: #edf3ff;
  --green: #1d8a63;
  --green-soft: #eaf8f2;
  --amber: #a7690a;
  --amber-soft: #fff4dc;
  --red: #b33c3c;
  --red-soft: #fff0f0;
  --violet: #7955cf;
  --violet-soft: #f1edff;
  --radius: 16px;
  --shadow: 0 14px 35px rgb(35 50 72 / 10%);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-size: 14px; line-height: 1.45; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.danger-text { color: var(--red); }
.nowrap { white-space: nowrap; }

.loading-screen { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 16px; color: var(--muted); }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 12px; color: #fff; background: var(--primary); font-weight: 850; letter-spacing: -.05em; }
.brand-mark--large { width: 56px; height: 56px; border-radius: 16px; color: #fff; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0, 1fr); }
.sidebar { position: sticky; z-index: 30; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 24px 17px 17px; color: #fff; background: var(--nav); }
.brand-row { display: flex; align-items: center; gap: 12px; padding: 0 9px 24px; text-decoration: none; }
.brand-row > span:last-child { min-width: 0; display: grid; }
.brand-row strong { font-size: 14px; }
.brand-row small { margin-top: 3px; color: #94a2b8; font-size: 11px; }
.side-nav { display: grid; gap: 5px; }
.nav-item { width: 100%; min-height: 41px; display: flex; align-items: center; gap: 11px; padding: 9px 12px; border: 0; border-radius: 10px; color: #aeb9ca; background: transparent; text-align: left; text-decoration: none; font-weight: 650; }
.nav-item > span:first-child { width: 22px; color: #8ea3c2; font-size: 18px; text-align: center; }
.nav-item:hover { color: #fff; background: rgb(255 255 255 / 6%); }
.nav-item.is-active { color: #fff; background: var(--nav-soft); box-shadow: inset 3px 0 var(--primary); }
.nav-item--link { margin-top: 6px; }
.sidebar-spacer { flex: 1; }
.user-card { display: grid; grid-template-columns: 38px minmax(0,1fr) 34px; align-items: center; gap: 10px; margin-top: 10px; padding: 12px 7px 0; border-top: 1px solid rgb(255 255 255 / 9%); }
.user-card > span:nth-child(2) { min-width: 0; display: grid; }
.user-card strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.user-card small { color: #8f9db1; }
.avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: #334660; font-size: 12px; font-weight: 800; }
.icon-button { width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 9px; color: #9dabbf; background: transparent; font-size: 20px; }
.icon-button:hover { color: #fff; background: rgb(255 255 255 / 8%); }
.icon-button--light { color: var(--muted); }
.icon-button--light:hover { color: var(--ink); background: #eef1f5; }

.workspace { min-width: 0; }
.content { width: min(1600px, 100%); min-height: 100vh; margin: 0 auto; padding: 32px 38px 70px; outline: 0; }
.preview-banner { position: sticky; z-index: 20; top: 0; padding: 7px 28px; color: #704809; background: #ffe8ad; border-bottom: 1px solid #f1d082; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-align: center; }
.mobile-header { display: none; }

.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-header h1 { margin: 0; font-size: clamp(28px, 3vw, 36px); line-height: 1.12; letter-spacing: -.035em; }
.page-header p:last-child { max-width: 720px; margin: 7px 0 0; color: var(--muted); }
.eyebrow { margin: 0 0 7px; color: var(--primary); font-size: 11px; font-weight: 850; letter-spacing: .11em; text-transform: uppercase; }
.header-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.button { min-height: 41px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 15px; border: 1px solid transparent; border-radius: 10px; font-weight: 750; text-decoration: none; transition: transform .12s, box-shadow .12s, background .12s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .55; }
.button--primary { color: #fff; background: var(--primary); box-shadow: 0 7px 16px rgb(229 84 45 / 20%); }
.button--primary:hover:not(:disabled) { background: var(--primary-dark); }
.button--secondary { color: #28364a; border-color: #ccd3de; background: #fff; }
.button--ghost { color: #43516a; border-color: #d9dfe7; background: transparent; }
.button--ghost:hover:not(:disabled) { background: #fff; }
.button--small { min-height: 32px; padding: 5px 10px; border-radius: 8px; font-size: 12px; }
.button--wide { width: 100%; }

.panel { min-width: 0; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 2px 5px rgb(32 48 71 / 3%); }
.panel--compact { padding: 13px 15px; }
.panel-spaced { margin-top: 18px; }
.table-spaced { margin-top: 12px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 17px; }
.panel-heading h2, .panel-heading h3 { margin: 0; font-size: 18px; }
.panel-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.summary-grid { display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); gap: 12px; margin-bottom: 18px; }
.summary-card { min-width: 0; padding: 17px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.summary-card span { display: block; color: var(--muted); font-size: 12px; }
.summary-card strong { display: block; margin-top: 7px; font-size: 28px; line-height: 1; }
.summary-card--danger strong { color: var(--red); }
.summary-card--accent { border-color: #f0c8bc; background: #fff8f5; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(320px, .75fr); gap: 18px; }
.dashboard-column { min-width: 0; display: grid; align-content: start; gap: 18px; }

.work-queue { display: grid; gap: 8px; }
.queue-item { display: grid; grid-template-columns: 44px minmax(0,1fr) auto; align-items: center; gap: 12px; padding: 12px; border: 1px solid #e7ebf0; border-radius: 12px; background: #fff; }
.queue-time { color: var(--primary); font-size: 11px; font-weight: 850; text-align: center; }
.queue-item strong, .queue-item span { display: block; }
.queue-item small { color: var(--muted); }
.queue-item.is-overdue { border-left: 4px solid var(--red); }
.queue-item.is-today { border-left: 4px solid #e0a126; }
.attention-list { display: grid; gap: 8px; }
.attention-item { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; padding: 12px; border-radius: 11px; background: var(--amber-soft); }
.attention-item strong { display: block; }
.attention-item small { color: #765523; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 17px; }
.toolbar-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.search-field { min-width: min(380px, 100%); display: flex; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid #d7dce4; border-radius: 10px; background: #fff; }
.search-field input { width: 100%; min-height: 40px; border: 0; outline: 0; background: transparent; }
.toolbar select { min-height: 40px; padding: 7px 31px 7px 10px; border: 1px solid #d7dce4; border-radius: 10px; color: var(--ink); background: #fff; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { position: sticky; z-index: 1; top: 0; padding: 11px 13px; border-bottom: 1px solid var(--line); color: var(--muted); background: #f8f9fb; font-size: 11px; letter-spacing: .035em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 12px 13px; border-bottom: 1px solid #edf0f3; vertical-align: top; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fbfcfd; }
.row-link { padding: 0; border: 0; color: #274d9c; background: none; font-weight: 750; text-align: left; }
.row-link:hover { text-decoration: underline; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 999px; color: #526073; background: #eef1f4; font-size: 11px; font-weight: 800; white-space: nowrap; }
.badge--green { color: #116b4c; background: var(--green-soft); }
.badge--amber { color: #8c5606; background: var(--amber-soft); }
.badge--red { color: #9c3333; background: var(--red-soft); }
.badge--blue { color: #244fa9; background: var(--blue-soft); }
.badge--violet { color: #5d3da5; background: var(--violet-soft); }
.priority { width: 28px; height: 28px; display: inline-grid; place-items: center; border-radius: 8px; font-size: 12px; font-weight: 900; }
.priority-A { color: #9c3333; background: var(--red-soft); }
.priority-B { color: #8c5606; background: var(--amber-soft); }
.priority-C { color: #244fa9; background: var(--blue-soft); }
.priority-D { color: #596474; background: #eef1f4; }

.kanban-shell { overflow: auto; margin: 0 -38px; padding: 2px 38px 24px; }
.kanban { min-width: max-content; display: grid; grid-auto-columns: 286px; grid-auto-flow: column; align-items: start; gap: 12px; }
.kanban-column { min-height: 450px; padding: 11px; border: 1px solid var(--line); border-radius: 15px; background: #eef1f4; }
.kanban-column.is-over { outline: 2px solid var(--primary); outline-offset: -2px; }
.kanban-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 3px 12px; }
.kanban-header strong { max-width: 225px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kanban-count { min-width: 24px; height: 24px; display: grid; place-items: center; border-radius: 8px; color: var(--muted); background: #fff; font-size: 11px; font-weight: 800; }
.kanban-cards { display: grid; gap: 9px; }
.deal-card { display: grid; gap: 10px; padding: 14px; border: 1px solid #dce1e7; border-radius: 12px; background: #fff; box-shadow: 0 4px 12px rgb(31 47 69 / 5%); cursor: grab; }
.deal-card:active { cursor: grabbing; }
.deal-card.is-aging { border-left: 4px solid var(--amber); }
.deal-card h3 { margin: 0; font-size: 14px; line-height: 1.25; }
.deal-card p { margin: 0; color: var(--muted); font-size: 12px; }
.deal-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 11px; }
.deal-card-actions { display: flex; justify-content: space-between; gap: 7px; padding-top: 3px; border-top: 1px solid #edf0f3; }
.deal-card-actions button { padding: 3px; border: 0; color: #405275; background: none; font-size: 11px; font-weight: 750; }

.empty-state { padding: 52px 20px; border: 1px dashed #cdd4df; border-radius: var(--radius); color: var(--muted); background: rgb(255 255 255 / 55%); text-align: center; }
.empty-state h3 { margin: 8px 0 4px; color: var(--ink); }
.empty-state p { margin: 0; }
.loading-card { padding: 38px; color: var(--muted); text-align: center; }
.error-state { padding: 24px; border: 1px solid #f1caca; border-radius: 14px; color: var(--red); background: var(--red-soft); }

.drawer-backdrop { position: fixed; z-index: 80; inset: 0; background: rgb(16 27 43 / 38%); }
.company-drawer { position: fixed; z-index: 90; inset: 0 0 0 auto; width: min(820px, 94vw); overflow: auto; border-left: 1px solid #dce1e7; background: var(--canvas); box-shadow: -25px 0 60px rgb(18 30 49 / 20%); }
.drawer-header { position: sticky; z-index: 3; top: 0; padding: 22px 24px 17px; border-bottom: 1px solid var(--line); background: rgb(255 255 255 / 97%); backdrop-filter: blur(8px); }
.drawer-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.drawer-title-row h2 { margin: 0; font-size: 26px; letter-spacing: -.025em; }
.drawer-subtitle { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 16px; }
.tabs { position: sticky; z-index: 2; top: 137px; display: flex; overflow: auto; padding: 0 24px; border-bottom: 1px solid var(--line); background: #fff; }
.tab-button { padding: 13px 11px; border: 0; border-bottom: 2px solid transparent; color: var(--muted); background: none; font-size: 12px; font-weight: 750; white-space: nowrap; }
.tab-button.is-active { color: var(--primary); border-bottom-color: var(--primary); }
.drawer-body { display: grid; gap: 15px; padding: 20px 24px 50px; }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 9px; }
.detail-cell { min-width: 0; padding: 12px; border-radius: 11px; background: #f7f8fa; }
.detail-cell span { display: block; color: var(--muted); font-size: 11px; }
.detail-cell strong { display: block; overflow-wrap: anywhere; margin-top: 3px; }
.detail-cell--wide { grid-column: span 2; }
.activity-list { display: grid; gap: 0; }
.activity-item { position: relative; display: grid; grid-template-columns: 110px minmax(0,1fr); gap: 14px; padding: 0 0 18px 20px; border-left: 2px solid #dfe4eb; }
.activity-item::before { position: absolute; top: 3px; left: -6px; width: 10px; height: 10px; border: 2px solid #fff; border-radius: 50%; background: var(--primary); content: ""; }
.activity-item time { color: var(--muted); font-size: 11px; }
.activity-item p { margin: 0; }
.activity-item small { color: var(--muted); }
.journey-badges { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; }
.reference-item--stacked { align-items: flex-start; }
.journey-item--origin::before { background: #7c3aed; }
.journey-item--internal::before { background: #64748b; }
.journey-item--touchpoint::before { background: #059669; }
.journey-item--milestone::before { background: #ea580c; }

.action-dialog { width: min(720px, calc(100vw - 28px)); max-height: min(880px, calc(100vh - 28px)); padding: 0; overflow: auto; border: 0; border-radius: 18px; color: var(--ink); background: #fff; box-shadow: 0 30px 90px rgb(15 29 48 / 30%); }
.action-dialog::backdrop { background: rgb(17 28 44 / 52%); }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 22px 24px 16px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; font-size: 24px; }
.dialog-body { display: grid; gap: 14px; padding: 20px 24px; }
.dialog-footer { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--line); background: #fff; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 13px; }
.field { min-width: 0; display: grid; align-content: start; gap: 6px; }
.field--wide { grid-column: 1 / -1; }
.field > span { color: #4f5b6c; font-size: 12px; font-weight: 700; }
.field input, .field select, .field textarea { width: 100%; min-height: 41px; padding: 9px 11px; border: 1px solid #d4dae3; border-radius: 9px; color: var(--ink); background: #fff; outline: 0; }
.field textarea { min-height: 82px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #e28970; box-shadow: 0 0 0 3px rgb(229 84 45 / 10%); }
.field small { color: var(--muted); font-size: 11px; }
.check-field { display: flex; align-items: center; gap: 8px; color: #465368; font-size: 12px; font-weight: 700; }
.check-field input { width: 17px; height: 17px; }
.form-error { min-height: 20px; margin: 0; padding: 0 24px; color: var(--red); font-size: 12px; }
.form-section { grid-column: 1 / -1; padding-top: 4px; border-top: 1px solid #edf0f3; }
.form-section h3 { margin: 9px 0 1px; font-size: 14px; }

.funnel { display: grid; gap: 6px; }
.funnel-row { display: grid; grid-template-columns: 170px minmax(160px,1fr) 90px 110px; align-items: center; gap: 10px; }
.funnel-bar { height: 28px; overflow: hidden; border-radius: 8px; background: #edf0f4; }
.funnel-bar span { height: 100%; display: block; min-width: 2px; border-radius: 8px; background: linear-gradient(90deg, var(--primary), #ef8a67); }
.funnel-bar .bar-w-0 { width: 2px; }
.funnel-bar .bar-w-5 { width: 5%; }
.funnel-bar .bar-w-10 { width: 10%; }
.funnel-bar .bar-w-15 { width: 15%; }
.funnel-bar .bar-w-20 { width: 20%; }
.funnel-bar .bar-w-25 { width: 25%; }
.funnel-bar .bar-w-30 { width: 30%; }
.funnel-bar .bar-w-35 { width: 35%; }
.funnel-bar .bar-w-40 { width: 40%; }
.funnel-bar .bar-w-45 { width: 45%; }
.funnel-bar .bar-w-50 { width: 50%; }
.funnel-bar .bar-w-55 { width: 55%; }
.funnel-bar .bar-w-60 { width: 60%; }
.funnel-bar .bar-w-65 { width: 65%; }
.funnel-bar .bar-w-70 { width: 70%; }
.funnel-bar .bar-w-75 { width: 75%; }
.funnel-bar .bar-w-80 { width: 80%; }
.funnel-bar .bar-w-85 { width: 85%; }
.funnel-bar .bar-w-90 { width: 90%; }
.funnel-bar .bar-w-95 { width: 95%; }
.funnel-bar .bar-w-100 { width: 100%; }
.analytics-grid { display: grid; grid-template-columns: minmax(0,1.25fr) minmax(300px,.75fr); gap: 18px; }
.reference-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.reference-list { display: grid; gap: 7px; }
.reference-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 11px; border-radius: 9px; background: #f6f8fa; }
.reference-item code { color: var(--muted); font-size: 10px; }
.reference-item small { display: block; margin-top: 3px; color: var(--muted); }

.import-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.import-summary > div { padding: 13px; border-radius: 11px; background: #f6f8fa; text-align: center; }
.import-summary strong { display: block; font-size: 23px; }
.mapping-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; }
.mapping-grid label { display: grid; grid-template-columns: minmax(110px,1fr) minmax(130px,1fr); align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.mapping-grid select { min-height: 36px; border: 1px solid #d7dce4; border-radius: 8px; }

.toast-region { position: fixed; z-index: 200; top: 18px; right: 18px; width: min(390px, calc(100vw - 36px)); display: grid; gap: 8px; }
.toast { padding: 13px 15px; border: 1px solid #b9ded0; border-radius: 11px; color: #155f47; background: #f0fbf7; box-shadow: var(--shadow); font-weight: 650; }
.toast.is-error { border-color: #edc5c5; color: #943737; background: #fff4f4; }
.round-add { width: 34px; height: 34px; border: 0; border-radius: 50%; color: #fff; background: var(--primary); font-size: 22px; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 224px minmax(0,1fr); }
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
  .dashboard-grid, .analytics-grid { grid-template-columns: 1fr; }
  .reference-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; transform: translateX(-105%); transition: transform .2s; box-shadow: 16px 0 35px rgb(19 31 50 / 26%); }
  .sidebar.is-open { transform: translateX(0); }
  .mobile-header { position: sticky; z-index: 20; top: 0; height: 56px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; border-bottom: 1px solid var(--line); background: rgb(255 255 255 / 96%); }
  .mobile-header .icon-button { color: var(--ink); }
  .content { padding: 24px 17px 60px; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .kanban-shell { margin: 0 -17px; padding-left: 17px; padding-right: 17px; }
  .reference-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .tabs { top: 160px; }
}

@media (max-width: 560px) {
  .page-header { align-items: stretch; }
  .header-actions, .header-actions .button { width: 100%; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .summary-card { padding: 13px; }
  .summary-card strong { font-size: 23px; }
  .queue-item { grid-template-columns: 42px minmax(0,1fr); }
  .queue-item .button { grid-column: 1 / -1; }
  .form-grid { grid-template-columns: 1fr; }
  .field--wide { grid-column: auto; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-cell--wide { grid-column: auto; }
  .drawer-header, .drawer-body { padding-left: 16px; padding-right: 16px; }
  .tabs { padding: 0 16px; top: 192px; }
  .company-drawer { width: 100vw; }
  .activity-item { grid-template-columns: 1fr; gap: 2px; }
  .funnel-row { grid-template-columns: 120px minmax(100px,1fr) 55px; }
  .funnel-row > :last-child { display: none; }
  .mapping-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

:focus-visible { outline: 3px solid rgb(55 105 219 / 35%); outline-offset: 2px; }
