/* ===========================
   Apt Charge – Clean UI + No-Jump Navigation
   Author: you ✌️
   =========================== */

/* -------------------------------------------------
   0) فونت سراسری - Sans Serif (فونت‌های سیستم - بدون نیاز به لود)
   ------------------------------------------------- */
html, body, body *, body *::before, body *::after {
  font-family: var(--font-iran-yekan) !important;
  font-variant-numeric: normal !important;
}

/* -------------------------------------------------
   0) ترنزیشن نرم بین صفحات (View Transitions API)
   وقتی روی لینک‌های ناوبری (هدر، منو و ...) کلیک می‌شود، به‌جای پرش
   خشک صفحه، یک محو نرم بین صفحهٔ قبل و بعد نمایش داده می‌شود.
   در مرورگرهایی که پشتیبانی نمی‌کنند، بدون خطا نادیده گرفته می‌شود.
   ------------------------------------------------- */
@view-transition {
  navigation: auto;
}

@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: .22s;
    animation-timing-function: ease-out;
  }
}

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }
}

/* -------------------------------------------------
   0) ضدّپرش سراسری (قطعی)
   ------------------------------------------------- */
html {
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}

/* روی داشبورد، باز و بسته شدن آکاردیون ارتفاع صفحه را عوض می‌کند.
   overflow-x:hidden باعث می‌شود scrollbar-gutter در کروم فضا رزرو نکند
   و با ظاهر شدن اسکرول، عرض کل صفحه جابه‌جا شود. */
html:has(.dashboard-page) {
  overflow-x: clip;
  overflow-y: scroll;
}

@supports not (scrollbar-gutter: stable) {
  html { overflow-y: scroll; }
}

/* وقتی محتوا عوض می‌شود، باکس اصلی ارتفاع پایدار دارد → اسکرول‌بار غیب/ظاهر نشود */
.shell { min-height: calc(100vh - 140px); }      /* اگر هدر/فوتر متفاوت است، این مقدار را تنظیم کن */
.wrap, .shell { overflow-x: hidden; max-width: 100%; }      /* جلوگیری از هُل به چپ/راست در RTL */
body { max-width: 100%; }

/* -------------------------------------------------
   1) ریست سبک
   ------------------------------------------------- */
* { 
  box-sizing: border-box;
  font-family: var(--font-iran-yekan) !important;
  font-variant-numeric: normal;
}
html, body { margin: 0; padding: 0; background: var(--bg); }
img { max-width: 100%; height: auto; display: block; }

/* -------------------------------------------------
   2) تم‌ها و متغیرها
   ------------------------------------------------- */
/* Light (پیش‌فرض) */
:root{
  --tone-sea:      #2b3741;
  --tone-blue:     hsl(218, 58%, 40%);
  --tone-deep:     #0F3057;
  --tone-lilac:    #e2f1f7;
  --tone-sky:      hsl(0, 0%, 96%);
  --tone-steel:    #1b272c;
  --tone-cream:    #F3F4EF;
  --tone-surface:  #FFFFFF;

  --bg:            var(--tone-cream);
  --card:          var(--tone-surface);
  --surface:       var(--tone-surface);
  --text:          var(--tone-deep);
  --muted:         var(--tone-steel);

  --primary:       var(--tone-blue);
  --primary-600:   var(--tone-deep);
  --primary-50:    #E4EFEC;

  --success:       var(--tone-sea);
  --danger:        var(--tone-blue);
  --warning:       var(--tone-steel);
  --tertiary:      var(--tone-sea);
  --tertiary-600:  var(--tone-deep);

  /* رنگ‌های معنایی واقعی — برای وضعیت‌هایی که باید واقعاً سبز/قرمز دیده شوند
     (--success/--danger بالا معنایی نیستند و در بیشتر جاها به همان آبی/خاکستری برند برمی‌گردند) */
  --good:          #1F7A5C;
  --good-tint:     #E7F5EF;
  --bad:           #C23B4B;
  --bad-tint:      #FBEAEC;
  --warn:          #B7791F;
  --warn-tint:     #FCF3E3;

  --border:        var(--tone-steel);
  --border-strong: var(--tone-blue);

  --shadow:        0 1px 3px color-mix(in srgb, var(--tone-deep) 12%, transparent);
  --shadow-hover:  0 8px 24px color-mix(in srgb, var(--tone-blue) 18%, transparent);

  --radius:        8px;

  --focus-ring:    0 0 0 3px color-mix(in srgb, var(--tone-blue) 22%, transparent);
}

/* Dark */
html.theme-dark{
  --bg:            var(--tone-deep);
  --card:          var(--tone-sea);
  --surface:       var(--tone-sea);
  --text:          var(--tone-sky);
  --muted:         var(--tone-steel);

  --primary:       var(--tone-blue);
  --primary-600:   var(--tone-steel);
  --primary-50:    var(--tone-deep);
  --tertiary:      var(--tone-lilac);
  --tertiary-600:  var(--tone-sky);

  --good:          #37B583;
  --good-tint:     rgba(55,181,131,.14);
  --bad:           #E0687A;
  --bad-tint:      rgba(224,104,122,.14);
  --warn:          #E0B15B;
  --warn-tint:     rgba(224,177,91,.14);

  --border:        var(--tone-steel);
  --border-strong: var(--tone-lilac);

  --shadow:        0 8px 30px color-mix(in srgb, var(--tone-deep) 50%, transparent);
  --shadow-hover:  0 16px 46px color-mix(in srgb, var(--tone-blue) 24%, transparent);
}

/* -------------------------------------------------
   3) تایپوگرافی و بدنه
   ------------------------------------------------- */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-iran-yekan) !important;
  font-variant-numeric: normal;
  line-height: 1.65;
  font-size: 15px;
  margin: 0;
  padding: 0;
}

a{
  color: var(--primary);
  text-decoration: none;
  transition: color .18s ease;
}
a:hover{ color: var(--primary-600); }

/* -------------------------------------------------
   4) لِی‌اوت
   ------------------------------------------------- */
