:root {
  color-scheme: light dark;
  --bg: var(--tg-theme-bg-color, #f5f6f3);
  --surface: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #172019);
  --muted: var(--tg-theme-hint-color, #728078);
  --accent: var(--tg-theme-button-color, #2f7353);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --border: color-mix(in srgb, var(--text) 10%, transparent);
  --danger: #c34a4a;
  font-family: "Segoe UI", Inter, system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--text); background: var(--bg); }
button, input { font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.shell { width: min(100%, 680px); min-height: 100vh; margin: 0 auto; padding: max(22px, env(safe-area-inset-top)) 16px calc(100px + env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(26px, 7vw, 38px); letter-spacing: -.045em; }
.add-top { display: flex; align-items: center; gap: 5px; min-height: 42px; padding: 0 14px; border: 0; border-radius: 14px; color: var(--accent-text); background: var(--accent); font-weight: 700; }
.add-top span { font-size: 20px; line-height: 1; }
.overview { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.overview div { display: flex; align-items: baseline; gap: 8px; padding: 13px 15px; border: 1px solid var(--border); border-radius: 17px; background: var(--surface); }
.overview strong { font-size: 24px; font-variant-numeric: tabular-nums; }
.overview span { color: var(--muted); font-size: 12px; }
.items { display: grid; gap: 11px; }
.item-card { padding: 16px; border: 1px solid var(--border); border-radius: 21px; background: var(--surface); box-shadow: 0 7px 22px color-mix(in srgb, var(--text) 5%, transparent); transition: opacity .15s; }
.item-card.busy { opacity: .58; pointer-events: none; }
.item-heading { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.item-copy { min-width: 0; }
.item-copy h2 { overflow: hidden; margin-bottom: 4px; font-size: 17px; text-overflow: ellipsis; white-space: nowrap; }
.item-copy p { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.item-copy strong { color: var(--text); font-size: 25px; font-variant-numeric: tabular-nums; }
.edit-button, .icon-button { display: grid; flex: 0 0 auto; place-items: center; width: 38px; height: 38px; border: 1px solid var(--border); border-radius: 13px; color: var(--text); background: color-mix(in srgb, var(--surface) 75%, var(--bg)); font-size: 17px; }
.progress { overflow: hidden; height: 6px; margin: 13px 0 12px; border-radius: 10px; background: color-mix(in srgb, var(--text) 8%, transparent); }
.progress i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .2s ease; }
.low-stock .progress i { background: #d99b27; }
.empty-stock .progress i { background: var(--danger); }
.item-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stock-label { color: var(--accent); font-size: 12px; font-weight: 700; }
.low-stock .stock-label { color: #b67600; }
.empty-stock .stock-label { color: var(--danger); }
.stepper { display: flex; align-items: center; overflow: hidden; border: 1px solid var(--border); border-radius: 14px; background: var(--bg); }
.stepper button { width: 42px; height: 38px; border: 0; color: var(--text); background: transparent; font-size: 22px; }
.stepper button:active:not(:disabled) { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.stepper button:disabled { cursor: default; opacity: .28; }
.stepper span { min-width: 25px; color: var(--muted); text-align: center; font-size: 11px; }
.empty { margin-top: 8vh; padding: 34px 22px; border: 1px dashed color-mix(in srgb, var(--accent) 40%, var(--border)); border-radius: 26px; text-align: center; background: var(--surface); }
.empty p { max-width: 360px; margin: 0 auto 20px; color: var(--muted); line-height: 1.5; }
.empty-icon { display: grid; place-items: center; width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 18px; color: var(--accent-text); background: var(--accent); font-size: 28px; }
.primary, .danger { min-height: 48px; padding: 0 20px; border: 0; border-radius: 15px; font-weight: 750; }
.primary { color: var(--accent-text); background: var(--accent); }
.primary:disabled { opacity: .55; }
.danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.floating-add { position: fixed; right: max(18px, calc((100vw - 680px) / 2 + 18px)); bottom: calc(20px + env(safe-area-inset-bottom)); width: 58px; height: 58px; border: 0; border-radius: 19px; color: var(--accent-text); background: var(--accent); box-shadow: 0 14px 32px color-mix(in srgb, var(--accent) 32%, transparent); font-size: 31px; }
.status { margin-bottom: 14px; padding: 12px 14px; border-radius: 14px; color: #7a2525; background: #ffe1e1; font-size: 14px; }
.loading { display: grid; gap: 11px; }
.loading div { height: 134px; border-radius: 21px; background: linear-gradient(100deg, var(--surface) 20%, color-mix(in srgb, var(--surface) 65%, var(--text)) 40%, var(--surface) 60%); background-size: 300% 100%; animation: shimmer 1.2s infinite; }
dialog { width: min(calc(100% - 24px), 540px); padding: 0; border: 1px solid var(--border); border-radius: 25px; color: var(--text); background: var(--surface); box-shadow: 0 24px 70px #0005; }
dialog::backdrop { background: #11191380; backdrop-filter: blur(3px); }
dialog form { padding: 21px; }
.dialog-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 21px; }
.dialog-header h2 { margin: 0; font-size: 25px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
input { width: 100%; min-height: 50px; padding: 0 13px; border: 1px solid var(--border); border-radius: 14px; outline: none; color: var(--text); background: var(--bg); }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-top: 14px; }
.form-hint { margin: 10px 0 0; color: var(--muted); font-size: 11px; line-height: 1.4; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.dialog-actions .danger { margin-right: auto; }
.hidden { display: none !important; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@media (max-width: 410px) { .add-top { width: 42px; padding: 0; justify-content: center; font-size: 0; } .add-top span { font-size: 24px; } .overview div { display: grid; gap: 1px; } .form-row { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
