/* ==========================================================================
   پنل مدیریت NotifyHub — بدون وابستگی بیرونی
   هیچ CDN، فونت آنلاین یا کتابخانه‌ای بارگذاری نمی‌شود: سرور ممکن است
   دسترسی خروجی محدود داشته باشد و پنل باید همیشه بالا بیاید.
   رنگ‌ها از cfg.Brand خوانده و روی متغیرها ست می‌شوند ⇒ تغییر برند = داده.
   ========================================================================== */
:root {
    --primary: #0f766e;
    --accent: #f59e0b;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --danger: #dc2626;
    --ok: #16a34a;
    --warn: #d97706;
    --radius: 12px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    /* Minimal Swiss از typography.csv؛ بدون وب‌فونت — فونت‌های سیستمی
       که فارسی را درست رندر می‌کنند، به ترتیب کیفیت */
    font-family: "Segoe UI", "Vazirmatn", "IRANSans", Tahoma, system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    direction: rtl;
}

/* ==========================================================================
   صفحه ورود — بازطراحی بر پایه داده‌های skill «ui-ux-pro-max»

     پالت      : colors.csv #42 «Banking/Traditional Finance»
                 سرمه‌ای اعتماد (#0F172A) + طلایی ممتاز (#A16207)
     تایپوگرافی: typography.csv #5 «Minimal Swiss» — برای پنل ادمین سازمانی
     سبک       : styles.csv #1 «Minimalism & Swiss Style»

   ⚠️ چرا Glassmorphism نه: متن روی پس‌زمینه شفاف/متغیر کنتراست تضمین‌شده
      ندارد و قاعده اولویت ۱ (contrast 4.5:1) را می‌شکند.
   ⚠️ چرا فونت وب بارگذاری نمی‌شود: قاعده «بدون وابستگی بیرونی» — سرور
      ممکن است دسترسی خروجی نداشته باشد و صفحه ورود باید همیشه بالا بیاید.
   ========================================================================== */

:root {
    /* پالت اختصاصی صفحه ورود — مستقل از رنگ برند تا کنتراست تضمین بماند */
    --lg-ink:      #0F172A;   /* سرمه‌ای عمیق: بوم سمت برند */
    --lg-ink-2:    #1E293B;
    --lg-ink-3:    #334155;
    --lg-gold:     #C9962B;   /* طلایی روشن‌شده برای کنتراست روی سرمه‌ای */
    --lg-on-ink:   #F8FAFC;
    --lg-on-ink-2: #94A3B8;
}

#login {
    min-height: 100vh;
    min-height: 100dvh;              /* نوار آدرس موبایل نباید چیزی را ببرد */
    display: grid;
    grid-template-columns: 1.05fr .95fr;   /* RTL: ستون اول = بوم برند */
    background: var(--surface);
}

