:root {
  --bg: #0f172a;
  --bg-2: #1e293b;
  --bg-3: #273449;
  --card: #1e293b;
  --border: #334155;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --green: #22c55e;
  --yellow: #f59e0b;
  --red: #ef4444;
  --blue: #3b82f6;
  --gray: #64748b;
  --radius: 16px;
  --shadow: 0 4px 20px rgba(0,0,0,0.35);
  --font: 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  direction: rtl;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

.app-header {
  position: sticky; top: 0; z-index: 20;
  height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: rgba(15,23,42,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.app-title { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 16px; }
.app-logo { font-size: 22px; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; width: 40px; height: 40px; font-size: 18px; cursor: pointer;
}
.badge-btn {
  background: var(--yellow); color: #1f2937; border: none; border-radius: 999px;
  padding: 8px 12px; font-weight: 700; cursor: pointer; font-family: inherit; font-size: 13px;
}

main { max-width: 720px; margin: 0 auto; padding: 16px 12px 130px; }
.view[hidden] { display: none; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}

h2, h3 { margin: 0 0 6px; }
.hint { color: var(--text-dim); font-size: 13px; }
.field-label { display: block; margin: 14px 0 6px; font-size: 13px; color: var(--text-dim); font-weight: 500; }
.field-label-inline { font-size: 13px; color: var(--text-dim); white-space: nowrap; }

input[type=text], input[type=url], input[type=tel], .input {
  width: 100%; padding: 14px; font-size: 18px;
  background: var(--bg-3); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  font-family: inherit; outline: none;
}
input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59,130,246,0.2); }

.select {
  flex: 1; padding: 11px 12px; font-size: 14px;
  background: var(--bg-3); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; font-family: inherit;
}

.btn {
  border: none; border-radius: 12px; padding: 14px 18px;
  font-size: 16px; font-weight: 700; cursor: pointer; font-family: inherit;
  transition: transform 0.06s, opacity 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-green { background: var(--green); color: #052e16; }
.btn-warn { background: var(--yellow); color: #422006; }
.btn-secondary { background: var(--bg-2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); padding: 8px 12px; font-size: 13px; }
.btn-big { width: 100%; font-size: 18px; padding: 16px; }

.row-btns { display: flex; gap: 10px; margin-top: 14px; }
.row-btns .btn { flex: 1; }
.status-line { margin-top: 10px; font-size: 13px; color: var(--text-dim); }
.help-list { font-size: 13px; color: var(--text-dim); line-height: 1.9; padding-right: 18px; }
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

.login-wrap { margin-top: 8px; }
.divider { text-align: center; color: var(--text-dim); margin: 16px 0 6px; font-size: 13px; }
.custodian-list { max-height: 42vh; overflow-y: auto; margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.custodian-item {
  display: flex; flex-direction: column; gap: 2px; text-align: right;
  background: var(--bg-3); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; cursor: pointer; color: var(--text); font-family: inherit;
}
.custodian-item:active { background: var(--bg-2); }
.ci-name { font-weight: 700; }
.ci-meta { font-size: 12px; color: var(--text-dim); }
.ci-count { font-size: 12px; color: var(--blue); }

.quick-entry {
  position: sticky; top: 60px; z-index: 15;
  margin: -16px -12px 16px; padding: 10px 12px;
  background: rgba(15,23,42,0.95); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.quick-row { display: flex; gap: 10px; }
.quick-input { flex: 1; font-size: 22px !important; text-align: center; font-weight: 700; letter-spacing: 2px; }
.btn-quick { flex-shrink: 0; font-size: 18px; padding: 0 24px; background: var(--green); color: #052e16; }

.summary-card { margin-bottom: 16px; }
.summary-top { position: relative; padding-left: 100px; min-height: 40px; }
.btn-back { position: absolute; left: 0; top: 0; }
.cust-name { margin: 0 0 4px; font-size: 20px; }
.cust-meta { color: var(--text-dim); font-size: 13px; margin-bottom: 12px; }
.progress-track { height: 14px; background: var(--bg-3); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #16a34a, #22c55e); border-radius: 999px; transition: width 0.3s; }
.progress-label { font-size: 12px; color: var(--text-dim); margin-top: 6px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.stat { background: var(--bg-3); border-radius: 12px; padding: 10px 6px; text-align: center; border: 1px solid var(--border); }
.stat-val { display: block; font-size: 20px; font-weight: 800; }
.stat-label { display: block; font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.stat.ok .stat-val { color: var(--green); }
.stat.warn .stat-val { color: var(--yellow); }
.stat.err .stat-val { color: var(--red); }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; }
.tab {
  flex: 1; min-width: 0; white-space: nowrap;
  background: var(--bg-2); color: var(--text-dim); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 8px; font-size: 13px; font-weight: 700;
  cursor: pointer; font-family: inherit;
}
.tab.active { background: var(--blue); color: #fff; border-color: var(--blue); }

.sub-filter-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }

.asset-list { display: flex; flex-direction: column; gap: 10px; }
.asset-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.asset-card.st-ok { border-right: 4px solid var(--green); }
.asset-card.st-loc { border-right: 4px solid var(--yellow); }
.asset-card.st-repair, .asset-card.st-missing { border-right: 4px solid var(--red); }
.ac-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.ac-code { font-weight: 800; font-size: 17px; direction: ltr; }
.ac-status { font-size: 11px; padding: 3px 10px; border-radius: 999px; font-weight: 700; }
.ac-status.st-ok { background: rgba(34,197,94,0.15); color: var(--green); }
.ac-status.st-loc { background: rgba(245,158,11,0.15); color: var(--yellow); }
.ac-status.st-repair, .ac-status.st-missing { background: rgba(239,68,68,0.15); color: var(--red); }
.ac-status.st-empty { background: rgba(148,163,184,0.15); color: var(--text-dim); }
.ac-name { font-size: 15px; font-weight: 500; margin-bottom: 4px; }
.ac-meta { font-size: 12px; color: var(--text-dim); }
.ac-note { font-size: 12px; color: var(--yellow); margin-top: 6px; background: rgba(245,158,11,0.08); padding: 6px 8px; border-radius: 8px; }
.ac-check { font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.ac-actions { display: flex; gap: 8px; margin-top: 10px; }
.act { flex: 1; padding: 12px; border-radius: 10px; font-size: 14px; font-weight: 700; border: 1px solid var(--border); cursor: pointer; font-family: inherit; }
.act-confirm { background: var(--green); color: #052e16; border-color: var(--green); }
.act-discrepancy { background: var(--bg-2); color: var(--yellow); }

.sync-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 18;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: rgba(15,23,42,0.95); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  max-width: 720px; margin: 0 auto; border-radius: 16px 16px 0 0;
}
.sync-bar span { flex: 1; font-size: 13px; color: var(--text-dim); }
.btn-sync { background: var(--blue); color: #fff; padding: 12px 16px; font-size: 14px; white-space: nowrap; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 100; display: flex; align-items: flex-end; justify-content: center; padding: 16px; }
.modal {
  background: var(--card); border: 1px solid var(--border); border-radius: 20px;
  padding: 20px; width: 100%; max-width: 480px; max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow);
}
.modal-title { font-size: 18px; font-weight: 800; margin-bottom: 4px; }
.modal-title.warn-title { color: var(--yellow); }
.modal-name { font-size: 14px; color: var(--text-dim); margin-bottom: 12px; }
.modal-sub { font-size: 13px; color: var(--text-dim); margin: 8px 0; }
.modal-sub.gray { color: var(--gray); }
.owner-box { background: var(--bg-3); border-radius: 12px; padding: 12px; margin: 10px 0; font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
.modal-btns { display: flex; gap: 10px; margin-top: 16px; }
.modal-btns .btn { flex: 1; }
.modal-btns.col { flex-direction: column; }
.dup-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.dup-item {
  display: flex; flex-direction: column; gap: 2px; background: var(--bg-3);
  border: 1px solid var(--border); border-radius: 12px; padding: 12px;
  cursor: pointer; color: var(--text); font-family: inherit; text-align: right;
}
.di-name { font-weight: 700; }
.di-meta { font-size: 12px; color: var(--text-dim); }
.notfound-code { font-size: 24px; font-weight: 800; direction: ltr; text-align: center; margin: 12px 0; color: var(--gray); }

#toast-root {
  position: fixed; top: 70px; left: 0; right: 0; z-index: 200;
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  background: var(--bg-3); color: var(--text); border: 1px solid var(--border);
  border-radius: 999px; padding: 10px 18px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow); opacity: 0; transform: translateY(-8px);
  transition: opacity 0.25s, transform 0.25s; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.ok { border-color: var(--green); color: var(--green); }
.toast.warn { border-color: var(--yellow); color: var(--yellow); }
.toast.error { border-color: var(--red); color: var(--red); }
.toast.info { border-color: var(--blue); color: var(--blue); }

.empty { text-align: center; color: var(--text-dim); padding: 30px 10px; }
body.loading { cursor: progress; }
