:root {
  color-scheme: light dark;
  --bg: #f3f6fb;
  --surface: #fbfcff;
  --surface-soft: #edf2f8;
  --surface-strong: #e3eaf4;
  --text: #172033;
  --muted: #66738a;
  --line: #d6dfeb;
  --accent: #2463d4;
  --accent-strong: #17499e;
  --accent-soft: #e8f0ff;
  --success: #117a4c;
  --success-soft: #e3f5ec;
  --danger: #c63f45;
  --danger-soft: #fbeaec;
  --warning: #a35d08;
  --shadow: 0 18px 50px rgba(40, 61, 92, 0.1);
  --panel-radius: 18px;
  --control-radius: 12px;
  font-family: Pretendard, "Noto Sans SC", "Microsoft YaHei", "PingFang SC", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--bg);
  color: var(--text);
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at 8% -10%, rgba(36, 99, 212, 0.13), transparent 29rem),
    var(--bg);
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(36, 99, 212, 0.32);
  outline-offset: 3px;
}

.app-shell {
  width: min(100%, 1040px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0 22px 48px;
}

.site-header {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  color: #f8fbff;
  font-size: 18px;
  font-weight: 850;
  box-shadow: 0 8px 20px rgba(36, 99, 212, 0.24);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 16px;
  letter-spacing: -0.02em;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.internal-label {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  padding: 7px 11px;
}

.lookup-view {
  min-height: calc(100dvh - 116px);
  display: grid;
  grid-template-columns: minmax(340px, 430px);
  justify-content: center;
  align-items: center;
  padding: 48px 34px 100px;
}

.section-kicker,
.section-label {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.02em;
}

.lookup-card {
  min-width: 0;
  border: 1px solid color-mix(in srgb, var(--line) 92%, transparent);
  border-radius: 22px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow);
  padding: 28px;
}

.lookup-card label {
  display: block;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 850;
}

.lookup-card .field-help + label {
  margin-top: 18px;
}

.phone-field {
  height: 58px;
  display: flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--control-radius);
  background: var(--surface);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.phone-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(36, 99, 212, 0.12);
}

.phone-field > span {
  height: 25px;
  display: flex;
  align-items: center;
  border-right: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
  padding: 0 14px;
}

.phone-field input {
  width: 100%;
  height: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 17px;
  font-weight: 750;
  letter-spacing: 0.015em;
  padding: 0 14px;
}

.phone-field input::placeholder {
  color: color-mix(in srgb, var(--muted) 62%, transparent);
  font-weight: 500;
}

.field-help,
.form-message,
.privacy-note {
  font-size: 12px;
  line-height: 1.55;
}

.field-help {
  margin: 8px 0 0;
  color: var(--muted);
}

.form-message {
  min-height: 19px;
  margin: 8px 0 5px;
  color: var(--danger);
  font-weight: 750;
}

.primary-button,
.back-button,
.period-tab,
.refresh-button {
  border: 0;
  cursor: pointer;
}

.primary-button {
  width: 100%;
  min-height: 54px;
  border-radius: var(--control-radius);
  background: var(--accent);
  color: #f8fbff;
  font-size: 15px;
  font-weight: 850;
  box-shadow: 0 10px 22px rgba(36, 99, 212, 0.2);
  transition: background 160ms ease, transform 100ms ease;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.primary-button:active,
.back-button:active,
.period-tab:active,
.refresh-button:active {
  transform: translateY(1px);
}

.primary-button:disabled,
.refresh-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.primary-button.loading .button-label::after,
.refresh-button.loading::after {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 8px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  vertical-align: -2px;
  animation: spin 700ms linear infinite;
}

.privacy-note {
  margin: 16px 0 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding-top: 16px;
}

.has-dashboard .site-header {
  display: none;
}

.dashboard-view {
  min-width: 0;
  width: min(100%, 860px);
  margin: 0 auto;
  padding-top: 22px;
  animation: view-in 240ms ease-out both;
}

.dashboard-toolbar {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.back-button {
  flex: 0 0 auto;
  background: transparent;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 850;
  padding: 9px 0;
}

.back-button span {
  margin-right: 5px;
  font-size: 21px;
  line-height: 0;
  vertical-align: -2px;
}

.refresh-area {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  text-align: right;
}

.refresh-area strong,
.refresh-area span {
  display: block;
}

.refresh-area strong {
  color: var(--success);
  font-size: 12px;
}

.refresh-area strong.syncing,
.refresh-area strong.neutral {
  color: var(--muted);
}

.refresh-area strong.error {
  color: var(--danger);
}

.refresh-area span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.refresh-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  padding: 0 13px;
}

.rider-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 8px 2px 24px;
}

.rider-summary h1 {
  margin: 4px 0 7px;
  font-size: clamp(30px, 5vw, 42px);
  line-height: 1.12;
  letter-spacing: -0.045em;
}

.rider-branch,
.rider-meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.rider-branch {
  color: var(--accent);
  font-weight: 850;
}

.rider-status {
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 12px;
  font-weight: 850;
  padding: 8px 11px;
}

