/* Telegram WebApp theme variables — light/dark avtomatik */
:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f4f6fa);
  --text: var(--tg-theme-text-color, #0f172a);
  --hint: var(--tg-theme-hint-color, #64748b);
  --link: var(--tg-theme-link-color, #1F6FEB);
  --button: var(--tg-theme-button-color, #1F6FEB);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #f59e0b;
  --border: rgba(127,127,127,.18);
  --radius: 14px;
  --shadow: 0 4px 14px rgba(0,0,0,.06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 76px;          /* bottom nav uchun joy */
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  padding: 14px 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 19px; font-weight: 700; }
.topbar-sub   { font-size: 13px; color: var(--hint); margin-top: 2px; }

/* ---------- Screens ---------- */
.screen { display: none; padding: 14px 14px 24px; }
.screen.active { display: block; }

.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--hint);
  margin: 18px 4px 8px;
  font-weight: 600;
}

/* ---------- Cards ---------- */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card {
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.card.stat .stat-label { font-size: 12px; color: var(--hint); }
.card.stat .stat-value { font-size: 28px; font-weight: 800; margin-top: 4px; line-height: 1; }
.card.stat .stat-sub   { font-size: 12px; color: var(--hint); margin-top: 2px; }

/* ---------- List ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  background: var(--bg2);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px;
}
.list-item .name { font-weight: 600; }
.list-item .sub  { font-size: 12px; color: var(--hint); margin-top: 2px; }
.list-item .value { font-weight: 700; }
.list-item.muted { opacity: .65; }
.empty {
  text-align: center; color: var(--hint); padding: 14px; font-size: 13px;
}

/* ---------- Forms ---------- */
.form {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 14px;
}
.form label { font-size: 12px; color: var(--hint); margin-top: 8px; }
.form label:first-child { margin-top: 0; }
.form input, .form select, .date-range input {
  font-size: 16px;          /* iOS auto-zoom ni oldini olish */
  padding: 12px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  width: 100%;
  appearance: none;
}
.form input:focus, .form select:focus, .date-range input:focus {
  outline: 2px solid var(--button);
  outline-offset: 0;
}
.hint { font-size: 12px; color: var(--hint); margin-top: 4px; }
.calc {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text);
  background: rgba(31,111,235,.08);
  padding: 10px 12px;
  border-radius: 10px;
  display: none;
}
.calc.show { display: block; }
.calc .row { display: flex; justify-content: space-between; padding: 2px 0; }
.calc .row.danger { color: var(--danger); }
.calc .row.ok { color: var(--success); }

/* ---------- Buttons ---------- */
.btn-primary, .btn-secondary {
  font-size: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 0;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-top: 14px;
}
.btn-primary {
  background: var(--button);
  color: var(--button-text);
}
.btn-primary:active { opacity: .9; }
.btn-secondary {
  background: transparent;
  color: var(--link);
  border: 1px solid var(--border);
}

.row-actions { margin-top: 12px; }

.date-range {
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 14px;
}
.date-range label { display:block; font-size: 12px; color: var(--hint); margin: 6px 0 4px; }
.quick-ranges { display: flex; gap: 6px; margin: 10px 0 4px; flex-wrap: wrap; }
.chip {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}
.chip:active { background: rgba(31,111,235,.1); }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 6px 4px max(6px, env(safe-area-inset-bottom));
  z-index: 20;
}
.nav-btn {
  background: transparent; border: 0; padding: 6px 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--hint);
  font-size: 11px;
  cursor: pointer;
}
.nav-btn.active { color: var(--button); }
.nav-icon { font-size: 20px; line-height: 1; }
.nav-label { font-size: 11px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 30;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--bg); color: var(--text);
  width: 100%; max-width: 480px;
  border-radius: 16px 16px 0 0;
  padding: 16px;
  animation: slideUp .2s ease-out;
}
.modal-title { font-weight: 700; font-size: 16px; margin-bottom: 10px; }
.modal-body { display: flex; flex-direction: column; gap: 8px; }
.modal-body label { font-size: 12px; color: var(--hint); margin-top: 6px; }
.modal-body input, .modal-body select {
  font-size: 16px; padding: 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg2); color: var(--text); width: 100%;
}
.modal-actions { display: flex; gap: 8px; margin-top: 14px; }
.modal-actions .btn-primary, .modal-actions .btn-secondary { margin: 0; }
@keyframes slideUp { from { transform: translateY(50px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: rgba(0,0,0,.85); color: #fff;
  padding: 10px 16px; border-radius: 10px;
  font-size: 14px; z-index: 50;
  max-width: 88%;
  text-align: center;
}
.toast.hidden { display: none; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* ---------- Misc ---------- */
.director-only { display: none; }
body.is-director .director-only { display: block; }

.recipe-list { margin: 8px 0; padding: 0; list-style: none; }
.recipe-list li {
  font-size: 13px; color: var(--text);
  padding: 4px 0; display: flex; justify-content: space-between;
  border-bottom: 1px dashed var(--border);
}
.recipe-list li:last-child { border-bottom: 0; }

.report-block {
  background: var(--bg2); border-radius: var(--radius);
  padding: 12px 14px; margin-top: 10px;
}
.report-block h3 { font-size: 14px; margin: 0 0 8px; }
.report-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; }
.report-total { margin-top: 8px; font-weight: 700; border-top: 1px solid var(--border); padding-top: 6px; }
