:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f6f7f8;
  --surface-strong: #eef2f3;
  --text: #171a1c;
  --muted: #5e6870;
  --faint: #879099;
  --line: #d9dee2;
  --line-soft: #e8ecef;
  --teal: #087f95;
  --teal-dark: #006a7f;
  --teal-soft: #d9f4f7;
  --blue: #0a6fc2;
  --green: #157a2c;
  --green-soft: #e6f5ea;
  --amber: #a75f00;
  --amber-soft: #fff4de;
  --red: #cc1f1f;
  --red-soft: #fff0f0;
  --shadow: 0 10px 30px rgba(24, 36, 44, 0.1);
  --radius: 8px;
  --nav-height: 76px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  background: var(--bg);
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  gap: 8px;
  height: 76px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

h1 {
  margin: 0;
  font-size: 25px;
  font-weight: 760;
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 740;
  line-height: 1.15;
  letter-spacing: 0;
}

.icon-button {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
}

.icon-button:hover,
.icon-button:focus-visible {
  background: var(--surface-soft);
  outline: none;
}

svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mode-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid #aab2b8;
  border-radius: 7px;
  background: #fafafa;
  color: #3f464c;
  font-size: 13px;
  font-weight: 720;
  text-transform: uppercase;
  white-space: nowrap;
}

.mode-chip svg {
  width: 18px;
  height: 18px;
}

.screen {
  width: min(100%, 900px);
  margin: 0 auto;
  padding: 12px 12px 18px;
}

.summary-rail {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.summary-tile {
  min-height: 66px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.summary-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.summary-tile strong {
  display: block;
  margin-top: 6px;
  color: var(--teal-dark);
  font-size: 23px;
  line-height: 1;
  letter-spacing: 0;
}

.summary-tile.attention strong {
  color: var(--amber);
}

.summary-tile.blocked strong {
  color: var(--red);
}

.segmented-control {
  position: sticky;
  top: 76px;
  z-index: 18;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  margin: 0 -12px 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(16px);
}

.segmented-control button {
  min-width: 0;
  height: 44px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-left-width: 0;
  background: var(--surface-soft);
  color: #2e3439;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.1;
}

.segmented-control button:first-child {
  border-left-width: 1px;
  border-radius: 8px 0 0 8px;
}

.segmented-control button:last-child {
  border-radius: 0 8px 8px 0;
}

.segmented-control button.active {
  background: var(--teal);
  color: #ffffff;
  border-color: var(--teal);
}

.section-panel {
  overflow: hidden;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.section-panel.hidden-by-filter {
  display: none;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line-soft);
}

.section-header > div {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.section-header svg {
  color: var(--teal);
  flex: 0 0 auto;
}

.section-header button {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 13px;
  font-weight: 650;
}

.auction-list {
  display: grid;
}

.auction-row {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) auto 34px;
  gap: 10px;
  min-height: 88px;
  padding: 10px 10px 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface);
}

.auction-list.compact .auction-row {
  grid-template-columns: 52px minmax(0, 1fr) auto 30px;
  min-height: 68px;
  padding: 8px 10px 8px 12px;
}

.auction-row:last-child {
  border-bottom: 0;
}

.thumb {
  display: grid;
  place-items: center;
  width: 70px;
  height: 64px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f4f6f7;
}

.auction-list.compact .thumb {
  width: 52px;
  height: 46px;
}

.thumb svg {
  width: 100%;
  height: 100%;
  stroke-width: 1.7;
}

.auction-main {
  min-width: 0;
  align-self: center;
}

.auction-title {
  margin: 0 0 4px;
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  font-weight: 730;
  line-height: 1.2;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auction-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.route-chip {
  display: inline-flex;
  width: fit-content;
  margin-top: 5px;
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 10px;
  font-weight: 760;
  line-height: 1.2;
  text-transform: uppercase;
}

.auction-money {
  align-self: center;
  min-width: 76px;
  text-align: right;
}

.time-left {
  display: block;
  color: var(--red);
  font-size: 13px;
  font-weight: 760;
  line-height: 1.15;
}

.price {
  display: block;
  margin-top: 3px;
  color: #111417;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.1;
}

.bid-count {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.1;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  min-height: 26px;
  margin-top: 5px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: #31383d;
  font-size: 12px;
  font-weight: 720;
}

.status-pill.good {
  border-color: #98caa4;
  background: var(--green-soft);
  color: var(--green);
}

.status-pill.warn {
  border-color: #f1ca86;
  background: var(--amber-soft);
  color: var(--amber);
}

.status-pill.bad {
  border-color: #ee9a9a;
  background: var(--red-soft);
  color: var(--red);
}

.row-action {
  display: grid;
  place-items: center;
  align-self: center;
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
}

.row-action:hover,
.row-action:focus-visible {
  border-color: var(--line);
  background: var(--surface-soft);
  outline: none;
}

.row-action svg {
  width: 18px;
  height: 18px;
}

.alert-panel .section-header svg,
.inline-alert svg:first-child {
  color: var(--red);
}

.inline-alert {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 8px;
  width: calc(100% - 20px);
  min-height: 48px;
  margin: 10px;
  padding: 0 10px;
  border: 1px solid #f0a5a5;
  border-radius: 7px;
  background: var(--red-soft);
  color: var(--red);
  text-align: left;
}

.inline-alert span {
  color: #3c2525;
  font-size: 13px;
  font-weight: 650;
}

.split-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.mini-panel {
  margin-bottom: 0;
}

.status-list {
  display: grid;
}

.status-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-soft);
  color: #333a40;
  font-size: 13px;
}