.wrap{ max-width: 100%; margin: 0; padding: 16px; }

.shell { 
  display: flex; 
  flex-direction: column; 
  gap: 16px; 
}

/* -------------------------------------------------
   5) ناوبار قدیمی - حذف شده (استفاده از phx-header.css)
   ------------------------------------------------- */

/* -------------------------------------------------
   6) دکمه‌ها و بَچ‌ها
   ------------------------------------------------- */
.btn{
  background: linear-gradient(135deg,var(--primary),var(--primary-600));
  border: none; border-radius: 6px;
  padding: 10px 16px; color:#fff; cursor:pointer; font-weight: 600;
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
  transition: box-shadow .2s ease, transform .12s ease;
}
.btn:hover{ transform: translateY(-1px); box-shadow: 0 10px 28px rgba(0,0,0,.25); }
.btn:active{ transform: none; }

.btn[disabled],
.btn:disabled{
  opacity: .5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary{ background: linear-gradient(135deg,var(--success),var(--tertiary-600)); }
.btn-danger{ background: linear-gradient(135deg,var(--primary),var(--primary-600)); }
.btn-muted{
  background: var(--tone-sky); color: var(--text); border: 1px solid var(--border);
}

.badge{
  display:inline-block; padding:6px 10px; border-radius:6px;
  background: var(--primary-50); color: var(--text); border: 1px solid var(--border);
}

/* -------------------------------------------------
   7) کارت‌ها
   ------------------------------------------------- */
.card{
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); transition: box-shadow .25s ease, transform .2s ease;
}
.card:hover{ box-shadow: var(--shadow-hover); transform: translateY(-2px); }

/* -------------------------------------------------
   8) فرم‌ها
   ------------------------------------------------- */
input, select, textarea{
  width: 100%; padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px; background: var(--card); color: var(--text);
  transition: border-color .18s ease, box-shadow .18s ease;
}
input:focus, select:focus, textarea:focus{
  border-color: var(--primary); outline: none; box-shadow: var(--focus-ring);
}
label{ display:block; margin-bottom:6px; font-size: .92rem; color: var(--muted); }
small.muted{ color: var(--muted); }

/* -------------------------------------------------
   9) گرید ریسپانسیو
   ------------------------------------------------- */
