/* ==========================================================================
   سامانه فیش حقوقی — استایل مشترک (ریسپانسیو: موبایل + دسکتاپ)
   ABR BARAN LLC — AbrBaranIDC.IR
   رنگ‌های برند از تنظیمات مدیر روی :root تزریق می‌شوند (--brand, --accent ...)
   ========================================================================== */

:root {
    --brand: #0b5a4a;
    --brand-dark: #0a4070;
    --brand-soft: #e7f0f9;
    --accent: #2a9d7f;
    --accent-soft: #e3f4fb;
    --ink: #12263a;
    --muted: #5d6f82;
    --line: #dce5ee;
    --bg: #f1f5fa;
    --card: #ffffff;
    --ok: #1c9a62;
    --ok-soft: #e4f6ed;
    --warn: #c47d0a;
    --warn-soft: #fdf3dc;
    --bad: #d03f3f;
    --bad-soft: #fde9e9;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(18, 38, 58, .06), 0 8px 24px rgba(18, 38, 58, .06);
    --nav-h: 66px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Vazirmatn', 'Vazir', Tahoma, 'Segoe UI', Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    line-height: 1.8;
    font-size: 15px;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
.ic { flex: none; vertical-align: middle; }
.muted { color: var(--muted); }
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* ---------- هدر ---------- */
.app-header {
    position: sticky; top: 0; z-index: 40;
    background: #fff; border-bottom: 1px solid var(--line);
    box-shadow: 0 1px 0 rgba(18,38,58,.03);
}
.app-header__in {
    max-width: 1120px; margin: 0 auto; padding: 8px 16px;
    display: flex; align-items: center; gap: 16px; min-height: 64px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); min-width: 0; flex: 1 1 auto; }
.brand:hover { text-decoration: none; }
.brand__txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.4; }
.brand__txt strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand__txt small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo-default {
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 12px; color: #fff;
    background: linear-gradient(135deg, var(--brand), var(--accent));
    flex: none;
}
.logo-img { width: auto; object-fit: contain; border-radius: 6px; }
.top-nav { display: none; gap: 4px; }
.top-nav a {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px; border-radius: 10px; color: var(--muted); font-size: 14px;
}
.top-nav a:hover { background: var(--brand-soft); color: var(--brand); text-decoration: none; }
.top-nav a.is-active { background: var(--brand-soft); color: var(--brand); font-weight: bold; }
.who { display: flex; align-items: center; gap: 10px; flex: none; }
.who__name { display: none; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- صفحه ---------- */
.page { padding: 20px 0 32px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 21px; line-height: 1.5; }
.page-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card > h2, .card__title { font-size: 16px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card--flush { padding: 0; overflow: hidden; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.card__head h2 { font-size: 16px; }

.grid { display: grid; gap: 14px; }
.grid--stats { grid-template-columns: repeat(3, 1fr); }
.grid--tiles { grid-template-columns: repeat(2, 1fr); }
.grid--2 { grid-template-columns: 1fr; }

/* ---------- آمار ---------- */
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.stat span { display: block; color: var(--muted); font-size: 12.5px; }
.stat b { display: block; font-size: 26px; color: var(--brand); line-height: 1.4; }

/* ---------- کاشی منو ---------- */
.tile {
    display: flex; flex-direction: column; gap: 6px; padding: 16px; color: var(--ink);
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
    transition: transform .15s, border-color .15s;
}
.tile:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--accent); }
.tile__ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--brand), var(--accent)); }
.tile h3 { font-size: 15px; }
.tile p { font-size: 12.5px; color: var(--muted); line-height: 1.7; }

