@font-face { font-family: 'IRANSans'; src: url('/fonts/iransans.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'IRANSans'; src: url('/fonts/iransans-medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'IRANSans'; src: url('/fonts/iransans-bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --brand: #0D47A1; --brand2: #1976D2;
  --grad: linear-gradient(180deg, #0D47A1, #1565C0, #1976D2);
  --bg: #F7F9FD; --surface: #FBFCFF; --low: #F2F4F9; --high: #E6E8EE; --lowest: #FFFFFF;
  --on: #191C20; --muted: #42474E; --outline: #C2C7CE;
  --green: #2E7D32; --amber: #F9A825; --red: #D84315; --purple: #8E24AA; --grey: #757575;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body { font-family: 'IRANSans', sans-serif; background: var(--bg); color: var(--on); font-size: 14px; line-height: 1.7; }
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; position: relative; }
button { font-family: inherit; cursor: pointer; border: none; }
input, textarea, select { font-family: inherit; font-size: 14px; }
a { color: var(--brand2); }

/* auth */
.auth { min-height: 100vh; background: var(--grad); display: flex; flex-direction: column; align-items: center; padding: 40px 24px; color: #fff; }
.logo { width: 84px; height: 84px; border-radius: 24px; background: rgba(255,255,255,.15); display: flex; align-items: center; justify-content: center; font-size: 44px; }
.auth h1 { font-size: 22px; margin: 16px 0 2px; }
.auth .sub { opacity: .85; font-size: 14px; }
.card-form { background: var(--surface); color: var(--on); border-radius: 24px; padding: 20px; width: 100%; margin-top: 24px; box-shadow: 0 8px 30px rgba(0,0,0,.2); }

/* fields */
.field { position: relative; margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 12px 14px; border: 1px solid var(--outline); border-radius: 14px; background: var(--low); outline: none; color: var(--on);
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--brand2); }
textarea { resize: vertical; min-height: 60px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--brand); color: #fff; border-radius: 999px; padding: 12px 20px; font-weight: 700; font-size: 15px; }
.btn:disabled { opacity: .5; }
.btn.full { width: 100%; }
.btn.ghost { background: transparent; color: var(--brand2); font-weight: 500; }
.btn.outline { background: transparent; color: var(--brand); border: 1px solid var(--outline); }
.btn.sm { padding: 8px 16px; font-size: 13px; font-weight: 500; }
.btn.red { background: var(--red); } .btn.green { background: var(--green); } .btn.grey { background: var(--grey); }

/* top bar */
.topbar { background: var(--grad); color: #fff; padding: 14px 14px; display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 10; }
.topbar .avatar { width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,.2); display:flex;align-items:center;justify-content:center; font-size: 20px; }
.topbar .who { flex: 1; min-width: 0; }
.topbar .who .name { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .role { display: inline-block; background: rgba(255,255,255,.2); border-radius: 8px; padding: 1px 8px; font-size: 11px; }
.topbar .ic { background: transparent; color: #fff; font-size: 20px; padding: 8px; position: relative; }
.badge { position: absolute; top: 2px; left: 2px; background: var(--red); color:#fff; border-radius: 10px; font-size: 10px; padding: 0 5px; }

/* content */
.content { padding-bottom: 76px; }
.section-title { font-weight: 700; font-size: 16px; color: var(--brand); margin: 16px 16px 8px; }
.hint { font-size: 11px; color: var(--muted); margin: 0 16px; }

/* cards */
.card { background: var(--lowest); border-radius: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.08); padding: 14px; margin: 8px 16px; }
.hero { background: var(--grad); color: #fff; border-radius: 20px; padding: 16px; margin: 12px 16px; box-shadow: 0 4px 14px rgba(13,71,161,.3); }
.hero .big { font-size: 30px; font-weight: 700; }
.bar { display: flex; height: 8px; border-radius: 5px; overflow: hidden; margin-top: 10px; background: rgba(255,255,255,.2); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; font-size: 11px; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 8px 16px; }
.stat { background: var(--lowest); border-radius: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.08); padding: 12px; display: flex; align-items: center; gap: 10px; }
.stat:active { background: var(--low); }
.stat .sic { width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.stat .num { font-size: 22px; font-weight: 700; }
.stat .lbl { font-size: 11px; color: var(--muted); }

.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.ellip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { display: inline-block; border-radius: 8px; padding: 2px 8px; font-size: 11px; font-weight: 500; }
.muted { color: var(--muted); } .small { font-size: 12px; } .xs { font-size: 11px; }

.list-item { background: var(--lowest); border-radius: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.06); padding: 14px; margin: 8px 16px; }
.list-item:active { background: var(--low); }

/* bottom nav */
.nav { position: fixed; bottom: 0; left: 0; right: 0; max-width: 560px; margin: 0 auto; background: var(--surface); display: flex; border-top: 1px solid var(--high); z-index: 20; }
.nav button { flex: 1; background: transparent; padding: 8px 0 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 10px; }
.nav button.on { color: var(--brand); }
.nav .ni { font-size: 22px; }

/* FAB */
.fab { position: fixed; bottom: 86px; right: calc(50% - 280px + 16px); background: var(--brand); color: #fff; border-radius: 16px; padding: 14px 18px; font-weight: 700; box-shadow: 0 6px 16px rgba(13,71,161,.4); display: flex; gap: 8px; align-items: center; z-index: 21; }
@media (max-width: 560px){ .fab{ right: 16px; } }

/* dialog */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.dialog { background: var(--surface); border-radius: 20px; width: 100%; max-width: 480px; max-height: 88vh; overflow: auto; padding: 20px; }
.dialog h3 { margin: 0 0 12px; font-size: 17px; }
.dialog .actions { display: flex; gap: 8px; justify-content: flex-start; margin-top: 14px; }
.dialog .actions .spacer { flex: 1; }

.fchip { display: inline-block; border: 1px solid var(--outline); border-radius: 999px; padding: 6px 12px; font-size: 12px; margin: 0 0 6px 6px; background: var(--surface); }
.fchip.on { background: rgba(13,71,161,.12); border-color: var(--brand); color: var(--brand); }

.timeline .ev { display: flex; gap: 8px; margin-bottom: 8px; }
.timeline .tdot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand2); margin-top: 7px; flex: none; }
.doc { display:flex; align-items:center; gap:8px; background: var(--high); border-radius: 10px; padding: 10px; margin: 6px 0; }
.sub-row { display: flex; align-items: center; gap: 6px; margin: 4px 0; }
.note { background: var(--low); border-radius: 10px; padding: 10px; margin: 6px 0; }

/* chat */
.chat-wrap { display: flex; flex-direction: column; height: 70vh; }
.chat-msgs { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 6px; padding: 4px; }
.bubble { max-width: 78%; border-radius: 14px; padding: 8px 12px; font-size: 13px; }
.bubble.me { background: rgba(13,71,161,.12); align-self: flex-start; }
.bubble.them { background: var(--high); align-self: flex-end; }
.chat-in { display: flex; gap: 6px; align-items: center; margin-top: 8px; }
.chat-in input { flex: 1; padding: 10px 14px; border: 1px solid var(--outline); border-radius: 999px; outline: none; }

/* AI */
.ai-shell { display: flex; flex-direction: column; height: 100vh; }
.ai-msgs { flex: 1; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.ai-b { max-width: 86%; border-radius: 16px; padding: 10px 14px; white-space: pre-wrap; font-size: 14px; }
.ai-b.me { background: var(--brand); color: #fff; align-self: flex-start; }
.ai-b.ai { background: var(--high); align-self: flex-end; }
.ai-in { display: flex; gap: 8px; padding: 8px; border-top: 1px solid var(--high); align-items: center; }
.ai-in input { flex: 1; padding: 12px 16px; border: 1px solid var(--outline); border-radius: 24px; outline: none; }

.spin { width: 28px; height: 28px; border: 3px solid rgba(13,71,161,.2); border-top-color: var(--brand); border-radius: 50%; animation: sp 1s linear infinite; margin: 40px auto; }
@keyframes sp { to { transform: rotate(360deg); } }
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 16px; color: var(--muted); text-align: center; }

.toast { position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%); background: #323232; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13px; z-index: 100; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90%; }
.toast.show { opacity: 1; }
.err { color: var(--red); font-size: 13px; text-align: center; }
.switch { display: inline-flex; align-items: center; gap: 8px; }