.grid{ display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
@media (max-width: 992px){ .grid{ grid-template-columns: repeat(2,1fr); } }
@media (max-width: 600px){ .grid{ grid-template-columns: 1fr; } }

.g2{ grid-template-columns: repeat(2,1fr); }
.g3{ grid-template-columns: repeat(3,1fr); }

/* -------------------------------------------------
   10) جدول‌ها
   ------------------------------------------------- */
.table-wrap{
  overflow: auto; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
  -webkit-overflow-scrolling: touch;
}
.tbl{
  width: 100%; border-collapse: separate; border-spacing: 0; min-width: 720px;
}
.tbl th{
  background: color-mix(in srgb, var(--primary) 10%, var(--card)); color: var(--primary-600); font-weight: 700; padding: 13px 14px; text-align: right;
  position: sticky; top: 0; z-index: 1;
}
.tbl td{ padding: 13px 14px; border-bottom: 1px solid color-mix(in srgb, var(--text) 8%, transparent); }
.tbl tr:last-child td{ border-bottom: none; }
.tbl tr:hover td{ background: rgba(0,0,0,.04); }

/* -------------------------------------------------
   11) پیام‌ها
   ------------------------------------------------- */
.alert{
  border-radius: 6px; padding: 10px 12px; border:1px solid var(--border);
  background: var(--card);
}
.alert-success{ border-color: var(--border); background: var(--tone-sky); color:var(--success); }
.alert-danger{  border-color: var(--border-strong); background: var(--tone-lilac); color:var(--primary-600); }

/* -------------------------------------------------
   12) ابزارهای کمکی
   ------------------------------------------------- */
.mt-1{ margin-top: 6px; } .mt-2{ margin-top: 12px; } .mt-3{ margin-top: 18px; }
.mb-1{ margin-bottom: 6px; } .mb-2{ margin-bottom: 12px; } .mb-3{ margin-bottom: 18px; }
.flex{ display: flex; } .aic{ align-items: center; } .jcsb{ justify-content: space-between; }
.center{ text-align: center; }

/* -------------------------------------------------
   13) دسترس‌پذیری
   ------------------------------------------------- */
:focus-visible{ outline: 2px solid var(--primary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce){
  *{ animation: none !important; transition: none !important; }
}

/* -------------------------------------------------
   14) ریسپانسیو
   ------------------------------------------------- */

/* -------------------------------------------------
   Auth Experience
   ------------------------------------------------- */
.auth-shell{
  display: grid;
  grid-template-columns: minmax(0,1.1fr) minmax(0,420px);
  gap: 32px;
  align-items: stretch;
  margin: 40px 0 56px;
  width: 100%;
  max-width: 100%;
}
.auth-shell > :only-child{
  grid-column: 1 / -1;
}
.auth-hero{
  position: relative;
  padding: 36px 32px;
  border-radius: calc(var(--radius) + 2px);
  border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent);
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(255,255,255,.22) 0%, rgba(255,255,255,0) 60%),
    linear-gradient(135deg, color-mix(in srgb, var(--primary) 75%, transparent), color-mix(in srgb, var(--primary-600) 85%, transparent));
  color: #fff;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow: hidden;
  min-height: 100%;
}
.hero-badge{
  align-self: flex-start;
  background: rgba(255,255,255,.18);
  color: #fff;
  border-radius: 8px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .04em;
}
.auth-hero h1{
  margin: 0;
  font-size: 30px;
  line-height: 1.35;
}
.auth-hero p{
  margin: 0;
  font-size: 15px;
  color: rgba(255,255,255,.82);
  max-width: 520px;
}
.hero-highlights{
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 8px 0 0;
  padding: 0;
}
.hero-highlights li{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 8px;
  background: rgba(15,23,42,.28);
  color: rgba(255,255,255,.92);
  font-weight: 500;
  backdrop-filter: blur(6px);
}
.hero-highlights li::before{
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 8px;
  background: rgba(255,255,255,.85);
  flex-shrink: 0;
}
.hero-footnote{
  margin-top: auto;
  font-size: 13px;
  line-height: 1.8;
  color: rgba(255,255,255,.72);
  max-width: 520px;
}
.auth-card{
  padding: 32px 36px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.auth-card-header h2{
  margin: 0;
  font-size: 24px;
}
.auth-card-header p{
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}
.auth-badge{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-50);
  color: var(--primary-600);
  border-radius: 8px;
  padding: 4px 12px;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .05em;
}
.auth-form{
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth-form .form-field{
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.auth-form-grid{
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(240px,1fr));
  gap: 16px;
  align-items: start;
}
.auth-form-grid .form-field{
  height: 100%;
}
.auth-form label{
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
}
.auth-form input{
  border-radius: 6px;
}
.auth-form .form-captcha{
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.auth-form .captcha-box{
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.auth-form .captcha-question{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--primary-600);
  color: #111827;
  font-weight: 600;
  white-space: nowrap;
}
.auth-form .captcha-box input{
  flex: 1;
  min-width: 120px;
}
.auth-form .captcha-tip{
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}
.input-password{
  display: flex;
  align-items: center;
  gap: 10px;
}
.input-password input{
  flex: 1;
}
.input-password .auth-toggle{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,.72);
  color: var(--muted);
  cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.input-password .auth-toggle:hover,
.input-password .auth-toggle.is-active{
  background: var(--primary-600);
  border-color: var(--primary-600);
  color: #111827;
}
.input-password .auth-toggle:focus-visible{
  outline: none;
  box-shadow: var(--focus-ring);
}
.form-hint{
  font-size: 12px;
  color: var(--muted);
  margin-top: -4px;
}
.btn-full{
  width: 100%;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  text-align: center;
}
.auth-meta{
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-radius: 8px;
  border: 1px dashed color-mix(in srgb, var(--primary) 45%, transparent);
  background: color-mix(in srgb, var(--primary-50) 40%, white 60%);
  padding: 20px 22px;
}
.auth-meta strong{
  display: block;
  margin-bottom: 6px;
  color: var(--primary-600);
  font-size: 14px;
}
.auth-meta p{
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
}
.auth-alert{
  margin: 0;
}
@media (max-width: 1100px){
  .auth-shell{
    grid-template-columns: minmax(0,1fr);
    margin: 28px 0 48px;
  }
  .auth-card{
    padding: 28px 30px;
  }
  .auth-hero{
    order: 2;
    padding: 32px 30px;
  }
}
@media (max-width: 640px){
  .auth-shell{
    gap: 24px;
    margin: 24px 0 40px;
  }
  .auth-card{
    padding: 24px;
  }
  .hero-highlights li{
    font-size: 14px;
    padding: 10px 14px;
  }
  .input-password{
    flex-direction: column;
    align-items: stretch;
  }
  .input-password .auth-toggle{
    width: 100%;
  }
}

/* -------------------------------------------------
   Print Overrides
   ------------------------------------------------- */
@media print{
  .phx-header, .theme-toggle { display:none !important; }
  .wrap{ max-width: 100%; padding: 0; }
  .card, .table-wrap{ box-shadow: none; border-color: #ddd; }
}



/* ===== No-Shift RTL Scrollbar Compensation ===== */
/* پوشش داده شده در ابتدای فایل با scrollbar-gutter + fallback */

.theme-toggle {
  cursor: pointer;
  background: linear-gradient(135deg, #4f46e5, #3b82f6);
  border: none;
  border-radius: 50px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  transition: all 0.3s ease;
}

.theme-toggle:hover {
  background: linear-gradient(135deg, var(--primary), var(--primary-600));
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(0,0,0,0.25);
}

.theme-toggle:active {
  transform: scale(0.95);
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

/* وقتی theme-toggle همراه با کلاس btn استفاده می‌شود، از استایل دکمه‌های دیگر استفاده کند */
.btn.theme-toggle,
.btn.btn-secondary.theme-toggle {
  background: linear-gradient(135deg, var(--success), var(--tertiary-600)) !important;
  border-radius: 6px !important;
  padding: 10px 16px !important;
  box-shadow: 0 6px 20px rgba(0,0,0,.2) !important;
  transition: box-shadow .2s ease, transform .12s ease !important;
  font-size: inherit !important;
}

.btn.theme-toggle:hover,
.btn.btn-secondary.theme-toggle:hover {
  background: linear-gradient(135deg, var(--success), var(--tertiary-600)) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 10px 28px rgba(0,0,0,.25) !important;
}

.btn.theme-toggle:active,
.btn.btn-secondary.theme-toggle:active {
  transform: none !important;
  box-shadow: 0 6px 20px rgba(0,0,0,.2) !important;
}


/* ====== Anti-shift for calc form (RTL-safe) ====== */

/* 1) کارت پارامترها: هیچ تغییری موقع :focus / :active باعث ری‌فلو نشه */
.calc-form .card, .criteria-grid, .crit-col { min-width: 0; }
.criteria-grid { align-items: stretch; }

.crit-col { border: 1px solid var(--border); border-radius: 6px; }
.crit-col:focus-within { outline: 2px solid color-mix(in srgb, var(--primary), transparent 70%); outline-offset: 2px; }
.crit-col, .crit-col * { transition: background-color .15s ease, color .15s ease, box-shadow .15s ease; }
.crit-col.is-clickable { cursor: pointer; }
.crit-col.is-clickable input,
.crit-col.is-clickable .crit-active,
.crit-col.is-clickable .coef { cursor: auto; }
.crit-col.is-active { border-color: color-mix(in srgb, var(--primary) 60%, transparent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 25%, transparent); background-color: color-mix(in srgb, var(--primary) 6%, var(--surface) 94%); }
.crit-col.manager-mode.is-active { background-color: color-mix(in srgb, var(--primary) 10%, var(--surface) 90%); }
.crit-col .coef.disabled { opacity: .6; background-color: color-mix(in srgb, var(--surface) 92%, white 8%); }
.jalali-input.is-invalid {
  border-color: #e63946;
  box-shadow: 0 0 0 2px color-mix(in srgb, #e63946 25%, transparent);
}

/* ورودی‌ها: مرز همیشه یکسان؛ transform و تغییر وزن ممنوع */
.crit-col input, .crit-col label { font-weight: 500; }
.crit-col input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,0,0,.08); outline: 0; }
.crit-col input:active { transform: none !important; }

/* 2) نمایش/مخفی‌شدن خطا و کارت نتیجه بدون تکان عرضی صفحه */
#coef_error { min-height: 0; }
#result_card { will-change: contents; }

/* 3) اگر با ظاهر شدن نتیجه اسکرول‌بار ایجاد می‌شود، محتوای اصلی همیشه فضای کافی داشته باشد */
.shell { min-height: calc(100vh - 140px); } /* با layout خودت تنظیمش کن */

/* 4) جلوگیری از اسکرول افقی ناگهانی در این بخش */
.calc-form, .calc-form .card { overflow-x: hidden; }

/* Result card should span full width of the 2-column grid */
.calc-form #result_card { grid-column: 1 / -1; }

/* روی موبایل هم که تک‌ستونه است، مشکلی نیست؛ ولی برای اطمینان: */
@media (max-width: 992px){
  .calc-form #result_card { grid-column: auto; }
}


/* Unit edit overrides */
.unit-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 16px;
  margin-bottom: 16px;
}
.unit-details .detail-card {
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: 8px;
  padding: 14px 16px;
  line-height: 1.6;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.unit-details .detail-card strong {
  display: block;
  margin-bottom: 4px;
  color: var(--primary);
  font-weight: 600;
}
.unit-details .detail-card .detail-note {
  display: block;
  font-size: .85rem;
  color: var(--muted);
}
.unit-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 18px;
}
@media (max-width: 720px){
  .unit-form {
    grid-template-columns: 1fr;
  }
}
.unit-form .form-hint {
  grid-column: 1 / -1;
  font-size: .85rem;
  color: var(--muted);
  margin: 0;
}
.unit-form .full-span {
  grid-column: 1 / -1;
}
.unit-form .checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.unit-form .checkbox-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.unit-form .unit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}
.unit-form .unit-actions button {
  min-width: 140px;
}

/* ====== Auth Action Cards (Login Page) ====== */
.auth-action-card {
  background: linear-gradient(135deg, var(--card) 0%, color-mix(in srgb, var(--primary) 3%, var(--card)) 100%);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  display: flex;
  gap: 20px;
  align-items: flex-start;
  transition: all .3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
  margin: 16px 0;
}

.auth-action-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.auth-action-card-secondary {
  background: linear-gradient(135deg, var(--card) 0%, color-mix(in srgb, var(--success) 3%, var(--card)) 100%);
}

.auth-action-icon {
  font-size: 2.5rem;
  line-height: 1;
  flex-shrink: 0;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  border-radius: 8px;
  transition: transform .3s ease;
}

.auth-action-card:hover .auth-action-icon {
  transform: scale(1.1) rotate(5deg);
}

.auth-action-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-action-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}

.auth-action-desc {
  margin: 0;
  font-size: .9rem;
  color: var(--muted);
  line-height: 1.6;
}

.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-radius: 6px;
  font-weight: 600;
  font-size: .95rem;
  text-decoration: none;
  transition: all .25s cubic-bezier(0.4, 0, 0.2, 1);
  margin-top: 4px;
  position: relative;
  overflow: hidden;
}

