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

:root{
  --bg:#f5f0e6;
  --card:#ffffff;
  --text:#2c2416;
  --muted:#7a6a55;
  --primary:#c0392b;
  --success:#27ae60;
  --border:#e0d8c8;
  --shadow:0 3px 8px rgba(0,0,0,.1);
}

body.night{
  --bg:#1a1a1a;
  --card:#2a2a2a;
  --text:#f0f0f0;
  --muted:#aaa;
  --border:#3a3a3a;
  --shadow:0 3px 8px rgba(0,0,0,.5);
}

body{
  font-family:'Vazirmatn',Tahoma,sans-serif;
  background:var(--bg);
  color:var(--text);
  font-size:16px;
  line-height:1.7;
  padding-bottom:100px;
  transition:background .3s, color .3s;
  overflow-x:hidden;
}

[hidden]{display:none !important;}

header{
  background:var(--primary);
  color:#fff;
  text-align:center;
  padding:22px 16px;
  position:relative;
}
header h1{font-size:24px;margin-bottom:4px}
header p{font-size:14px;opacity:.9}

.theme-toggle{
  position:absolute;
  top:16px;
  left:16px;
  width:44px;
  height:44px;
  border-radius:50%;
  background:rgba(255,255,255,.2);
  border:none;
  color:#fff;
  font-size:20px;
  cursor:pointer;
  display:grid;
  place-items:center;
}

.tabs-bar{
  display:grid;
  background:var(--card);
  border-bottom:2px solid var(--border);
  position:sticky;
  top:0;
  z-index:30;
}
.tab-btn{
  padding:14px 8px;
  background:none;
  border:none;
  font-family:inherit;
  font-size:14px;
  font-weight:bold;
  color:var(--muted);
  cursor:pointer;
  position:relative;
}
.tab-btn.active{color:var(--primary)}
.tab-btn.active::after{
  content:"";
  position:absolute;
  bottom:-2px;
  left:10%;
  right:10%;
  height:3px;
  background:var(--primary);
  border-radius:4px 4px 0 0;
}

.swipe-container{
  position:relative;
  min-height:calc(100vh - 250px);
  touch-action:pan-y;
}
.page{padding:16px;}

.section-title{
  font-size:17px;
  color:var(--primary);
  margin:20px 0 12px;
  display:flex;
  align-items:center;
  gap:6px;
}

.bottom-nav{
  position:fixed;
  bottom:0;
  left:0;
  right:0;
  z-index:50;
  display:grid;
  background:var(--card);
  border-top:2px solid var(--border);
  box-shadow:0 -4px 14px rgba(0,0,0,.12);
  padding-bottom:env(safe-area-inset-bottom,0px);
}

.nav-btn{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:2px;
  padding:12px 8px;
  min-height:74px;
  background:none;
  border:none;
  font-family:inherit;
  cursor:pointer;
  color:var(--muted);
  position:relative;
}
.nav-btn.active{color:var(--primary)}
.nav-btn.active::before{
  content:"";
  position:absolute;
  top:0;
  left:20%;
  right:20%;
  height:3px;
  background:var(--primary);
  border-radius:0 0 4px 4px;
}

.nav-icon{font-size:24px;line-height:1}
.nav-label{font-size:12px;font-weight:bold}

