:root {
  --navy: #111d35;
  --navy-2: #1b2944;
  --blue: #2268e9;
  --blue-dark: #174eb5;
  --cyan: #1ba7b6;
  --green: #20a36a;
  --violet: #7857d7;
  --orange: #e6812f;
  --red: #d84b5d;
  --ink: #192238;
  --muted: #66728a;
  --line: #dfe5ef;
  --soft: #f4f7fb;
  --white: #fff;
  --shadow: 0 12px 32px rgba(24, 42, 75, .08);
  --radius: 16px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #f5f7fb;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 1040px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 0%, rgba(34, 104, 233, .07), transparent 25rem),
    #f5f7fb;
}

button, input, select { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

.topbar {
  height: 76px;
  padding: 0 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white;
  background: var(--navy);
  box-shadow: 0 5px 24px rgba(17, 29, 53, .18);
}

.brand, .top-actions, .dataset-strip > div, .card-heading, .table-toolbar,
.journey-heading, .journey-filters {
  display: flex;
  align-items: center;
}

.brand { gap: 13px; }

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: rgba(255, 255, 255, .08);
}

.brand-mark svg {
  width: 29px;
  fill: none;
  stroke: #fff;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-mark svg .accent { stroke: #4ccfbe; }
.brand h1 { margin: 0 0 2px; font-size: 19px; letter-spacing: .1px; }
.brand p { margin: 0; color: #9facc3; font-size: 11px; letter-spacing: .35px; }
.top-actions { gap: 12px; }

.privacy-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #b5c1d4;
  font-size: 12px;
}

.privacy-pill em { font-style: normal; }

.privacy-pill > span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #43c68a;
  box-shadow: 0 0 0 4px rgba(67, 198, 138, .12);
}

.page-shell {
  width: min(1560px, calc(100% - 64px));
  margin: 0 auto;
  padding: 26px 0 38px;
}

.upload-view {
  min-height: calc(100vh - 166px);
  display: grid;
  place-items: center;
}

.upload-card {
  width: min(760px, 90vw);
  padding: 42px 48px 34px;
  text-align: center;
  background: white;
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.upload-icon {
  width: 68px;
  height: 68px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  color: var(--blue);
  background: #edf3ff;
  border-radius: 18px;
}

.upload-icon svg {
  width: 38px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--blue);
  font-size: 10px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 1.25px;
}

.upload-card h2 { margin: 0; font-size: 25px; }

