/* ===== Asos ===== */
* { box-sizing: border-box; }
:root {
  --bg: #0f172a;
  --card: #1e293b;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --green: #148c5f;
  --yellow: #ffc148;
  --red: #d82117;
}
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== Header ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(6px);
}
.app-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.lang-btn {
  flex: 0 0 auto;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 11px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
}
.lang-btn:active { opacity: 0.7; }
.back-btn {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}

.content {
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  padding: 16px;
  flex: 1 0 auto;
}

/* ===== Pastki aloqa bo'limi ===== */
.app-footer {
  flex-shrink: 0;
  text-align: center;
  padding: 18px 16px 26px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}
.footer-label {
  font-size: 0.82rem;
  color: var(--muted);
  margin-right: 6px;
}
.footer-phone {
  display: inline-block;
  color: #64748b;
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.3px;
  text-decoration: none;
}
.footer-phone:active { opacity: 0.7; }

/* ===== Holat (loading / error / empty) ===== */
.state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.state .icon { font-size: 2.4rem; display: block; margin-bottom: 10px; }
.state .title { font-size: 1.1rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 14px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn {
  margin-top: 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
}

.dev-banner {
  background: #422006;
  color: #fcd34d;
  border: 1px solid #92400e;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.78rem;
  text-align: center;
  margin-bottom: 12px;
}

/* ===== Mijoz sarlavhasi ===== */
.contractor-head { margin-bottom: 14px; }
.contractor-name { font-size: 1.05rem; font-weight: 700; }
.factory-name { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }

.section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin: 16px 0 8px;
}

/* ===== Boshqaruv: filtr + yangilash ===== */
.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
}
.filters {
  display: flex;
  gap: 6px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  background: var(--card);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 13px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.refresh-btn {
  flex: 0 0 auto;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 40px;
  height: 34px;
  font-size: 1rem;
  cursor: pointer;
}
.refresh-btn.spinning { animation: spin 0.8s linear infinite; }

.org-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  margin: 16px 0 8px;
}

/* ===== Buyurtmalar ro'yxati ===== */
.order-list { display: flex; flex-direction: column; gap: 12px; }
.order-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  color: var(--text);
  cursor: pointer;
  font: inherit;
}
.order-card:active { transform: scale(0.99); }
.order-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.order-title { font-weight: 700; font-size: 1rem; flex: 1; min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
.order-title-lg { font-weight: 700; font-size: 1.15rem; overflow-wrap: anywhere; word-break: break-word; }

.badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge.done { background: var(--green); color: #fff; }
.badge.process, .badge.in_production { background: var(--yellow); color: #1a1a1a; }
.badge.new { background: #475569; color: #fff; }

.deadline { font-size: 0.78rem; color: var(--muted); margin: 6px 0; }
.deadline .late { color: #fca5a5; font-weight: 700; }
.deadline .soon { color: #fcd34d; font-weight: 700; }

.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 6px 0 4px;
  font-size: 0.85rem;
}
.muted { color: var(--muted); }
.percent { font-weight: 700; }

.progress-track {
  width: 100%;
  height: 8px;
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress-track.big { height: 12px; }
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  border-radius: 999px;
  transition: width 0.8s ease;
}
.progress-fill.full { background: linear-gradient(90deg, #22c55e, #4ade80); }

/* ===== Tafsilot sarlavhasi ===== */
.detail-head {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
}
.detail-head .muted { font-size: 0.82rem; margin-top: 4px; }

/* ===== Rangli tablo (status grid) ===== */
.status-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.status-item {
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  min-height: 96px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}
.status-item.done { background: var(--green); color: #fff; }
.status-item.process { background: var(--yellow); color: #1a1a1a; }
.status-item.not-started { background: var(--red); color: #fff; }

.step-name {
  font-size: 0.66rem;
  text-transform: uppercase;
  font-weight: 700;
  opacity: 0.9;
  letter-spacing: 0.3px;
}
.main-val { font-size: 1.5rem; font-weight: 800; line-height: 1; }
.main-val small { font-size: 0.6rem; font-weight: normal; margin-left: 2px; }
.sub-text { font-size: 0.6rem; opacity: 0.9; margin-top: 3px; letter-spacing: 0.3px; }
.status-label { font-size: 0.6rem; font-weight: 800; letter-spacing: 0.5px; margin-top: 2px; }
.empty-grid { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 24px; }

/* Aylanadigan qiymatlar (foiz → hajm → dona, har 5s) */
.cycle-wrap {
  position: relative;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cycle-item {
  position: absolute;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}
.cycle-item.active {
  position: relative;
  opacity: 1;
  transform: translateY(0);
}

/* ===== Umumiy progress ===== */
.overall {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.overall-label {
  text-align: center;
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

/* ===== Fabrika kartochkalari ===== */
.factory-card { border-left: 4px solid var(--accent); }
.factory-card .order-title { font-size: 1.05rem; }
.controls .section-title { flex: 1; margin: 0; }
.progress-meta .late { color: #fca5a5; font-weight: 700; }

/* ===== Fabrika logotipi — kartochka foni ===== */
/* Logotip bo'lmasa kartochka avvalgidek ko'rinadi (hech narsa o'zgarmaydi) */
.factory-card { position: relative; overflow: hidden; }
.factory-card > *:not(.factory-logo) { position: relative; z-index: 1; }
.factory-logo {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.35;
}
/* Matn va progress-bar o'qilishi uchun logotip ustidan qorong'i qatlam */
.factory-card.has-logo::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(90deg, rgba(15, 23, 42, 0.94) 0%,
                                     rgba(15, 23, 42, 0.78) 50%,
                                     rgba(15, 23, 42, 0.58) 100%);
}
