@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@400;500;600;700&family=Prompt:wght@400;500;600;700&display=swap");

/*
  LeadHub Hub Interface CSS Contract
  Version: 2026-05-18 final operator-approved direction

  Design rule:
  - Prompt is the primary font.
  - Four type levels only.
  - One semantic spacing system across every visible surface.
  - Main list is compact decision surface.
  - Detail lives behind drill-down route/sheet, not in the list.
*/

:root {
  --hub-ink: #07133f;
  --hub-blue: #06186f;
  --hub-line: #dfe4ee;
  --hub-muted: #667085;
  --hub-bg: #f7f8fb;
  --hub-panel: #ffffff;
  --hub-soft: #eef3ff;
  --hub-hot: #ffefe0;
  --hub-hot-text: #a34d00;
  --hub-warm: #edf3ff;
  --hub-warm-text: #174bb0;
  --hub-review: #fff0f3;
  --hub-review-text: #c4123e;
  --hub-shadow: 0 4px 18px rgba(15, 23, 42, 0.04);
  --hub-shadow-active: 0 12px 22px rgba(6, 24, 111, 0.18);
  --hub-shadow-float: 0 24px 70px rgba(15, 23, 42, 0.22);

  --type-display: 22px;
  --type-title: 15px;
  --type-body: 13px;
  --type-meta: 11px;

  --weight-display: 600;
  --weight-title: 500;
  --weight-body: 400;
  --weight-meta: 600;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;

  --gap-section: var(--space-3);
  --gap-inline: var(--space-2);
  --pad-surface: var(--space-4);
  --pad-row-y: var(--space-3);
  --pad-row-x: var(--space-4);
  --pad-control-y: var(--space-2);
  --pad-control-x: var(--space-3);
  --pad-chip-y: var(--space-1);
  --pad-chip-x: var(--space-2);

  --radius-control: 10px;
  --radius-card: 16px;
  --radius-panel: 18px;
  --service-rail-width: 58px;
  --module-rail-width: 148px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--hub-bg);
  color: #111827;
  font-family:
    "Prompt",
    "Noto Sans Thai",
    ui-sans-serif,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: var(--type-body);
  font-weight: var(--weight-body);
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--service-rail-width) var(--module-rail-width) minmax(0, 1fr);
}

.shell.rails-hidden {
  display: block;
}

.shell.rails-hidden .global-rail,
.shell.rails-hidden .module-rail {
  display: none;
}

.global-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap-inline);
  padding: var(--pad-row-y) var(--gap-inline);
  background: var(--hub-blue);
  color: #fff;
}

.brand,
.global-dot {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-control);
}

.brand {
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #fff;
}

.brand img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.global-dot {
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.84);
  font-size: var(--type-meta);
  font-weight: var(--weight-body);
  letter-spacing: 0.02em;
}

.module-rail {
  border-right: 1px solid var(--hub-line);
  background: #fff;
  padding: var(--pad-row-y) var(--gap-inline);
}

.module-title {
  margin: 0 var(--gap-inline) var(--gap-section);
  color: var(--hub-blue);
  font-size: var(--type-meta);
  font-weight: var(--weight-meta);
  letter-spacing: 0.18em;
}

.rail-toggle {
  float: right;
  width: 24px;
  height: 24px;
  border: 1px solid var(--hub-line);
  border-radius: var(--radius-control);
  background: #fff;
  color: var(--hub-muted);
  font-size: var(--type-meta);
  font-weight: var(--weight-meta);
}

.module-nav {
  display: grid;
  gap: var(--space-1);
  clear: both;
}

.module-nav button {
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: #202939;
  padding: var(--pad-control-y) var(--pad-control-x);
  text-align: left;
  font-size: var(--type-body);
  font-weight: var(--weight-body);
}