.big-btn{
  width:100%;
  padding:20px;
  border:none;
  border-radius:16px;
  font-size:20px;
  font-weight:bold;
  font-family:inherit;
  color:#fff;
  cursor:pointer;
  box-shadow:0 4px 10px rgba(0,0,0,.15);
  transition:transform .1s;
  margin-top:10px;
}
.big-btn:active{transform:scale(.97)}
.big-btn.green{background:var(--success)}
.big-btn.red{background:var(--primary)}
.big-btn.gray{background:#7f8c8d}

.page h2{
  font-size:22px;
  color:var(--primary);
  margin-bottom:16px;
  text-align:center;
}

.search{
  width:100%;
  padding:16px;
  font-size:16px;
  border:2px solid var(--border);
  border-radius:12px;
  font-family:inherit;
  margin-bottom:14px;
  background:var(--card);
  color:var(--text);
}
.search:focus{outline:none;border-color:var(--primary)}

.filters{
  display:flex;
  gap:8px;
  margin-bottom:18px;
  flex-wrap:wrap;
}
.filter{
  padding:12px 16px;
  border:2px solid var(--border);
  background:var(--card);
  color:var(--text);
  border-radius:12px;
  font-size:14px;
  font-family:inherit;
  cursor:pointer;
  flex:1;
  min-width:70px;
}
.filter.active{
  background:var(--primary);
  color:#fff;
  border-color:var(--primary);
  font-weight:bold;
}

/* ============ گرید دسته‌بندی ============ */
.categories-grid{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:10px;
  margin-bottom:20px;
}
@media(min-width:600px){.categories-grid{grid-template-columns:repeat(4,1fr)}}
@media(min-width:900px){.categories-grid{grid-template-columns:repeat(6,1fr)}}

.cat-card{
  background:var(--card);
  border-radius:14px;
  padding:14px 6px;
  text-align:center;
  box-shadow:var(--shadow);
  cursor:pointer;
  transition:transform .15s, border-color .15s;
  border:2px solid transparent;
}
.cat-card:active{transform:scale(.95)}
.cat-card:hover{border-color:var(--primary)}
.cat-card .cat-icon{
  font-size:30px;
  display:block;
  margin-bottom:6px;
}
.cat-card .cat-name{
  font-size:12px;
  font-weight:bold;
  color:var(--text);
}

/* ============ کارت‌ها ============ */
.cards{
  display:grid;
  gap:14px;
  grid-template-columns:1fr;
}
@media(min-width:600px){.cards{grid-template-columns:1fr 1fr}}
@media(min-width:1000px){.cards{grid-template-columns:1fr 1fr 1fr}}

.card{
  background:var(--card);
  border-radius:16px;
  overflow:hidden;
  box-shadow:var(--shadow);
  cursor:pointer;
}
.card img{
  width:100%;
  height:200px;
  object-fit:cover;
  display:block;
}
.card .no-img{
  width:100%;
  height:200px;
  background:#ede7dc;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:50px;
}
body.night .card .no-img{background:#3a3a3a}
.card .info{padding:14px}
.card h3{font-size:16px;margin-bottom:6px;color:var(--text)}
.card .row{font-size:14px;color:var(--muted);margin-bottom:4px}
.card .price{
  font-size:16px;
  color:var(--primary);
  font-weight:bold;
  margin-top:8px;
}

/* ============ فرم ============ */
.field{display:block;margin-bottom:16px}
.field span{
  display:block;
  font-size:15px;
  font-weight:bold;
  margin-bottom:8px;
  color:var(--text);
}
.field input,
.field select,
.field textarea{
  width:100%;
  padding:16px;
  font-size:16px;
  border:2px solid var(--border);
  border-radius:12px;
  font-family:inherit;
  background:var(--card);
  color:var(--text);
}
.field input:focus,
.field select:focus,
.field textarea:focus{outline:none;border-color:var(--primary)}
.field textarea{resize:vertical;min-height:80px}

.preview{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-bottom:16px;
}
.preview img{
  width:80px;
  height:80px;
  object-fit:cover;
  border-radius:10px;
  border:2px solid var(--border);
}

/* ============ پنل کاربری ============ */
.profile-header{
  background:var(--card);
  border-radius:16px;
  padding:20px;
  margin-bottom:16px;
  text-align:center;
  box-shadow:var(--shadow);
}
.profile-header .avatar{
  width:80px;
  height:80px;
  border-radius:50%;
  background:var(--primary);
  color:#fff;
  display:grid;
  place-items:center;
  font-size:34px;
  font-weight:bold;
  margin:0 auto 12px;
}
.profile-header h3{font-size:20px;margin-bottom:6px}
.profile-header p{color:var(--muted);font-size:14px;direction:ltr}

.profile-stats{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:10px;
  margin-bottom:16px;
}
.profile-stat{
  background:var(--card);
  border-radius:14px;
  padding:14px 8px;
  text-align:center;
  box-shadow:var(--shadow);
}
.profile-stat .num{
  font-size:20px;
  font-weight:bold;
  color:var(--primary);
  display:block;
  margin-bottom:4px;
}
.profile-stat .lbl{font-size:12px;color:var(--muted)}

.my-listings-title{
  font-size:17px;
  font-weight:bold;
  margin:16px 0 12px;
  color:var(--text);
}

.my-listing{
  background:var(--card);
  border-radius:14px;
  padding:12px;
  margin-bottom:12px;
  box-shadow:var(--shadow);
  display:flex;
  gap:12px;
  align-items:flex-start;
}
.my-listing img,
.my-listing .no-img-sm{
  width:80px;
  height:80px;
  border-radius:10px;
  object-fit:cover;
  flex-shrink:0;
}
.my-listing .no-img-sm{
  background:#ede7dc;
  display:grid;
  place-items:center;
  font-size:32px;
}
body.night .my-listing .no-img-sm{background:#3a3a3a}
.my-listing .info{flex:1;min-width:0}
.my-listing h4{font-size:15px;margin-bottom:6px;color:var(--text)}
.my-listing .meta{font-size:13px;color:var(--muted);margin-bottom:4px}
.my-listing .status{
  display:inline-block;
  padding:3px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:bold;
  margin-top:4px;
}
.status.pending{background:#fff3cd;color:#856404}
.status.approved{background:#d4edda;color:#155724}
.status.rejected{background:#f8d7da;color:#721c24}

.my-listing .actions{
  display:flex;
  gap:6px;
  margin-top:8px;
  flex-wrap:wrap;
}
.mini-btn{
  padding:6px 12px;
  border-radius:8px;
  border:1px solid var(--border);
  background:var(--card);
  color:var(--text);
  font-size:13px;
  font-family:inherit;
  cursor:pointer;
}
.mini-btn.danger{
  background:#f8d7da;
  color:#721c24;
  border-color:#f5c6cb;
}

.login-prompt{
  text-align:center;
  padding:40px 20px;
  background:var(--card);
  border-radius:16px;
  box-shadow:var(--shadow);
}
.login-prompt .icon{font-size:56px;margin-bottom:12px}
.login-prompt h3{font-size:19px;margin-bottom:8px;color:var(--text)}
.login-prompt p{color:var(--muted);margin-bottom:20px;font-size:14px}

/* ============ مودال ============ */
.modal{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.7);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:16px;
  z-index:100;
}
.modal[hidden]{display:none !important;}

.modal-box{
  background:var(--card);
  color:var(--text);
  border-radius:18px;
  width:100%;
  max-width:600px;
  max-height:90vh;
  overflow-y:auto;
  padding:20px;
  position:relative;
}

.modal-close{
  position:absolute;
  top:12px;
  left:12px;
  width:42px;
  height:42px;
  border-radius:50%;
  background:var(--bg);
  color:var(--text);
  border:none;
  font-size:20px;
  cursor:pointer;
  z-index:10;
  display:grid;
  place-items:center;
}

.gallery{
  display:flex;
  gap:8px;
  overflow-x:auto;
  scroll-snap-type:x mandatory;
  margin-bottom:16px;
  padding-bottom:8px;
}
.gallery img{
  min-width:100%;
  height:260px;
  object-fit:cover;
  border-radius:14px;
  scroll-snap-align:center;
}

.modal-info h2{
  font-size:20px;
  color:var(--primary);
  margin-bottom:14px;
}
.modal-info .row{
  font-size:15px;
  padding:10px 0;
  border-bottom:1px solid var(--border);
}
.modal-info .row b{color:var(--muted)}

.call-btns{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
  margin-top:20px;
}
.call-btns a{
  display:block;
  text-align:center;
  padding:18px;
  border-radius:14px;
  color:#fff;
  text-decoration:none;
  font-size:18px;
  font-weight:bold;
}
.call-btns .call{background:var(--primary)}
.call-btns .wa{background:#25d366}

/* ============ احراز هویت ============ */
.auth-tabs{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
  margin-bottom:20px;
}
.auth-tab{
  padding:12px;
  border:none;
  border-radius:10px;
  background:var(--bg);
  color:var(--muted);
  font-family:inherit;
  font-size:15px;
  font-weight:bold;
  cursor:pointer;
}
.auth-tab.active{
  background:var(--primary);
  color:#fff;
}
.auth-form h2{
  font-size:19px;
  margin-bottom:16px;
  text-align:center;
  color:var(--text);
}

.empty{
  text-align:center;
  padding:50px 20px;
  color:var(--muted);
  font-size:16px;
}

/* ============ بنر نصب شناور ============ */
#installPwaWrapper{
  position:fixed;
  bottom:90px;
  left:16px;
  right:16px;
  z-index:60;
  animation:slideUp .4s ease;
  transition:transform .3s ease, opacity .3s ease;
}
#installPwaWrapper.closing{
  transform:translateY(120px);
  opacity:0;
}
.install-banner{
  position:relative;
  background:var(--card);
  border-radius:16px;
  padding:12px;
  box-shadow:0 8px 24px rgba(0,0,0,.25);
  border:2px solid var(--success);
}
.install-banner .big-btn{
  width:100%;
  margin:0;
}
.install-close{
  position:absolute;
  top:-10px;
  left:-10px;
  width:32px;
  height:32px;
  border-radius:50%;
  background:var(--primary);
  color:#fff;
  border:2px solid var(--card);
  font-size:16px;
  font-weight:bold;
  cursor:pointer;
  display:grid;
  place-items:center;
  z-index:10;
}
@keyframes slideUp{
  from{ transform:translateY(120px); opacity:0; }
  to{ transform:translateY(0); opacity:1; }
}
@media(min-width:768px){
  #installPwaWrapper{
    bottom:20px;
    left:auto;
    right:20px;
    width:300px;
  }
}