.btn-action::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 100%;
  background: rgba(255,255,255,.15);
  transition: width .3s ease;
  z-index: 0;
}

.btn-action:hover::before {
  width: 100%;
}

.btn-action > span {
  position: relative;
  z-index: 1;
}

.btn-primary-action {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-600) 100%);
  color: white;
  border: 2px solid transparent;
}

.btn-primary-action:hover {
  box-shadow: var(--shadow-hover);
  transform: translateX(-4px);
  border-color: rgba(255,255,255,.3);
}

.btn-secondary-action {
  background: linear-gradient(135deg, var(--success) 0%, #15803d 100%);
  color: white;
  border: 2px solid transparent;
}

.btn-secondary-action:hover {
  box-shadow: 0 14px 40px rgba(22,163,74,.3);
  transform: translateX(-4px);
  border-color: rgba(255,255,255,.3);
}

.btn-tertiary-action {
  background: linear-gradient(135deg, var(--tertiary) 0%, var(--tertiary-600) 100%);
  color: white;
  border: 2px solid transparent;
}

.btn-tertiary-action:hover {
  box-shadow: 0 14px 40px color-mix(in srgb, var(--tertiary) 35%, transparent);
  transform: translateX(-4px);
  border-color: rgba(255,255,255,.3);
}

.auth-action-card-tertiary {
  background: linear-gradient(135deg, var(--card) 0%, color-mix(in srgb, var(--tertiary) 3%, var(--card)) 100%);
}

.btn-action-arrow {
  font-size: 1.2em;
  transition: transform .25s ease;
  display: inline-block;
}

.btn-action:hover .btn-action-arrow {
  transform: translateX(-6px);
}

.auth-divider {
  text-align: center;
  margin: 24px 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}

.auth-divider span {
  padding: 0 16px;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 600;
  background: var(--card);
  position: relative;
}

@media (max-width: 640px) {
  .auth-action-card {
    flex-direction: column;
    text-align: center;
    gap: 16px;
    padding: 20px;
  }
  
  .auth-action-icon {
    margin: 0 auto;
  }
  
.btn-action {
    width: 100%;
  }
}

/* -------------------------------------------------
   Dashboard KPI grid & panels (modern SaaS)
   ------------------------------------------------- */
.page-head{ margin-bottom: 24px; }
.page-title{ font-size: 22px; font-weight: 800; color: var(--primary-600); }
.page-sub{ font-size: 13.5px; color: var(--muted); margin-top: 4px; }

.dashboard-overview{
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
}

.kpi-grid{
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.kpi-card-wide{
  grid-column: auto;
}

@media (max-width: 1100px){
  .kpi-grid{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .kpi-card-wide{
    grid-column: span 1;
  }
}

@media (max-width: 720px){
  .kpi-grid{
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  
  .kpi-card{
    padding: 10px 6px;
    gap: 6px;
  }
  
  .kpi-header{
    gap: 0;
    justify-content: center;
  }
  
  .kpi-icon{
    display: none;
  }
  
  .kpi-title{
    font-size: 11px;
    text-align: center;
    line-height: 1.3;
    font-weight: 600;
  }
  
  .kpi-value{
    font-size: 20px;
    text-align: center;
    line-height: 1.2;
  }
  
  .kpi-meta{
    font-size: 10px;
    display: none;
  }
  
  .kpi-card-wide{
    grid-column: span 3;
  }
}

@media (max-width: 480px){
  .kpi-grid{
    gap: 6px;
  }
  
  .kpi-card{
    padding: 8px 4px;
    gap: 4px;
    min-width: 0;
  }
  
  .kpi-header{
    justify-content: center;
    gap: 0;
  }
  
  .kpi-icon{
    display: none;
  }
  
  .kpi-title{
    font-size: 10px;
    text-align: center;
    line-height: 1.3;
    font-weight: 600;
  }
  
  .kpi-value{
    font-size: 18px;
    text-align: center;
    line-height: 1.2;
  }
}

@media (max-width: 360px){
  .kpi-grid{
    gap: 4px;
  }
  
  .kpi-card{
    padding: 6px 3px;
    gap: 3px;
  }
  
  .kpi-header{
    justify-content: center;
    gap: 0;
  }
  
  .kpi-icon{
    display: none;
  }
  
  .kpi-title{
    font-size: 9px;
    text-align: center;
    line-height: 1.3;
    font-weight: 600;
  }
  
  .kpi-value{
    font-size: 16px;
    text-align: center;
    line-height: 1.2;
  }
}

.kpi-card{
  --kpi-accent: var(--primary-600);
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
  border-radius: 14px;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--text) 4%, transparent), 0 10px 24px -14px color-mix(in srgb, var(--text) 24%, transparent);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: box-shadow .18s ease, transform .18s ease, border-color .18s ease;
}

/* is-teal = وضعیت خوب/خنثی، is-red = وضعیت بد/فوری — قبلاً هر دو عملاً رنگ برند بودند، اینجا به سبز/قرمز واقعی اصلاح شده */
.kpi-card.is-teal{ --kpi-accent: var(--good); }
.kpi-card.is-navy{ --kpi-accent: var(--primary-600); }
.kpi-card.is-red{ --kpi-accent: var(--bad); }

.kpi-card:hover{
  box-shadow: 0 8px 20px -10px color-mix(in srgb, var(--text) 30%, transparent);
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--primary) 30%, transparent);
}

