/* Peyvand Lite — dark, RTL-first, mobile */
:root {
  --bg: #0b0b0e;
  --bg2: #101014;
  --card: #141419;
  --card2: #1a1a21;
  --line: #26262e;
  --line2: #32323c;
  --text: #ececf1;
  --muted: #9b9ba6;
  --dim: #6b6b76;
  --amber: #f5a623;
  --amber2: #ffbe4d;
  --green: #34d399;
  --red: #f87171;
  --blue: #60a5fa;
  --radius: 16px;
}

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

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, "Noto Sans", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

html[dir="rtl"] body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, "Vazirmatn", "Noto Naskh Arabic", Tahoma, sans-serif; }

#app { max-width: 640px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }

/* ---------- top bar ---------- */
#topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: rgba(11, 11, 14, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-icon {
  width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--amber);
  background: linear-gradient(135deg, rgba(245,166,35,.18), rgba(245,166,35,.05));
  border: 1px solid rgba(245,166,35,.35);
}
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: -.2px; }
.brand-sub { color: var(--muted); font-size: 11.5px; margin-inline-start: 2px; border: 1px solid var(--line2); padding: 1px 7px; border-radius: 999px; }

.pill-btn {
  border: 1px solid var(--line2); color: var(--text); background: var(--card);
  padding: 6px 13px; border-radius: 999px; font-weight: 700; font-size: 12.5px;
  cursor: pointer;
}
.pill-btn:active { transform: scale(.97); }

/* ---------- main ---------- */
main { flex: 1; padding: 14px 14px calc(84px + env(safe-area-inset-bottom)); }

.section-title { font-size: 13px; font-weight: 800; color: var(--muted); margin: 4px 2px 10px; }

/* ---------- contacts ---------- */
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.search-wrap { position: relative; flex: 1; }
.search-wrap svg { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--dim); }
.search-wrap input {
  width: 100%; padding: 11px 38px 11px 38px; border-radius: 13px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  font-size: 14px; outline: none;
}
.search-wrap input:focus { border-color: rgba(245,166,35,.6); }
.add-btn {
  display: flex; align-items: center; gap: 6px;
  background: linear-gradient(135deg, var(--amber), #e09612); color: #141414;
  border: none; border-radius: 13px; padding: 0 16px; font-weight: 800; font-size: 13.5px;
  cursor: pointer;
}
.add-btn:active { transform: scale(.97); }

.cards { display: flex; flex-direction: column; gap: 9px; }
.card {
  display: flex; align-items: center; gap: 11px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 13px; cursor: pointer;
  transition: border-color .15s;
}
.card:active { border-color: rgba(245,166,35,.55); background: var(--card2); }
.avatar {
  width: 44px; height: 44px; border-radius: 14px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 17px; color: #fff;
}
.card-main { flex: 1; min-width: 0; }
.card-name { font-weight: 750; font-size: 15px; }
.card-sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-badges { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 4px; }
.badge {
  font-size: 10.5px; color: var(--muted); border: 1px solid var(--line2);
  border-radius: 999px; padding: 1px 8px;
}
.badge.green { color: var(--green); border-color: rgba(52,211,153,.35); }
.badge.amber { color: var(--amber); border-color: rgba(245,166,35,.35); }
.badge.blue { color: var(--blue); border-color: rgba(96,165,250,.35); }

.empty {
  text-align: center; color: var(--muted); padding: 46px 20px; font-size: 13.5px;
}
.empty .big { font-size: 34px; margin-bottom: 8px; }

/* ---------- graph ---------- */
#graph-wrap { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
#graph { display: block; width: 100%; height: 62vh; min-height: 380px; touch-action: pan-y; }
.graph-hint { text-align: center; color: var(--dim); font-size: 12px; margin-top: 8px; }

/* ---------- market ---------- */
.market-grid { display: flex; flex-direction: column; gap: 10px; }
.mcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px; }
.mcard-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font-size: 11px; background: var(--card2); border: 1px solid var(--line2); color: var(--text); border-radius: 999px; padding: 2px 9px; }

/* ---------- data tab ---------- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.panel h3 { margin: 0 0 6px; font-size: 14.5px; }
.panel p { margin: 0 0 10px; color: var(--muted); font-size: 12.5px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn {
  border: 1px solid var(--line2); background: var(--card2); color: var(--text);
  border-radius: 12px; padding: 9px 14px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, var(--amber), #e09612); border: none; color: #141414; }
.btn.danger { color: var(--red); border-color: rgba(248,113,113,.4); }
.btn.green { color: var(--green); border-color: rgba(52,211,153,.4); }
.install-hint { border: 1px dashed rgba(245,166,35,.5); background: rgba(245,166,35,.06); border-radius: var(--radius); padding: 13px; font-size: 13px; }
.install-hint .ttl { font-weight: 800; color: var(--amber); margin-bottom: 5px; font-size: 13.5px; }
.install-hint ol { margin: 6px 0 0; padding-inline-start: 20px; color: var(--text); }
.install-hint li { margin-bottom: 3px; }

/* ---------- bottom tabs ---------- */
#tabbar {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 40;
  display: flex; justify-content: center; gap: 4px;
  padding: 7px 10px calc(7px + env(safe-area-inset-bottom));
  background: rgba(13, 13, 17, 0.92);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; max-width: 110px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; color: var(--dim);
  font-size: 10.5px; font-weight: 700; padding: 5px 2px; border-radius: 12px; cursor: pointer;
}
.tab.active { color: var(--amber); background: rgba(245,166,35,.08); }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.6);
  display: flex; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.modal {
  width: 100%; max-width: 640px; max-height: 88dvh; overflow-y: auto;
  background: var(--bg2); border: 1px solid var(--line2); border-bottom: none;
  border-radius: 22px 22px 0 0;
  padding: 18px 16px calc(22px + env(safe-area-inset-bottom));
  animation: sheet .22s ease-out;
}
@keyframes sheet { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.modal h2 { margin: 2px 0 14px; font-size: 17px; }
.field { margin-bottom: 11px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 700; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line2); background: var(--card); color: var(--text);
  font-size: 14px; outline: none; font-family: inherit;
}
.field textarea { resize: vertical; min-height: 64px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: rgba(245,166,35,.65); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.modal-actions { display: flex; gap: 9px; margin-top: 14px; }
.modal-actions .btn { flex: 1; text-align: center; justify-content: center; }

.dossier-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.dossier-head .avatar { width: 56px; height: 56px; font-size: 22px; border-radius: 18px; }
.dossier-name { font-size: 18px; font-weight: 800; }
.dossier-role { color: var(--muted); font-size: 13px; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); flex: 0 0 auto; }
.kv .v { text-align: end; word-break: break-word; }
.contact-links { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.contact-links a {
  text-decoration: none; color: var(--text);
  border: 1px solid var(--line2); background: var(--card2);
  padding: 8px 13px; border-radius: 12px; font-size: 13px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 6px;
}
.contact-links a.green { color: var(--green); border-color: rgba(52,211,153,.4); }
.contact-links a.blue { color: var(--blue); border-color: rgba(96,165,250,.4); }

/* ---------- toast ---------- */
#toast-root { position: fixed; bottom: calc(96px + env(safe-area-inset-bottom)); inset-inline: 0; display: flex; justify-content: center; pointer-events: none; z-index: 80; }
.toast {
  background: #23232b; border: 1px solid var(--line2); color: var(--text);
  border-radius: 999px; padding: 9px 18px; font-size: 13px; font-weight: 650;
  box-shadow: 0 8px 30px rgba(0,0,0,.5); animation: toastIn .18s ease-out;
}
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
