/* ==========================================================================
   سام — سامانه اعتبارسنجی مشتریان
   لایه‌ی اختصاصی سام؛ روی style.css + chelle-theme.css چله
   سوار می‌شود و فقط اجزای مخصوص سام را اضافه می‌کند.
   همه‌ی دارایی‌ها لوکال‌اند — بدون CDN.
   ========================================================================== */

/* ---------------------------------------------------------- لوگوی سام */
/* از ماسک CSS استفاده می‌کنیم تا لوگو با گرادیان برند رنگ بگیرد و
   حجم HTML هم سنگین نشود. */
.sam-logo {
    display: inline-block;
    background: var(--pl-gradient);
    -webkit-mask: url("../img/sam-logo.90580506c4ea.svg") center / contain no-repeat;
    mask: url("../img/sam-logo.90580506c4ea.svg") center / contain no-repeat;
}
.sam-logo.on-dark { background: #fff; }

/* ---------------------------------------------------------- سایدبار */
.sidebar-brand .brand-mark { background: rgba(255, 255, 255, .14); }

/* فشرده‌سازی منو تا همه‌ی گروه‌ها بدون اسکرول در یک صفحه‌ی ۱۰۸۰p جا شوند */
.sidebar-nav { padding: 6px 10px 10px; }
.sidebar-nav .side-group-label { padding: 10px 12px 3px; }
.sidebar-nav .side-group-label:first-child { padding-top: 4px; }
.sidebar-nav .side-link { padding: 7px 12px; margin-bottom: 1px; font-size: .875rem; }

/* سایه‌ی محو در پایین منو؛ نشانه‌ی این‌که هنوز محتوا هست */
.app-sidebar { position: fixed; }
.app-sidebar::after {
    content: ''; position: absolute; inset-inline: 0; bottom: 56px; height: 22px;
    background: linear-gradient(to top, rgba(0, 0, 0, .18), transparent);
    pointer-events: none; opacity: 0; transition: opacity .2s ease;
}
.app-sidebar.has-more::after { opacity: 1; }
.sidebar-footer { padding: 8px 16px; }

/* ---------------------------------------------------------- کاشی گرادیانی داشبورد */
.metric-card { padding: 16px 18px; display: flex; flex-direction: column; height: 100%; }
.metric-card .metric-head { display: flex; align-items: center; gap: 8px;
                            position: relative; z-index: 1; }
.metric-card .metric-icon { font-size: 1.05rem; margin: 0; width: 30px; height: 30px;
                            border-radius: 9px; background: rgba(255, 255, 255, .2);
                            display: grid; place-items: center; flex: none; }
.metric-card .metric-label { font-size: .8rem; opacity: .95; margin: 0; }
.metric-card .metric-value { font-size: 1.55rem; font-weight: 800; line-height: 1.25;
                             margin: 10px 0 0; white-space: nowrap; overflow: hidden;
                             text-overflow: ellipsis; letter-spacing: -.4px; }
.metric-card .metric-value small { font-size: .78rem; font-weight: 500; opacity: .9;
                                   margin-right: 3px; }
.metric-card .metric-trend { font-size: .74rem; opacity: .9; margin-top: 5px;
                             white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 575.98px) {
    .metric-card .metric-value { font-size: 1.25rem; }
}

/* ---------------------------------------------------------- عنوان صفحه در تاپ‌بار */
.page-head { min-width: 0; line-height: 1.35; }
.page-head-title { font-size: 1.02rem; font-weight: 700; margin: 0; white-space: nowrap;
                   overflow: hidden; text-overflow: ellipsis; }
.page-head-sub { font-size: .74rem; color: var(--pl-muted); white-space: nowrap;
                 overflow: hidden; text-overflow: ellipsis; max-width: 46ch; }
@media (max-width: 767.98px) {
    .page-head-title { font-size: 1.15rem; }
}

/* ---------------------------------------------------------- نشان حالت آزمایشی */
.badge-mock {
    display: inline-flex; align-items: center; gap: 5px;
    background: rgba(249, 115, 22, .12); color: #b45309;
    border: 1px solid rgba(249, 115, 22, .28);
    border-radius: 99px; font-size: .72rem; font-weight: 600; padding: 4px 11px;
    white-space: nowrap; flex: none;
}
html.dark-mode .badge-mock { color: #fbbf24; background: rgba(249, 115, 22, .16); }

/* ---------------------------------------------------------- اعداد */
.num { font-variant-numeric: tabular-nums; letter-spacing: .2px; }
.fw-6 { font-weight: 600; }
.text-muted-2 { color: var(--pl-muted) !important; }
.text-dim { color: var(--pl-muted) !important; opacity: .75; }

/* ---------------------------------------------------------- کارت و جدول */
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--pl-border);
    padding: 14px 18px;
    font-weight: 600; font-size: .93rem;
}
.card-header .hint { font-weight: 400; color: var(--pl-muted); font-size: .78rem; }
.card-body { padding: 16px 18px; }

