:root {
  color-scheme: light;
  font-family: "Public Sans", Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --base-text: #15191e;
  --muted-text: #68717d;
  --line: #dfe3e7;
  --soft-line: #edf0f2;
  --header: #1c1d1f;
  --surface: #ffffff;
  --canvas: #f4f6f8;
  --primary: #1f77e0;
  --secondary: #0b3b6f;
}

* { box-sizing: border-box; }

body { margin: 0; color: var(--base-text); background: var(--canvas); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.portal-page { min-width: 320px; min-height: 100vh; }

.portal-header {
  position: sticky;
  z-index: 20;
  top: 0;
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 18px;
  color: #fff;
  background: var(--header);
  box-shadow: 0 2px 5px rgb(0 0 0 / 16%);
}

.tenant-wordmark {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 178px;
}

.tenant-symbol {
  position: relative;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  overflow: hidden;
  color: #fff;
  background: var(--primary);
}

.tenant-symbol i { position: absolute; display: block; background: currentColor; }
.tenant-symbol.logo-a { border-radius: 5px 13px 5px 5px; transform: skew(-5deg); }
.tenant-symbol.logo-a i { bottom: 8px; width: 4px; border-radius: 2px; transform: skew(-10deg); }
.tenant-symbol.logo-a i:nth-child(1) { left: 9px; height: 15px; }
.tenant-symbol.logo-a i:nth-child(2) { left: 16px; height: 22px; }
.tenant-symbol.logo-a i:nth-child(3) { left: 23px; height: 28px; }

.tenant-symbol.logo-b { border-radius: 50%; background: transparent; border: 8px solid var(--primary); }
.tenant-symbol.logo-b::after { content: ""; position: absolute; width: 12px; height: 8px; right: -4px; bottom: 2px; background: var(--primary); transform: rotate(35deg); }
.tenant-symbol.logo-b i:nth-child(1) { width: 7px; height: 7px; border-radius: 50%; left: 7px; top: 7px; }
.tenant-symbol.logo-b i:nth-child(n+2) { display: none; }

.tenant-symbol.logo-c { background: transparent; }
.tenant-symbol.logo-c i { width: 15px; height: 15px; border-radius: 3px; background: var(--primary); }
.tenant-symbol.logo-c i:nth-child(1) { left: 1px; top: 1px; border-radius: 8px 3px 3px; }
.tenant-symbol.logo-c i:nth-child(2) { right: 1px; top: 1px; opacity: .72; }
.tenant-symbol.logo-c i:nth-child(3) { left: 10px; bottom: 1px; width: 24px; opacity: .9; }

.wordmark-copy { min-width: 0; display: grid; line-height: 1.05; }
.wordmark-copy strong { max-width: 132px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; letter-spacing: .01em; }
.wordmark-copy small { margin-top: 5px; color: #bdc3c9; font-size: 9px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; }

.global-search, .table-search {
  display: flex;
  align-items: center;
  color: #737b84;
  background: #fff;
  border-radius: 4px;
}

.global-search { width: clamp(190px, 18vw, 280px); height: 38px; padding: 0 10px; }
.global-search span, .table-search span { margin-right: 8px; font-size: 20px; line-height: 1; }
.global-search input, .table-search input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--base-text); background: transparent; font-size: 13px; }