/* ---------- دکمه‌ها ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px; border-radius: 10px; border: 1px solid transparent; cursor: pointer;
    font: inherit; font-size: 14px; font-weight: bold; line-height: 1.6; text-decoration: none;
    background: var(--brand); color: #fff; transition: background .15s, box-shadow .15s;
    min-height: 44px;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn--block { width: 100%; }
.btn--sm { padding: 6px 12px; min-height: 36px; font-size: 13px; }
.btn--ghost { background: transparent; color: var(--brand); border-color: var(--line); }
.btn--ghost:hover { background: var(--brand-soft); }
.btn--danger { background: var(--bad); }
.btn--danger:hover { background: #b03232; }
.btn--ok { background: var(--ok); }
.btn--ok:hover { background: #157a4d; }
.btn--light { background: #fff; color: var(--brand); border-color: var(--line); }
.btn--light:hover { background: var(--brand-soft); }

/* ---------- فرم ---------- */
.field { margin-bottom: 16px; }
.field label, .label { display: block; margin-bottom: 6px; font-weight: bold; font-size: 14px; }
.field .hint { color: var(--muted); font-size: 12.5px; margin-top: 4px; line-height: 1.7; }
.req { color: var(--bad); }
input[type=text], input[type=password], input[type=search], input[type=url], input[type=tel], input[type=number], select, textarea {
    width: 100%; padding: 11px 14px; border: 1.5px solid var(--line); border-radius: 10px;
    font: inherit; font-size: 15px; background: #fff; color: var(--ink); min-height: 46px;
    transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=color] { width: 56px; height: 46px; padding: 3px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--brand); }
.form-row { display: grid; gap: 14px; grid-template-columns: 1fr; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.ltr { direction: ltr; text-align: left; }

.file-pick { position: relative; }
.file-pick input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.file-pick__box {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    border: 2px dashed var(--line); border-radius: 12px; padding: 14px 16px; background: #fafcfe; min-height: 56px;
}
.file-pick__box.has-file { border-style: solid; border-color: var(--ok); background: var(--ok-soft); }
.file-pick__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: right; flex: 1; }