.module-nav button.active {
  background: var(--hub-blue);
  color: #fff;
  box-shadow: var(--hub-shadow-active);
  font-weight: var(--weight-title);
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-section);
  padding: var(--pad-row-y) var(--pad-row-x);
  border-bottom: 1px solid var(--hub-line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
}

h1,
.detail-route-title,
.kpi-value {
  margin: 0;
  font-size: var(--type-display);
  font-weight: var(--weight-display);
  line-height: 1.24;
  letter-spacing: -0.015em;
}

.hamburger,
.primary-button,
.ghost-button,
.help {
  border: 1px solid var(--hub-line);
  border-radius: var(--radius-control);
  background: #fff;
  color: var(--hub-ink);
  font-weight: var(--weight-body);
}

.hamburger {
  display: none;
  width: 40px;
  height: 40px;
}

.primary-button {
  background: var(--hub-blue);
  border-color: var(--hub-blue);
  color: #fff;
  padding: var(--pad-control-y) var(--pad-control-x);
  font-weight: var(--weight-title);
}

.ghost-button {
  padding: var(--pad-control-y) var(--pad-control-x);
}

.help {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  color: #718096;
  font-size: var(--type-meta);
  font-weight: var(--weight-meta);
}

.workspace {
  display: grid;
  gap: var(--gap-section);
  max-width: 1120px;
  padding: var(--pad-surface) var(--pad-surface) 72px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) repeat(3, minmax(120px, 154px));
  gap: var(--gap-inline);
}

.filters input,
.filters select,
.import-grid textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--hub-line);
  border-radius: var(--radius-control);
  background: #fff;
  color: #1f2937;
  padding: var(--pad-control-y) var(--pad-control-x);
}

.status-strip {
  display: flex;
  gap: var(--gap-inline);
  overflow-x: auto;
}

.chip,
.badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  padding: var(--pad-chip-y) var(--pad-chip-x);
  font-size: var(--type-meta);
  font-weight: var(--weight-meta);
  white-space: nowrap;
}

.chip {
  border: 1px solid var(--hub-line);
  background: #fff;
  color: #111827;
}

.chip.active {
  background: var(--hub-blue);
  border-color: var(--hub-blue);
  color: #fff;
}

.badge.hot {
  background: var(--hub-hot);
  color: var(--hub-hot-text);
}

.badge.warm {
  background: var(--hub-warm);
  color: var(--hub-warm-text);
}

.badge.review,
.badge.needs_review {
  background: var(--hub-review);
  color: var(--hub-review-text);
}

.badge.cold,
.badge.unknown {
  background: #f2f4f7;
  color: #475467;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--gap-inline);
}

.kpi,
.panel,
.detail-route-hero,
.detail-card {
  border: 1px solid var(--hub-line);
  border-radius: var(--radius-card);
  background: var(--hub-panel);
  box-shadow: var(--hub-shadow);
}

.kpi,
.detail-route-hero,
.detail-card {
  padding: var(--pad-surface);
}

.kpi-label,
.eyebrow,
.table-head {
  color: #687386;
  font-size: var(--type-meta);
  font-weight: var(--weight-meta);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.kpi-value {
  margin-top: var(--space-1);
  color: var(--hub-blue);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-section);
  padding: var(--pad-row-y) var(--pad-row-x);
  border-bottom: 1px solid var(--hub-line);
}

.panel-head h2,
.panel-head h3,
.detail-card strong,
.global-menu-head strong,
.event strong {
  margin: 0;
  font-size: var(--type-title);
  font-weight: var(--weight-title);
}

.lead-layout {
  display: block;
}

.table-head,
.lead-row {
  display: grid;
  grid-template-columns: minmax(170px, 1.2fr) minmax(160px, 1fr) 96px minmax(130px, 0.9fr) 142px;
  align-items: center;
  gap: var(--gap-section);
  padding: var(--pad-row-y) var(--pad-row-x);
}

.table-head {
  border-bottom: 1px solid var(--hub-line);
}