.period-tabs {
  width: fit-content;
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 7px;
  margin: 0 0 14px;
}

.period-tab {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  padding: 0 18px;
}

.period-tab.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #f8fbff;
}

.period-range-panel {
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  border-radius: var(--panel-radius);
  background: var(--surface);
  box-shadow: 0 7px 24px rgba(40, 61, 92, 0.05);
  padding: 18px;
  margin-bottom: 14px;
}

.period-range-heading,
.period-date-range,
.period-presets {
  display: flex;
  align-items: center;
}

.period-range-heading {
  justify-content: space-between;
  gap: 18px;
}

.period-range-heading strong,
.period-range-heading span,
.period-date-range label span {
  display: block;
}

.period-range-heading strong {
  font-size: 15px;
}

.period-range-heading > div > span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.period-presets {
  flex: 0 0 auto;
  gap: 6px;
}

.period-presets button,
#period-apply-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  padding: 0 12px;
}

.period-presets button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.period-presets button:active,
#period-apply-button:active {
  transform: translateY(1px);
}

.period-date-range {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto;
  gap: 10px;
  margin-top: 15px;
}

.period-date-range label span {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.period-date-range input {
  width: 100%;
  min-height: 42px;
  box-sizing: border-box;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
}

.period-date-separator {
  align-self: end;
  min-height: 42px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}

#period-apply-button {
  align-self: end;
  min-height: 42px;
  border-color: var(--accent);
  background: var(--accent);
  color: #f8fbff;
  padding-inline: 18px;
}

.period-range-message {
  min-height: 18px;
  margin: 8px 0 -2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--panel-radius);
  background: var(--surface);
  box-shadow: 0 7px 24px rgba(40, 61, 92, 0.05);
  padding: 22px;
  margin-bottom: 14px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 20px;
}

.section-heading > * {
  min-width: 0;
}

.section-heading h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.025em;
}

.section-context {
  max-width: 260px;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  text-align: right;
}

.performance-panel {
  display: grid;
  grid-template-columns: 0.72fr 1.28fr;
  column-gap: 26px;
}

.performance-panel .section-heading,
.performance-panel .comparison-row {
  grid-column: 1 / -1;
}

.primary-metric {
  align-self: stretch;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  border-right: 1px solid var(--line);
  padding: 8px 26px 8px 4px;
}

.primary-metric span {
  width: 100%;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.primary-metric strong {
  margin-top: 8px;
  color: var(--accent);
  font-size: clamp(54px, 8vw, 76px);
  line-height: 0.95;
  letter-spacing: -0.06em;
}

.primary-metric small {
  align-self: flex-end;
  margin: 0 0 6px 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
}

.metric-item {
  min-width: 0;
  border-bottom: 1px solid var(--line);
  padding: 8px 0 14px;
}

.metric-item:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.metric-item.metric-total {
  border-bottom: 0;
}

.metric-item span,
.metric-item strong {
  display: block;
}

.metric-item span {
  color: var(--muted);
  font-size: 11px;
}

.metric-item strong {
  margin-top: 8px;
  font-size: 21px;
  letter-spacing: -0.025em;
}

.comparison-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(190px, auto);
  align-items: center;
  gap: 16px;
  border-radius: 13px;
  background: var(--surface-soft);
  padding: 14px 16px;
  margin-top: 20px;
}

.comparison-row span,
.comparison-row strong {
  display: block;
}

.comparison-row span {
  color: var(--muted);
  font-size: 11px;
}

.comparison-row strong {
  margin-top: 4px;
  font-size: 16px;
}

.comparison-row p {
  margin: 0;
  font-size: 12px;
  font-weight: 850;
  text-align: right;
}

.comparison-row p.better {
  color: var(--success);
}

.comparison-row p.worse {
  color: var(--danger);
}

.comparison-row p.neutral {
  color: var(--muted);
}

.business-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.business-item {
  border-radius: 13px;
  background: var(--surface-soft);
  padding: 16px;
}

.business-item h3 {
  margin: 0 0 15px;
  font-size: 15px;
}

.business-item dl {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin: 0;
}

.business-item dt {
  color: var(--muted);
  font-size: 10px;
}

.business-item dd {
  margin: 4px 0 0;
  font-size: 17px;
  font-weight: 850;
}

.time-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.time-item {
  min-width: 0;
  border-left: 3px solid var(--accent);
  border-radius: 4px 12px 12px 4px;
  background: var(--surface-soft);
  padding: 15px 13px;
}

.time-item span,
.time-item strong,
.time-item small {
  display: block;
}