.table { font-size: .845rem; margin-bottom: 0; }
.table > thead > tr > th {
    color: var(--pl-muted); font-weight: 600; font-size: .76rem;
    border-bottom: 1px solid var(--pl-border); padding: 10px 11px; white-space: nowrap;
    background: transparent;
}
.table > tbody > tr > td { padding: 11px; vertical-align: middle; border-color: var(--pl-border); }
.table-wrap { overflow-x: auto; border-radius: 0 0 20px 20px; }

/* ---------------------------------------------------------- نشان‌ها (pill) */
.pil {
    display: inline-block; padding: 3px 11px; border-radius: 99px;
    font-size: .72rem; font-weight: 600; white-space: nowrap; line-height: 1.75;
}
.pil-ok     { background: rgba(20, 184, 166, .14); color: #0f766e; }
.pil-info   { background: rgba(59, 130, 246, .14); color: #1d4ed8; }
.pil-warn   { background: rgba(250, 204, 21, .20);  color: #a16207; }
.pil-bad    { background: rgba(236, 72, 153, .14);  color: #be185d; }
.pil-mute   { background: rgba(139, 132, 163, .16); color: var(--pl-muted); }
.pil-purple { background: rgba(124, 58, 237, .14);  color: #6d28d9; }
html.dark-mode .pil-ok     { color: #5eead4; }
html.dark-mode .pil-info   { color: #93c5fd; }
html.dark-mode .pil-warn   { color: #fde047; }
html.dark-mode .pil-bad    { color: #f9a8d4; }
html.dark-mode .pil-purple { color: #c4b5fd; }

/* ---------------------------------------------------------- درجه اعتباری */
.grade {
    display: inline-grid; place-items: center; min-width: 44px; height: 29px;
    border-radius: 10px; font-weight: 800; font-size: .85rem; padding: 0 9px;
    color: #fff;
}
.grade-AA { background: linear-gradient(135deg, #0d9488, #2dd4bf); }
.grade-A  { background: linear-gradient(135deg, #14b8a6, #5eead4); }
.grade-B  { background: linear-gradient(135deg, #3b82f6, #60a5fa); }
.grade-C  { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.grade-D  { background: linear-gradient(135deg, #f97316, #fb923c); }
.grade-E  { background: linear-gradient(135deg, #e11d48, #f472b6); }

/* ---------------------------------------------------------- رنگ چک صیادی */
.sayad { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 600; }
.sayad .dot { width: 14px; height: 14px; border-radius: 50%; flex: none;
              border: 1px solid rgba(0, 0, 0, .18); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.sayad-white   .dot { background: #ffffff; }
.sayad-yellow  .dot { background: #facc15; }
.sayad-orange  .dot { background: #f97316; }
.sayad-brown   .dot { background: #92400e; }
.sayad-red     .dot { background: #e11d48; }
.sayad-unknown .dot { background: #cbd5e1; }

/* ---------------------------------------------------------- نوار پیشرفت */
.meter { height: 8px; background: rgba(124, 58, 237, .10); border-radius: 99px; overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 99px;
                background: var(--pl-gradient); transition: width .4s ease; }
html.dark-mode .meter { background: rgba(168, 85, 247, .16); }

/* ---------------------------------------------------------- گیج امتیاز */
.gauge { position: relative; width: 210px; height: 128px; margin: 0 auto; }
.gauge .cap { position: absolute; inset: auto 0 2px; text-align: center; }
.gauge .cap b { display: block; font-size: 2.15rem; font-weight: 800; line-height: 1; letter-spacing: -1px; }
.gauge .cap i { font-style: normal; color: var(--pl-muted); font-size: .72rem; }

/* ---------------------------------------------------------- خط زمانی */
.tl { position: relative; padding-right: 20px; margin: 0; }
.tl::before { content: ''; position: absolute; right: 5px; top: 7px; bottom: 7px;
              width: 2px; background: var(--pl-border); }
.tl .item { position: relative; padding-bottom: 15px; }
.tl .item::before {
    content: ''; position: absolute; right: -19px; top: 6px; width: 12px; height: 12px;
    border-radius: 50%; background: var(--pl-surface); border: 2px solid var(--pl-muted);
}
.tl .item.ok::before   { border-color: #14b8a6; }
.tl .item.warn::before { border-color: #f59e0b; }
.tl .item.bad::before  { border-color: #e11d48; }
.tl .item.open::before { border-color: #7c3aed; }
.tl .item .h { font-size: .845rem; font-weight: 600; }
.tl .item .m { color: var(--pl-muted); font-size: .78rem; }

/* ---------------------------------------------------------- هشدارها */
.alrt {
    display: flex; gap: 12px; padding: 12px 14px; border-radius: 14px;
    background: var(--pl-surface); border: 1px solid var(--pl-border);
    border-right: 3px solid var(--pl-muted); margin-bottom: 10px;
    transition: transform .2s ease, box-shadow .2s ease;
}
.alrt:hover { transform: translateY(-2px); box-shadow: var(--pl-shadow); }
.alrt.critical { border-right-color: #e11d48; background: rgba(225, 29, 72, .05); }
.alrt.high     { border-right-color: #ec4899; background: rgba(236, 72, 153, .05); }
.alrt.medium   { border-right-color: #f59e0b; background: rgba(245, 158, 11, .05); }
.alrt.low, .alrt.info { border-right-color: #3b82f6; background: rgba(59, 130, 246, .05); }
.alrt .ic { font-size: 1.1rem; line-height: 1.35; flex: none; }
.alrt b { display: block; font-size: .855rem; }
.alrt p { margin: 0; color: var(--pl-muted); font-size: .795rem; line-height: 1.75; }
.alrt time { color: var(--pl-muted); font-size: .72rem; opacity: .8; }

/* ---------------------------------------------------------- فرم */
.form-label { font-size: .8rem; font-weight: 600; margin-bottom: 5px; }
.form-control, .form-select { font-size: .875rem; border-radius: 12px; padding: .5rem .8rem; }
.form-control:focus, .form-select:focus {
    border-color: var(--pl-primary);
    box-shadow: 0 0 0 .2rem rgba(var(--pl-primary-rgb), .15);
}
.form-text { font-size: .74rem; color: var(--pl-muted); }
.btn-sm { font-size: .78rem; border-radius: 10px; padding: .3rem .75rem; }
.btn-teal { background: linear-gradient(135deg, #0d9488, #14b8a6); border: 0; color: #fff; }
.btn-teal:hover { filter: brightness(1.07); color: #fff; }
.btn-ghost { background: var(--pl-surface); border: 1px solid var(--pl-border); color: var(--pl-text); }
.btn-ghost:hover { background: rgba(var(--pl-primary-rgb), .07); border-color: var(--pl-primary); color: var(--pl-primary); }

.amount-field { position: relative; }
.amount-hint { font-size: .74rem; color: var(--pl-primary); font-weight: 600;
               min-height: 18px; display: block; margin-top: 3px; }

/* ---------------------------------------------------------- تقویم شمسی */
.jdp {
    position: absolute; z-index: 1080; background: var(--pl-surface);
    border: 1px solid var(--pl-border); border-radius: 16px;
    box-shadow: var(--pl-shadow-lg); padding: 12px; width: 268px; display: none;
    font-size: .82rem;
}
.jdp.show { display: block; }
.jdp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.jdp-head button { background: none; border: none; color: var(--pl-primary);
                   font-size: 1rem; padding: 3px 9px; border-radius: 8px; cursor: pointer; }
.jdp-head button:hover { background: rgba(var(--pl-primary-rgb), .1); }
.jdp-title { font-weight: 700; font-size: .85rem; cursor: pointer; padding: 3px 9px; border-radius: 8px; }
.jdp-title:hover { background: rgba(var(--pl-primary-rgb), .1); }
.jdp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.jdp-grid .wd { color: var(--pl-muted); font-size: .68rem; text-align: center; padding: 4px 0; }
.jdp-grid button { background: none; border: none; border-radius: 9px; padding: 6px 0;
                   font-size: .8rem; cursor: pointer; color: var(--pl-text); }
.jdp-grid button:hover { background: rgba(var(--pl-primary-rgb), .1); }
.jdp-grid button.today { box-shadow: inset 0 0 0 1px var(--pl-primary); color: var(--pl-primary); font-weight: 700; }
.jdp-grid button.sel { background-image: var(--pl-gradient); color: #fff; font-weight: 700; }
.jdp-grid button.off { opacity: .4; }
.jdp-grid button.hol { color: #e11d48; }
.jdp-months { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.jdp-months button { padding: 9px 0; border-radius: 10px; border: none;
                     background: rgba(var(--pl-primary-rgb), .07); font-size: .8rem; cursor: pointer;
                     color: var(--pl-text); }
.jdp-months button:hover { background: rgba(var(--pl-primary-rgb), .16); }
.jdp-foot { display: flex; gap: 6px; margin-top: 9px; border-top: 1px solid var(--pl-border); padding-top: 9px; }
.jdp-foot button { flex: 1; border: none; background: rgba(var(--pl-primary-rgb), .07);
                   border-radius: 9px; padding: 6px; font-size: .76rem; cursor: pointer; color: var(--pl-text); }
.jdp-foot button:hover { background: rgba(var(--pl-primary-rgb), .16); }
html.dark-mode .jdp-grid button { color: var(--pl-text); }

/* ---------------------------------------------------------- حالت خالی و راهنما */
.empty { text-align: center; padding: 46px 16px; color: var(--pl-muted); }
.empty i { font-size: 2.4rem; opacity: .45; display: block; margin-bottom: 10px; }

.hintbox {
    background: rgba(var(--pl-primary-rgb), .05);
    border: 1px dashed rgba(var(--pl-primary-rgb), .25);
    border-radius: 14px; padding: 11px 14px;
    font-size: .795rem; color: var(--pl-muted); line-height: 1.9;
}
.hintbox b { color: var(--pl-text); }

.sep { height: 1px; background: var(--pl-border); margin: 15px 0; }
.quick-actions .btn { display: flex; align-items: center; gap: 9px;
                      justify-content: flex-start; width: 100%; margin-bottom: 8px; }

/* ---------------------------------------------------------- کاشی آماری ساده */
.stat {
    background: var(--pl-surface); border: 1px solid var(--pl-border); border-radius: 20px;
    padding: 16px 18px; box-shadow: var(--pl-shadow); height: 100%;
    transition: transform .3s ease, box-shadow .3s ease;
}
.stat:hover { transform: translateY(-4px); box-shadow: var(--pl-shadow-lg); }
.stat .lbl { color: var(--pl-muted); font-size: .78rem; }
.stat .val { font-size: 1.5rem; font-weight: 700; margin: 3px 0 1px; letter-spacing: -.3px; }
.stat .val small { font-size: .8rem; font-weight: 400; color: var(--pl-muted); }
.stat .dlt { font-size: .72rem; font-weight: 600; }

/* ---------------------------------------------------------- ورودی چپ‌چین */
.ltr-input, input[dir="ltr"] { direction: ltr; text-align: left; }

/* ---------------------------------------------------------- چاپ */
@media print {
    .app-sidebar, .app-topbar, .app-footer, .ch-blob, #chPageLoader { display: none !important; }
    .app-main { margin: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; }
}

/* ---------------------------------------------------------- تاپ‌بار: جلوگیری از شکستن دکمه‌ها */
.topbar-inner { flex-wrap: nowrap; overflow: hidden; }
.topbar-actions { flex-wrap: nowrap; }
.topbar-actions .btn,
.topbar-actions .btn-quick-add { white-space: nowrap; }
.page-head { flex: 1 1 auto; min-width: 150px; }
.topbar-search { flex: 0 1 240px; min-width: 120px; }
/* نام کاربر و تاریخ به‌جای شکستن، کوتاه می‌شوند */
.topbar-user { flex: 0 1 auto; min-width: 0; }
.topbar-user-info { min-width: 0; max-width: 15ch; }
.topbar-user-name, .topbar-user-role {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
@media (max-width: 1399.98px) {
    .topbar-actions .btn .btn-txt { display: none; }
}
