:root {
  --ink: #121416;
  --muted: #6f7680;
  --line: #d7dce2;
  --paper: #f3f5f7;
  --card: #ffffff;
  --accent: #121212;
  --accent-soft: #f1f3f5;
  --warn: #a03333;
  --shadow: 0 22px 60px rgba(18, 20, 22, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(90, 97, 107, 0.14), transparent 30%),
    linear-gradient(145deg, #f4f5f6 0%, #ffffff 55%, #edf0f3 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

.portal-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.portal-header {
  margin-bottom: 24px;
}

.portal-kicker,
.section-tag,
.app-card-tag {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
}

.portal-header h1,
.card h2,
.app-card h3 {
  margin: 0;
  line-height: 1.04;
}

.portal-header h1 {
  font-size: clamp(2.1rem, 4vw, 4.25rem);
  max-width: 760px;
}

.portal-header p {
  margin: 10px 0 0;
  max-width: 720px;
  color: var(--muted);
  font-size: 1.05rem;
}

.portal-main {
  display: grid;
  gap: 20px;
}

.card {
  background: rgba(255, 253, 250, 0.92);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.card-login {
  max-width: 640px;
}

body.page-login .portal-shell {
  max-width: 100%;
  min-height: 100vh;
  padding: 0;
}

body.page-login .portal-header {
  display: none;
}

.portal-main-login {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 86px 1fr;
  background:
    radial-gradient(circle at center, rgba(188, 192, 198, 0.36), transparent 14%),
    radial-gradient(circle at 18% 28%, rgba(98, 104, 122, 0.22), transparent 26%),
    radial-gradient(circle at 80% 24%, rgba(73, 83, 94, 0.26), transparent 32%),
    linear-gradient(135deg, #353645 0%, #3f505c 48%, #46475a 100%);
}

.login-brandbar {
  display: flex;
  align-items: center;
  padding: 0 26px;
  background: #242424;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.login-brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: #f4f6f8;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: 0;
}

.login-brand-logo {
  display: block;
  height: 42px;
  width: auto;
  max-width: 240px;
}

.login-center-wrap {
  display: grid;
  grid-template-columns: minmax(0, 560px) minmax(360px, 420px);
  align-items: center;
  justify-content: center;
  gap: 52px;
  padding: 40px 32px;
}

body.page-login .card-login {
  max-width: 420px;
  width: 100%;
}

.login-story {
  max-width: 560px;
  color: #eef2f5;
}

.login-story .section-tag {
  color: #c7ced6;
}

.login-story h2 {
  margin: 10px 0 14px;
  max-width: 520px;
  color: #ffffff;
  font-size: clamp(1.85rem, 2.3vw, 2.65rem);
  line-height: 1.06;
}

.login-story > p {
  margin: 0;
  max-width: 520px;
  color: #d8dde3;
  font-size: 1.06rem;
  line-height: 1.55;
}

.login-story-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 22px;
  margin-top: 28px;
}

.login-story-grid div {
  padding-left: 14px;
  border-left: 2px solid rgba(255, 255, 255, 0.24);
}

.login-story-grid span {
  display: block;
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 700;
}

.login-story-grid p {
  margin: 6px 0 0;
  color: #c8d0d8;
  font-size: 0.93rem;
  line-height: 1.42;
}

.login-story-note {
  margin-top: 24px !important;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  color: #f0f3f6 !important;
  font-weight: 700;
}

.card-login-dark {
  padding: 34px 38px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(18, 18, 18, 0.92);
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.28);
}

.card-login-dark .section-tag,
.card-login-dark .card-copy p,
.card-login-dark .portal-form span,
.login-footer-note {
  color: #b8bec6;
}

.card-login-dark h2 {
  color: #ffffff;
  font-size: 2.2rem;
}

.card-login-dark .portal-form {
  gap: 16px;
}

.card-login-dark .portal-form input {
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 6px;
  padding: 12px 14px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.card-login-dark .portal-form input::placeholder {
  color: #aeb4bc;
}

.card-login-dark .portal-form button {
  margin-top: 6px;
  min-height: 42px;
  border-radius: 4px;
  background: linear-gradient(180deg, #c8cdd4 0%, #a8afb8 100%);
  color: #101214;
  font-weight: 700;
}

.login-footer-note {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.95rem;
}

.login-footer-note a {
  color: #ffffff;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.card-copy p,
.callout,
.detail-card span,
.panel-footnote,
.app-card p {
  color: var(--muted);
}

.portal-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.portal-form label {
  display: grid;
  gap: 8px;
}

.portal-form span {
  font-size: 0.92rem;
  font-weight: 700;
}

.portal-form input {
  width: 100%;
  border: 1px solid #cfd5dc;
  border-radius: 16px;
  padding: 14px 16px;
  font-size: 1rem;
  background: #f8f9fb;
}

.portal-form button,
.logout-link,
.topbar-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  border-radius: 999px;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 0.98rem;
  font-weight: 700;
  padding: 0 20px;
  cursor: pointer;
}

.logout-link,
.topbar-link {
  min-height: 42px;
  padding: 0 16px;
}

.topbar-link-secondary {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--ink);
}

.topbar-link-primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #ffffff;
}

.topbar-close {
  appearance: none;
}

.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.account-menu {
  position: relative;
}

.account-menu[open] .account-avatar {
  background: #3f88c5;
  border-color: #3f88c5;
  color: #ffffff;
}

.account-trigger {
  display: block;
  cursor: pointer;
  list-style: none;
}

.account-trigger::-webkit-details-marker {
  display: none;
}

.account-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #ffffff;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 700;
}

.account-panel {
  position: absolute;
  z-index: 10;
  top: calc(100% + 10px);
  right: 0;
  width: min(300px, calc(100vw - 28px));
  padding: 16px;
  border: 1px solid #30343a;
  border-radius: 8px;
  background: #222426;
  color: #ffffff;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.22);
}

.account-panel-label {
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 700;
  color: #9ca3af;
}

.account-panel-name {
  margin-top: 4px;
  font-size: 1rem;
  font-weight: 700;
}

.account-panel-email {
  margin-top: 2px;
  color: #c4cad2;
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.account-logout {
  display: flex;
  align-items: center;
  min-height: 42px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  font-size: 0.98rem;
  font-weight: 700;
}

.notice {
  margin-top: 18px;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 0.94rem;
}

.notice-error {
  background: #fff1f1;
  border: 1px solid #e6b8b8;
  color: var(--warn);
}

.panel-footnote,
.callout {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--accent-soft);
  border: 1px solid #d8dde3;
  font-size: 0.95rem;
}

.dashboard-top {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
}

.stats-row,
.route-details {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.stat-card,
.detail-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
}

.stat-card span,
.detail-card span {
  display: block;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-card strong,
.detail-card strong,
.app-card-path {
  display: block;
  margin-top: 8px;
  font-size: 1.1rem;
  line-height: 1.2;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.app-card {
  background: rgba(255, 253, 250, 0.92);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 20px;
  transition: transform 140ms ease, border-color 140ms ease;
}

.app-card:hover {
  transform: translateY(-2px);
  border-color: #9fb4a9;
}

.app-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.app-card-arrow {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--accent);
}

.app-card h3 {
  margin-top: 16px;
  font-size: 1.4rem;
}

.app-card p {
  margin: 10px 0 18px;
  min-height: 56px;
}

.app-card-path {
  font-size: 0.94rem;
  color: var(--accent);
}

.empty-card {
  color: var(--muted);
}

.portal-main-owner {
  gap: 24px;
}

body.page-owner .portal-shell {
  max-width: 1180px;
  padding: 22px 18px 44px;
}

body.page-owner .portal-header {
  display: none;
}

.owner-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  padding: 8px 0 16px;
  border-bottom: 1px solid var(--line);
}

.owner-brand {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.owner-topbar h2 {
  margin: 3px 0 0;
  font-size: 1.35rem;
  line-height: 1.05;
}

.owner-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 24px;
  padding: 22px 0 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.owner-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(94px, 1fr));
  gap: 10px;
}

