:root {
  color-scheme: light;
  --app-max-width: 430px;
  --surface: #f5f5f5;
  --surface-0: #ffffff;
  --surface-500: #ebebeb;
  --ink: #333333;
  --muted: #555555;
  --line: #dddddd;
  --line-strong: #cccccc;
  --brand-dark: #002e4a;
  --header: rgba(0, 56, 73, 0.9);
  --accent: #0092b2;
  --primary: #0078a8;
  --onboarding: #00667c;
  --nav-bg: rgba(38, 38, 38, 0.8);
  --shortcut-bg: rgba(217, 217, 217, 0.8);
  --header-height: calc(104px + env(safe-area-inset-top));
  --nav-height: calc(76px + env(safe-area-inset-bottom));
  --shortcut-height: 38px;
  --bottom-height: calc(var(--nav-height) + var(--shortcut-height));
  --side-pad: 16px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: #1e1e1e;
  color: var(--ink);
  font-family: Helvetica, Arial, sans-serif;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  outline: 3px solid rgba(0, 146, 178, 0.55);
  outline-offset: 3px;
}

.mobile-app {
  width: min(100vw, var(--app-max-width));
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--surface);
}

.mobile-app[data-shortcuts="open"] {
  --shortcut-height: 124px;
}

.app-header,
.bottom-system,
.widget-sheet,
.sheet-backdrop {
  position: fixed;
  left: 50%;
  width: min(100vw, var(--app-max-width));
  transform: translateX(-50%);
}

.app-header {
  top: 0;
  z-index: 40;
  display: flex;
  height: var(--header-height);
  padding: calc(60px + env(safe-area-inset-top)) 16px 20px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(204, 204, 204, 0.9);
  background: var(--header);
  backdrop-filter: blur(10px);
}

.brand-logo {
  display: block;
  width: 120px;
  height: auto;
  flex: 0 1 auto;
  min-width: 104px;
}

.smartbar-button {
  display: flex;
  width: 124px;
  min-width: 124px;
  height: 32px;
  padding: 6px 10px 6px 12px;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-radius: 1000px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
}

.smartbar-button span {
  display: block;
  flex: 0 0 auto;
  white-space: nowrap;
  font-size: 18px;
  line-height: 1;
}

.smartbar-button img {
  width: 19px;
  height: 20px;
  flex: 0 0 auto;
}

.dashboard-scroll {
  min-height: 100dvh;
  padding: calc(var(--header-height) + 24px) var(--side-pad)
    calc(var(--bottom-height) + 24px);
  transition: padding-bottom 180ms ease;
}

.page-placeholder {
  min-height: calc(100dvh - var(--header-height) - var(--bottom-height) - 48px);
}

.onboarding-card {
  position: relative;
  display: flex;
  min-height: 142px;
  padding: 16px 20px;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  overflow: hidden;
  border-left: 4px solid var(--accent);
  border-radius: 16px;
  background: var(--onboarding);
}

.onboarding-card > img {
  position: absolute;
  right: 12px;
  top: -1px;
  width: 141px;
  height: 141px;
  opacity: 1;
  pointer-events: none;
}

.onboarding-card h1,
.onboarding-card p,
.onboarding-card button {
  position: relative;
  z-index: 1;
}

.onboarding-card h1 {
  margin: 0;
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.18;
}

.onboarding-card p {
  max-width: min(100%, 255px);
  margin: 0;
  color: #ccf6ff;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.18;
}

.onboarding-card button {
  display: flex;
  min-height: 31px;
  padding: 8px 12px;
  align-items: center;
  border-radius: 16px;
  background: #ffffff;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.section-heading {
  display: flex;
  margin: 0 0 12px;
  align-items: center;
  justify-content: space-between;
}

.section-heading h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.16;
}

.section-heading button {
  padding: 0;
  background: transparent;
  color: var(--primary);
  font-size: 16px;
  font-weight: 400;
  cursor: pointer;
}

.widget-list {
  display: grid;
  gap: 12px;
}

.widget-card {
  display: grid;
  width: 100%;
  min-height: 82px;
  padding: 16px;
  grid-template-columns: minmax(0, 1fr) auto 16px;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
  text-align: left;
  cursor: pointer;
}