.kpi-header{
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 700;
}

.kpi-icon{
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--kpi-accent) 12%, var(--card));
  display: grid;
  place-items: center;
  color: var(--kpi-accent);
}

.kpi-icon svg{
  width: 17px;
  height: 17px;
}

.kpi-title{
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.kpi-value{
  font-size: 28px;
  font-weight: 800;
  color: var(--kpi-accent);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.kpi-meta{
  font-size: 12px;
  color: color-mix(in srgb, var(--muted) 80%, var(--bg) 20%);
  line-height: 1.6;
}

.kpi-progress{
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-progress-track{
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.kpi-progress-fill{
  height: 100%;
  background: linear-gradient(90deg, var(--good), color-mix(in srgb, var(--good) 70%, black 15%));
  border-radius: 999px;
  transition: width .25s ease;
}

.kpi-progress-label{
  font-size: 12px;
  color: #4b5563;
}

.dashboard-panel{
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
  border-radius: 14px;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--text) 4%, transparent), 0 10px 24px -14px color-mix(in srgb, var(--text) 24%, transparent);
  padding: 18px 20px;
}

.dashboard-panel .panel-heading{
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.dashboard-panel .panel-icon{
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--primary-50);
  color: var(--primary-600);
  display: grid;
  place-items: center;
  font-weight: 700;
}

.dashboard-panel .panel-title{
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--primary-600);
}

.dashboard-panel .panel-subtitle{
  margin: 0;
  font-size: 13px;
  color: #6b7280;
}

/* ---- کارت‌های دعوت‌نامه/در انتظار ---- */
.invite-card{ border-radius: 18px; padding: 20px 22px; margin-bottom: 16px; border: 1.5px solid; display: flex; flex-direction: column; gap: 14px; }
.invite-card.is-info{ background: color-mix(in srgb, var(--primary) 8%, var(--card)); border-color: color-mix(in srgb, var(--primary) 22%, transparent); }
.invite-card.is-warn{ background: var(--warn-tint); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.invite-card.is-success{ background: var(--good-tint); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.invite-head{ display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.invite-title{ font-size: 15px; font-weight: 800; color: var(--primary-600); margin: 0; }
.invite-desc{ font-size: 12.5px; color: var(--muted); margin: 4px 0 0; }
.invite-rows{ display: grid; gap: 10px; }
.invite-row{ display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--card); border: 1px solid color-mix(in srgb, var(--text) 10%, transparent); border-radius: 10px; padding: 12px 14px; }
.invite-row-title{ font-weight: 700; font-size: 13.5px; color: var(--primary-600); }
.invite-row-meta{ font-size: 12px; color: var(--muted); margin-top: 3px; }
.invite-row-date{ color: var(--muted); font-size: 12px; min-width: 140px; text-align: left; }
.invite-actions{ display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.count-pill{ font-size: 11.5px; font-weight: 800; padding: 6px 12px; border-radius: 999px; background: var(--card); color: var(--primary); border: 1px solid color-mix(in srgb, var(--text) 10%, transparent); flex-shrink: 0; }
.mini-btn{ padding: 9px 14px; border-radius: 10px; font-size: 12.5px; font-weight: 700; border: 1.5px solid transparent; cursor: pointer; font-family: inherit; }
.mini-btn-primary{ background: linear-gradient(135deg, var(--primary), var(--primary-600)); color: #fff; }
.mini-btn-ghost{ background: var(--card); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }

/* ---- آمار مدیریتی (پنل ثانویه، اطلاعاتی/خنثی - بدون رنگ‌بندی معنایی دلبخواهی) ---- */
.mstat-grid{ display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.mstat-card{ display: flex; flex-direction: column; align-items: center; text-align: center; gap: 9px; padding: 18px 12px; background: color-mix(in srgb, var(--primary) 6%, var(--card)); border: 1px solid color-mix(in srgb, var(--primary) 14%, transparent); border-radius: 12px; transition: transform .15s ease, border-color .15s ease; }
.mstat-card:hover{ transform: translateY(-2px); border-color: color-mix(in srgb, var(--primary) 30%, transparent); }
.mstat-icon{ width: 34px; height: 34px; border-radius: 10px; background: color-mix(in srgb, var(--primary) 14%, var(--card)); color: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.mstat-label{ font-size: 11.5px; color: var(--muted); font-weight: 600; line-height: 1.4; }
.mstat-value{ font-size: 23px; font-weight: 800; color: var(--primary-600); font-variant-numeric: tabular-nums; line-height: 1.2; }
.mstat-value.is-text{ font-size: 15px; }

/* ============================================
   تابلو اعلانات ساختمان (Building Bulletin Board)
   ============================================ */

.bb-section {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  padding: 24px;
  margin-top: 0;
  margin-bottom: 0;
}

.bb-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.bb-header-title h3 {
  margin: 0 0 4px 0;
  font-size: 20px;
  font-weight: 800;
  color: #1e293b;
}

.bb-building-name {
  font-size: 14px;
  color: #64748b;
  font-weight: 600;
}

.bb-btn-create {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
}

.bb-filters-wrapper {
  margin-bottom: 20px;
}

.bb-search-box {
  position: relative;
  margin-bottom: 12px;
}

.bb-search-input {
  width: 100%;
  padding: 10px 40px 10px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-size: 14px;
  transition: all 0.2s ease;
  background: #ffffff;
  direction: rtl;
}

.bb-search-input:focus {
  outline: none;
  border-color: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 18%, transparent);
}

.bb-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.bb-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
}

.bb-filter-pill {
  padding: 8px 16px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  position: relative;
}

.bb-filter-pill:hover {
  background: var(--primary-50);
  border-color: var(--border);
  transform: translateY(-1px);
}

.bb-filter-pill.active {
  background: var(--success);
  color: var(--tone-sky);
  border-color: var(--success);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--success) 28%, transparent);
}

.bb-content-wrapper {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
}

.bb-announcements {
  min-width: 0;
}

.bb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.bb-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px;
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  cursor: pointer;
}

.bb-card:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  transform: translateY(-4px);
  border-color: #cbd5e1;
}

.bb-card:active {
  transform: translateY(-2px);
}

.bb-pinned-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: #fef3c7;
  color: #92400e;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}

.bb-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.bb-type-icon {
  font-size: 18px;
}

.bb-type-label {
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
}

.bb-priority-badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid;
}