/* ----------------------------------------------------------- بوم برند */
.lg-canvas {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(120% 90% at 80% 10%, #16233d 0%, transparent 55%),
        radial-gradient(90%  80% at 10% 90%, #12304a 0%, transparent 50%),
        linear-gradient(150deg, var(--lg-ink) 0%, var(--lg-ink-2) 100%);
    color: var(--lg-on-ink);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 3rem 3.2rem;
    isolation: isolate;
}

/* شبکه ظریف — ارجاع سوئیسی، بدون تصویر و بدون درخواست شبکه */
.lg-canvas::before {
    content: '';
    position: absolute; inset: 0; z-index: -1;
    background-image:
        linear-gradient(to right, rgba(255,255,255,.045) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255,255,255,.045) 1px, transparent 1px);
    background-size: 68px 68px;
    mask-image: radial-gradient(75% 65% at 60% 40%, #000 30%, transparent 100%);
}

/* هاله طلایی — عمق، بدون کاهش کنتراست متن */
.lg-canvas::after {
    content: '';
    position: absolute; z-index: -1;
    width: 460px; height: 460px; border-radius: 50%;
    inset-inline-end: -160px; top: -140px;
    background: radial-gradient(circle, rgba(201,150,43,.20) 0%, transparent 68%);
    filter: blur(8px);
}

.lg-mark { display: flex; align-items: center; gap: .85rem; }
.lg-mark svg { width: 42px; height: 42px; flex-shrink: 0; }
.lg-mark-t b { display: block; font-size: 1.18rem; letter-spacing: -.01em; }
.lg-mark-t span { display: block; font-size: .78rem; color: var(--lg-on-ink-2); margin-top: .15rem; }

.lg-hero { max-width: 30ch; }
.lg-hero h2 {
    font-size: clamp(1.55rem, 2.4vw, 2.15rem);
    line-height: 1.45;
    margin: 0 0 .9rem;
    font-weight: 700;
    letter-spacing: -.015em;
}
.lg-hero h2 em { font-style: normal; color: var(--lg-gold); }
.lg-hero p { color: var(--lg-on-ink-2); font-size: .95rem; line-height: 1.9; margin: 0; }

/* سه نکته اعتماد — چرا این محصول */
.lg-points { display: grid; gap: .9rem; margin-top: 2.2rem; }
.lg-point { display: flex; align-items: flex-start; gap: .7rem; font-size: .87rem; }
.lg-point svg { width: 19px; height: 19px; flex-shrink: 0; margin-top: .15rem; color: var(--lg-gold); }
.lg-point span { color: #CBD5E1; line-height: 1.7; }

.lg-foot {
    display: flex; align-items: center; gap: .55rem;
    font-size: .76rem; color: var(--lg-on-ink-2);
}
/* نشانگر زنده سلامت سرویس — برای یک پنل عملیاتی واقعاً مفید است */
.lg-dot { width: 8px; height: 8px; border-radius: 50%; background: #64748B; flex-shrink: 0; }
.lg-dot.up   { background: #22C55E; box-shadow: 0 0 0 3px rgba(34,197,94,.18); }
.lg-dot.down { background: #EF4444; box-shadow: 0 0 0 3px rgba(239,68,68,.18); }

/* ---------------------------------------------------------- سمت فرم */
.lg-form {
    display: flex; align-items: center; justify-content: center;
    padding: 2.5rem 2rem;
}
.lg-form .box {
    width: 100%; max-width: 384px;
    background: none; padding: 0; box-shadow: none; border-radius: 0;
}
.lg-form h1 {
    margin: 0 0 .35rem;
    font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em;
    color: var(--text);
}
.lg-form .tag { color: var(--muted); font-size: .88rem; margin-bottom: 2rem; line-height: 1.7; }

#loginBtn { width: 100%; margin-top: .4rem; font-size: .95rem; }

/* هشدار Caps Lock — خطای رایجی که کاربر خودش نمی‌بیند */
.lg-caps {
    display: none; align-items: center; gap: .4rem;
    background: #FEF3C7; color: #92400E; border-radius: 8px;
    padding: .5rem .7rem; font-size: .78rem; margin-top: .5rem;
}
.lg-caps.show { display: flex; }

.lg-meta {
    margin-top: 2rem; padding-top: 1.2rem; border-top: 1px solid var(--border);
    color: var(--muted); font-size: .74rem; line-height: 1.9;
}
.lg-meta a { color: var(--primary); }

/* ورود نرم — با احترام به prefers-reduced-motion */
@keyframes lgIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.lg-form .box > * { animation: lgIn .45s cubic-bezier(.22,.61,.36,1) backwards; }
.lg-form .box > *:nth-child(2) { animation-delay: .05s; }
.lg-form .box > *:nth-child(3) { animation-delay: .10s; }
.lg-form .box > *:nth-child(4) { animation-delay: .15s; }
.lg-form .box > *:nth-child(5) { animation-delay: .20s; }
@media (prefers-reduced-motion: reduce) {
    .lg-form .box > * { animation: none; }
}

/* mobile-first: زیر ۹۰۰px بوم برند به یک نوار جمع می‌شود، فرم اول می‌آید */
@media (max-width: 900px) {
    #login { grid-template-columns: 1fr; }
    .lg-canvas {
        order: 2; padding: 1.6rem 1.4rem;
        /* بدون hero، فاصله‌گذاری space-between یک حفره بزرگ می‌سازد */
        justify-content: flex-start; gap: 1.1rem;
    }
    .lg-canvas::after { display: none; }
    .lg-hero, .lg-points { display: none; }   /* progressive-disclosure */
    .lg-canvas .lg-foot { margin-top: 1rem; }
    .lg-form { order: 1; padding: 2.5rem 1.4rem 1.5rem; }
}

/* ------------------------------------------------------------------ shell */
#app { display: none; }
.layout { display: flex; min-height: 100vh; }

/* ⚠️ فقط سایدبار پوسته اپ. بوم صفحه ورود هم <aside> است و قاعده
   عمومی، عرض ۲۲۰px را به آن هم می‌داد و چیدمان را می‌شکست. */
.layout > aside {
    width: 220px; background: var(--surface); border-inline-start: 1px solid var(--border);
    padding: 1.2rem 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; flex-shrink: 0;
}
.layout > aside .brand { padding: 0 1.2rem 1.2rem; border-bottom: 1px solid var(--border); margin-bottom: .8rem; }
.layout > aside .brand b { color: var(--primary); font-size: 1.1rem; display: block; }
.layout > aside .brand span { color: var(--muted); font-size: .75rem; }
nav a {
    display: flex; align-items: center; gap: .6rem; padding: .7rem 1.2rem;
    color: var(--text); text-decoration: none; cursor: pointer; border-inline-start: 3px solid transparent;
}
nav a:hover { background: var(--bg); }
nav a.active { background: var(--bg); border-inline-start-color: var(--primary); color: var(--primary); font-weight: bold; }
nav .sep { padding: .9rem 1.2rem .3rem; color: var(--muted); font-size: .72rem; letter-spacing: .04em; }

main { flex: 1; padding: 1.5rem 2rem; overflow-x: auto; min-width: 0; }
header.page { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.2rem; gap: 1rem; }
header.page h2 { margin: 0; font-size: 1.25rem; }
header.page .who { color: var(--muted); font-size: .8rem; }

/* ------------------------------------------------------------------ cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .9rem; margin-bottom: 1.4rem; }
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem;
}
.card .label { color: var(--muted); font-size: .78rem; margin-bottom: .4rem; }
.card .value { font-size: 1.6rem; font-weight: 700; color: var(--primary); }
.card .value.sm { font-size: 1.1rem; }

.panel {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.2rem; margin-bottom: 1.2rem;
}
.panel h3 { margin: 0 0 1rem; font-size: 1rem; display: flex; justify-content: space-between; align-items: center; }

/* ----------------------------------------------------------------- tables */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td { padding: .55rem .6rem; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: normal; font-size: .78rem; background: var(--bg); position: sticky; top: 0; }
tbody tr:hover { background: #f8fafc; }
td.wrap { white-space: normal; min-width: 220px; }

/* ---------------------------------------------------------------- controls
   بازطراحی‌شده بر پایه قواعد skill «ui-ux-pro-max»:
   دسته ۸ (فرم و بازخورد) و دسته‌های ۱ و ۲ (دسترس‌پذیری و لمس).
   هر قاعده‌ای که اینجا اعمال شده، با نام خودش کامنت خورده تا بعداً معلوم
   باشد چرا این‌طور است و کسی سهواً برش نگرداند.
   ------------------------------------------------------------------------ */

/* touch-friendly-input: ارتفاع حداقل ۴۴px — قبلاً ~۳۴px بود و روی موبایل
   هدف لمسی کوچک‌تر از استاندارد داشت */
input, select, textarea {
    width: 100%;
    min-height: 44px;
    padding: .6rem .7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: .9rem;
    background: #fff;
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 88px; resize: vertical; }

/* focus-states + focus-appearance: حلقه فوکوس ۳px با کنتراست کافی */
input:focus-visible, select:focus-visible, textarea:focus-visible,
button:focus-visible, a:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

/* disabled-states: شفافیت کاهش‌یافته + تغییر نشانگر + ویژگی معنایی */
input:disabled, select:disabled, textarea:disabled {
    opacity: .45; cursor: not-allowed; background: var(--bg);
}
/* read-only-distinction: فقط‌خواندنی باید از غیرفعال متمایز باشد */
input[readonly], textarea[readonly] {
    background: var(--bg); border-style: dashed; opacity: 1; cursor: default;
}

/* ------------------------------------------------------------- ساختار فیلد */
.f { display: block; margin-bottom: 1.1rem; }
.f > .f-label {
    display: flex; align-items: baseline; gap: .3rem;
    color: var(--text); font-size: .82rem; font-weight: 600; margin-bottom: .3rem;
}
/* required-indicators */
.f-req { color: var(--danger); font-weight: 700; }
.f-optional { color: var(--muted); font-weight: 400; font-size: .75rem; }

/* input-helper-text: راهنمای ماندگار زیر فیلد، نه فقط placeholder */
.f-help { display: block; color: var(--muted); font-size: .76rem; margin-top: .3rem; line-height: 1.6; }

/* error-placement + contrast-feedback: خطا زیر همان فیلد، با کنتراست کافی */
.f-err {
    display: none; color: var(--danger); font-size: .78rem; margin-top: .3rem;
    line-height: 1.6; font-weight: 600;
}
.f.has-error .f-err { display: block; }
.f.has-error input, .f.has-error select, .f.has-error textarea {
    border-color: var(--danger);
}
.f.has-error input:focus, .f.has-error select:focus, .f.has-error textarea:focus {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 20%, transparent);
}
/* success-feedback: تأیید کوتاه پس از اعتبارسنجی موفق */
.f.is-valid input, .f.is-valid select { border-color: var(--ok); }

/* password-toggle: دکمه نمایش/پنهان رمز */
.f-wrap { position: relative; display: block; }
.f-toggle {
    position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%);
    min-height: 34px; padding: .25rem .5rem; background: transparent; color: var(--muted);
    border: 0; font-size: .74rem; cursor: pointer; border-radius: 6px;
}
.f-toggle:hover { background: var(--bg); color: var(--text); }
.f-wrap input { padding-inline-end: 4.2rem; }

/* error-summary: خلاصه خطاها در بالای فرم، هر مورد لینک به فیلد خودش */
.f-summary {
    display: none; background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5;
    border-radius: 10px; padding: .8rem 1rem; margin-bottom: 1rem; font-size: .84rem;
}
.f-summary.show { display: block; }
.f-summary b { display: block; margin-bottom: .4rem; }
.f-summary ul { margin: 0; padding-inline-start: 1.1rem; }
.f-summary a { color: #991b1b; }

/* field-grouping: گروه‌بندی منطقی فیلدهای مرتبط */
fieldset {
    border: 1px solid var(--border); border-radius: 10px;
    padding: 1rem 1rem .2rem; margin: 0 0 1.1rem;
}
legend { padding: 0 .5rem; font-size: .8rem; font-weight: 600; color: var(--muted); }

label { display: block; margin-bottom: .8rem; }
label span { display: block; color: var(--muted); font-size: .78rem; margin-bottom: .25rem; }
label.inline { display: flex; align-items: center; gap: .6rem; margin-bottom: .9rem; }
label.inline input { width: auto; min-height: auto; }
/* هدف لمسی چک‌باکس هم باید ۴۴px باشد */
label.inline input[type=checkbox] { width: 22px; height: 22px; }

button {
    min-height: 44px;
    padding: .55rem 1rem; border: 1px solid var(--primary); border-radius: 8px;
    background: var(--primary); color: #fff; cursor: pointer;
    font-family: inherit; font-size: .88rem; font-weight: 600;
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
}
button:hover:not(:disabled) { filter: brightness(1.08); }
button.ghost { background: transparent; color: var(--primary); }
button.small { min-height: 34px; padding: .3rem .6rem; font-size: .78rem; font-weight: 400; }
/* destructive-emphasis: رنگ معنایی خطر برای عملیات مخرب */
button.danger { background: var(--danger); border-color: var(--danger); }
button:disabled { opacity: .45; cursor: not-allowed; }
/* submit-feedback: حالت در حال ارسال */
button.busy { position: relative; color: transparent; }
button.busy::after {
    content: ''; position: absolute; width: 16px; height: 16px;
    border: 2px solid #fff; border-top-color: transparent; border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    button.busy::after { animation-duration: 2s; }
    input, select, textarea { transition: none; }
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 1rem; }
.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar input, .toolbar select { width: auto; min-width: 150px; }

/* ------------------------------------------------------------------ badges */
.badge { padding: .15rem .5rem; border-radius: 20px; font-size: .72rem; display: inline-block; }
.b-ok { background: #dcfce7; color: #166534; }
.b-warn { background: #fef3c7; color: #92400e; }
.b-err { background: #fee2e2; color: #991b1b; }
.b-mut { background: #e2e8f0; color: #475569; }
.b-info { background: #dbeafe; color: #1e40af; }

/* ------------------------------------------------------------------ modal */
.modal {
    position: fixed; inset: 0; background: #0f172acc; display: flex; align-items: center;
    justify-content: center; z-index: 50; padding: 1rem;
}
.modal .box {
    background: var(--surface); border-radius: 16px; padding: 1.5rem; width: 620px;
    max-width: 96vw; max-height: 90vh; overflow-y: auto;
}
.modal h3 { margin: 0 0 1.2rem; }
.modal .actions { display: flex; gap: .6rem; justify-content: flex-start; margin-top: 1.2rem; }

/* ------------------------------------------------------------------- misc */
.note { background: #fef3c7; color: #92400e; padding: .7rem .9rem; border-radius: 8px; font-size: .8rem; margin-bottom: 1rem; }
.note.info { background: #dbeafe; color: #1e40af; }
.note.err { background: #fee2e2; color: #991b1b; }
.muted { color: var(--muted); font-size: .8rem; }
.mono { font-family: Consolas, monospace; direction: ltr; text-align: left; font-size: .78rem; }
pre.mono { background: #0f172a; color: #e2e8f0; padding: .8rem; border-radius: 8px; overflow-x: auto; max-height: 260px; }
.empty { text-align: center; color: var(--muted); padding: 2.5rem; }
.bar { display: flex; align-items: flex-end; gap: 3px; height: 90px; }
.bar div { flex: 1; background: var(--primary); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.bar div:hover { opacity: 1; }

#toast {
    position: fixed; bottom: 1.5rem; inset-inline-start: 1.5rem; background: #0f172a; color: #fff;
    padding: .8rem 1.2rem; border-radius: 10px; display: none; z-index: 100; max-width: 460px;
}

@media (max-width: 820px) {
    .layout > aside { width: 62px; }
    .layout > aside .brand span, nav a span.t, nav .sep { display: none; }
    main { padding: 1rem; }
    .grid2, .grid3 { grid-template-columns: 1fr; }
}
