:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #10233f;
  --muted: #6f7e94;
  --line: #e5ebf3;
  --navy: #07182e;
  --navy-2: #0c2544;
  --blue: #246bfe;
  --blue-soft: #eaf1ff;
  --cyan: #14b8c8;
  --green: #14a673;
  --red: #e45656;
  --amber: #e8a12a;
  --purple: #8a5cf6;
  --magenta: #e83ac8;
  --shadow: 0 18px 50px rgba(15, 35, 65, 0.08);
}

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

.login-view { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 42%) 1fr; background: #fff; }
.login-card { width: min(430px, calc(100% - 64px)); margin: auto; padding: 48px 0; }
.brand-mark { width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; color: #fff; font-size: 28px; font-weight: 800; background: linear-gradient(135deg, #246bfe, #14b8c8); box-shadow: 0 12px 24px rgba(36,107,254,.24); }
.brand-mark.small { width: 42px; height: 42px; border-radius: 13px; font-size: 20px; box-shadow: none; }
.eyebrow, .panel-kicker { margin: 22px 0 8px; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.login-card h1 { margin: 0; font-size: clamp(36px, 4vw, 52px); letter-spacing: -.04em; }
.login-copy { color: var(--muted); line-height: 1.65; margin: 16px 0 30px; }
.login-form { display: grid; gap: 18px; }
.login-form label, .filterbar label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.login-form input, .filterbar input, .filterbar select { width: 100%; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 12px; padding: 13px 14px; outline: none; transition: .2s ease; }
.login-form input:focus, .filterbar input:focus, .filterbar select:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(36,107,254,.1); }
.primary-button, .secondary-button { border: 0; border-radius: 12px; padding: 13px 18px; font-weight: 800; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.primary-button { background: linear-gradient(135deg, var(--blue), #3b82f6); color: #fff; box-shadow: 0 10px 22px rgba(36,107,254,.22); }
.primary-button:hover { transform: translateY(-1px); box-shadow: 0 14px 28px rgba(36,107,254,.27); }
.secondary-button { color: var(--ink); background: #fff; border: 1px solid var(--line); }
.secondary-button:hover { background: #f8faff; }
.compact { padding: 11px 16px; min-height: 42px; }
.form-error { margin: 0; color: var(--red); font-size: 13px; }
.security-note { margin-top: 20px; color: #94a1b5; font-size: 12px; }
.login-visual { position: relative; overflow: hidden; min-height: 100vh; color: #fff; background: radial-gradient(circle at 70% 15%, rgba(36,107,254,.75), transparent 34%), radial-gradient(circle at 20% 80%, rgba(20,184,200,.28), transparent 38%), linear-gradient(145deg, #07182e 0%, #0b2441 48%, #07182e 100%); }
.visual-grid { position: absolute; inset: 0; opacity: .22; background-image: linear-gradient(rgba(255,255,255,.12) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.12) 1px, transparent 1px); background-size: 58px 58px; transform: perspective(700px) rotateX(55deg) scale(1.4) translateY(22%); }
.visual-content { position: relative; z-index: 1; height: 100%; padding: 12vh 9vw; display: flex; flex-direction: column; justify-content: center; }
.visual-pill { width: fit-content; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.08); backdrop-filter: blur(12px); border-radius: 999px; padding: 9px 14px; font-size: 12px; }
.visual-content h2 { margin: 28px 0 50px; font-size: clamp(38px, 5vw, 72px); line-height: 1.05; letter-spacing: -.04em; max-width: 900px; }
.visual-stats { display: flex; gap: 52px; }
.visual-stats div { display: grid; gap: 2px; }
.visual-stats strong { font-size: 32px; }
.visual-stats span { color: rgba(255,255,255,.65); font-size: 13px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px 1fr; }
.sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 248px; background: linear-gradient(180deg, var(--navy), #071425); color: #fff; padding: 24px 18px; display: flex; flex-direction: column; z-index: 20; }
.sidebar-brand { display: flex; gap: 12px; align-items: center; padding: 0 10px 26px; }
.sidebar-brand div:last-child { display: grid; gap: 2px; }
.sidebar-brand strong { font-size: 17px; }
.sidebar-brand span { color: #8fa2bb; font-size: 11px; }
.nav-list { display: grid; gap: 6px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 13px; border: 0; border-radius: 11px; color: #9db0c7; background: transparent; text-align: left; cursor: pointer; transition: .18s ease; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, rgba(36,107,254,.28), rgba(36,107,254,.11)); color: #fff; box-shadow: inset 3px 0 0 var(--blue); }
.nav-icon { width: 20px; text-align: center; font-size: 17px; }
.sidebar-bottom { margin-top: auto; display: grid; gap: 14px; }
.source-health { display: flex; gap: 10px; align-items: flex-start; padding: 13px; border: 1px solid rgba(255,255,255,.08); background: rgba(255,255,255,.035); border-radius: 12px; }
.source-health div { display: grid; gap: 3px; }
.source-health strong { font-size: 12px; }
.source-health span { color: #879ab1; font-size: 10px; line-height: 1.4; }
.status-dot { width: 8px; height: 8px; flex: 0 0 8px; margin-top: 4px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(20,166,115,.12); }
.status-dot.warning { background: var(--amber); box-shadow: 0 0 0 4px rgba(232,161,42,.12); }
.logout-button { border: 0; background: transparent; color: #8094ad; text-align: left; padding: 8px 13px; cursor: pointer; }
.logout-button:hover { color: #fff; }
.workspace { grid-column: 2; min-width: 0; }
.topbar { min-height: 88px; padding: 20px 30px; background: rgba(255,255,255,.9); backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 15; }
.topbar .eyebrow { margin: 0 0 4px; }
.topbar h1 { margin: 0; font-size: 23px; letter-spacing: -.02em; }
.topbar-right { display: flex; gap: 22px; align-items: center; }
.freshness { display: grid; grid-template-columns: auto auto; column-gap: 8px; align-items: center; color: var(--muted); font-size: 11px; }
.freshness strong { grid-column: 2; color: var(--ink); font-size: 11px; }
.user-menu { display: flex; gap: 10px; align-items: center; }
.user-menu > span { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: var(--blue); background: var(--blue-soft); }
.user-menu div { display: grid; }
.user-menu strong { font-size: 12px; }
.user-menu small { color: var(--muted); }
.filterbar { position: sticky; top: 88px; z-index: 12; padding: 14px 30px; display: grid; grid-template-columns: 155px 155px minmax(160px, 1fr) minmax(180px, 1.2fr) auto auto; gap: 10px; align-items: end; border-bottom: 1px solid var(--line); background: rgba(244,247,251,.94); backdrop-filter: blur(14px); }
.demo-banner { margin: 20px 30px 0; padding: 12px 16px; border: 1px solid #f3d99d; background: #fff9e9; color: #73551b; border-radius: 12px; font-size: 12px; line-height: 1.5; }
.page-section { display: none; padding: 22px 30px 36px; }
.page-section.active { display: block; }
.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 17px; box-shadow: 0 8px 28px rgba(19,47,84,.045); position: relative; overflow: hidden; }
.kpi-card::after { content: ""; position: absolute; right: -18px; top: -18px; width: 70px; height: 70px; border-radius: 50%; background: var(--accent-soft, var(--blue-soft)); }
.kpi-label { color: var(--muted); font-size: 11px; font-weight: 700; }
.kpi-value { margin: 9px 0 8px; font-size: clamp(21px, 2vw, 29px); line-height: 1; letter-spacing: -.04em; font-weight: 850; }
.kpi-footer { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: 10px; color: var(--muted); }
.delta { padding: 4px 7px; border-radius: 999px; font-weight: 800; }
.delta.good { color: var(--green); background: #eaf8f2; }
.delta.bad { color: var(--red); background: #fff0f0; }
.delta.neutral { color: var(--muted); background: #f0f3f7; }
.content-grid { display: grid; gap: 16px; margin-bottom: 16px; }
.content-grid.two-thirds { grid-template-columns: minmax(0, 1.8fr) minmax(320px, .8fr); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 17px; box-shadow: var(--shadow); overflow: hidden; }
.panel-header { display: flex; justify-content: space-between; gap: 18px; align-items: center; padding: 18px 20px 14px; }
.panel-kicker { margin: 0 0 5px; font-size: 9px; }
.panel h2 { margin: 0; font-size: 17px; letter-spacing: -.02em; }
.chart-wrap { height: 330px; padding: 5px 18px 18px; }
.segmented { display: flex; padding: 3px; background: #f0f4f9; border-radius: 10px; }
.segmented button { border: 0; background: transparent; color: var(--muted); border-radius: 8px; padding: 7px 10px; font-size: 10px; font-weight: 800; cursor: pointer; }
.segmented button.active { color: var(--ink); background: #fff; box-shadow: 0 3px 10px rgba(10,30,60,.08); }
.funnel-compact { padding: 6px 20px 22px; display: grid; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: 92px 1fr auto; gap: 10px; align-items: center; }
.funnel-row label { color: var(--muted); font-size: 11px; }
.funnel-bar { height: 11px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.funnel-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--cyan)); min-width: 4px; }
.funnel-row strong { min-width: 58px; text-align: right; font-size: 12px; }
.table-panel { margin-bottom: 16px; }
.table-scroll { overflow: auto; max-width: 100%; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 11px; white-space: nowrap; }
th { position: sticky; top: 0; z-index: 2; padding: 11px 12px; color: #6c7a90; background: #f8fafc; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-weight: 800; text-align: right; }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; z-index: 1; }
th:first-child { z-index: 3; background: #f8fafc; }
td { padding: 11px 12px; border-bottom: 1px solid #edf1f6; text-align: right; background: #fff; }
td:first-child { background: #fff; }
tbody tr:hover td { background: #f9fbff; }
tbody tr:hover td:first-child { background: #f9fbff; }
.clickable-row { cursor: pointer; }
.row-title { display: grid; gap: 2px; }
.row-title strong { font-size: 11px; }
.row-title span { color: var(--muted); font-size: 9px; }
.metric-good { color: var(--green); font-weight: 800; }
.metric-warn { color: var(--amber); font-weight: 800; }
.metric-bad { color: var(--red); font-weight: 800; }
.table-hint, .muted { color: var(--muted); font-size: 11px; }
.count-badge { border-radius: 999px; padding: 6px 10px; background: var(--blue-soft); color: var(--blue); font-size: 10px; font-weight: 800; }
.full-height { min-height: calc(100vh - 240px); }
.funnel-large-panel { min-height: 620px; }
.funnel-large { display: flex; flex-direction: column; align-items: center; padding: 30px 30px 60px; gap: 7px; }
.funnel-stage { height: 70px; border-radius: 12px; color: #fff; display: grid; grid-template-columns: 1fr auto; align-items: center; padding: 0 24px; box-shadow: 0 12px 25px rgba(30,60,110,.12); }
.funnel-stage div { display: grid; gap: 4px; }
.funnel-stage span { opacity: .72; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.funnel-stage strong { font-size: 23px; }
.funnel-stage em { font-style: normal; font-size: 11px; opacity: .85; }
.quality-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.quality-card { padding: 18px; border-radius: 15px; border: 1px solid var(--line); background: #fff; }
.quality-card span { color: var(--muted); font-size: 11px; }
.quality-card strong { display: block; margin-top: 8px; font-size: 26px; }
.integration-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; padding: 2px 20px 22px; }
.integration-card { border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: grid; gap: 11px; }
.integration-head { display: flex; justify-content: space-between; align-items: center; }
.integration-head strong { font-size: 13px; }
.status-chip { padding: 5px 8px; border-radius: 999px; font-size: 9px; font-weight: 800; }
.status-chip.ready { color: var(--green); background: #e9f8f2; }
.status-chip.waiting { color: var(--amber); background: #fff6df; }
.status-chip.not_connected { color: var(--muted); background: #f0f3f7; }
.integration-card p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.import-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .7fr); gap: 16px; }
.import-panel, .template-panel { padding-bottom: 22px; }
.import-panel > .muted, .template-panel > p, .template-panel > h2, .template-panel > a, .template-panel > .column-tags { margin-left: 20px; margin-right: 20px; }
.upload-zone { margin: 20px; min-height: 280px; border: 2px dashed #cbd6e5; background: #f9fbfe; border-radius: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 28px; }
.upload-zone input { max-width: 290px; }
.upload-zone span { color: var(--muted); font-size: 11px; }
.upload-icon { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 18px; color: var(--blue); background: var(--blue-soft); font-size: 28px; }
.column-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.column-tags span { padding: 7px 10px; border-radius: 9px; background: #eef3fa; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.import-result { margin: 0 20px; padding: 14px; border-radius: 12px; background: #eaf8f2; color: #176847; font-size: 12px; line-height: 1.6; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 100; max-width: 360px; padding: 13px 16px; border-radius: 12px; color: #fff; background: #142942; box-shadow: 0 16px 40px rgba(0,0,0,.2); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; font-size: 12px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #a83c3c; }
.loading-skeleton { min-height: 100px; border-radius: 14px; background: linear-gradient(90deg, #f1f4f8 25%, #f8fafc 40%, #f1f4f8 60%); background-size: 300% 100%; animation: shimmer 1.5s infinite; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

@media (max-width: 1250px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .filterbar { grid-template-columns: repeat(4, minmax(140px, 1fr)); }
  .content-grid.two-thirds { grid-template-columns: 1fr; }
  .integration-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .login-view { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .app-shell { grid-template-columns: 72px 1fr; }
  .sidebar { width: 72px; padding: 18px 10px; }
  .sidebar-brand div:last-child, .nav-item:not(.active) { font-size: 0; }
  .sidebar-brand { padding: 0 5px 24px; }
  .nav-item { justify-content: center; padding: 12px; font-size: 0; }
  .nav-item.active { font-size: 0; }
  .nav-icon { font-size: 18px; }
  .source-health, .logout-button { display: none; }
  .workspace { grid-column: 2; }
  .topbar, .filterbar, .page-section { padding-left: 18px; padding-right: 18px; }
  .demo-banner { margin-left: 18px; margin-right: 18px; }
  .freshness { display: none; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .quality-summary, .integration-grid, .import-layout { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .workspace { grid-column: auto; }
  .topbar { min-height: 74px; }
  .topbar-right .user-menu div { display: none; }
  .filterbar { position: static; grid-template-columns: 1fr 1fr; top: auto; }
  .kpi-grid { grid-template-columns: 1fr; }
  .page-section { padding-top: 16px; }
  .chart-wrap { height: 280px; }
}
.trend-svg { width: 100%; height: 100%; display: block; overflow: visible; }