.widget-card:not(.has-badge):not(.has-metrics) {
  grid-template-columns: minmax(0, 1fr) 16px;
}

.widget-card:active {
  transform: translateY(1px);
}

.widget-main {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 16px;
}

.widget-icon {
  display: flex;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--surface-500);
}

.widget-icon img {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

.widget-copy {
  display: grid;
  min-width: 0;
  gap: 8px;
}

.widget-title {
  display: block;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.14;
}

.widget-summary {
  display: block;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.22;
}

.widget-badge {
  display: inline-flex;
  min-width: 42px;
  min-height: 20px;
  padding: 2px 6px;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--accent);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.22;
  white-space: nowrap;
}

.widget-card > .chevron {
  width: 16px;
  height: 16px;
}

.widget-card.has-metrics {
  min-height: 140px;
  grid-template-columns: minmax(0, 1fr) 16px;
}

.widget-card.has-metrics.has-badge {
  grid-template-columns: minmax(0, 1fr) auto 16px;
}

.widget-card.has-metrics .widget-main {
  grid-column: 1;
}

.widget-card.has-metrics > .chevron {
  grid-column: -2;
}

.widget-card.has-metrics .widget-badge {
  grid-column: 2;
}

.metric-grid {
  display: grid;
  grid-column: 1 / -1;
  width: 100%;
  grid-template-columns: repeat(var(--metric-count, 3), minmax(0, 1fr));
  gap: 8px;
}

.metric-box {
  display: flex;
  min-width: 0;
  min-height: 58px;
  padding: 8px;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 2px;
  border-radius: 6px;
  background: var(--surface);
}

.metric-box strong {
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.12;
}

.metric-box span {
  display: block;
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  line-height: 1.15;
}

.bottom-system {
  bottom: 0;
  z-index: 45;
  transform: translateX(-50%);
  pointer-events: none;
}

.shortcut-drawer,
.nav-bar {
  pointer-events: auto;
}

.shortcut-drawer {
  display: flex;
  min-height: var(--shortcut-height);
  padding: 10px 16px 2px;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  border-radius: 16px 16px 0 0;
  background: var(--shortcut-bg);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(15px);
  transition: min-height 180ms ease;
}

.mobile-app[data-shortcuts="open"] .shortcut-drawer {
  padding: 12px 16px 8px;
}

.shortcut-toggle {
  display: flex;
  min-height: 24px;
  padding: 0;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.16;
  cursor: pointer;
}

.shortcut-toggle img {
  width: 16px;
  height: 16px;
  transition: transform 180ms ease;
}

.mobile-app[data-shortcuts="closed"] .shortcut-toggle img {
  transform: rotate(180deg);
}

.shortcut-content {
  display: grid;
  width: 100%;
  max-height: 0;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    max-height 180ms ease,
    opacity 150ms ease,
    transform 180ms ease;
}