.lead-row {
  width: 100%;
  border: 0;
  border-bottom: 1px solid #edf0f5;
  background: #fff;
  color: inherit;
  text-align: left;
  text-decoration: none;
}

.lead-row > *,
.table-head > * {
  min-width: 0;
}

.lead-row:hover,
.lead-row.active {
  background: #f3f6ff;
}

.lead-row .row-primary {
  display: block;
  color: #0c1222;
  font-size: var(--type-body);
  font-weight: var(--weight-title);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lead-row .row-secondary {
  display: block;
  color: #0c1222;
  font-size: var(--type-body);
  font-weight: var(--weight-title);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subline,
.lead-row .subline {
  margin-top: var(--space-1);
  color: var(--hub-muted);
  font-size: var(--type-body);
  font-weight: var(--weight-body);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-detail-view {
  display: grid;
  gap: var(--gap-section);
  max-width: 980px;
}

.detail-route-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--gap-section);
}

.detail-route-title {
  margin: var(--gap-inline) 0 var(--space-1);
}

.detail-route-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--gap-section);
}

.detail-card p,
.detail-card li,
.detail-route-hero .subline {
  line-height: 1.55;
}

.detail-eyebrow,
.field-list {
  margin-top: var(--gap-section);
}

.field-list {
  display: grid;
  gap: 0;
}

.field-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--gap-section);
  padding: var(--pad-row-y) 0;
  border-bottom: 1px solid #f0f2f5;
  font-size: var(--type-body);
  line-height: 1.45;
}

.field-row span:first-child {
  color: var(--hub-muted);
}

.field-row span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: right;
  font-weight: 500;
}

.next-action-line {
  margin: var(--gap-section) 0 0;
}

.timeline {
  display: grid;
  gap: var(--gap-inline);
}

.event {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  align-items: start;
  gap: var(--gap-inline);
}

.event::before {
  content: "";
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 999px;
  background: var(--hub-blue);
}

.activity-card {
  grid-column: 1 / -1;
}

.empty-state {
  padding: var(--pad-surface);
}

.module-page {
  display: grid;
  gap: var(--gap-section);
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--gap-section);
  padding: var(--pad-surface);
}

.insight-card {
  border: 1px solid #edf0f5;
  border-radius: var(--radius-card);
  background: #fff;
  padding: var(--pad-row-y) var(--pad-row-x);
}

.module-rows {
  display: block;
}

.module-table-head,
.module-row {
  display: grid;
  grid-template-columns: minmax(190px, 1.25fr) minmax(150px, 1fr) 96px minmax(120px, 0.8fr) minmax(150px, 0.9fr);
  align-items: center;
  gap: var(--gap-section);
  padding: var(--pad-row-y) var(--pad-row-x);
}

.module-table-head {
  border-bottom: 1px solid var(--hub-line);
  color: #687386;
  font-size: var(--type-meta);
  font-weight: var(--weight-meta);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.module-row {
  width: 100%;
  border: 0;
  border-bottom: 1px solid #edf0f5;
  background: #fff;
  color: inherit;
  text-align: left;
}

.module-row > *,
.module-table-head > * {
  min-width: 0;
}

.module-row:hover,
.module-row.active {
  background: #f3f6ff;
}

.module-row .row-primary,
.module-row .row-secondary {
  display: block;
  color: #0c1222;
  font-size: var(--type-body);
  font-weight: var(--weight-title);
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.module-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-inline);
}

.module-actions button {
  border: 1px solid var(--hub-line);
  border-radius: var(--radius-control);
  background: var(--hub-soft);
  color: var(--hub-blue);
  padding: var(--pad-chip-y) var(--pad-chip-x);
  font-size: var(--type-meta);
  font-weight: var(--weight-meta);
  line-height: 1.25;
}

.module-actions button:hover {
  border-color: var(--hub-blue);
}

