* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: var(--tg-theme-bg-color, #fff);
  --text: var(--tg-theme-text-color, #1a1a1a);
  --hint: var(--tg-theme-hint-color, #999);
  --link: var(--tg-theme-link-color, #2481cc);
  --btn: var(--tg-theme-button-color, #2481cc);
  --btn-text: var(--tg-theme-button-text-color, #fff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #f0f0f0);
  --section-bg: var(--tg-theme-section-bg-color, var(--bg));
  --section-header: var(--tg-theme-section-header-text-color, var(--hint));
  --subtitle: var(--tg-theme-subtitle-text-color, var(--hint));
  --destructive: var(--tg-theme-destructive-text-color, #e53935);
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--secondary-bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  padding-bottom: 80px;
}

.header {
  background: var(--section-bg);
  padding: 16px;
  margin-bottom: 8px;
}

.header h1 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.header .meta {
  color: var(--subtitle);
  font-size: 13px;
}

.header .badge {
  float: right;
  background: var(--btn);
  color: var(--btn-text);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
}

.section {
  background: var(--section-bg);
  margin-bottom: 8px;
}

.section-title {
  padding: 12px 16px 8px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.section-title.resolved { color: #43a047; }
.section-title.pending { color: #f57c00; }
.section-title.unresolved { color: var(--destructive); }
.section-title.skipped { color: var(--hint); }

.item {
  padding: 12px 16px;
  border-top: 0.5px solid var(--secondary-bg);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.item:first-child { border-top: none; }

.item .check {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  margin-top: 2px;
  border-radius: 6px;
  border: 2px solid var(--hint);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #fff;
  transition: all 0.15s;
}

.item .check.checked {
  background: #43a047;
  border-color: #43a047;
}

.item .check.skip {
  background: var(--hint);
  border-color: var(--hint);
}

.item-body { flex: 1; min-width: 0; }

.item-name {
  font-weight: 500;
  word-break: break-word;
}

.item-details {
  font-size: 13px;
  color: var(--subtitle);
  margin-top: 2px;
}

.item-details span { margin-right: 12px; }

.suggestion-banner {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--secondary-bg);
  border-radius: 8px;
  font-size: 13px;
}

.suggestion-banner .label {
  color: var(--subtitle);
  font-size: 12px;
  margin-bottom: 4px;
}

.suggestion-banner .name {
  font-weight: 500;
  color: var(--link);
}

.action-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.action-btn {
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--hint);
  background: var(--section-bg);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}

.action-btn.primary {
  background: var(--btn);
  color: var(--btn-text);
  border-color: var(--btn);
}

.empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--hint);
}

.loading {
  padding: 60px 16px;
  text-align: center;
  color: var(--hint);
  font-size: 16px;
}

.error-msg {
  padding: 32px 16px;
  text-align: center;
  color: var(--destructive);
}

/* Modal bottom sheet */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  display: flex;
  align-items: flex-end;
}

.modal {
  background: var(--section-bg);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  padding: 16px;
  animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--secondary-bg);
  border-radius: 50%;
  font-size: 16px;
  color: var(--hint);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-item-name {
  font-size: 13px;
  color: var(--subtitle);
  margin-bottom: 8px;
}

/* Search */
.search-input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--hint);
  border-radius: 8px;
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  margin-bottom: 12px;
  font-family: inherit;
  outline: none;
}

.search-input:focus {
  border-color: var(--link);
}

.search-results {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.search-result {
  padding: 12px;
  border-bottom: 0.5px solid var(--secondary-bg);
  cursor: pointer;
}

.search-result:active {
  background: var(--secondary-bg);
}

.result-name {
  font-weight: 500;
  word-break: break-word;
}

.result-meta {
  font-size: 12px;
  color: var(--subtitle);
  margin-top: 2px;
}

/* Editable price */
.editable-price {
  cursor: pointer;
  color: var(--link);
}

.price-edit {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.price-input {
  width: 80px;
  padding: 4px 8px;
  border: 1px solid var(--link);
  border-radius: 6px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  outline: none;
}

.price-unit {
  font-size: 13px;
  color: var(--subtitle);
}

/* Button states */
.action-btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.action-btn.loading {
  position: relative;
  color: transparent;
}

.action-btn.loading::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  top: 50%;
  left: 50%;
  margin: -7px 0 0 -7px;
  border: 2px solid var(--hint);
  border-top-color: var(--btn);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