.bb-card-body {
  margin-bottom: 12px;
}

.bb-card-title {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.4;
}

.bb-card-text {
  margin: 0;
  font-size: 13px;
  color: #475569;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.bb-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
  gap: 12px;
  flex-wrap: wrap;
}

.bb-card-footer-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.bb-card-footer-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.bb-card-date {
  font-size: 12px;
  color: #94a3b8;
}

.bb-card-creator {
  font-size: 11px;
  color: #cbd5e1;
}

.bb-btn-view,
.bb-btn-edit,
.bb-btn-archive {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
}

.bb-btn-view:hover {
  background: #eff6ff;
  color: #2563eb;
}

.bb-btn-edit:hover {
  background: #fef3c7;
  color: #d97706;
}

.bb-btn-archive:hover {
  background: #fef2f2;
  color: #dc2626;
}

.bb-empty-state {
  text-align: center;
  padding: 48px 24px;
  color: #94a3b8;
}

.bb-empty-state svg {
  margin: 0 auto 16px;
  color: #cbd5e1;
}

.bb-empty-state p {
  margin: 0 0 16px;
  font-size: 14px;
}

.bb-timeline {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 20px;
  height: fit-content;
  position: sticky;
  top: 20px;
}

.bb-timeline-title {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
}

.bb-timeline-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bb-timeline-item {
  display: flex;
  gap: 12px;
  position: relative;
  padding-right: 8px;
}

.bb-timeline-item:not(:last-child)::after {
  content: '';
  position: absolute;
  right: 5px;
  top: 20px;
  bottom: -16px;
  width: 2px;
  background: #e5e7eb;
}

.bb-timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  border: 2px solid var(--tone-sky);
  flex-shrink: 0;
  margin-top: 4px;
  position: relative;
  z-index: 1;
}

.bb-timeline-content {
  flex: 1;
  min-width: 0;
}

.bb-timeline-text {
  font-size: 13px;
  color: #1e293b;
  line-height: 1.5;
  margin-bottom: 4px;
}

.bb-timeline-time {
  font-size: 11px;
  color: #94a3b8;
}

.bb-timeline-empty {
  text-align: center;
  padding: 24px;
  color: #94a3b8;
  font-size: 13px;
}

/* مودال */
.bb-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.bb-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease-out;
}

.bb-modal-content {
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.bb-modal-content {
  position: relative;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  z-index: 1;
}

.bb-modal-large {
  max-width: 800px;
}

.bb-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #e5e7eb;
}

