:root {
  --navy: #123f73;
  --navy-deep: #0b2f58;
  --blue: #2474d2;
  --blue-soft: #eaf3ff;
  --green: #1c8b61;
  --green-soft: #e9f7f1;
  --amber: #c47a16;
  --amber-soft: #fff5df;
  --red: #c74343;
  --red-soft: #fff0f0;
  --ink: #17324d;
  --muted: #698096;
  --line: #dce6ef;
  --surface: #ffffff;
  --background: #f5f8fb;
  --shadow: 0 12px 32px rgba(17, 55, 91, .08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--background); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--background); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 10% 10%, #dceeff, transparent 38%), linear-gradient(145deg, #f8fbff 0%, #eef5fb 100%); }
.login-card { width: min(100%, 430px); padding: 42px; border: 1px solid rgba(220,230,239,.9); border-radius: 26px; background: rgba(255,255,255,.96); box-shadow: 0 24px 70px rgba(18,63,115,.13); }
.brand-mark { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 16px; color: white; background: linear-gradient(135deg, #1a5794, #2a82dc); font-size: 26px; font-weight: 800; box-shadow: 0 9px 22px rgba(36,116,210,.24); }
.brand-mark.small { width: 42px; height: 42px; border-radius: 13px; font-size: 20px; box-shadow: none; }
.eyebrow { margin: 22px 0 5px; color: var(--blue); font-size: 12px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
.login-card h1 { margin-bottom: 8px; font-size: 31px; letter-spacing: -.025em; }
.muted, .section-heading p, .panel-heading p { color: var(--muted); }
label { display: block; margin: 22px 0 8px; font-size: 14px; font-weight: 700; }
input[type="text"], input[type="password"], #username { width: 100%; height: 50px; padding: 0 14px; border: 1px solid #cbd9e6; border-radius: 12px; background: white; color: var(--ink); outline: none; transition: border-color .2s, box-shadow .2s; }
input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(36,116,210,.12); }
.support-note { margin: 24px 0 0; color: var(--muted); text-align: center; font-size: 13px; }
.form-message { margin: 14px 0 0; font-size: 14px; }
.error { color: #a53131; }

.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 0 18px; border: 0; border-radius: 12px; font-weight: 750; cursor: pointer; transition: transform .15s, box-shadow .15s, background .15s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:focus-visible, .nav-item:focus-visible, .icon-button:focus-visible { outline: 3px solid rgba(36,116,210,.3); outline-offset: 2px; }
.button.primary { color: white; background: linear-gradient(135deg, var(--navy), var(--blue)); box-shadow: 0 8px 18px rgba(36,116,210,.2); }
.button.secondary { color: var(--navy); background: white; border: 1px solid var(--line); }
.button.wide { width: 100%; margin-top: 24px; }
.button:disabled { opacity: .48; cursor: not-allowed; }
.button-spinner { width: 16px; height: 16px; display: none; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.button.loading .button-spinner { display: block; }
.button.loading > span:first-child { opacity: .8; }
@keyframes spin { to { transform: rotate(360deg); } }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: 252px; display: flex; flex-direction: column; padding: 26px 18px; background: var(--navy-deep); color: white; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 0 9px 28px; }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand strong { font-size: 18px; }
.sidebar-brand span { margin-top: 2px; color: #bcd0e4; font-size: 12px; }
.sidebar nav { display: grid; gap: 6px; }
.nav-item, .logout-button { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 13px; border: 0; border-radius: 11px; color: #c9d8e6; background: transparent; text-align: left; font-weight: 650; cursor: pointer; }
.nav-item:hover, .nav-item.active { color: white; background: rgba(255,255,255,.11); }
.nav-icon { width: 23px; color: #87b9eb; font-size: 20px; text-align: center; }
.logout-button { margin-top: auto; border: 1px solid rgba(255,255,255,.14); justify-content: center; }
.logout-button:hover { color: white; background: rgba(255,255,255,.08); }
.main-content { min-height: 100vh; margin-left: 252px; padding: 30px 38px 54px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin: 0 auto 30px; max-width: 1280px; }
.topbar .eyebrow { margin: 0 0 3px; }
.topbar h1 { margin: 0; font-size: 29px; letter-spacing: -.025em; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.updated-wrap { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.icon-button { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 12px; background: white; color: var(--navy); cursor: pointer; }
.menu-button { display: none; }
.view { display: none; max-width: 1280px; margin: 0 auto; }
.view.active { display: block; animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } }
.section-heading { display: flex; justify-content: space-between; align-items: end; margin-bottom: 19px; }
.section-heading h2 { margin-bottom: 5px; font-size: 23px; letter-spacing: -.02em; }
.section-heading p { margin-bottom: 0; }
.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 16px; }
.metric-card, .panel, .mailbox-card, .health-card { border: 1px solid rgba(220,230,239,.95); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.metric-card { min-height: 142px; padding: 20px; }
.metric-card .metric-icon { width: 38px; height: 38px; display: grid; place-items: center; margin-bottom: 15px; border-radius: 11px; background: var(--blue-soft); color: var(--blue); font-weight: 900; }
.metric-card strong { display: block; margin-bottom: 4px; font-size: clamp(27px, 3vw, 38px); line-height: 1; letter-spacing: -.04em; }
.metric-card span { color: var(--muted); font-size: 13px; font-weight: 650; }
.panel { padding: 23px; }
.two-column { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; }
.overview-lower { margin-top: 18px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.panel-heading h3 { margin-bottom: 4px; font-size: 17px; }
.panel-heading p { margin-bottom: 0; font-size: 13px; }
.notice { margin: 0 auto 18px; max-width: 1280px; padding: 14px 16px; border: 1px solid #b8dfcf; border-radius: 12px; background: var(--green-soft); color: #146c4b; font-weight: 650; }
.notice.error { border-color: #efc2c2; background: var(--red-soft); color: #9e3030; }
.loading-state { min-height: 420px; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); }
.large-spinner { width: 36px; height: 36px; border: 3px solid #d8e5f0; border-top-color: var(--blue); border-radius: 50%; animation: spin .75s linear infinite; }

.mini-chart, .bar-chart { min-height: 210px; display: flex; align-items: end; gap: 8px; padding-top: 15px; }
.chart-column { flex: 1; min-width: 0; display: grid; grid-template-rows: 24px 145px 30px; align-items: end; justify-items: center; gap: 6px; }
.chart-column strong { font-size: 11px; color: var(--ink); }
.chart-track { width: min(26px, 65%); height: 100%; display: flex; align-items: end; border-radius: 8px; background: #edf3f8; overflow: hidden; }
.chart-bar { width: 100%; min-height: 3px; border-radius: 8px 8px 0 0; background: linear-gradient(180deg, #4b96e4, #1766b8); transition: height .35s ease; }
.chart-column span { color: var(--muted); font-size: 10px; white-space: nowrap; transform: rotate(-35deg); transform-origin: center; }
.empty-state { padding: 45px 18px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; margin-bottom: 7px; color: var(--ink); font-size: 17px; }
.compact-pipeline { display: grid; gap: 11px; }
.compact-step { display: grid; grid-template-columns: 95px 1fr 44px; align-items: center; gap: 10px; font-size: 13px; }
.compact-track { height: 9px; border-radius: 99px; background: #ecf2f7; overflow: hidden; }
.compact-fill { height: 100%; border-radius: inherit; background: var(--blue); }
.chart-bar.size-0 { height: 0; } .chart-bar.size-5 { height: 5%; } .chart-bar.size-10 { height: 10%; } .chart-bar.size-15 { height: 15%; } .chart-bar.size-20 { height: 20%; } .chart-bar.size-25 { height: 25%; } .chart-bar.size-30 { height: 30%; } .chart-bar.size-35 { height: 35%; } .chart-bar.size-40 { height: 40%; } .chart-bar.size-45 { height: 45%; } .chart-bar.size-50 { height: 50%; } .chart-bar.size-55 { height: 55%; } .chart-bar.size-60 { height: 60%; } .chart-bar.size-65 { height: 65%; } .chart-bar.size-70 { height: 70%; } .chart-bar.size-75 { height: 75%; } .chart-bar.size-80 { height: 80%; } .chart-bar.size-85 { height: 85%; } .chart-bar.size-90 { height: 90%; } .chart-bar.size-95 { height: 95%; } .chart-bar.size-100 { height: 100%; }
.compact-fill.size-0 { width: 0; } .compact-fill.size-5 { width: 5%; } .compact-fill.size-10 { width: 10%; } .compact-fill.size-15 { width: 15%; } .compact-fill.size-20 { width: 20%; } .compact-fill.size-25 { width: 25%; } .compact-fill.size-30 { width: 30%; } .compact-fill.size-35 { width: 35%; } .compact-fill.size-40 { width: 40%; } .compact-fill.size-45 { width: 45%; } .compact-fill.size-50 { width: 50%; } .compact-fill.size-55 { width: 55%; } .compact-fill.size-60 { width: 60%; } .compact-fill.size-65 { width: 65%; } .compact-fill.size-70 { width: 70%; } .compact-fill.size-75 { width: 75%; } .compact-fill.size-80 { width: 80%; } .compact-fill.size-85 { width: 85%; } .compact-fill.size-90 { width: 90%; } .compact-fill.size-95 { width: 95%; } .compact-fill.size-100 { width: 100%; }
.compact-step strong { text-align: right; }

.upload-panel { max-width: 720px; }
.drop-zone { min-height: 260px; display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0 0 16px; padding: 24px; border: 2px dashed #b8cde0; border-radius: 16px; background: #f8fbfe; cursor: pointer; transition: border .2s, background .2s; text-align: center; }
.drop-zone:hover, .drop-zone.dragging { border-color: var(--blue); background: var(--blue-soft); }
.drop-zone strong { margin: 14px 0 5px; font-size: 18px; }
.drop-zone span:not(.upload-icon), .drop-zone small { color: var(--muted); }
.drop-zone small { margin-top: 12px; }
.upload-icon { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 16px; background: var(--blue-soft); color: var(--blue); font-size: 28px; font-weight: 900; }
.selected-file { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 15px; padding: 13px 15px; border-radius: 11px; background: #f0f5f9; }
.selected-file span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.selected-file button { border: 0; background: transparent; color: var(--red); cursor: pointer; }
.upload-panel .button { width: 100%; }
.upload-panel .notice { margin: 16px 0 0; }
.format-help { max-width: 720px; margin-top: 18px; box-shadow: none; }
.format-help h3 { margin-bottom: 6px; }
.format-help p { color: var(--muted); }
.format-example { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.format-example span { padding: 10px 12px; background: #f7fafc; font-family: ui-monospace, monospace; font-size: 12px; }
.format-example span + span { border-left: 1px solid var(--line); }

.mailbox-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 18px; }
.mailbox-card { padding: 21px; }
.mailbox-top { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.mailbox-card h3 { margin-bottom: 4px; font-size: 16px; overflow-wrap: anywhere; }
.mailbox-card p { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.status-pill, .activity-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border-radius: 99px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.status-pill.green, .activity-pill.replied { color: #167451; background: var(--green-soft); }
.status-pill.yellow { color: #966011; background: var(--amber-soft); }
.status-pill.red { color: #a33333; background: var(--red-soft); }
.activity-pill.opened { color: #1d68b5; background: var(--blue-soft); }
.mailbox-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 20px; }
.mailbox-stat { padding: 12px; border-radius: 11px; background: #f5f8fb; }
.mailbox-stat strong, .mailbox-stat span { display: block; }
.mailbox-stat strong { font-size: 23px; }
.mailbox-stat span { margin-top: 2px; color: var(--muted); font-size: 12px; }

.engagement-panel { padding: 0; overflow: hidden; }
.engagement-row { display: grid; grid-template-columns: minmax(180px, 1.2fr) minmax(120px, 1fr) 110px 140px; align-items: center; gap: 18px; min-height: 72px; padding: 14px 20px; }
.engagement-row + .engagement-row { border-top: 1px solid var(--line); }
.person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar { width: 40px; height: 40px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--blue-soft); color: var(--navy); font-weight: 850; }
.person strong, .person span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person span, .company-name, .engagement-date { color: var(--muted); font-size: 13px; }

.health-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.health-card { padding: 27px; }
.health-card-top { display: flex; justify-content: space-between; align-items: start; gap: 14px; }
.health-card h3 { margin-bottom: 6px; }
.health-value { margin: 25px 0 14px; font-size: 48px; font-weight: 850; letter-spacing: -.05em; }
.health-card > p { margin-bottom: 0; color: var(--muted); line-height: 1.6; }
.health-scale { height: 9px; margin-top: 23px; border-radius: 99px; background: linear-gradient(90deg, var(--green) 0 45%, #e6ad39 45% 72%, var(--red) 72%); }

.pipeline-panel { padding: 32px; }
.funnel { max-width: 850px; margin: 0 auto; display: grid; gap: 12px; }
.funnel-step { min-height: 86px; margin-inline: auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 28px; border-radius: 14px; color: white; box-shadow: 0 8px 16px rgba(17,55,91,.1); }
.funnel-step:nth-child(1) { width: 100%; background: #174f86; }
.funnel-step:nth-child(2) { width: 86%; background: #1e69ad; }
.funnel-step:nth-child(3) { width: 72%; background: #2883c9; }
.funnel-step:nth-child(4) { width: 58%; background: #219375; }
.funnel-step strong { font-size: 30px; }
.funnel-step span { font-weight: 700; }
.sidebar-backdrop { position: fixed; inset: 0; z-index: 25; background: rgba(5,26,47,.42); }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .metric-card:nth-child(4), .metric-card:nth-child(5) { grid-column: span 1; }
}

@media (max-width: 800px) {
  .sidebar { transform: translateX(-105%); transition: transform .22s ease; box-shadow: 18px 0 45px rgba(3,25,47,.24); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 20px 18px 42px; }
  .menu-button { display: block; flex: 0 0 auto; }
  .topbar { align-items: flex-start; }
  .topbar > div:nth-child(2) { flex: 1; }
  .topbar h1 { font-size: 24px; }
  .updated-wrap { display: none; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-column, .health-grid { grid-template-columns: 1fr; }
  .mailbox-grid { grid-template-columns: 1fr; }
  .engagement-row { grid-template-columns: 1fr auto; gap: 7px 12px; padding: 15px; }
  .company-name { grid-column: 1; padding-left: 52px; }
  .activity-pill { grid-column: 2; grid-row: 1; }
  .engagement-date { grid-column: 2; grid-row: 2; }
}

@media (max-width: 520px) {
  .login-screen { padding: 14px; }
  .login-card { padding: 28px 22px; border-radius: 20px; }
  .main-content { padding: 16px 13px 35px; }
  .topbar { gap: 10px; margin-bottom: 23px; }
  .topbar .eyebrow { font-size: 10px; }
  .topbar-actions .button { width: 44px; padding: 0; }
  .topbar-actions .button > span:first-child { display: none; }
  .topbar-actions .button::before { content: '↻'; font-size: 21px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric-card { min-height: 126px; padding: 15px; }
  .metric-card .metric-icon { width: 33px; height: 33px; margin-bottom: 13px; }
  .metric-card strong { font-size: 28px; }
  .metric-card:nth-child(5) { grid-column: 1 / -1; }
  .panel { padding: 17px; border-radius: 15px; }
  .mini-chart, .bar-chart { gap: 3px; overflow-x: auto; }
  .chart-column { min-width: 25px; }
  .chart-column span { font-size: 9px; }
  .format-example { grid-template-columns: 1fr; }
  .format-example span + span { border-left: 0; border-top: 1px solid var(--line); }
  .drop-zone { min-height: 220px; }
  .mailbox-top { display: grid; }
  .health-card { padding: 21px; }
  .health-value { font-size: 42px; }
  .pipeline-panel { padding: 16px 8px; }
  .funnel-step { min-height: 74px; padding: 14px 16px; }
  .funnel-step:nth-child(2) { width: 91%; }
  .funnel-step:nth-child(3) { width: 82%; }
  .funnel-step:nth-child(4) { width: 73%; }
  .funnel-step strong { font-size: 25px; }
}