.primary-nav { align-self: stretch; display: flex; align-items: stretch; gap: 2px; }
.primary-nav button { padding: 0 9px; border: 0; color: #fff; background: transparent; font-size: 13px; font-weight: 650; white-space: nowrap; cursor: default; }
.primary-nav button:first-child { box-shadow: inset 0 -3px 0 var(--primary); }
.primary-nav button span { margin-left: 3px; color: #aab0b6; }

.session-tools { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 13px; font-weight: 650; white-space: nowrap; }
.icon-button { width: 32px; height: 32px; padding: 0; border: 0; color: var(--primary); background: transparent; font-size: 12px; }
.session-user { display: flex; align-items: center; gap: 7px; }
.avatar { width: 26px; height: 26px; display: inline-grid; place-items: center; border-radius: 50%; color: var(--secondary); background: color-mix(in srgb, var(--primary) 18%, #fff); font-size: 11px; font-weight: 800; }

.context-bar {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.breadcrumbs { display: flex; align-items: center; gap: 9px; min-width: 0; font-size: 13px; white-space: nowrap; overflow: hidden; }
.breadcrumbs a { color: var(--primary); text-decoration: none; }
.breadcrumbs span { color: #9aa1a9; font-size: 20px; }
.breadcrumbs strong { overflow: hidden; text-overflow: ellipsis; }
.mode-badge { flex: 0 0 auto; display: flex; align-items: center; gap: 7px; padding: 6px 10px; border-radius: 999px; font-size: 11px; font-weight: 750; }
.mode-badge.is-authenticated { color: #17663a; background: #e5f6ec; }
.mode-badge.is-preview { color: var(--secondary); background: color-mix(in srgb, var(--primary) 12%, #fff); }
.mode-badge span { color: var(--primary); }

.portal-main { width: 100%; max-width: 1680px; margin: 0 auto; padding: 24px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.eyebrow { margin: 0 0 6px; color: var(--primary); font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.page-heading h1 { margin: 0; font-size: 26px; line-height: 1.18; letter-spacing: -.02em; }
.page-heading p:not(.eyebrow) { margin: 7px 0 0; color: var(--muted-text); font-size: 13px; }
.heading-actions { display: flex; gap: 10px; }
.heading-actions button, .heading-actions a { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; padding: 0 15px; border-radius: 4px; font-size: 13px; font-weight: 700; text-decoration: none; }
.secondary-action { border: 1px solid #aeb5bc; color: #39424c; background: #fff; }
.primary-action { border: 1px solid var(--primary); color: #fff; background: var(--primary); box-shadow: 0 1px 2px rgb(0 0 0 / 10%); }
.primary-action span { margin-right: 6px; font-size: 18px; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.metrics article { min-width: 0; padding: 15px 17px; border: 1px solid var(--line); border-top: 3px solid var(--primary); background: #fff; box-shadow: 0 1px 2px rgb(15 23 42 / 4%); }
.metrics span { display: block; color: var(--muted-text); font-size: 12px; font-weight: 650; }
.metrics strong { display: block; margin: 7px 0 5px; color: var(--secondary); font-size: 26px; line-height: 1; }
.metrics small { color: #848c95; font-size: 11px; }
.metrics small b { color: #18814d; }
.metrics small b.warning { color: #a86200; }

.workspace-card { overflow: hidden; border: 1px solid var(--line); background: #fff; box-shadow: 0 2px 7px rgb(25 33 42 / 5%); }
.table-toolbar { min-height: 56px; display: flex; align-items: stretch; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.view-tabs { display: flex; align-items: stretch; }
.view-tabs button { position: relative; padding: 0 18px; border: 0; color: #5c6570; background: transparent; font-size: 13px; font-weight: 650; }
.view-tabs button.active { color: var(--primary); }
.view-tabs button.active::after { content: ""; position: absolute; right: 14px; bottom: 0; left: 14px; height: 3px; background: var(--primary); }
.view-tabs span { min-width: 22px; display: inline-block; margin-left: 5px; padding: 2px 5px; border-radius: 10px; background: #eef1f3; font-size: 10px; }
.table-actions { display: flex; align-items: center; gap: 5px; padding: 8px 10px; }
.table-search { width: 220px; height: 34px; padding: 0 10px; border: 1px solid #cbd1d6; }
.table-actions > button { position: relative; width: 34px; height: 34px; border: 0; color: #424a53; background: transparent; font-weight: 700; }
.filter-count { position: absolute; top: 0; right: 0; width: 16px; height: 16px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--primary); font-size: 9px; }

.data-grid-wrap { width: 100%; overflow: auto; }
.data-grid { width: 100%; min-width: 1120px; border-collapse: collapse; table-layout: fixed; font-size: 12px; }
.data-grid th { height: 48px; padding: 8px 12px; border-right: 1px solid var(--line); color: #444d57; background: #edeff0; text-align: left; font-weight: 700; }
.data-grid th:first-child, .data-grid td:first-child { width: 42px; text-align: center; }
.data-grid th:nth-child(2) { width: 92px; }
.data-grid th:nth-child(3) { width: 190px; }
.data-grid th:nth-child(4) { width: 160px; }
.data-grid th:nth-child(5) { width: 120px; }
.data-grid th:nth-child(6), .data-grid th:nth-child(7) { width: 145px; }
.data-grid th:nth-child(8) { width: 130px; }
.data-grid th:nth-child(9) { width: 110px; }
.data-grid td { height: 66px; padding: 9px 12px; border-right: 1px solid var(--soft-line); border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-grid tbody tr:hover { background: color-mix(in srgb, var(--primary) 4%, #fff); }
.data-grid td a { color: var(--primary); font-weight: 700; text-decoration: none; }
.data-grid td strong, .data-grid td span:not(.status) { display: block; }
.data-grid td strong { margin-bottom: 4px; font-size: 12px; }
.data-grid td span:not(.status) { color: #7c858e; font-size: 11px; }
.data-grid input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--primary); }
.status { display: inline-flex; align-items: center; padding: 5px 8px; border-radius: 3px; font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .035em; }
.status.in-transit { color: var(--secondary); background: color-mix(in srgb, var(--primary) 13%, #fff); }
.status.attention { color: #8a4c00; background: #fff0d6; }
.status.at-stop { color: #394b62; background: #edf1f5; }
.status.delivered { color: #17663a; background: #dff3e8; }

.table-footer { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 14px; color: var(--muted-text); font-size: 11px; }
.table-footer div { display: flex; gap: 4px; }
.table-footer button { width: 28px; height: 28px; border: 1px solid var(--line); color: #56606a; background: #fff; }
.table-footer button.current { border-color: var(--primary); color: #fff; background: var(--primary); }
.demo-notice { margin: 12px 0 0; color: #858d96; font-size: 10px; text-align: right; }

.empty-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 0, #edf4fc, #f6f8fa 48%); }
.empty-state { width: min(520px, 100%); padding: 42px; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: 0 18px 60px rgb(34 50 68 / 10%); text-align: center; }
.neutral-symbol { position: relative; width: 48px; height: 48px; display: inline-block; margin-bottom: 18px; border-radius: 6px 16px 6px 6px; background: #52616f; transform: skew(-5deg); }
.neutral-symbol i { position: absolute; bottom: 10px; width: 5px; border-radius: 3px; background: #fff; }
.neutral-symbol i:nth-child(1) { left: 12px; height: 18px; }
.neutral-symbol i:nth-child(2) { left: 21px; height: 27px; }
.neutral-symbol i:nth-child(3) { left: 30px; height: 35px; }
.empty-state h1 { margin: 0 0 12px; font-size: 30px; }
.empty-state > p:not(.eyebrow) { margin: 0 0 18px; color: var(--muted-text); line-height: 1.6; }
.empty-state > p.error { color: #9c2727; }
.empty-state small { color: #9299a1; }

@media (max-width: 1360px) {
  .portal-header { gap: 12px; padding: 0 12px; }
  .tenant-wordmark { min-width: 155px; }
  .primary-nav button { padding: 0 6px; font-size: 11px; }
  .global-search { width: 210px; }
}

@media (max-width: 1080px) {
  .primary-nav { display: none; }
  .global-search { width: min(360px, 40vw); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .portal-header { min-height: 58px; }
  .tenant-symbol { width: 32px; height: 32px; flex-basis: 32px; }
  .tenant-wordmark { min-width: 0; flex: 1; }
  .wordmark-copy strong { max-width: 130px; font-size: 15px; }
  .wordmark-copy small, .global-search, .session-user { display: none; }
  .session-tools { margin-left: 0; }
  .context-bar { min-height: 44px; padding: 0 14px; }
  .breadcrumbs a:not(:first-child), .breadcrumbs span { display: none; }
  .breadcrumbs strong { font-size: 12px; }
  .mode-badge { padding: 5px 8px; font-size: 9px; }
  .portal-main { padding: 16px 12px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 14px; }
  .page-heading h1 { font-size: 23px; }
  .heading-actions { width: 100%; }
  .heading-actions > * { flex: 1; }
  .metrics { gap: 8px; }
  .metrics article { padding: 12px; }
  .metrics strong { font-size: 22px; }
  .table-toolbar { align-items: stretch; flex-direction: column; gap: 0; }
  .view-tabs { min-height: 48px; overflow-x: auto; }
  .view-tabs button { padding: 0 13px; white-space: nowrap; }
  .table-actions { border-top: 1px solid var(--line); }
  .table-search { width: 100%; }
  .table-footer { align-items: flex-start; flex-direction: column; }
  .demo-notice { text-align: left; }
  .empty-state { padding: 32px 22px; }
}