.module-detail {
  border-top: 1px solid var(--hub-line);
  background: #fbfcff;
  padding: var(--pad-surface);
}

.module-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--gap-section);
  margin-bottom: var(--gap-section);
}

.module-detail-head h3 {
  margin: var(--space-1) 0 0;
  font-size: var(--type-title);
  font-weight: var(--weight-title);
}

.module-detail .field-list {
  margin-top: 0;
}

.insight-card {
  display: grid;
  gap: var(--space-1);
}

.insight-card span {
  color: var(--hub-muted);
  font-size: var(--type-meta);
  font-weight: var(--weight-meta);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.insight-card strong {
  color: var(--hub-blue);
  font-size: var(--type-display);
  font-weight: var(--weight-display);
  line-height: 1.25;
}

.insight-card.wide {
  grid-column: span 2;
}

.global-menu {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 90;
  width: min(320px, calc(100vw - 20px));
  border: 1px solid var(--hub-line);
  border-radius: var(--radius-panel);
  background: #fff;
  box-shadow: var(--hub-shadow-float);
  padding: var(--pad-surface);
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 23, 42, 0.32);
}

.global-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap-section);
  padding-bottom: var(--gap-inline);
  border-bottom: 1px solid var(--hub-line);
}

.global-menu-grid {
  display: grid;
  gap: var(--gap-inline);
  margin-top: var(--gap-section);
}

.global-menu-grid button {
  min-height: 40px;
  border: 1px solid var(--hub-line);
  border-radius: var(--radius-control);
  background: #fff;
  color: #202939;
  padding: 0 var(--pad-control-x);
  text-align: left;
}

.global-menu-grid button.active {
  border-color: var(--hub-blue);
  background: var(--hub-soft);
  color: var(--hub-blue);
}

.bottom-nav {
  display: none;
}

@media (max-width: 1180px) {
  .route-detail-view {
    max-width: 760px;
  }

  .detail-route-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 960px) {
  .shell,
  .shell.rails-hidden {
    display: block;
  }

  .global-rail,
  .module-rail,
  .desktop-rail-button {
    display: none;
  }

  .hamburger {
    display: inline-grid;
    place-items: center;
  }

  .topbar,
  .workspace {
    padding-left: var(--gap-section);
    padding-right: var(--gap-section);
  }

  .workspace {
    padding-bottom: 78px;
  }

  .filters {
    grid-template-columns: minmax(0, 1fr) 112px;
  }

  .filters select:nth-of-type(n + 2) {
    display: none;
  }

  .kpis {
    display: flex;
    overflow-x: auto;
  }

  .kpi {
    min-width: 112px;
  }

  .table-head,
  .module-table-head {
    display: none;
  }

  .lead-row,
  .module-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--gap-inline);
    padding: var(--pad-row-y);
  }

  .lead-row .source,
  .lead-row .activity {
    display: none;
  }

  .lead-row .action {
    grid-column: 1 / -1;
  }

  .module-row > :nth-child(2),
  .module-row > :nth-child(4) {
    display: none;
  }

  .module-row > :nth-child(5) {
    grid-column: 1 / -1;
  }

  .import-grid,
  .detail-route-grid {
    grid-template-columns: 1fr;
  }

  .insight-grid {
    grid-template-columns: 1fr;
    padding: var(--pad-row-y);
  }

  .insight-card.wide {
    grid-column: auto;
  }

  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-1);
    padding: var(--gap-inline) var(--gap-inline) var(--gap-section);
    border-top: 1px solid var(--hub-line);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(14px);
  }

  .bottom-nav button {
    border: 0;
    border-radius: var(--radius-control);
    background: transparent;
    color: #344054;
    padding: var(--gap-inline) var(--space-1);
    font-size: var(--type-meta);
    font-weight: var(--weight-meta);
  }

  .bottom-nav button.active {
    background: var(--hub-blue);
    color: #fff;
  }
}