.time-item span {
  min-height: 32px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.time-item strong {
  margin-top: 5px;
  font-size: 25px;
}

.time-item small {
  min-height: 29px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
}

.empty-state {
  grid-column: 1 / -1;
  margin: 0;
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 28px 16px;
}

.trend-scroll {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
  padding-bottom: 5px;
}

.trend-chart {
  --trend-columns: 7;
  height: 180px;
  display: grid;
  grid-template-columns: repeat(var(--trend-columns), minmax(0, 1fr));
  align-items: end;
  gap: 8px;
}

.trend-chart.long-range {
  width: max(100%, calc(var(--trend-columns) * 32px));
  grid-template-columns: repeat(var(--trend-columns), minmax(22px, 1fr));
  gap: 5px;
}

.trend-item {
  height: 100%;
  min-width: 0;
  display: grid;
  grid-template-rows: 24px 1fr 22px;
  align-items: end;
  justify-items: center;
}

.trend-item strong {
  color: var(--muted);
  font-size: 11px;
}

.trend-bar {
  width: min(70%, 34px);
  height: var(--bar-height);
  min-height: 8px;
  border-radius: 7px 7px 3px 3px;
  background: var(--accent);
  transition: height 240ms ease;
}

.trend-item small {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.interval-label {
  margin: -6px 0 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.interval-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-radius: 13px;
  background: var(--surface-soft);
}

.interval-stats > div {
  min-width: 0;
  text-align: center;
  padding: 17px 10px;
}

.interval-stats > div + div {
  border-left: 1px solid var(--line);
}

.interval-stats span,
.interval-stats strong {
  display: block;
}

.interval-stats span {
  color: var(--muted);
  font-size: 11px;
}

.interval-stats strong {
  margin-top: 7px;
  font-size: 16px;
}

.team-summary-meta {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.team-slot-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.team-slot-card {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.team-slot-heading,
.team-slot-figures,
.team-slot-footer {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.team-slot-heading h3 {
  margin: 0;
  font-size: 13px;
}

.team-slot-heading span,
.team-slot-figures span,
.team-slot-footer {
  color: var(--muted);
  font-size: 10px;
}

.team-slot-figures {
  margin-top: 15px;
}

.team-slot-figures strong {
  font-size: 20px;
}

.team-slot-progress {
  height: 6px;
  overflow: hidden;
  margin-top: 11px;
  border-radius: 99px;
  background: var(--surface-strong);
}

.team-slot-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.team-slot-footer {
  margin-top: 8px;
}

.team-slot-footer strong {
  color: var(--text);
  font-size: 11px;
}

.team-slot-note {
  margin: 13px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 760px) {
  .app-shell {
    padding-inline: 14px;
  }

  .lookup-view {
    min-height: auto;
    padding: 48px 4px 72px;
  }

  .performance-panel {
    grid-template-columns: 1fr;
  }

  .primary-metric {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 2px 0 19px;
    margin-bottom: 10px;
  }

  .metric-grid {
    padding-top: 2px;
  }

  .comparison-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .comparison-row p {
    grid-column: 1 / -1;
    text-align: left;
  }

  .time-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .period-range-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .period-date-range {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  }

  #period-apply-button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .site-header {
    min-height: 68px;
  }

  .brand small,
  .internal-label {
    display: none;
  }

  .lookup-view {
    padding-top: 34px;
  }

  .lookup-card {
    border-radius: 19px;
    padding: 22px;
  }

  .dashboard-view {
    padding-top: 12px;
  }

  .dashboard-toolbar {
    align-items: flex-start;
    margin-bottom: 14px;
  }

  .refresh-area {
    gap: 8px;
  }

  .refresh-button {
    padding-inline: 10px;
  }

  .rider-summary {
    padding-bottom: 20px;
  }

  .period-presets {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .period-presets button {
    padding-inline: 7px;
  }

  .period-date-range {
    grid-template-columns: 1fr;
  }

  .period-date-separator {
    display: none;
  }

  .rider-summary h1 {
    font-size: 31px;
  }

  .panel {
    padding: 17px;
  }

  .section-heading {
    gap: 14px;
  }

  .section-heading h2 {
    font-size: 18px;
  }

  .section-context {
    max-width: 145px;
  }

  .business-grid {
    grid-template-columns: 1fr;
  }

  .business-item {
    display: grid;
    grid-template-columns: 0.7fr 1.3fr;
    align-items: center;
  }

  .business-item h3 {
    margin: 0;
  }

  .interval-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .interval-stats > div + div {
    border-left: 0;
  }

  .interval-stats > div:nth-child(even) {
    border-left: 1px solid var(--line);
  }

  .interval-stats > div:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

  .team-slot-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .trend-chart {
    gap: 4px;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111722;
    --surface: #182130;
    --surface-soft: #202b3c;
    --surface-strong: #29364a;
    --text: #edf3fc;
    --muted: #a7b4c8;
    --line: #334258;
    --accent: #72a1f5;
    --accent-strong: #9dbcf7;
    --accent-soft: #21375d;
    --success: #65cf99;
    --success-soft: #1c3c30;
    --danger: #f18489;
    --danger-soft: #4b292e;
    --warning: #efb15c;
    --shadow: 0 18px 50px rgba(6, 10, 18, 0.34);
  }

  body {
    background:
      radial-gradient(circle at 8% -10%, rgba(80, 132, 226, 0.17), transparent 29rem),
      var(--bg);
  }

  .brand-mark,
  .primary-button,
  .period-tab.active {
    color: #101725;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