.owner-stats div {
  min-width: 100px;
  padding: 14px;
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 8px;
}

.owner-stats span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.owner-stats strong {
  display: block;
  margin-top: 8px;
  font-size: 1.8rem;
  line-height: 1;
}

.owner-hero-copy {
  max-width: 720px;
}

.owner-hero h2,
.owner-section h2 {
  margin: 8px 0 0;
  line-height: 1.08;
}

.owner-hero h2 {
  max-width: 720px;
  font-size: clamp(2rem, 4vw, 3.35rem);
}

.owner-hero p {
  max-width: 660px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.5;
}

.owner-quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.owner-quick-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
}

.owner-hero-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.owner-section {
  display: grid;
  gap: 14px;
  padding-top: 6px;
}

.owner-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.owner-section h2 {
  font-size: 1.35rem;
}

.owner-app-grid .app-card {
  min-height: 198px;
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(18, 20, 22, 0.06);
}

.owner-app-grid .app-card h3 {
  font-size: 1.22rem;
}

.owner-app-grid .app-card p {
  min-height: 66px;
  font-size: 0.95rem;
  line-height: 1.22;
}

.portal-main-activity {
  gap: 22px;
}

.activity-hero {
  align-items: center;
}

.activity-stats {
  grid-template-columns: repeat(4, minmax(88px, 1fr));
}