/* ---------- هشدارها و بج ---------- */
.alert { padding: 12px 16px; border-radius: 12px; margin-bottom: 14px; font-size: 14px; border: 1px solid transparent; line-height: 1.9; }
.alert--ok { background: var(--ok-soft); color: #0f6a42; border-color: #b9e6cf; }
.alert--err { background: var(--bad-soft); color: #9d2a2a; border-color: #f5c3c3; }
.alert--info { background: var(--accent-soft); color: #0b5f82; border-color: #b8e1f2; }
.alert--warn { background: var(--warn-soft); color: #8a5806; border-color: #f2dba6; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: bold; line-height: 1.8; }
.badge--ok { background: var(--ok-soft); color: #0f6a42; }
.badge--bad { background: var(--bad-soft); color: #9d2a2a; }
.badge--muted { background: #eef2f6; color: var(--muted); }
.badge--brand { background: var(--brand-soft); color: var(--brand); }
.pwbox { text-align: center; padding: 16px; border-radius: 12px; background: var(--warn-soft); border: 2px dashed var(--warn); margin-bottom: 14px; }
.pwbox code { display: block; font-size: 28px; letter-spacing: 3px; direction: ltr; margin: 8px 0; font-family: Consolas, monospace; font-weight: bold; }

/* ---------- لیست‌ها ---------- */
.row-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.row-item:last-child { border-bottom: 0; }
.row-item__main { min-width: 0; flex: 1 1 200px; }
.row-item__title { font-weight: bold; }
.row-item__sub { font-size: 13px; color: var(--muted); }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty .ic { color: #b9c6d4; margin-bottom: 8px; }

/* ---------- جدول (روی موبایل به کارت تبدیل می‌شود) ---------- */
.table-wrap { overflow-x: auto; }
table.rtable { width: 100%; border-collapse: collapse; font-size: 14px; }
.rtable th { background: #f6f9fc; color: var(--muted); font-size: 12.5px; text-align: right; padding: 10px 12px; white-space: nowrap; border-bottom: 1px solid var(--line); }
.rtable td { padding: 10px 12px; border-bottom: 1px solid #edf1f6; vertical-align: middle; }
.rtable tr:hover td { background: #fafcff; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- فیلتر / صفحه‌بندی ---------- */
.filters { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; align-items: end; }
.filters .field { margin-bottom: 0; }
.filters__btns { display: flex; gap: 8px; grid-column: 1 / -1; }
.pager { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; padding: 14px; }
.pager a, .pager span { min-width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 0 10px; }
.pager .is-cur { background: var(--brand); color: #fff; border-color: var(--brand); }
.pager a:hover { text-decoration: none; background: var(--brand-soft); }

/* ---------- پشتیبانی / فوتر ---------- */
.app-footer { padding: 8px 0 28px; }
.support h2 { color: var(--brand); }
.support__addr { display: flex; gap: 8px; align-items: flex-start; color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.support__links { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-weight: bold; font-size: 14px; border: 1px solid transparent; }
.chip:hover { text-decoration: none; border-color: var(--accent); }
.chip__sub { font-weight: normal; color: var(--muted); font-size: 12.5px; }
.credit { text-align: center; color: var(--muted); font-size: 12.5px; padding: 6px 0; }

/* ---------- منوی چسبان موبایل ---------- */
.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    display: flex; justify-content: space-around; align-items: stretch;
    background: #fff; border-top: 1px solid var(--line);
    box-shadow: 0 -4px 18px rgba(18,38,58,.08);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    min-height: var(--nav-h);
}
.bottom-nav a {
    flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--muted); font-size: 11.5px; line-height: 1.4; border-radius: 12px; padding: 6px 2px; text-align: center;
}
.bottom-nav a span { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bottom-nav a:hover { text-decoration: none; background: var(--brand-soft); color: var(--brand); }
.bottom-nav a.is-active { color: var(--brand); font-weight: bold; background: var(--brand-soft); }
body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }

/* ---------- ورود ---------- */
body.auth { background: radial-gradient(1200px 500px at 90% -10%, var(--accent-soft), transparent), radial-gradient(900px 500px at -10% 110%, var(--brand-soft), transparent), var(--bg); }
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 28px 16px; gap: 16px; }
.auth__card { width: 100%; max-width: 440px; padding: 0; overflow: hidden; margin: 0; }
.auth__head { text-align: center; padding: 26px 20px 18px; background: linear-gradient(135deg, var(--brand), var(--accent)); color: #fff; }
.auth__head .logo-default { background: rgba(255,255,255,.2); }
.auth__head .logo-img { background: #fff; padding: 6px; border-radius: 12px; }
.auth__head h1 { font-size: 19px; margin-top: 10px; line-height: 1.6; }
.auth__head p { font-size: 13px; opacity: .92; }
.auth__body { padding: 22px 20px; }
.auth__support { width: 100%; max-width: 440px; }
.auth__support .card { margin-bottom: 8px; }
.switch-link { text-align: center; margin-top: 14px; font-size: 14px; }

/* ---------- انتخاب نقش (صفحه اول) ---------- */
.roles { display: grid; gap: 14px; grid-template-columns: 1fr; margin-bottom: 8px; }
.role { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 14px; border: 1.5px solid var(--line); color: var(--ink); background: #fff; }
.role:hover { text-decoration: none; border-color: var(--accent); background: var(--accent-soft); }
.role__ic { width: 50px; height: 50px; border-radius: 14px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--brand), var(--accent)); flex: none; }
.role h3 { font-size: 16px; }
.role p { font-size: 12.5px; color: var(--muted); line-height: 1.7; }

/* ---------- تنظیمات / انتخاب مدل فیش ---------- */
.tpl-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
.tpl { display: block; border: 2px solid var(--line); border-radius: 14px; padding: 12px; cursor: pointer; background: #fff; position: relative; }
.tpl input { position: absolute; top: 12px; left: 12px; }
.tpl:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.tpl__thumb { height: 120px; border-radius: 8px; border: 1px solid var(--line); background: #fff; margin-bottom: 8px; overflow: hidden; position: relative; }
.tpl__name { font-weight: bold; }
.tpl__desc { font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.tpl__actions { margin-top: 8px; }
.logo-prev { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.logo-prev__box { width: 120px; height: 64px; border: 1px dashed var(--line); border-radius: 10px; display: grid; place-items: center; background: #fafcfe; overflow: hidden; }
.logo-prev__box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.ql-row { display: grid; gap: 10px; grid-template-columns: 1fr; padding: 12px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; background: #fafcfe; }
.ql-row__title { font-weight: bold; display: flex; align-items: center; gap: 8px; }
.color-row { display: flex; gap: 12px; flex-wrap: wrap; }
.color-row .field { margin-bottom: 0; }
.sticky-save { position: sticky; bottom: calc(var(--nav-h) + 8px + env(safe-area-inset-bottom)); z-index: 20; display: flex; justify-content: flex-end; padding: 8px 0; }
.sticky-save .btn { box-shadow: 0 8px 24px rgba(18,38,58,.25); }

/* ---------- پروگرس ---------- */
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin 1s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* ===================== ریسپانسیو ===================== */
@media (max-width: 899px) {
    .hide-sm { display: none; }

    /* جدول → کارت */
    table.rtable thead { display: none; }
    table.rtable, .rtable tbody, .rtable tr, .rtable td { display: block; width: 100%; }
    .rtable tr { border-bottom: 1px solid var(--line); padding: 10px 14px; position: relative; }
    .rtable td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: left; }
    .rtable td::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; text-align: right; flex: none; }
    .rtable td.cell-check { position: absolute; top: 12px; left: 14px; width: auto; padding: 0; }
    .rtable td.cell-check::before { display: none; }
    .rtable td[data-label=""]::before { display: none; }
    .rtable td.cell-actions { justify-content: flex-end; padding-top: 8px; }
    .rtable td.cell-actions::before { display: none; }
}
@media (min-width: 600px) {
    .grid--tiles { grid-template-columns: repeat(3, 1fr); }
    .form-row { grid-template-columns: 1fr 1fr; }
    .filters { grid-template-columns: repeat(4, 1fr); }
    .filters__btns { grid-column: auto; }
    .tpl-grid { grid-template-columns: 1fr 1fr; }
    .ql-row { grid-template-columns: 1fr 2fr auto; align-items: center; }
    .roles { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 900px) {
    body { padding-bottom: 0; }
    .bottom-nav { display: none; }
    .top-nav { display: flex; }
    .who__name { display: inline-flex; }
    .brand { flex: 0 1 auto; }
    .top-nav { margin-inline-start: 12px; flex: 1; }
    .grid--tiles { grid-template-columns: repeat(4, 1fr); }
    .grid--2 { grid-template-columns: 1fr 1fr; }
    .page { padding: 28px 0 40px; }
    .page-head h1 { font-size: 24px; }
    .tpl-grid { grid-template-columns: repeat(4, 1fr); }
    .sticky-save { bottom: 12px; }
    .auth { justify-content: center; }
    /* بالا بودن منوی پایین فقط موبایل */
    body.auth .bottom-nav { display: none; }
}
/* در صفحه‌های ورود روی دسکتاپ نیازی به فضای خالی پایین نیست */
@media print {
    .app-header, .bottom-nav, .app-footer, .no-print { display: none !important; }
    body { background: #fff; padding: 0; }
}

.logo-guide { background: var(--brand-soft, #eef6f3); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; font-size: 13px; line-height: 1.9; }
.logo-guide table { width: 100%; border-collapse: collapse; margin: 8px 0; display: block; overflow-x: auto; }
.logo-guide th, .logo-guide td { padding: 5px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.logo-guide ul { margin: 6px 18px 0 0; padding: 0; }