.upload-copy {
  max-width: 600px;
  margin: 11px auto 25px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.drop-zone {
  min-height: 190px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: var(--muted);
  background: #fafcff;
  border: 2px dashed #bdc9da;
  border-radius: 15px;
  cursor: pointer;
  transition: .18s ease;
}

.drop-zone strong { color: var(--ink); font-size: 15px; }
.drop-zone.dragging { border-color: var(--blue); background: #f0f5ff; transform: translateY(-2px); }

.expected-columns {
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
}

.expected-columns code {
  padding: 4px 7px;
  color: #42506a;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 5px;
}

.upload-actions { margin-top: 15px; }

.parse-progress { margin-top: 20px; text-align: left; }
.progress-header { display: flex; justify-content: space-between; font-size: 12px; }
.progress-track { height: 8px; margin-top: 9px; overflow: hidden; background: #e8edf5; border-radius: 10px; }
.progress-track span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--blue), #3e9be9); border-radius: inherit; transition: width .2s; }
.parse-progress p { margin: 7px 0 0; color: var(--muted); font-size: 11px; }

.button {
  min-height: 38px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: inherit;
  background: white;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: .16s ease;
}

.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.button.primary { color: white; background: var(--blue); box-shadow: 0 6px 16px rgba(34, 104, 233, .2); }
.button.primary:hover { background: var(--blue-dark); }
.button.dark { color: white; background: var(--navy); }
.button.ghost { color: #43506a; background: white; border-color: var(--line); }
.topbar .button.ghost { color: white; background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .17); }
.text-button { padding: 0; color: var(--blue); background: transparent; border: 0; font-size: 11px; font-weight: 700; cursor: pointer; }

.dashboard { display: grid; gap: 17px; }

.dataset-strip {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
}

.dataset-strip > div { gap: 8px; }
.dataset-strip strong { max-width: 620px; overflow: hidden; color: var(--ink); text-overflow: ellipsis; white-space: nowrap; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }

.kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }

.kpi-card {
  min-height: 112px;
  padding: 20px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 15px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: 0 5px 18px rgba(24, 42, 75, .045);
}

.kpi-card::after {
  content: "";
  position: absolute;
  width: 80px;
  height: 80px;
  right: -33px;
  bottom: -39px;
  border-radius: 50%;
  background: currentColor;
  opacity: .055;
}

.kpi-icon {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
}

.kpi-icon svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.kpi-card div { min-width: 0; display: grid; color: initial; }
.kpi-card div > span { color: var(--muted); font-size: 10px; font-weight: 700; }
.kpi-card strong { margin-top: 4px; font-size: 25px; letter-spacing: -.6px; }
.kpi-card small { margin-top: 2px; overflow: hidden; color: #8a94a7; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.kpi-units { color: var(--blue); }.kpi-units .kpi-icon { background: #eaf1ff; }
.kpi-c5 { color: var(--green); }.kpi-c5 .kpi-icon { background: #e7f7f0; }
.kpi-c6 { color: var(--violet); }.kpi-c6 .kpi-icon { background: #f0ebfc; }
.kpi-pallet { color: var(--orange); }.kpi-pallet .kpi-icon { background: #fff0e3; }
.kpi-people { color: var(--cyan); }.kpi-people .kpi-icon { background: #e8f7f9; }

.analysis-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(340px, .55fr);
  gap: 17px;
}

.card, .table-card, .journey-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 5px 20px rgba(24, 42, 75, .045);
}

.card { padding: 19px 21px; }
.card-heading, .table-toolbar, .journey-heading { justify-content: space-between; }
.card-heading h2, .table-toolbar h2, .journey-heading h2 { margin: 0; font-size: 15px; }
.chart-total { padding: 6px 10px; color: var(--muted); background: var(--soft); border-radius: 6px; font-size: 10px; }

.stacked-bar {
  height: 54px;
  margin-top: 24px;
  display: flex;
  overflow: hidden;
  background: #edf1f7;
  border-radius: 10px;
}

.stacked-bar > div {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  font-weight: 800;
  transition: width .35s ease;
}

.stacked-bar span { overflow: hidden; padding: 0 8px; text-overflow: ellipsis; white-space: nowrap; }
.bar-c5 { background: var(--green); }
.bar-c6 { background: var(--violet); }
.legend { margin-top: 13px; display: flex; flex-wrap: wrap; gap: 18px; color: var(--muted); font-size: 10px; }
.legend-dot { width: 8px; height: 8px; margin-right: 6px; display: inline-block; border-radius: 2px; }
.legend-dot.c5 { background: var(--green); }
.legend-dot.c6 { background: var(--violet); }

.rules-card ul {
  margin: 16px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.rules-card li + li { margin-top: 7px; }
.rules-card strong { color: #43506a; }

.table-card { overflow: hidden; }

.table-toolbar {
  min-height: 69px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
}

.table-toolbar .eyebrow { margin-bottom: 5px; }
.table-scroll { overflow: auto; }
.compact-table { max-height: 260px; }

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 11px;
}

thead { position: sticky; top: 0; z-index: 2; }

th {
  height: 38px;
  padding: 0 16px;
  color: #69748a;
  background: #f6f8fb;
  border-bottom: 1px solid var(--line);
  font-size: 9px;
  letter-spacing: .45px;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

th.numeric, td.numeric { text-align: right; }

td {
  height: 46px;
  padding: 0 16px;
  color: #39455a;
  border-bottom: 1px solid #edf0f5;
  white-space: nowrap;
}

tbody tr:nth-child(even) { background: #fbfcfe; }
tbody tr:hover { background: #f3f7ff; }
.flow-pill, .path-pill, .process-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 5px;
  font-size: 9px;
  font-weight: 800;
}

.flow-pill { padding: 5px 8px; color: var(--blue); background: #edf3ff; }
.path-pill { min-width: 34px; padding: 4px 7px; justify-content: center; }
.path-pill.c5 { color: #158259; background: #e7f7f0; }
.path-pill.c6 { color: #6947c4; background: #f0ebfc; }
.process-pill { padding: 4px 7px; color: #345694; background: #e8effb; }

.journey-card { overflow: hidden; }

.journey-heading {
  min-height: 88px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.journey-heading > div > p:last-child { margin: 6px 0 0; color: var(--muted); font-size: 10px; }

.journey-filters {
  padding: 14px 20px;
  align-items: end;
  gap: 12px;
  background: #f8faff;
  border-bottom: 1px solid var(--line);
}

.field { min-width: 230px; display: grid; gap: 6px; }
.field > span:first-child { color: #4f5c72; font-size: 10px; font-weight: 700; }

.field select {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #d6dde8;
  border-radius: 7px;
  outline: 0;
  font-size: 11px;
}

.field select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(34, 104, 233, .09); }
.journey-result { margin-left: auto; display: grid; justify-items: end; gap: 3px; }
.journey-result span { color: var(--ink); font-size: 12px; font-weight: 800; }
.journey-result small { color: var(--muted); font-size: 9px; }

.route-preview {
  min-height: 100px;
  padding: 18px 20px;
  overflow-x: auto;
  background: white;
  border-bottom: 1px solid var(--line);
}

.route-empty {
  min-height: 62px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--soft);
  border: 1px dashed #cad3e0;
  border-radius: 10px;
  font-size: 11px;
}

.route-track { min-width: max-content; display: flex; align-items: center; }
.route-step { display: flex; align-items: center; }

.route-node {
  min-width: 126px;
  padding: 10px 12px;
  display: grid;
  gap: 3px;
  background: #fbfcfe;
  border: 1px solid #dce3ee;
  border-radius: 10px;
}

.route-node strong { color: var(--ink); font-size: 13px; }
.route-node span { color: var(--muted); font-size: 9px; }
.route-node.c5 { border-top: 3px solid var(--green); }
.route-node.c6 { border-top: 3px solid var(--violet); }
.route-arrow { width: 34px; display: grid; place-items: center; color: #9da8b9; font-size: 17px; }
.route-more { padding: 0 12px; color: var(--muted); font-size: 10px; font-weight: 700; }

.journey-table-scroll { max-height: 560px; }
.journey-table { min-width: 1120px; }

.associate-group-row td {
  height: 43px;
  position: sticky;
  top: 38px;
  z-index: 1;
  color: var(--ink);
  background: #eef4ff !important;
  border-bottom-color: #dce7fa;
  font-weight: 800;
}

.associate-group {
  display: flex;
  align-items: center;
  gap: 9px;
}

.avatar {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  color: #345694;
  background: #dfeaff;
  border-radius: 7px;
  font-size: 9px;
  font-weight: 800;
}

.associate-group small { margin-left: 5px; color: var(--muted); font-size: 9px; font-weight: 600; }
.location-cell { color: var(--ink); font-weight: 800; }
.muted-value { color: #8993a5; }

.table-empty {
  min-height: 175px;
  display: grid;
  place-content: center;
  gap: 6px;
  color: var(--muted);
  text-align: center;
}

.table-empty strong { color: var(--ink); font-size: 14px; }
.table-empty span { font-size: 11px; }
.limit-note { margin: 0; padding: 10px 20px; color: #8a5a16; background: #fff8e8; border-top: 1px solid #f3dfb7; font-size: 10px; }

.warnings {
  padding: 15px 18px;
  color: #8a5a16;
  background: #fff8e8;
  border: 1px solid #f0dbab;
  border-radius: 10px;
  font-size: 10px;
  line-height: 1.55;
}

.app-footer {
  min-height: 54px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #818ca0;
  background: #edf1f7;
  border-top: 1px solid #dfe5ef;
  font-size: 10px;
}

.developer-credit a { color: var(--blue); font-weight: 800; text-decoration: none; }
.developer-credit a:hover { text-decoration: underline; }

.toast {
  position: fixed;
  right: 25px;
  bottom: 25px;
  z-index: 50;
  max-width: 420px;
  padding: 12px 16px;
  color: white;
  background: var(--navy);
  border-radius: 9px;
  box-shadow: 0 12px 30px rgba(9, 20, 40, .25);
  font-size: 11px;
  font-weight: 700;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: .2s;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #b7374c; }

@media (max-width: 1240px) {
  .kpi-card { padding: 15px; gap: 10px; }
  .kpi-icon { width: 38px; height: 38px; }
  .analysis-grid { grid-template-columns: 1fr 390px; }
}

@media print {
  body { min-width: 0; background: white; }
  .topbar, .dataset-strip, .upload-view, .app-footer, .button, .journey-filters { display: none !important; }
  .page-shell { width: 100%; padding: 0; }
  .kpi-grid, .analysis-grid { break-inside: avoid; }
  .card, .table-card, .journey-card, .kpi-card { box-shadow: none; }
  .table-scroll { max-height: none; overflow: visible; }
  thead, .associate-group-row td { position: static; }
}
