:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #718096;
  --line: #e8edf4;
  --blue: #2f80ed;
  --blue-dark: #1769d1;
  --green: #18a874;
  --red: #e45b69;
  --amber: #f0ad3d;
  --shadow: 0 8px 28px rgba(33, 54, 84, .08);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
.app-shell { width: min(1440px, 100%); margin: 0 auto; padding: 28px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.eyebrow { color: var(--blue); font-size: 12px; font-weight: 800; letter-spacing: .1em; margin: 0 0 6px; text-transform: uppercase; }
h1 { font-size: clamp(25px, 3vw, 36px); line-height: 1.1; margin: 0; }
h2 { font-size: 18px; margin: 0 0 5px; }
.subtitle, .panel-heading p { color: var(--muted); margin: 7px 0 0; }
.topbar-actions { display: flex; gap: 10px; }
.button { border: 0; border-radius: 10px; cursor: pointer; font-weight: 700; min-height: 44px; padding: 0 18px; transition: .2s ease; }
.button:disabled { cursor: not-allowed; opacity: .5; }
.button-primary { background: var(--blue); color: white; }
.button-primary:hover:not(:disabled) { background: var(--blue-dark); transform: translateY(-1px); }
.button-secondary { background: white; border: 1px solid var(--line); color: var(--text); }
.panel { background: var(--panel); border: 1px solid rgba(225, 232, 241, .85); border-radius: 16px; box-shadow: var(--shadow); }
.filters { display: grid; gap: 14px; grid-template-columns: repeat(5, minmax(150px, 1fr)); padding: 18px; }
label span { color: var(--muted); display: block; font-size: 12px; font-weight: 700; margin: 0 0 7px; }
input, select { background: #fbfcfe; border: 1px solid #dbe3ee; border-radius: 9px; color: var(--text); min-height: 42px; outline: none; padding: 0 11px; width: 100%; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47,128,237,.12); }
.notice { background: #edf6ff; border: 1px solid #cfe5ff; border-radius: 10px; color: #23558b; margin-bottom: 16px; padding: 12px 15px; }
.status-line { align-items: center; color: var(--muted); display: flex; font-size: 13px; gap: 9px; min-height: 42px; padding: 10px 4px; }
.spinner { animation: spin .8s linear infinite; border: 2px solid #d7e2f0; border-top-color: var(--blue); border-radius: 50%; height: 17px; width: 17px; }
@keyframes spin { to { transform: rotate(360deg); } }
.metrics { display: grid; gap: 16px; grid-template-columns: repeat(4, 1fr); margin-bottom: 16px; }
.metric-card { background: white; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 19px; }
.metric-card span { color: var(--muted); display: block; font-size: 13px; margin-bottom: 9px; }
.metric-card strong { font-size: clamp(22px, 2.4vw, 30px); }
.metric-card.accent { background: linear-gradient(135deg, #2677e5, #52a4ff); border: 0; color: white; }
.metric-card.accent span { color: rgba(255,255,255,.8); }
.metric-card.success { border-color: #bcebd8; background: #f1fbf7; }
.metric-card.warning { border-color: #f5dcae; background: #fff9ed; }
.metric-card.danger { border-color: #f2c4ca; background: #fff5f6; }
.content-grid { display: grid; gap: 16px; grid-template-columns: 2fr 1fr; margin-bottom: 16px; }
.chart-panel, .funnel-panel, .stage-panel { min-height: 290px; padding: 20px; }
.panel-heading { display: flex; justify-content: space-between; margin-bottom: 22px; }
.bar-chart { display: flex; flex-direction: column; gap: 15px; }
.bar-row { display: grid; gap: 11px; grid-template-columns: minmax(120px, 210px) 1fr minmax(90px, auto); align-items: center; }
.bar-label { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: #edf2f8; border-radius: 20px; height: 11px; overflow: hidden; }
.bar-fill { background: linear-gradient(90deg, var(--blue), #74b4ff); border-radius: inherit; height: 100%; min-width: 3px; transition: width .4s ease; }
.bar-value { font-size: 13px; font-weight: 800; text-align: right; }
.dual-bars { display: flex; flex-direction: column; gap: 5px; }
.bar-fill.converted { background: linear-gradient(90deg, var(--green), #65d0aa); }
.funnel-summary { display: flex; flex-direction: column; gap: 12px; }
.funnel-summary > div { align-items: center; background: #f8fafc; border-radius: 10px; display: grid; gap: 9px; grid-template-columns: 12px 1fr auto; padding: 14px; }
.funnel-summary span { color: var(--muted); }
.funnel-summary strong { font-size: 19px; }
.dot { border-radius: 50%; height: 10px; width: 10px; }
.dot.active { background: var(--amber); } .dot.won { background: var(--green); } .dot.lost { background: var(--red); }
.dot.service { background: #8657d9; }
.table-panel { margin-bottom: 16px; overflow: hidden; }
.table-heading { align-items: center; padding: 20px 20px 0; }
.search-box { width: min(260px, 100%); }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { border-top: 1px solid var(--line); font-size: 13px; padding: 14px 16px; text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); cursor: pointer; font-size: 11px; letter-spacing: .035em; text-transform: uppercase; }
th:hover { color: var(--blue); }
tbody tr:hover { background: #f8fbff; }
.manager-name { font-weight: 750; }
.conversion-pill { background: #eaf8f2; border-radius: 20px; color: #14835c; display: inline-block; font-weight: 800; padding: 5px 9px; }
.status-badge { border-radius: 20px; display: inline-block; font-size: 11px; font-weight: 800; padding: 5px 9px; }
.status-badge.stale { background: #fff0d8; color: #a66500; }
.status-badge.untouched { background: #ffe9ec; color: #b73345; }
.status-badge.moved { background: #eaf8f2; color: #14835c; }
.status-badge.ok { background: #edf4ff; color: #276ab9; }
.stage-cell { max-width: 380px; white-space: normal; }
.stage-cell span { background: #f0f4f9; border-radius: 6px; display: inline-block; font-size: 11px; margin: 2px; padding: 4px 6px; }
.deal-link { background: none; border: 0; color: #1769d1; cursor: pointer; font: inherit; font-weight: 750; padding: 0; text-align: left; }
.deal-link:hover { text-decoration: underline; }
.deal-id { color: var(--muted); display: block; font-size: 10px; margin-top: 4px; }
.empty-cell { color: var(--muted); padding: 45px 16px; text-align: center !important; }
.stage-list { display: grid; gap: 11px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.stage-item { background: #f8fafc; border-left: 4px solid var(--blue); border-radius: 9px; padding: 13px; }
.stage-item span { color: var(--muted); display: block; font-size: 12px; margin-bottom: 6px; }
.stage-item strong { display: block; font-size: 15px; }
.stage-item small { color: var(--muted); display: block; margin-top: 4px; }
.empty-state { align-items: center; color: var(--muted); display: flex; justify-content: center; min-height: 180px; }
footer { color: var(--muted); font-size: 12px; padding: 9px 4px 20px; text-align: center; }
.sr-only { clip: rect(0,0,0,0); clip-path: inset(50%); height: 1px; overflow: hidden; position: absolute; white-space: nowrap; width: 1px; }

@media (max-width: 1000px) {
  .filters { grid-template-columns: repeat(2, 1fr); }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .app-shell { padding: 16px; }
  .topbar { flex-direction: column; }
  .topbar-actions { width: 100%; }
  .topbar-actions .button { flex: 1; }
  .filters, .metrics { grid-template-columns: 1fr; }
  .table-heading { align-items: stretch; flex-direction: column; gap: 14px; }
  .bar-row { grid-template-columns: 100px 1fr; }
  .bar-value { grid-column: 2; }
}
