:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #1c1c1e);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --link: var(--tg-theme-link-color, #2a7);
  --btn: var(--tg-theme-button-color, #2a7);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --card: var(--tg-theme-secondary-bg-color, #f2f2f7);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 12px 14px 40px;
}

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
header h1 {
  font-size: 20px;
  margin: 4px 0 10px;
}
#me {
  color: var(--hint);
  font-size: 14px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}
.tab {
  flex: 1 1 auto;
  padding: 8px 10px;
  border: none;
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  white-space: nowrap;
}
.tab.active {
  background: var(--btn);
  color: var(--btn-text);
  font-weight: 600;
}
.subtab {
  flex: 1;
  padding: 7px;
  border: none;
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font-size: 14px;
}
.subtab.active {
  background: var(--btn);
  color: var(--btn-text);
  font-weight: 600;
}
.balance {
  background: var(--card);
  border-radius: 10px;
  padding: 12px;
  margin: 0 0 12px;
  font-weight: 600;
  text-align: center;
}
.inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  color: var(--text);
}
.inline input {
  flex: 0 0 auto;
}

.row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.row input {
  flex: 1;
}
.row .qty {
  flex: 0 0 80px;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0 14px;
}

input,
select {
  padding: 11px;
  border: 1px solid var(--card);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-size: 16px;
}
.grow {
  flex: 1;
}
label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--hint);
}

button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  background: var(--btn);
  color: var(--btn-text);
  font-size: 16px;
  padding: 11px 16px;
}
button.secondary {
  background: var(--card);
  color: var(--text);
  width: 100%;
  margin-top: 8px;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 12px;
  background: var(--card);
  border-radius: 10px;
  margin-bottom: 8px;
}
.item-label {
  flex: 1;
  cursor: pointer;
}
.item.done .item-label {
  text-decoration: line-through;
  color: var(--hint);
}
.item.urgent {
  border-left: 4px solid #e0392b;
}
.item .del {
  background: transparent;
  color: var(--hint);
  padding: 4px 8px;
  font-size: 18px;
}
.muted {
  color: var(--hint);
}

details {
  background: var(--card);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 10px;
}
summary {
  cursor: pointer;
  font-weight: 600;
}

h2 {
  font-size: 16px;
  margin: 6px 0 10px;
}

.error {
  position: fixed;
  bottom: 14px;
  left: 14px;
  right: 14px;
  background: #e0392b;
  color: #fff;
  padding: 12px;
  border-radius: 10px;
  text-align: center;
}
.error.ok {
  background: #2a9d5c;
}
.hidden {
  display: none !important;
}
