/* فونت وزیرمتن روی خود سرور (بدون وابستگی به سرویس خارجی؛ مجوز OFL در fonts/OFL.txt) */
@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/vazirmatn.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --paper: #f3f6f5;
  --sheet: #ffffff;
  --ink: #17233b;
  --muted: #5b6678;
  --rule: #d8dfe6;
  --navy: #1f3a68;
  --ok: #0f7b5f;      /* مهلت کافی */
  --soon: #b0620a;    /* کمتر از یک هفته */
  --urgent: #c0362c;  /* ۳ روز یا کمتر */
  --closed: #8a94a3;  /* گذشته */
  --focus: #2f6fd6;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Vazirmatn", Tahoma, sans-serif;
  font-size: 16px;
  line-height: 1.7;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- بالای صفحه (فشرده) ---------- */
.top { background: var(--navy); color: #fff; }
.top-inner { max-width: 980px; margin: 0 auto; padding: 8px 16px; }

.top-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; }
.brand { margin: 0; font-size: 1.05rem; font-weight: 800; white-space: nowrap; }

.search { display: flex; gap: 6px; flex: 1 1 300px; min-width: 0; }
.search input {
  flex: 1; min-width: 0;
  font: inherit; font-size: .95rem;
  padding: 5px 12px;
  border: 0; border-radius: 8px;
  color: var(--ink); background: #fff;
}
.search input::placeholder { color: #8b95a6; }
.search button {
  font: inherit; font-size: .92rem; font-weight: 700;
  padding: 0 16px;
  border: 0; border-radius: 8px;
  background: #f2c94c; color: #1d2433;
  cursor: pointer;
}
.search button:hover { background: #f5d46e; }

.filters {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 6px 12px; margin-top: 0;
}
.field { display: flex; align-items: center; gap: 6px; font-size: .8rem; color: #c9d5ea; }
.field select {
  font: inherit; font-size: .85rem; color: var(--ink);
  padding: 3px 8px; min-width: 140px;
  border: 0; border-radius: 6px; background: #fff;
}
.field select:disabled { background: #d9e0ea; color: #6d7789; }

.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  font: inherit; font-size: .8rem;
  padding: 2px 10px;
  border: 1px solid #7f95bd; border-radius: 999px;
  background: transparent; color: #fff;
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: #fff; color: var(--navy); border-color: #fff; font-weight: 700; }

.toggle { display: flex; align-items: center; gap: 6px; font-size: .8rem; color: #e4ebf6; cursor: pointer; }
.toggle input { width: 15px; height: 15px; accent-color: #f2c94c; }

/* ---------- نتایج ---------- */
.results { max-width: 980px; margin: 0 auto; padding: 18px 16px 48px; }
.summary { margin: 0 0 10px; color: var(--muted); font-size: .95rem; }

/* پیام سطح دسترسی بالای نتیجه‌ها */
.access-note {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 0 0 12px; padding: 10px 14px;
  border-radius: 10px; border: 1px solid #c9d6ea; background: #eef3fb;
  font-size: .92rem;
}
.access-note[hidden] { display: none; }
.access-note p { margin: 0; }
.access-note.no_balance { border-color: #efc7a6; background: #fdf3ea; }
.access-note.charged { border-color: #b9dccd; background: #edf7f2; }
.note-btn {
  font: inherit; font-weight: 700; font-size: .88rem;
  padding: 5px 14px; border: 0; border-radius: 8px;
  background: var(--navy); color: #fff; cursor: pointer; white-space: nowrap;
}

.list { list-style: none; margin: 0; padding: 0; background: var(--sheet); border: 1px solid var(--rule); border-radius: 12px; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }

.card {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 18px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid var(--rule);
}
.card:last-child { border-bottom: 0; }

/* مُهر «روز مانده» — شخصیت اصلی صفحه */
.stamp {
  --c: var(--ok);
  width: 88px; height: 88px; margin-top: 2px;
  border-radius: 50%;
  border: 3px solid var(--c);
  box-shadow: inset 0 0 0 4px #fff, inset 0 0 0 5px var(--c);
  color: var(--c);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transform: rotate(-8deg);
  line-height: 1.1;
  text-align: center;
}
.stamp-num { font-size: 1.9rem; font-weight: 900; }
.stamp-unit { font-size: .78rem; font-weight: 700; }
.stamp.soon { --c: var(--soon); }
.stamp.urgent { --c: var(--urgent); }
.stamp.closed { --c: var(--closed); }
.stamp.closed .stamp-num, .stamp.unknown .stamp-num { font-size: 1.05rem; }
.stamp.unknown { --c: var(--closed); }
.stamp.locked { --c: #b3bccb; }
.card.limited .title { margin-bottom: 2px; }
.card.limited .place { margin-bottom: 0; }

.title { margin: 0 0 4px; font-size: 1.08rem; font-weight: 700; line-height: 1.75; }
.org { margin: 0; color: var(--ink); font-size: .95rem; }
.place { margin: 0 0 10px; color: var(--muted); font-size: .92rem; }

.dates { display: flex; flex-wrap: wrap; gap: 6px 28px; margin: 0 0 10px; }
.dates div { display: flex; gap: 8px; align-items: baseline; }
.dates dt { color: var(--muted); font-size: .85rem; }
.dates dd { margin: 0; font-weight: 700; font-size: .95rem; }

.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; font-size: .86rem; }
.cat { color: var(--navy); background: #e8eef8; border-radius: 6px; padding: 2px 10px; }
.num, .details-btn {
  font: inherit; font-size: .86rem;
  background: none; border: 0; padding: 2px 0;
  color: var(--muted); cursor: pointer;
}
.num { direction: ltr; letter-spacing: .02em; }
.num:hover, .details-btn:hover { color: var(--ink); text-decoration: underline; }
.num.copied { color: var(--ok); }
.star-btn {
  font: inherit; font-size: .86rem; cursor: pointer;
  background: none; border: 1px solid var(--rule); border-radius: 999px;
  padding: 1px 12px; color: var(--muted);
}
.star-btn:hover { border-color: #e0b100; color: var(--ink); }
.star-btn.on { background: #fff6d6; border-color: #e0b100; color: #8a6400; font-weight: 700; }
.card.closed-saved { opacity: .7; }
.saved-head { margin: 0 0 10px; font-weight: 700; }

.details { margin-top: 12px; padding: 12px 14px; background: var(--paper); border-radius: 8px; font-size: .92rem; }
.desc { margin: 0 0 8px; white-space: pre-line; }
.extra { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 2px 14px; }
.extra dt { color: var(--muted); }
.extra dd { margin: 0; }

.more-wrap { text-align: center; margin-top: 16px; }
.more {
  font: inherit; font-weight: 700;
  padding: 10px 26px;
  border: 1px solid var(--navy); border-radius: 10px;
  background: #fff; color: var(--navy); cursor: pointer;
}
.more:hover { background: var(--navy); color: #fff; }

/* ---------- حساب کاربری در هدر ---------- */
.account { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 6px 8px; white-space: nowrap; font-size: .82rem; margin-inline-start: auto; }
.account-btn {
  font: inherit; font-weight: 700; color: #fff;
  background: none; border: 1px solid #a9bbdb; border-radius: 8px;
  padding: 2px 10px; cursor: pointer;
}
.account-btn:hover { background: rgba(255, 255, 255, .12); }
.account-user { color: #dbe5f4; direction: ltr; }
a.account-me { text-decoration: none; direction: rtl; }
.account-link { font: inherit; color: #c9d5ea; background: none; border: 0; cursor: pointer; padding: 0; }
.account-link:hover { color: #fff; text-decoration: underline; }

/* ---------- پنجره ورود ---------- */
.login-dialog {
  width: min(380px, calc(100vw - 32px));
  border: 0; border-radius: 14px; padding: 22px 22px 18px;
  color: var(--ink); background: #fff;
  box-shadow: 0 20px 60px rgba(15, 30, 60, .35);
}
.login-dialog::backdrop { background: rgba(15, 25, 45, .55); }
.login-head { display: flex; align-items: center; justify-content: space-between; }
.login-head h2 { margin: 0; font-size: 1.15rem; }
.login-close { font-size: 1.6rem; line-height: 1; background: none; border: 0; color: var(--muted); cursor: pointer; }
.login-note { margin: 6px 0 16px; color: var(--muted); font-size: .88rem; }

/* فرم ورود (مشترک با صفحه مدیر) */
.lg-step { display: flex; flex-direction: column; gap: 8px; }
.lg-step[hidden] { display: none; }
.lg-label { font-size: .88rem; color: var(--muted); }
.lg-input {
  font: inherit; font-size: 1.15rem; letter-spacing: .04em; text-align: center;
  padding: 10px 12px; border: 1px solid var(--rule); border-radius: 10px;
  width: 100%; min-width: 0;
}
.lg-input:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px rgba(47, 111, 214, .18); }
.lg-code-input { font-size: 1.5rem; letter-spacing: .3em; }
.lg-btn {
  font: inherit; font-weight: 700; font-size: 1rem;
  padding: 10px; margin-top: 4px;
  border: 0; border-radius: 10px; background: var(--navy); color: #fff; cursor: pointer;
}
.lg-btn:disabled { opacity: .6; cursor: wait; }
.lg-sent { margin: 0 0 4px; font-size: .92rem; }
.lg-links { display: flex; justify-content: space-between; margin-top: 4px; }
.lg-link { font: inherit; font-size: .85rem; color: var(--navy); background: none; border: 0; padding: 0; cursor: pointer; }
.lg-link:disabled { color: var(--muted); cursor: default; }
.lg-msg { min-height: 1.4em; margin: 12px 0 0; font-size: .9rem; color: var(--urgent); }
.lg-msg.ok { color: var(--ok); }

.filters-toggle { display: none; }

/* ---------- موبایل ---------- */
@media (max-width: 640px) {
  .top-row { flex-wrap: wrap; gap: 8px; }
  .brand { font-size: .98rem; }
  .search { flex-basis: 100%; order: 3; }
  .account { margin-inline-start: auto; }
  .filters-toggle {
    display: block; margin-top: 0;
    font: inherit; font-size: .92rem; color: #fff;
    background: none; border: 1px solid #7f95bd; border-radius: 8px;
    padding: 3px 12px; cursor: pointer;
  }
  .filters { display: none; }
  .filters.open { display: flex; flex-basis: 100%; }
  .dates { flex-direction: column; gap: 6px; }
  .dates div { flex-direction: column; gap: 0; }
  .dates dd { white-space: nowrap; }
  .field { flex-direction: column; align-items: stretch; flex: 1 1 140px; }
  .field select { width: 100%; padding: 5px 8px; }
  .card { grid-template-columns: 70px 1fr; gap: 12px; padding: 16px 14px; }
  .stamp { width: 68px; height: 68px; border-width: 2px; box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 4px var(--c); }
  .stamp-num { font-size: 1.4rem; }
  .stamp-unit { font-size: .6rem; }
  .title { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}


/* 🔨 مناقصه / مزایده */
.field[hidden] { display: none !important; }
.search-hint { margin: 5px 0 0; font-size: .78rem; color: #d7e1f2; line-height: 1.6; }
.search-hint b { color: #fff; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin-top: 6px; }
.modes { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.top .modes button {
  font: inherit; font-weight: 700; font-size: .86rem; cursor: pointer;
  padding: 3px 14px; border-radius: 10px;
  border: 2px solid #f2c94c; background: rgba(255,255,255,.08); color: #fff;
  box-shadow: 0 2px 0 rgba(0,0,0,.25); transition: background .15s, color .15s, transform .05s;
}
.top .modes button:hover { background: rgba(242,201,76,.22); }
.top .modes button:active { transform: translateY(1px); box-shadow: none; }
.top .modes button[aria-pressed="true"] { background: #f2c94c; color: #1d2433; border-color: #f2c94c; }
.top .modes button[aria-pressed="true"]::before { content: "✓ "; }
.modes .mode-count { font-weight: 400; font-size: .8rem; opacity: .85; }
.kind-tag {
  display: inline-block; margin: 0 0 4px; padding: 0 10px; border-radius: 999px;
  background: #fbefe2; color: #8a4b0c; font-size: .78rem; font-weight: 700;
}
.kind-tag.tender { background: #e6edf8; color: var(--navy); }
.card .price { font-weight: 700; color: var(--navy); }

/* 📢 تبلیغات — کادرها نسبت ثابت دارند (همان نسبتی که پیش‌نمایش داشبورد نشان می‌دهد) */
.ad-top { display: grid; grid-template-columns: repeat(var(--ad-per, 1), minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.ad { position: relative; display: block; border-radius: 12px; overflow: hidden; background: #fff;
      border: 1px solid var(--rule); text-decoration: none; color: var(--ink); }
.ad img { display: block; width: 100%; aspect-ratio: var(--ad-ratio, 5.7); object-fit: cover; }
.ad-title { display: grid; place-items: center; aspect-ratio: var(--ad-ratio, 5.7); padding: 10px 16px; font-weight: 700; text-align: center; }
.ad-label { position: absolute; top: 6px; inset-inline-start: 6px; background: rgba(0,0,0,.55); color: #fff;
            font-size: .7rem; padding: 1px 8px; border-radius: 999px; }
.ad-cta { position: absolute; bottom: 0; inset-inline: 0; padding: 6px 10px; text-align: center;
          background: linear-gradient(to top, rgba(0,0,0,.72), rgba(0,0,0,.3) 75%, transparent);
          color: #fff; font-weight: 700; font-size: .88rem; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
a.ad:hover { border-color: var(--navy); }
a.ad:hover .ad-cta { background: linear-gradient(to top, rgba(31,58,110,.92), rgba(31,58,110,.45) 75%, transparent); }
.list > .ad-slot { list-style: none; margin: 4px 0 10px; }
@media (max-width: 640px) { .ad-top { grid-template-columns: 1fr; } }   /* گوشی: زیر هم، با همان نسبت کادر */

/* گوشی: هدر فشرده (بعد از قانون‌های اصلی تا روی آن‌ها بنشیند) */
@media (max-width: 640px) {
  .modes { flex: 1 1 100%; flex-wrap: nowrap; }
  .top .modes button { flex: 1 1 0; padding: 3px 6px; font-size: .8rem; white-space: nowrap; }
  .account { gap: 6px; }
  .account-btn { padding: 2px 8px; }
}
