:root {
  color-scheme: light dark;
  --bg: var(--tg-theme-bg-color, #f7f7f4);
  --panel: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #18201f);
  --muted: var(--tg-theme-hint-color, #687371);
  --button: var(--tg-theme-button-color, #0f766e);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --line: rgba(104, 115, 113, 0.22);
  --warn: #a16207;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.shell {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 14px max(24px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 19px;
  line-height: 1.2;
  letter-spacing: 0;
}

.topbar p,
.status-line,
.detail-head p,
.empty p {
  color: var(--muted);
  margin-top: 4px;
}

.icon-button,
.text-button,
.primary-button,
.periods button,
.date-tools button,
.breadcrumbs button,
.menu-card {
  border: 0;
  cursor: pointer;
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  font-size: 22px;
}

.search-row {
  margin-top: 18px;
}

.menu-grid {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.menu-grid.compact {
  grid-template-columns: 1fr;
}

.menu-card {
  min-height: 86px;
  text-align: left;
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
}

.menu-card strong {
  display: block;
  font-size: 18px;
  line-height: 1.15;
}

.menu-card span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
}

input[type="search"] {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0 13px;
}

input[type="date"] {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 0 10px;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 0 10px;
  scrollbar-width: none;
}

.breadcrumbs:empty {
  display: none;
}

.breadcrumbs button {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 21px;
  line-height: 1;
}

.quote-list {
  display: grid;
  gap: 8px;
}

.quote-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

.quote-row.featured {
  border-color: var(--button);
}

.quote-row strong {
  display: block;
  font-size: 15px;
  line-height: 1.22;
}

.quote-row span {
  display: block;
  color: var(--muted);
  margin-top: 4px;
  font-size: 12px;
}

.quote-value {
  text-align: right;
  min-width: 92px;
}

.detail-panel {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  background: var(--bg);
  padding: max(16px, env(safe-area-inset-top)) 14px max(24px, env(safe-area-inset-bottom));
  z-index: 10;
}

.text-button {
  min-height: 36px;
  padding: 0;
  background: transparent;
  color: var(--button);
}

.detail-head {
  margin-top: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.detail-head strong {
  display: block;
  margin-top: 12px;
  font-size: 28px;
  line-height: 1.05;
}

.date-tools {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 8px;
  margin-top: 14px;
}

.date-tools label {
  color: var(--muted);
  font-size: 12px;
}

.date-tools input {
  margin-top: 6px;
}

.date-tools button {
  min-height: 42px;
  border-radius: 8px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 0 12px;
}

.periods {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 14px 0;
}

.periods button {
  min-height: 38px;
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
}

.periods button.active {
  background: var(--button);
  color: var(--button-text);
}

.chart-box {
  width: 100%;
  min-height: 230px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.chart-box img {
  width: 100%;
  display: block;
}

.primary-button {
  width: 100%;
  min-height: 46px;
  margin-top: 14px;
  border-radius: 8px;
  background: var(--button);
  color: var(--button-text);
}

.primary-button:disabled {
  opacity: 0.55;
}

.empty {
  padding: 24px 6px;
}

@media (min-width: 700px) {
  .menu-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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