.activity-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.activity-table {
  width: 100%;
  min-width: 880px;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.activity-table th,
.activity-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.activity-table th {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.activity-table tr:last-child td {
  border-bottom: 0;
}

.audit-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef3ef;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.audit-badge.is-good {
  background: #e7f6ec;
  color: #176b38;
}

.audit-badge.is-warning {
  background: #fff0df;
  color: #9a4d00;
}

.mini-link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.mini-link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
}

.mini-link.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.app-frame-wrap {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
  background: #edf3ef;
}

.app-frame {
  width: 100%;
  min-height: 74vh;
  border: 0;
  display: block;
  background: #fff;
}

.runtime-placeholder-body {
  background: linear-gradient(145deg, #eef3ef 0%, #f8faf7 100%);
}

.runtime-placeholder {
  max-width: 760px;
  margin: 48px auto;
  padding: 28px;
}

@media (max-width: 760px) {
  .portal-main-login {
    grid-template-rows: 72px 1fr;
  }

  .login-brandbar {
    padding: 0 16px;
  }

  .login-brand {
    gap: 10px;
    font-size: 1.2rem;
  }

  .login-brand-logo {
    height: 32px;
    max-width: 180px;
  }

  .login-center-wrap {
    padding: 16px;
    grid-template-columns: 1fr;
    gap: 22px;
    align-content: center;
    justify-items: center;
  }

  .login-story {
    max-width: 420px;
    order: 2;
  }

  .login-story h2 {
    font-size: 1.65rem;
  }

  .login-story > p {
    font-size: 0.98rem;
  }

  .login-story-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 20px;
  }

  .login-story-grid p {
    font-size: 0.9rem;
  }

  .login-story-note {
    margin-top: 18px !important;
  }

  .card-login-dark {
    padding: 26px 22px;
    order: 1;
  }

  .dashboard-top {
    flex-direction: column;
  }

  body.page-owner .portal-shell {
    padding: 14px 14px 32px;
  }

  .owner-topbar {
    align-items: flex-start;
    padding-bottom: 12px;
  }

  .owner-hero,
  .owner-section-head {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .owner-hero {
    padding: 16px 0 0;
  }

  .owner-hero h2 {
    font-size: 2rem;
  }

  .owner-hero p {
    font-size: 0.96rem;
  }

  .owner-hero-actions {
    justify-content: flex-start;
  }

  .owner-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .owner-app-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .owner-app-grid .app-card {
    min-height: auto;
  }

  .owner-app-grid .app-card p {
    min-height: 0;
  }

  .top-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .stats-row,
  .route-details {
    grid-template-columns: 1fr;
  }

  .portal-shell {
    padding: 24px 14px 40px;
  }

  .card {
    padding: 18px;
    border-radius: 20px;
  }

  .app-frame {
    min-height: 68vh;
  }
}

body.page-dashboard,
body.page-app {
  background: #ffffff;
}

body.page-dashboard .portal-shell,
body.page-app .portal-shell {
  max-width: 100%;
  padding: 0;
}

body.page-dashboard .portal-header,
body.page-app .portal-header {
  display: none;
}

.portal-main-app {
  gap: 0;
}

.app-shell {
  min-height: 100vh;
  padding: 0;
  background: transparent;
}

.app-shell-dashboard {
  background: transparent;
}

.app-shell-topbar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid rgba(16, 36, 29, 0.06);
}

.app-shell-topbar-minimal .top-actions {
  gap: 10px;
  justify-content: flex-end;
}

.app-shell-brand h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-shell-product {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

.app-frame-wrap-full {
  margin-top: 0;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  background: #fff;
  min-height: calc(100vh - 56px);
}

.app-frame-full {
  min-height: calc(100vh - 56px);
  height: calc(100vh - 56px);
}

body.page-app-gps-map {
  height: 100dvh;
  overflow: hidden;
}

body.page-app-gps-map .portal-shell,
body.page-app-gps-map .portal-main-app,
body.page-app-gps-map .app-shell {
  height: 100dvh;
  min-height: 0;
}

body.page-app-gps-map .app-shell {
  display: grid;
  grid-template-rows: 56px minmax(0, 1fr);
}

body.page-app-gps-map .app-shell-topbar {
  min-height: 56px;
  height: 56px;
  padding: 6px 12px;
  overflow: visible;
  position: relative;
  z-index: 30;
}

body.page-app-gps-map .app-frame-wrap-full,
body.page-app-gps-map .app-frame-full {
  min-height: 0;
  height: 100%;
}

body.page-app-gps-map .app-frame-wrap-full {
  position: relative;
  z-index: 1;
}

body.page-dashboard .logout-link,
body.page-app .logout-link,
body.page-dashboard .topbar-link,
body.page-app .topbar-link {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.9rem;
}

@media (max-width: 760px) {
  body.page-app-gps-map .app-shell {
    grid-template-rows: 48px minmax(0, 1fr);
  }

  body.page-app-gps-map .app-shell-topbar {
    min-height: 48px;
    height: 48px;
    gap: 6px;
    padding: 5px 8px;
    flex-wrap: nowrap;
    overflow: visible;
  }

	  body.page-app-gps-map .app-shell-brand {
	    min-width: 0;
	    flex: 1 1 auto;
	  }

  body.page-app-gps-map .app-shell-product {
    display: none;
  }

  body.page-app-gps-map .app-shell-brand h2 {
    font-size: 0.82rem;
    line-height: 0.95;
  }

	  body.page-app-gps-map .top-actions {
	    width: auto;
	    min-width: 0;
	    flex: 0 0 auto;
	    flex-wrap: nowrap;
	    justify-content: flex-end;
	    gap: 6px;
	  }

	  body.page-app-gps-map .topbar-popout {
	    display: none;
	  }

  body.page-app-gps-map .topbar-link {
    min-height: 34px;
    padding: 0 10px;
    font-size: 0.84rem;
    white-space: nowrap;
  }

  body.page-app-gps-map .account-avatar {
    width: 34px;
    height: 34px;
    font-size: 0.82rem;
  }

  body.page-app-gps-map .app-frame-wrap-full,
  body.page-app-gps-map .app-frame-full {
    min-height: 0;
    height: 100%;
  }

  body.page-dashboard .app-shell-topbar,
  body.page-app .app-shell-topbar {
    padding: 8px 10px;
    min-height: auto;
  }

  body.page-dashboard .app-shell-brand h2,
  body.page-app .app-shell-brand h2 {
    font-size: 0.88rem;
  }

  body.page-dashboard .app-frame-wrap-full,
  body.page-app .app-frame-wrap-full,
  body.page-dashboard .app-frame-full,
  body.page-app .app-frame-full {
    min-height: calc(100vh - 56px);
    height: calc(100vh - 56px);
  }

  body.page-app-gps-map .app-shell-topbar {
    min-height: 48px;
    height: 48px;
    padding: 5px 8px;
  }

  body.page-app-gps-map .app-frame-wrap-full,
  body.page-app-gps-map .app-frame-full {
    min-height: 0;
    height: 100%;
  }
}
