:root {
  --bg: #0e1116;
  --panel: #171d26;
  --panel-2: #1f2733;
  --text: #eef3f8;
  --muted: #9caaba;
  --line: #2d3846;
  --accent: #70d7b5;
  --warn: #f0c66a;
  --error: #ff8a8a;
  --link: #8fc7ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 14px) 14px 12px;
  background: rgba(14, 17, 22, 0.95);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

h1 {
  margin: 0 0 4px;
  font-size: 20px;
  line-height: 1.15;
}

.topbar p,
.notice,
.status,
.meta,
.detail-list,
.lot-summary,
.lot-title {
  overflow-wrap: anywhere;
}

.topbar p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
}

button {
  min-height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  color: #07100d;
  background: var(--accent);
  font-weight: 700;
}

button.secondary,
.map-link {
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.map-link {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-radius: 8px;
  font-weight: 700;
}

button:disabled {
  opacity: 0.65;
}

main {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 14px 12px 28px;
}

.status {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
  color: var(--muted);
}

.status strong {
  color: var(--text);
}

.status .stale {
  color: var(--warn);
}

.status .error {
  color: var(--error);
}

.controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 0 11px;
  border-radius: 8px;
  outline: none;
}

input:focus,
select:focus,
button:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(112, 215, 181, 0.18);
}

.notice {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-left: 3px solid var(--warn);
  background: rgba(240, 198, 106, 0.1);
  color: #f7df9f;
  border-radius: 6px;
  line-height: 1.35;
}

.lots {
  display: grid;
  gap: 10px;
}

.lot {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
}

.lot-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.lot-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.price {
  flex: 0 0 auto;
  text-align: right;
  font-size: 18px;
  font-weight: 800;
  color: var(--accent);
}

.period {
  display: block;
  margin-top: 2px;
  max-width: 150px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.lot-summary {
  margin: 9px 0;
  color: #d4dde8;
  line-height: 1.35;
  font-weight: 700;
}

.meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
  margin: 0 0 10px;
}

.meta div {
  min-width: 0;
  padding: 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
}

.meta dt {
  color: var(--muted);
  font-size: 11px;
}

.meta dd {
  margin: 2px 0 0;
  font-weight: 700;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

a {
  color: var(--link);
  text-decoration: none;
}

a:focus-visible {
  outline: 3px solid rgba(143, 199, 255, 0.35);
  outline-offset: 3px;
  border-radius: 4px;
}

details {
  color: var(--muted);
}

summary {
  cursor: pointer;
  color: var(--text);
}

.detail-list {
  margin: 8px 0 0;
  padding-left: 18px;
  line-height: 1.35;
}

.reason {
  margin: 8px 0 0;
  color: #d4dde8;
  line-height: 1.35;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 20px 14px;
  color: var(--muted);
  text-align: center;
}

dialog {
  max-width: min(720px, calc(100vw - 20px));
  max-height: min(820px, calc(100vh - 24px));
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

.dialog-panel,
.photo-panel {
  overflow: auto;
  max-height: min(820px, calc(100vh - 24px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.dialog-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: rgba(23, 29, 38, 0.96);
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  margin: 0;
  font-size: 18px;
}

.dialog-body {
  padding: 12px;
}

.dialog-title {
  margin: 0 0 10px;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.dialog-meta {
  grid-template-columns: repeat(2, 1fr);
}

.media-status {
  margin: 10px 0;
  color: #d4dde8;
  line-height: 1.35;
}

.map-action {
  min-height: 40px;
  margin-bottom: 12px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.gallery a {
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b0f14;
}

.gallery img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.photo-panel {
  padding: 10px;
}

.photo-panel button {
  margin-bottom: 10px;
}

.photo-panel img {
  display: block;
  width: min(100%, 900px);
  max-height: calc(100vh - 120px);
  object-fit: contain;
  border-radius: 6px;
}

@media (min-width: 560px) {
  .controls {
    grid-template-columns: 1fr 190px;
  }

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

@media (max-width: 420px) {
  .lot-head {
    flex-direction: column;
  }

  .price {
    text-align: left;
  }

  .period {
    max-width: none;
  }

  .meta {
    grid-template-columns: 1fr;
  }

  .actions {
    align-items: stretch;
  }

  .actions > * {
    flex: 1 1 100%;
  }

  .dialog-meta {
    grid-template-columns: 1fr;
  }
}
