:root {
  --ink: #17243a;
  --muted: #69778c;
  --line: #e1e7ef;
  --soft: #f4f7fb;
  --canvas: #f6f8fc;
  --surface: #ffffff;
  --blue: #315fe8;
  --blue-dark: #234bc2;
  --navy: #172b4d;
  --mint: #e7f6f1;
  --mint-ink: #23836b;
  --violet: #f0edff;
  --violet-ink: #6954c8;
  --red: #c53434;
  --red-soft: #fff1f1;
  --shadow: 0 2px 4px rgba(27, 43, 70, .025), 0 10px 28px rgba(27, 43, 70, .055);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; font-size: 16px; line-height: 1.45; background: radial-gradient(ellipse at 85% 0%, rgba(230, 238, 255, .52), transparent 34rem), var(--canvas); }
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-dark); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.5rem, 2vw, 1.9rem); letter-spacing: -.035em; line-height: 1.2; }
h2 { margin-bottom: 0; font-size: 1rem; letter-spacing: -.01em; }
::selection { color: #fff; background: var(--blue); }
:focus-visible { outline: 3px solid rgba(49, 95, 232, .38); outline-offset: 3px; }

.topbar { position: sticky; top: 0; z-index: 10; background: rgba(255,255,255,.91); border-bottom: 1px solid rgba(220, 228, 238, .85); backdrop-filter: blur(14px); }
.topbar-inner { min-height: 68px; max-width: 1340px; padding: 0 32px; margin: 0 auto; display: flex; align-items: center; gap: 34px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 740; font-size: 1.02rem; letter-spacing: -.03em; white-space: nowrap; }
.brand:hover { color: var(--ink); }
.brand-mark { width: 29px; height: 29px; padding: 7px; display: flex; align-items: flex-end; justify-content: center; gap: 2px; background: linear-gradient(145deg, #4b79f5, #315fe8); border-radius: 9px; box-shadow: 0 3px 8px rgba(49, 95, 232, .23); }
.brand-mark span { width: 3px; border-radius: 3px; background: #fff; }
.brand-mark span:nth-child(1) { height: 7px; opacity: .72; }
.brand-mark span:nth-child(2) { height: 11px; }
.brand-mark span:nth-child(3) { height: 15px; opacity: .82; }
.main-nav { display: flex; height: 68px; align-items: stretch; gap: 4px; }
.main-nav a { display: flex; align-items: center; padding: 0 12px; color: var(--muted); font-size: .9rem; border-bottom: 2px solid transparent; transition: color .15s ease, border-color .15s ease; }
.main-nav a:hover, .main-nav a.active { color: var(--ink); }
.main-nav a.active { border-bottom-color: var(--blue); font-weight: 650; }
.account-menu { position: relative; margin-left: auto; color: var(--muted); font-size: .88rem; }
.account-menu summary { display: flex; align-items: center; gap: 9px; list-style: none; cursor: pointer; padding: 6px 0 6px 10px; }
.account-menu summary::-webkit-details-marker { display: none; }
.account-avatar { width: 31px; height: 31px; display: grid; place-items: center; color: #3156b7; background: #eaf0ff; border: 1px solid #dbe5ff; border-radius: 50%; font-size: .76rem; font-weight: 750; }
.account-name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #3c4a60; font-weight: 600; }
.account-chevron { width: 7px; height: 7px; margin: -4px 2px 0 1px; border-right: 1.5px solid #8190a4; border-bottom: 1.5px solid #8190a4; transform: rotate(45deg); }
.account-menu form { position: absolute; min-width: 150px; right: 0; top: 45px; background: var(--surface); box-shadow: var(--shadow); border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.account-menu button { width: 100%; padding: 9px 12px; border: 0; background: transparent; color: var(--ink); text-align: left; font-size: .88rem; }
.account-menu button:hover { background: var(--soft); }

.page-shell { max-width: 1340px; margin: 0 auto; padding: 40px 32px 60px; }
.page-heading { margin: 0 0 26px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-eyebrow { display: block; margin-bottom: 6px; color: var(--blue); font-size: .7rem; font-weight: 760; letter-spacing: .1em; text-transform: uppercase; }
.page-description { margin: 8px 0 0; color: var(--muted); font-size: .9rem; }
.heading-actions, .form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; border: 1px solid transparent; border-radius: 8px; padding: 9px 14px; font-size: .875rem; font-weight: 650; line-height: 1.15; transition: background .15s ease, border .15s ease, color .15s ease, transform .15s ease, box-shadow .15s ease; }
.button:active { transform: translateY(1px); }
.button-primary { background: var(--blue); color: #fff; }
.button-primary:hover { background: var(--blue-dark); color: #fff; box-shadow: 0 3px 8px rgba(49, 95, 232, .2); }
.button-secondary { border-color: #d5dce7; background: #fff; color: #263346; }
.button-secondary:hover { background: var(--soft); color: var(--ink); }
.button-danger { background: var(--red); color: #fff; }
.button-danger:hover { background: #9f2727; color: #fff; }
.button-full { width: 100%; }

.metrics, .result-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 17px; margin-bottom: 25px; }
.metric-card { position: relative; display: flex; align-items: center; gap: 15px; min-height: 121px; padding: 20px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
a.metric-card:hover { color: var(--ink); transform: translateY(-2px); border-color: #cad5e6; box-shadow: 0 9px 22px rgba(27, 43, 70, .075); }
.metric-icon { flex: 0 0 47px; width: 47px; height: 47px; display: grid; place-items: center; border-radius: 13px; }
.metric-icon svg { width: 23px; height: 23px; }
.metric-company .metric-icon { color: var(--blue); background: #edf2ff; }
.metric-contact .metric-icon { color: var(--mint-ink); background: var(--mint); }
.metric-interaction .metric-icon { color: var(--violet-ink); background: var(--violet); }
.metric-info { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.metric-info .metric-label { color: var(--muted); font-size: .85rem; font-weight: 620; }
.metric-info strong { font-size: 1.85rem; font-weight: 720; letter-spacing: -.05em; line-height: 1.08; }
.metric-info .metric-caption { color: #8b96a7; font-size: .76rem; }
.metric-arrow { align-self: flex-start; margin: 1px 0 0 auto; color: #9ba8bb; font-size: .9rem; transition: color .15s ease, transform .15s ease; }
.metric-card:hover .metric-arrow { color: var(--blue); transform: translate(2px, -2px); }
.result-grid .metric-card { align-items: flex-start; flex-direction: column; gap: 4px; min-height: 109px; padding: 20px; }
.result-grid .metric-card > span { color: var(--muted); font-size: .86rem; }
.result-grid .metric-card strong { font-size: 2rem; font-weight: 690; letter-spacing: -.045em; line-height: 1.1; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); }
.panel-header { min-height: 74px; padding: 17px 20px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); }
.panel-header h2 { font-size: .98rem; }
.panel-header p { margin: 4px 0 0; color: var(--muted); font-size: .8rem; }
.panel-header a { flex: 0 0 auto; font-size: .84rem; font-weight: 650; }
.panel-header a span { margin-left: 3px; transition: margin .15s ease; }
.panel-header a:hover span { margin-left: 6px; }
.list-panel-header { min-height: 68px; }
.list-panel-header h2 { font-size: .95rem; }
.count-pill { display: inline-flex; min-width: 34px; height: 30px; align-items: center; justify-content: center; padding: 0 10px; color: #435578; background: #f1f4fa; border: 1px solid #e6ebf3; border-radius: 99px; font-size: .79rem; font-weight: 700; }
.dashboard-hero { position: relative; isolation: isolate; display: flex; justify-content: space-between; align-items: center; gap: 24px; min-height: 197px; margin-bottom: 23px; padding: 30px 34px; overflow: hidden; color: #fff; background: linear-gradient(112deg, var(--navy) 0%, #24436f 58%, #315e8d 100%); border: 1px solid rgba(255,255,255,.12); border-radius: 16px; box-shadow: 0 12px 30px rgba(30, 56, 94, .14); }
.dashboard-hero::before, .dashboard-hero::after { position: absolute; z-index: -1; content: ""; border-radius: 50%; pointer-events: none; }
.dashboard-hero::before { width: 370px; height: 370px; top: -235px; right: 15%; background: rgba(105, 150, 255, .11); }
.dashboard-hero::after { width: 285px; height: 285px; right: -70px; bottom: -220px; border: 1px solid rgba(255,255,255,.12); box-shadow: 0 0 0 22px rgba(255,255,255,.025), 0 0 0 46px rgba(255,255,255,.02); }
.dashboard-copy { position: relative; }
.hero-kicker { display: block; margin-bottom: 10px; color: #a9c5f6; font-size: .73rem; font-weight: 750; letter-spacing: .11em; text-transform: uppercase; }
.dashboard-hero h1 { font-size: clamp(1.75rem, 3vw, 2.35rem); letter-spacing: -.045em; }
.dashboard-hero p { margin: 9px 0 13px; color: #d5e0f1; font-size: .94rem; }
.hero-date { color: #aebdd2; font-size: .78rem; }
.button-hero { flex: 0 0 auto; min-height: 44px; padding: 10px 16px; color: #233b62; background: #fff; box-shadow: 0 4px 12px rgba(7, 23, 48, .13); }
.button-hero:hover { color: #1e3150; background: #edf3ff; box-shadow: 0 6px 16px rgba(7, 23, 48, .2); }
.button-plus { margin-right: 8px; font-size: 1.15rem; font-weight: 500; line-height: 1; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(265px, .85fr); align-items: start; gap: 18px; }
.interaction-feed { display: flex; flex-direction: column; }
.feed-item { display: flex; align-items: center; gap: 13px; min-width: 0; padding: 15px 20px; color: var(--ink); border-bottom: 1px solid var(--line); transition: background .15s ease; }
.feed-item:last-child { border-bottom: 0; }
.feed-item:hover { background: #f8faff; color: var(--ink); }
.feed-avatar { flex: 0 0 37px; width: 37px; height: 37px; display: grid; place-items: center; color: #4a65b5; background: #eef2ff; border: 1px solid #e3e9ff; border-radius: 50%; font-size: .82rem; font-weight: 720; }
.feed-content { min-width: 0; flex: 1; }
.feed-content strong, .feed-content > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-content strong { font-size: .9rem; }
.feed-content > span { margin-top: 3px; color: var(--muted); font-size: .81rem; }
.feed-separator { padding: 0 5px; color: #aab4c2; }
.feed-item time, .feed-date { flex: 0 0 auto; white-space: nowrap; color: var(--muted); font-size: .8rem; }
.shortcuts-panel .panel-header { min-height: 74px; }
.shortcut-list { padding: 5px 16px; }
.shortcut-link { display: flex; align-items: center; gap: 12px; padding: 14px 4px; color: var(--ink); border-bottom: 1px solid var(--line); }
.shortcut-link:last-child { border-bottom: 0; }
.shortcut-link:hover { color: var(--ink); }
.shortcut-icon { flex: 0 0 38px; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; font-size: 1.25rem; line-height: 1; transition: transform .15s ease; }
.shortcut-link:hover .shortcut-icon { transform: scale(1.06); }
.shortcut-company { color: var(--blue); background: #edf2ff; }
.shortcut-contact { color: var(--mint-ink); background: var(--mint); }
.shortcut-copy { min-width: 0; flex: 1; }
.shortcut-copy strong, .shortcut-copy > span { display: block; }
.shortcut-copy strong { font-size: .85rem; }
.shortcut-copy > span { margin-top: 3px; color: var(--muted); font-size: .75rem; line-height: 1.35; }
.shortcut-arrow { color: #a3afbf; font-size: 1rem; transition: color .15s ease, transform .15s ease; }
.shortcut-link:hover .shortcut-arrow { color: var(--blue); transform: translateX(3px); }

.search-bar { display: flex; max-width: 760px; align-items: center; gap: 9px; margin-bottom: 20px; }
.search-bar input { flex: 1; }
.search-input-wrap { position: relative; min-width: 0; flex: 1; }
.search-input-wrap input { padding-left: 38px; }
.search-symbol { position: absolute; z-index: 1; top: 50%; left: 13px; color: #8491a4; font-size: 1.35rem; line-height: 1; transform: translateY(-56%); pointer-events: none; }
.search-reset { flex: 0 0 auto; padding: 8px 3px; color: var(--muted); font-size: .84rem; font-weight: 620; }
.search-reset:hover { color: var(--ink); }
.form-control, .search-bar input, .stack-form input { min-width: 0; width: 100%; min-height: 42px; padding: 8px 11px; color: var(--ink); background: #fff; border: 1px solid #cbd4e1; border-radius: 8px; outline: none; transition: border-color .15s ease, box-shadow .15s ease; }
.form-control:focus, .search-bar input:focus, .stack-form input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(49, 95, 232, .13); }
select.form-control { padding-right: 30px; }
input[type="file"].form-control { padding: 7px 9px; }

.autocomplete { position: relative; width: 100%; }
.autocomplete-input { padding-right: 38px; }
.autocomplete-native { position: absolute; z-index: -1; width: 1px; height: 1px; padding: 0; overflow: hidden; opacity: 0; pointer-events: none; }
.autocomplete-options { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; width: 100%; max-height: 300px; overflow-y: auto; padding: 5px; background: #fff; border: 1px solid #dce3ed; border-radius: 11px; box-shadow: 0 12px 28px rgba(27, 43, 70, .14); }
.autocomplete-options[hidden] { display: none; }
.autocomplete-option { display: flex; width: 100%; flex-direction: column; align-items: flex-start; gap: 2px; padding: 9px 11px; color: var(--ink); background: transparent; border: 0; border-radius: 7px; text-align: left; }
.autocomplete-option:hover, .autocomplete-option.active { color: var(--ink); background: #f2f5fc; }
.autocomplete-option-label { font-size: .88rem; font-weight: 620; }
.autocomplete-option-detail { color: var(--muted); font-size: .76rem; }
.autocomplete-message { padding: 11px; color: var(--muted); font-size: .84rem; }

.table-panel { overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 13px 18px; color: #78869a; background: #f8fafd; border-bottom: 1px solid var(--line); font-size: .72rem; text-transform: uppercase; letter-spacing: .055em; font-weight: 720; white-space: nowrap; }
td { padding: 15px 18px; border-bottom: 1px solid var(--line); font-size: .91rem; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: #f8faff; }
.record-title { display: inline-flex; align-items: center; gap: 10px; }
.record-avatar { flex: 0 0 34px; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; font-size: .8rem; font-weight: 740; }
.company-avatar { color: #315fe8; background: #edf2ff; }
.contact-avatar { color: #23836b; background: #e7f6f1; }
.interaction-avatar { color: #6954c8; background: #f0edff; }
.row-actions { min-width: 154px; display: table-cell; white-space: nowrap; }
.row-actions a { margin-left: 13px; font-size: .84rem; font-weight: 600; }
.row-actions a:first-child { margin-left: 0; }
.danger-link { color: var(--red); }
.danger-link:hover { color: #982626; }
.tag { display: inline-block; padding: 4px 9px; font-size: .76rem; font-weight: 650; color: #364761; background: #edf2f7; border: 1px solid #e5ebf2; border-radius: 99px; white-space: nowrap; }
.pagination { padding: 16px 20px; display: flex; align-items: center; justify-content: center; gap: 17px; border-top: 1px solid var(--line); color: var(--muted); font-size: .84rem; }
.pagination a { font-weight: 650; }

.form-page { max-width: 760px; }
.form-page.narrow { max-width: 580px; }
.back-link { display: inline-block; margin-bottom: 7px; color: var(--muted); font-size: .86rem; font-weight: 600; }
.back-link:hover { color: var(--ink); }
.record-form, .mapping-form, .delete-panel { padding: 26px; }
.field-group { margin-bottom: 20px; }
.field-group:last-of-type { margin-bottom: 0; }
.field-group label, .stack-form label { display: block; margin-bottom: 7px; color: #344054; font-size: .86rem; font-weight: 650; }
.field-group label span, .mapping-row label span { color: var(--red); }
.field-error { margin-top: 6px; color: var(--red); font-size: .82rem; }
.field-error ul { margin: 0; padding: 0; list-style: none; }
.field-note, small { margin: 7px 0 0; color: var(--muted); font-size: .8rem; }
.form-actions { margin-top: 27px; padding-top: 20px; border-top: 1px solid var(--line); justify-content: flex-end; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 18px; }
.form-grid .wide { grid-column: 1 / -1; }
.delete-panel p { margin-bottom: 0; }

.empty-state { padding: 58px 24px; text-align: center; }
.empty-state.compact { padding: 38px 20px; }
.empty-state p { margin-bottom: 16px; color: var(--muted); }
.empty-state h2 { margin: 0 0 7px; font-size: 1rem; }
.empty-icon { width: 42px; height: 42px; display: grid; place-items: center; margin: 0 auto 12px; color: var(--blue); background: #edf2ff; border-radius: 13px; font-size: 1.2rem; }
.messages { margin-bottom: 20px; }
.message { padding: 11px 14px; border-radius: 8px; font-size: .9rem; background: #eaf1ff; border: 1px solid #ceddfb; color: #174a99; }
.message.error { background: var(--red-soft); border-color: #f3caca; color: #9e2020; }

.mapping-list { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.mapping-row { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.2fr); gap: 24px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.mapping-row label { font-weight: 650; font-size: .91rem; }
.muted { color: var(--muted); font-size: .87rem; }
.report-panel { margin-bottom: 18px; overflow: hidden; }
.report-panel h2 { padding: 17px 20px; border-bottom: 1px solid var(--line); }
.report-list { padding: 0; margin: 0; list-style: none; }
.report-list li { padding: 13px 20px; display: grid; grid-template-columns: 100px 1fr; gap: 12px; border-bottom: 1px solid var(--line); font-size: .88rem; }
.report-list li:last-child { border-bottom: 0; }
.report-list span { color: var(--muted); font-weight: 650; }

.auth-page { display: grid; place-items: center; padding: 24px; background: radial-gradient(ellipse at 20% 0%, #e8efff 0, transparent 40%), #f3f6fa; }
.auth-shell { width: 100%; max-width: 410px; }
.auth-card { padding: 36px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 16px 42px rgba(24, 39, 67, .1); }
.auth-card .brand { display: inline-flex; margin-bottom: 34px; }
.auth-card h1 { margin-bottom: 25px; }
.stack-form { display: flex; flex-direction: column; gap: 5px; }
.stack-form label:not(:first-of-type) { margin-top: 12px; }
.stack-form .button { margin-top: 20px; }
.auth-footer { margin: 24px 0 0; color: var(--muted); text-align: center; font-size: .86rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 920px) {
  .dashboard-grid { grid-template-columns: minmax(0, 1.25fr) minmax(245px, .9fr); }
  .metric-card { gap: 11px; padding: 17px; }
  .metric-icon { flex-basis: 42px; width: 42px; height: 42px; }
}

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

@media (max-width: 720px) {
  .topbar-inner { min-height: auto; padding: 0 16px; gap: 0; flex-wrap: wrap; }
  .brand { line-height: 53px; }
  .account-menu { line-height: 37px; }
  .account-name { display: none; }
  .main-nav { order: 3; width: 100%; height: 43px; gap: 0; overflow-x: auto; }
  .main-nav a { padding: 0 10px; font-size: .82rem; white-space: nowrap; }
  .page-shell { padding: 28px 16px 43px; }
  .page-heading { margin-bottom: 20px; align-items: flex-start; flex-direction: column; }
  .heading-actions { width: 100%; }
  .heading-actions .button { flex: 1; }
  .metrics, .result-grid { grid-template-columns: 1fr; gap: 10px; margin-bottom: 20px; }
  .metric-card { min-height: 85px; padding: 14px 16px; }
  .metric-info strong { font-size: 1.6rem; }
  .dashboard-hero { min-height: auto; margin-bottom: 16px; padding: 25px 22px; align-items: flex-start; flex-direction: column; gap: 20px; }
  .dashboard-hero p { max-width: 370px; }
  .dashboard-hero .button { width: 100%; }
  .dashboard-grid { gap: 13px; }
  .feed-item { padding: 14px 15px; gap: 10px; }
  .feed-avatar { flex-basis: 34px; width: 34px; height: 34px; }
  .panel-header { padding: 15px 16px; }
  .search-bar { max-width: none; flex-wrap: wrap; }
  .search-input-wrap { flex-basis: 100%; }
  .search-bar .button { padding-left: 10px; padding-right: 10px; }
  .search-reset { padding-right: 8px; }
  th, td { padding: 13px 14px; }
  .record-form, .mapping-form, .delete-panel { padding: 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .mapping-row { grid-template-columns: 1fr; gap: 7px; }
  .report-list li { grid-template-columns: 1fr; gap: 3px; }
  .form-actions .button { flex: 1; }
}

@media (max-width: 380px) {
  .account-avatar { width: 29px; height: 29px; }
  .brand { gap: 8px; font-size: .96rem; }
  .metric-card { gap: 11px; }
  .metric-icon { flex-basis: 39px; width: 39px; height: 39px; }
  .feed-item time { font-size: .73rem; }
  .panel-header a { font-size: .78rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