.mobile-app[data-shortcuts="open"] .shortcut-content {
  max-height: 68px;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.shortcut-item {
  display: flex;
  min-width: 0;
  padding: 0;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.16;
  cursor: pointer;
}

.shortcut-item > img {
  display: flex;
  width: 52px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}

.shortcut-item strong {
  display: block;
  width: 100%;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-bar {
  display: grid;
  height: var(--nav-height);
  padding: 0 16px env(safe-area-inset-bottom);
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: start;
  justify-content: center;
  background: var(--nav-bg);
  box-shadow: 0 -4px 4px rgba(0, 0, 0, 0.05);
  backdrop-filter: blur(15px);
}

.nav-item {
  display: flex;
  min-width: 0;
  height: 76px;
  padding: 8px 0 0;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: transparent;
  color: #ffffff;
  cursor: pointer;
}

.nav-icon-shell {
  display: flex;
  width: 44px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border-radius: 10000px;
}

.nav-item.is-active .nav-icon-shell {
  background: rgba(0, 180, 219, 0.4);
}

.nav-icon-shell img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.nav-item strong {
  display: block;
  width: 100%;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.16;
}

.nav-item.is-active strong {
  font-weight: 700;
}

.sheet-backdrop {
  inset: 0 auto 0 50%;
  z-index: 50;
  background: rgba(0, 0, 0, 0);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 180ms ease,
    background 180ms ease;
}

.mobile-app[data-sheet="open"] .sheet-backdrop {
  background: rgba(0, 0, 0, 0.18);
  opacity: 1;
  pointer-events: auto;
}

.widget-sheet {
  bottom: var(--nav-height);
  z-index: 60;
  display: flex;
  max-height: calc(100dvh - var(--header-height) - var(--nav-height) - 12px);
  flex-direction: column;
  align-items: stretch;
  overflow: hidden;
  border-radius: 16px 16px 0 0;
  background: #ffffff;
  box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  visibility: hidden;
  transform: translateX(-50%) translateY(calc(100% + var(--nav-height) + 24px));
  transition:
    transform 220ms ease,
    visibility 0s linear 220ms;
}

.mobile-app[data-sheet="open"] .widget-sheet {
  pointer-events: auto;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  transition:
    transform 220ms ease,
    visibility 0s;
}

.sheet-top {
  display: flex;
  padding: 12px 0 8px;
  justify-content: center;
  align-items: center;
}

.sheet-top img {
  width: 64px;
  height: 5px;
}

.sheet-header {
  display: flex;
  padding: 0 20px 16px;
  align-items: center;
  gap: 10px;
}

.sheet-icon-wrap {
  display: flex;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--surface-500);
}

.sheet-icon-wrap img {
  width: 16px;
  height: 16px;
}

.sheet-header h2 {
  min-width: 0;
  flex: 1 1 auto;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.22;
}

.sheet-close {
  display: flex;
  width: 32px;
  height: 32px;
  padding: 0;
  flex: 0 0 32px;
  align-items: center;
  justify-content: center;
  border-radius: 1000px;
  background: var(--surface);
  cursor: pointer;
}

.sheet-close img {
  width: 16px;
  height: 16px;
}

.sheet-body {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sheet-tabs {
  display: grid;
  grid-template-columns: repeat(var(--tab-count, 2), minmax(0, 1fr));
  border-top: 1px solid #f0f0f0;
  border-bottom: 1px solid #f0f0f0;
}

.sheet-tab {
  display: flex;
  min-height: 48px;
  padding: 12px 8px 8px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-bottom: 4px solid transparent;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.14;
}

.sheet-tab.is-active {
  border-color: var(--primary);
  color: var(--primary);
}

.tab-pill {
  display: inline-flex;
  min-width: 16px;
  padding: 1px 3px;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  background: rgba(0, 120, 168, 0.15);
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
}

.drawer-metrics {
  display: grid;
  padding: 4px 20px 16px;
  grid-template-columns: repeat(var(--metric-count, 3), minmax(0, 1fr));
  gap: 8px;
}

.drawer-list {
  display: grid;
}

.drawer-row {
  display: grid;
  min-height: 56px;
  padding: 16px 20px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border-top: 1px solid #eeeeee;
  color: var(--ink);
}

.drawer-row:first-child {
  border-top: 0;
}

.drawer-row-main {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.drawer-row-title {
  display: block;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.14;
}

.drawer-row-sub {
  display: block;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  line-height: 1.14;
}

.drawer-tag {
  display: inline-flex;
  min-width: 40px;
  min-height: 22px;
  padding: 3px 7px;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(0, 120, 168, 0.1);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.sheet-footer {
  display: flex;
  min-height: 64px;
  padding: 16px 24px calc(16px + env(safe-area-inset-bottom));
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(0, 120, 168, 0.05);
  box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.15);
  color: var(--primary);
  cursor: pointer;
}

.sheet-footer span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  line-height: 1.14;
}

.sheet-footer img {
  width: 12px;
  height: 12px;
}

@media (max-width: 360px) {
  :root {
    --side-pad: 12px;
  }

  .app-header {
    gap: 10px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .brand-logo {
    width: 112px;
  }

  .smartbar-button {
    width: 118px;
    min-width: 118px;
    padding-right: 8px;
    padding-left: 10px;
  }

  .smartbar-button span {
    font-size: 17px;
  }

  .metric-grid.is-four,
  .drawer-metrics.is-four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .shortcut-content {
    gap: 8px;
  }

  .nav-bar {
    padding-right: 8px;
    padding-left: 8px;
  }

  .nav-item strong,
  .shortcut-item {
    font-size: 11px;
  }
}

@media (min-width: 431px) {
  .mobile-app {
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.3);
  }
}