.status-row:last-child {
  border-bottom: 0;
}

.status-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-weight: 720;
  white-space: nowrap;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--faint);
}

.dot.good {
  background: #10952f;
}

.dot.warn {
  background: #d88200;
}

.dot.bad {
  background: var(--red);
}

.dot.info {
  background: var(--blue);
}

.alert-log {
  display: grid;
}

.alert-item {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12px;
}

.alert-item:last-child {
  border-bottom: 0;
}

.alert-time {
  color: var(--muted);
  white-space: nowrap;
}

.alert-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 25;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  min-height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  padding: 7px 6px calc(7px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(16px);
}

.bottom-nav button {
  display: grid;
  place-items: center;
  gap: 3px;
  min-width: 0;
  min-height: 58px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #30373d;
  font-size: 11px;
  font-weight: 640;
  line-height: 1.1;
}

.bottom-nav button.active {
  color: var(--teal);
  background: #eef8fa;
}

.bottom-nav svg {
  width: 22px;
  height: 22px;
}

.detail-sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
}

.detail-sheet.open {
  display: block;
}

.scrim {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
  background: rgba(10, 17, 21, 0.3);
}

.sheet-card {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  max-height: min(78vh, 680px);
  overflow: auto;
  padding: 10px 16px 18px;
  border-radius: 8px 8px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.sheet-handle {
  width: 42px;
  height: 4px;
  margin: 0 auto 12px;
  border-radius: 999px;
  background: #c8cfd4;
}

.sheet-title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 760;
}

.sheet-subtitle {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.sheet-grid {
  display: grid;
  gap: 8px;
}

.sheet-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}

.sheet-row strong {
  color: #30373d;
}

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

.sheet-actions a,
.sheet-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
  color: #20262b;
  font-size: 13px;
  font-weight: 720;
  text-decoration: none;
}

.sheet-actions .primary {
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
}

.empty-state {
  padding: 18px 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

@media (min-width: 760px) {
  .app-shell {
    background: linear-gradient(90deg, #f5f7f8, #ffffff 18%, #ffffff 82%, #f5f7f8);
  }

  .topbar {
    width: min(100%, 900px);
    margin: 0 auto;
    border-right: 1px solid var(--line);
    border-left: 1px solid var(--line);
  }

  .screen {
    padding: 16px;
  }

  .segmented-control {
    margin-right: 0;
    margin-left: 0;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
  }

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

  .bottom-nav {
    right: 50%;
    left: auto;
    width: min(100%, 900px);
    transform: translateX(50%);
    border-right: 1px solid var(--line);
    border-left: 1px solid var(--line);
  }

  .sheet-card {
    right: 50%;
    left: auto;
    width: min(560px, calc(100% - 32px));
    transform: translateX(50%);
    border-radius: 8px 8px 0 0;
  }
}

@media (max-width: 380px) {
  .topbar {
    grid-template-columns: 42px 1fr 42px;
    padding-right: 10px;
    padding-left: 10px;
  }

  h1 {
    font-size: 21px;
  }

  .mode-chip {
    min-height: 30px;
    padding: 0 8px;
    font-size: 11px;
  }

  .segmented-control button {
    font-size: 11px;
  }

  .auction-row {
    grid-template-columns: 58px minmax(0, 1fr) auto 26px;
    gap: 8px;
  }

  .thumb {
    width: 58px;
    height: 52px;
  }

  .auction-money {
    min-width: 62px;
  }

  .auction-title {
    font-size: 14px;
  }
}

@media (max-width: 430px) {
  h1 {
    font-size: 19px;
    white-space: nowrap;
  }

  .mode-chip {
    min-height: 30px;
    gap: 4px;
    padding: 0 6px;
    font-size: 10px;
  }

  .mode-chip svg {
    width: 16px;
    height: 16px;
  }
}