.bb-modal-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  color: #1e293b;
}

.bb-modal-close {
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.bb-modal-close:hover {
  background: #f1f5f9;
  color: #1e293b;
}

.bb-form-group {
  margin-bottom: 16px;
}

.bb-form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
}

.bb-form-group .required {
  color: var(--primary);
}

.bb-form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.2s ease;
  font-family: inherit;
}

.bb-form-control:focus {
  outline: none;
  border-color: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 18%, transparent);
}

.bb-form-help {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: #64748b;
}

.bb-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.bb-form-group input[type="checkbox"] {
  margin-left: 8px;
}

.bb-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 20px 24px;
  border-top: 1px solid #e5e7eb;
}

/* استایل‌های مشاهده جزئیات اعلان */
.bb-view-content {
  padding: 24px;
}

.bb-loading {
  text-align: center;
  padding: 40px;
  color: #94a3b8;
  font-size: 14px;
}

.bb-error {
  text-align: center;
  padding: 40px;
  color: #dc2626;
  font-size: 14px;
}

.bb-view-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e5e7eb;
}

.bb-view-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.bb-view-building {
  font-size: 13px;
  color: #64748b;
  margin-top: 8px;
}

.bb-view-body {
  margin-bottom: 24px;
}

.bb-view-body h2 {
  margin: 0 0 16px 0;
  font-size: 20px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.4;
}

.bb-view-text {
  font-size: 15px;
  color: #475569;
  line-height: 1.8;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.bb-view-footer {
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: #64748b;
}

.bb-view-footer div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bb-view-footer strong {
  color: #1e293b;
  min-width: 100px;
}

/* ریسپانسیو */
@media (max-width: 1024px) {
  .bb-content-wrapper {
    grid-template-columns: 1fr;
  }
  
  .bb-timeline {
    position: static;
  }
}

@media (max-width: 768px) {
  .bb-section {
    padding: 16px;
  }
  
  .bb-grid {
    grid-template-columns: 1fr;
  }
  
  .bb-filters {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .bb-form-row {
    grid-template-columns: 1fr;
  }
  
  .bb-modal-content {
    max-width: 100%;
    margin: 16px;
  }
}

@media (max-width: 500px) {
  .bb-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .bb-btn-create {
    width: 100%;
    justify-content: center;
  }
}

/* ========================================
   Accordion System (Phoenix) - Enhanced UI/UX
   ======================================== */
.phx-accordion {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--text) 4%, transparent), 0 10px 24px -14px color-mix(in srgb, var(--text) 24%, transparent);
}

.phx-acc-item {
  background: var(--card);
  border: none;
  border-radius: 0;
  overflow: hidden;
  transition: background-color 0.15s ease;
  box-shadow: none;
  position: relative;
  margin-bottom: 0;
}

.phx-acc-item + .phx-acc-item {
  border-top: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
}

.phx-acc-item.is-active {
  border-color: var(--primary);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--primary) 16%, transparent), 0 4px 8px color-mix(in srgb, var(--primary) 10%, transparent);
}

.phx-acc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  cursor: pointer;
  user-select: none;
  background: var(--card);
  border: none;
  width: 100%;
  text-align: right;
  transition: background-color 0.15s ease;
  outline: none;
  position: relative;
  z-index: 2;
}

.phx-acc-header:hover {
  background: color-mix(in srgb, var(--primary) 8%, var(--card));
}

.phx-acc-header:focus-visible {
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.phx-acc-header.is-open {
  border-bottom: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
  background: color-mix(in srgb, var(--primary) 8%, var(--card));
}

.phx-acc-header-left {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.phx-acc-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  margin: 0;
  line-height: 1.4;
  transition: color 0.15s ease;
}

.phx-acc-header.is-open .phx-acc-title {
  color: var(--primary);
}

.phx-acc-subtitle {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
  font-weight: 500;
}

.phx-acc-header-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.phx-acc-badge {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 800;
  white-space: nowrap;
  color: #ffffff;
}

.phx-acc-badge.badge--danger,
.phx-acc-badge.badge-danger {
  /* قبلاً به‌اشتباه آبی برند بود؛ برای وضعیت‌های فوری/معوق باید واقعاً قرمز باشد */
  background: var(--bad);
}

.phx-acc-badge.badge--warning,
.phx-acc-badge.badge-warning {
  background: var(--warn);
}

.phx-acc-badge.badge--success,
.phx-acc-badge.badge-success {
  background: var(--good);
}

.phx-acc-badge.badge {
  background: var(--primary);
}

.phx-acc-chevron {
  color: var(--muted);
  transition: transform 0.52s cubic-bezier(0.22, 1, 0.36, 1), color 0.2s ease;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.phx-acc-header.is-open .phx-acc-chevron {
  transform: rotate(180deg);
  color: var(--primary);
}

.phx-acc-body {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.52s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.42s cubic-bezier(0.22, 1, 0.36, 1);
  padding: 0;
}

/* برای اکاردیون‌های صفحه هاب ساختمان (building_hub)، ارتفاع بدنه را در حالت باز
   آزاد می‌کنیم تا فرم‌ها و جداول بلند داخل هر بخش (اسکلت ساختمان، تنظیمات جریمه و ...)
   کامل نمایش داده شوند. */
.phx-acc-item[data-group="building_hub"] > .phx-acc-body.is-open,
.phx-acc-item[data-group="building_hub_add_unit"] > .phx-acc-body.is-open {
  max-height: none !important;
}

/* ویرایش واحد: بعد از اتمام انیمیشن، JS ارتفاع را آزاد می‌کند (max-height:none)
   تا محتوا بریده نشود؛ اینجا !important نمی‌گذاریم تا انیمیشن نرم کار کند. */

@media (prefers-reduced-motion: reduce) {
  .phx-acc-body,
  .phx-acc-chevron,
  .phx-acc-item,
  .phx-acc-header,
  .phx-acc-badge {
    transition: none;
  }
  
  .phx-acc-item:hover {
    transform: none;
  }
  
  .phx-acc-header:active {
    transform: none;
  }
}

.phx-acc-body.is-open {
  max-height: 10000px;
  opacity: 1;
  padding-top: 0;
}

.phx-acc-inner {
  padding: 10px 18px;
  animation: fadeInUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .phx-acc-inner {
    animation: none;
  }
}

/* برای جداول داخل accordion */
.phx-acc-inner .table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.phx-acc-inner .tbl {
  width: 100%;
  min-width: 600px;
}

/* برای چارت‌ها داخل accordion */
.phx-acc-inner canvas {
  max-width: 100%;
  height: auto;
}

/* Dark theme support */
html.theme-dark .phx-acc-item {
  background: var(--card);
  border-color: var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

html.theme-dark .phx-acc-item:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  border-color: var(--border-strong);
}

html.theme-dark .phx-acc-item.is-active {
  box-shadow: 0 12px 32px rgba(192, 132, 252, 0.2), 0 4px 12px rgba(192, 132, 252, 0.15);
}

html.theme-dark .phx-acc-header:hover {
  background: linear-gradient(to left, rgba(192, 132, 252, 0.1) 0%, transparent 100%);
}

html.theme-dark .phx-acc-header.is-open {
  background: linear-gradient(to left, rgba(192, 132, 252, 0.08) 0%, transparent 100%);
  border-bottom-color: var(--border);
}

html.theme-dark .phx-acc-title {
  color: var(--text);
}

html.theme-dark .phx-acc-header.is-open .phx-acc-title {
  color: var(--primary);
}

html.theme-dark .phx-acc-subtitle {
  color: var(--muted);
}

html.theme-dark .phx-acc-header:hover .phx-acc-chevron {
  background: rgba(192, 132, 252, 0.15);
}

html.theme-dark .phx-acc-header.is-open .phx-acc-chevron {
  background: rgba(192, 132, 252, 0.2);
}

html.theme-dark .phx-acc-item::before {
  background: linear-gradient(180deg, var(--primary), var(--primary-600));
}

/* Mobile responsive */
@media (max-width: 768px) {
  .phx-accordion {
    gap: 0;
  }
  
  .phx-acc-item {
    border-radius: 0;
  }
  
  .phx-acc-item:first-child {
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
  }
  
  .phx-acc-item:last-child {
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
  }
  
  .phx-acc-header {
    padding: 12px 16px;
    min-height: 52px;
  }
  
  .phx-acc-title {
    font-size: 16px;
  }
  
  .phx-acc-subtitle {
    font-size: 12px;
  }
  
  .phx-acc-inner {
    padding: 14px 16px;
  }
  
  .phx-acc-header-right {
    margin-right: 12px;
    gap: 12px;
  }
  
  .phx-acc-badge {
    padding: 5px 12px;
    font-size: 11px;
  }
  
  .phx-acc-chevron {
    width: 22px;
    height: 22px;
  }
}

@media (max-width: 500px) {
  .phx-acc-header {
    padding: 12px 14px;
    min-height: auto;
    flex-wrap: nowrap;
    gap: 8px;
    align-items: center;
  }
  
  .phx-acc-header-left {
    flex: 1;
    min-width: 0;
    width: auto;
    order: 0;
  }
  
  .phx-acc-header-right {
    width: auto;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    margin-right: 0;
    order: 0;
    margin-top: 0;
    flex-shrink: 0;
  }

  .phx-acc-badge {
    min-width: 22px;
    height: 22px;
    padding: 0 5px;
    font-size: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
  }

  .phx-acc-chevron {
    width: 16px;
    height: 16px;
  }
  
  .phx-acc-inner {
    padding: 12px 14px;
  }
  
  .phx-acc-title {
    font-size: 13px;
  }
}

/* -------------------------------------------------
   فوتر سراسری سایت
   ------------------------------------------------- */
.app-site-footer {
  border-top: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
  padding: 20px 16px 24px;
  text-align: center;
  background: var(--bg);
}

.app-site-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
}

.app-site-footer-copy {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.6;
}

.app-site-footer-copy a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.app-site-footer-copy a:hover {
  text-decoration: underline;
}

/* موقت — بعداً قابل حذف */
.app-site-footer-version {
  display: inline-block;
  margin-inline-start: 8px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  opacity: 0.55;
  font-variant-numeric: tabular-nums;
}

/* پاپ‌آپ راهنمای اولیه مدیر */
.mgr-welcome {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: mgrWelcomeIn .28s ease;
}
.mgr-welcome.is-closing {
  animation: mgrWelcomeOut .22s ease forwards;
}
.mgr-welcome__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}
.mgr-welcome__panel {
  position: relative;
  width: min(420px, 100%);
  background: var(--bg, #fff);
  color: var(--text, #0f172a);
  border-radius: 18px;
  padding: 28px 24px 22px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.22);
  text-align: center;
}
.mgr-welcome__icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary, #2563eb);
  background: color-mix(in srgb, var(--primary, #2563eb) 12%, transparent);
}
.mgr-welcome__title {
  margin: 0 0 10px;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.mgr-welcome__text {
  margin: 0 0 20px;
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--muted, #64748b);
}
.mgr-welcome__btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  font: inherit;
  font-weight: 700;
  color: #fff;
  background: var(--primary, #2563eb);
}
.mgr-welcome__btn:hover {
  filter: brightness(1.05);
}
@keyframes mgrWelcomeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes mgrWelcomeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* انتخاب‌گر ساختمان (pill مشترک) */
.bld-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  min-height: 42px;
  background: #FFFFFF;
  border: 1px solid #D3D1C4;
  border-radius: 10px;
  padding: 10px 16px;
  color: #45524A;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.bld-pill:hover { background: #F5F4EE; }
.bld-pill svg { width: 16px; height: 16px; flex-shrink: 0; }
.bld-pill--active {
  background: #E4EFEC;
  border-color: #0F5C4F;
  color: #0F5C4F;
}
