/* ===== فونت (روی همین سرور میزبانی می‌شود؛ نیازی به اینترنت ندارد) ===== */
@font-face {
    font-family: 'Vazirmatn';
    src: url('fonts/Vazirmatn-Regular.woff2') format('woff2');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('fonts/Vazirmatn-Medium.woff2') format('woff2');
    font-weight: 600;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('fonts/Vazirmatn-Bold.woff2') format('woff2');
    font-weight: 700 900;
    font-display: swap;
}

/* ===== پایه ===== */
:root {
    --bg: #eef2f6;
    --card: #ffffff;
    --ink: #16202c;
    --ink-2: #5b6b7c;
    --line: #dde5ec;
    --brand: #0f766e;
    --brand-2: #0d9488;
    --brand-soft: #e6f5f3;
    --bad: #dc2626;
    --bad-soft: #fdecec;
    --good: #16a34a;
    --good-soft: #e9f7ee;
    --warn: #d97706;
    --warn-soft: #fdf3e3;
    --r: 14px;
    --shadow: 0 1px 2px rgba(16,32,44,.05), 0 6px 18px rgba(16,32,44,.06);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: 'Vazirmatn', "Segoe UI", Tahoma, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.85;
    -webkit-font-smoothing: antialiased;
}

input, select, textarea, button { font-family: inherit; }

a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.6; }
h1 { font-size: 21px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p { margin: 0 0 10px; }

/* ===== نوار بالا ===== */
.topbar {
    position: sticky; top: 0; z-index: 30;
    background: linear-gradient(180deg, var(--brand) 0%, var(--brand-2) 100%);
    color: #fff;
    box-shadow: 0 2px 12px rgba(15,118,110,.25);
}
.topbar-in {
    display: flex; align-items: center; gap: 14px;
    max-width: 1280px; margin: 0 auto; padding: 10px 14px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; white-space: nowrap; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: #bef264; box-shadow: 0 0 0 4px rgba(190,242,100,.25); }

.gsearch { position: relative; flex: 1; max-width: 520px; }
.gsearch svg { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: #7b8b99; }
.gsearch input {
    width: 100%; border: 0; border-radius: 12px; padding: 11px 40px 11px 14px;
    font: inherit; font-size: 14px; background: rgba(255,255,255,.96); color: var(--ink);
}
.gsearch input:focus { outline: 3px solid rgba(255,255,255,.5); }

.topbar-actions { display: flex; align-items: center; gap: 10px; margin-inline-start: auto; }

.menu { position: relative; }
.menu summary {
    list-style: none; cursor: pointer; padding: 8px 14px; border-radius: 12px;
    background: rgba(255,255,255,.16); font-size: 14px; white-space: nowrap;
}
.menu summary::-webkit-details-marker { display: none; }
.menu-box {
    position: absolute; inset-inline-end: 0; top: calc(100% + 8px); min-width: 210px;
    background: #fff; color: var(--ink); border-radius: 12px; box-shadow: var(--shadow);
    padding: 6px; z-index: 40; border: 1px solid var(--line);
}
.menu-box a { display: block; padding: 11px 14px; border-radius: 9px; font-size: 14px; }
.menu-box a:hover { background: var(--brand-soft); }
.menu-box a.danger { color: var(--bad); }

/* ===== چیدمان ===== */
.shell { display: flex; max-width: 1280px; margin: 0 auto; gap: 18px; padding: 0 14px; }
.sidebar { display: none; }
.main { flex: 1; min-width: 0; padding: 18px 0 100px; }
.bare-main { max-width: 420px; margin: 0 auto; padding: 8vh 16px; }

/* ===== منوی پایین (موبایل) ===== */
.bottomnav {
    position: fixed; inset-inline: 0; bottom: 0; z-index: 35;
    display: flex; background: #fff; border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 14px rgba(16,32,44,.07);
}
.bottomnav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 9px 2px 7px; font-size: 11px; color: var(--ink-2);
}
.bottomnav svg { width: 23px; height: 23px; }
.bottomnav a.active { color: var(--brand); font-weight: 700; }
.bottomnav a.primary svg {
    background: var(--brand); color: #fff; border-radius: 50%;
    width: 40px; height: 40px; padding: 9px; margin-top: -18px;
    box-shadow: 0 6px 14px rgba(15,118,110,.4);
}
.bottomnav a.primary { color: var(--brand); font-weight: 700; }

/* ===== کارت‌ها ===== */
.card {
    background: var(--card); border-radius: var(--r); box-shadow: var(--shadow);
    padding: 16px; margin-bottom: 14px; border: 1px solid rgba(221,229,236,.7);
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head .sp { margin-inline-start: auto; }
.card-tight { padding: 0; overflow: hidden; }

.page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head .sp { margin-inline-start: auto; }

/* ===== دکمه‌ها ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: 1px solid var(--line); background: #fff; color: var(--ink);
    padding: 11px 18px; border-radius: 12px; font: inherit; font-size: 14px;
    cursor: pointer; white-space: nowrap; transition: .15s; text-align: center;
}
.btn:hover { background: #f6f9fb; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }
.btn-primary:hover { background: var(--brand-2); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--brand); }
.btn-lg { padding: 15px 24px; font-size: 16px; border-radius: 14px; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn-block { display: flex; width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ===== فرم ===== */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 13.5px; color: var(--ink-2); margin-bottom: 6px; font-weight: 600; }
.field .hint { font-size: 12px; color: var(--ink-2); margin-top: 5px; }
input[type=text], input[type=search], input[type=password], input[type=tel], input[type=number], select, textarea {
    width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px;
    font: inherit; font-size: 15px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { min-height: 90px; resize: vertical; line-height: 1.9; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b6b7c' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 12px center; background-size: 18px; padding-left: 38px; }
.grid { display: grid; gap: 0 14px; grid-template-columns: 1fr; }
.grid-2 { grid-template-columns: 1fr; }
.req::after { content: " *"; color: var(--bad); }

.check-line { display: flex; align-items: center; gap: 9px; padding: 9px 0; }
.check-line input[type=checkbox], .check-line input[type=radio] { width: 20px; height: 20px; accent-color: var(--brand); }
.check-line label { margin: 0; font-size: 14.5px; }

.money-input { font-variant-numeric: tabular-nums; letter-spacing: .3px; font-weight: 700; font-size: 17px !important; }

/* دکمه‌های مبلغ سریع */
.quick-amounts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.quick-amounts button { border: 1px solid var(--line); background: #f8fafc; border-radius: 9px; padding: 5px 10px; font: inherit; font-size: 12.5px; cursor: pointer; color: var(--ink-2); }
.quick-amounts button:hover { background: var(--brand-soft); color: var(--brand); }

/* ===== جدول ===== */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th, table.tbl td { padding: 11px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tbl th { background: #f7fafc; color: var(--ink-2); font-weight: 700; font-size: 13px; position: sticky; top: 0; }
table.tbl tbody tr:hover { background: #fafcfd; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl td.wrap { white-space: normal; min-width: 160px; }
.num { font-variant-numeric: tabular-nums; }

/* ===== لیست موبایل ===== */
.list { display: flex; flex-direction: column; }
.list-item {
    display: flex; align-items: center; gap: 12px; padding: 13px 16px;
    border-bottom: 1px solid var(--line); background: #fff;
}
.list-item:last-child { border-bottom: 0; }
.list-item:active { background: #f6f9fb; }
.li-main { flex: 1; min-width: 0; }
.li-title { font-weight: 700; font-size: 15px; }
.li-sub { font-size: 12.5px; color: var(--ink-2); }
.li-end { text-align: left; font-size: 13.5px; white-space: nowrap; }
.avatar {
    width: 42px; height: 42px; border-radius: 50%; flex: none;
    background: var(--brand-soft); color: var(--brand);
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px;
}

/* ===== نشان‌ها ===== */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.neutral { background: #eef2f6; color: var(--ink-2); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }

.money-bad { color: var(--bad); font-weight: 700; }
.money-good { color: var(--good); font-weight: 700; }

/* ===== آمار ===== */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.stat {
    background: #fff; border-radius: var(--r); padding: 14px; box-shadow: var(--shadow);
    border: 1px solid rgba(221,229,236,.7);
}
.stat .k { font-size: 12.5px; color: var(--ink-2); }
.stat .v { font-size: 20px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .u { font-size: 12px; color: var(--ink-2); font-weight: 400; }
.stat.accent { background: linear-gradient(140deg, var(--brand) 0%, var(--brand-2) 100%); color: #fff; border: 0; }
.stat.accent .k, .stat.accent .u { color: rgba(255,255,255,.85); }

/* ===== اکشن‌های سریع ===== */
.quick-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.quick-tile {
    background: #fff; border-radius: var(--r); padding: 16px 12px; text-align: center;
    box-shadow: var(--shadow); border: 1px solid rgba(221,229,236,.7); font-weight: 700; font-size: 14.5px;
}
.quick-tile .ic { font-size: 26px; display: block; margin-bottom: 4px; }
.quick-tile:active { transform: scale(.98); }

/* ===== پیام‌ها ===== */
.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 14px; font-size: 14.5px; font-weight: 600; }
.flash-ok { background: var(--good-soft); color: #14532d; }
.flash-err { background: var(--bad-soft); color: #991b1b; }
.flash-warn { background: var(--warn-soft); color: #92400e; }

.empty { text-align: center; padding: 40px 20px; color: var(--ink-2); }
.empty .ic { font-size: 44px; display: block; margin-bottom: 8px; opacity: .5; }

/* ===== ردیف‌های فاکتور ===== */
.rows { display: flex; flex-direction: column; gap: 10px; }
.row-item { border: 1.5px solid var(--line); border-radius: 12px; padding: 12px; background: #fcfdfe; }
.row-item .r1 { display: flex; gap: 8px; align-items: flex-start; }
.row-item .r2 { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.row-item input, .row-item select { padding: 10px 12px; font-size: 14px; }
.row-del { border: 0; background: var(--bad-soft); color: var(--bad); border-radius: 10px; width: 40px; flex: none; font-size: 18px; cursor: pointer; }
.row-amount { margin-inline-start: auto; font-weight: 700; font-size: 14px; white-space: nowrap; }

.totals { border-top: 2px dashed var(--line); margin-top: 14px; padding-top: 12px; }
.totals .t-line { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14.5px; }
.totals .t-line.big { font-size: 18px; font-weight: 800; color: var(--brand); }

/* ===== نوار ابزار / فیلتر ===== */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
    padding: 8px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line);
    font-size: 13.5px; color: var(--ink-2);
}
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }

/* ===== سایر ===== */
.hide-sm { display: none; }
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.mt { margin-top: 14px; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.sticky-actions {
    position: sticky; bottom: 74px; background: rgba(255,255,255,.97); backdrop-filter: blur(6px);
    padding: 12px; border-radius: 14px; box-shadow: var(--shadow); border: 1px solid var(--line);
    display: flex; gap: 10px; z-index: 20;
}
.plate {
    display: inline-flex; align-items: center; gap: 5px; direction: ltr;
    background: #fff; border: 2px solid #2b3a48; border-radius: 6px; padding: 1px 4px;
    font-weight: 700; font-size: 13.5px; letter-spacing: .5px; white-space: nowrap;
}
.plate .ir { background: #1d4ed8; color: #fff; border-radius: 3px; padding: 1px 4px; font-size: 10px; }
.plate .prov { background: #eef2f6; border-radius: 3px; padding: 1px 5px; font-size: 11px; color: #334155; }

/* ===== دسکتاپ ===== */
@media (min-width: 860px) {
    body { font-size: 15px; }
    .hide-sm { display: inline-flex; }
    .bottomnav { display: none; }
    .main { padding: 22px 0 40px; }
    .sidebar {
        display: block; width: 210px; flex: none; padding: 22px 0;
        position: sticky; top: 62px; align-self: flex-start; max-height: calc(100vh - 70px); overflow: auto;
    }
    .side-link {
        display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 12px;
        color: var(--ink-2); font-size: 14.5px; margin-bottom: 3px;
    }
    .side-link svg { width: 20px; height: 20px; }
    .side-link:hover { background: #e4ebf1; color: var(--ink); }
    .side-link.active { background: var(--brand); color: #fff; font-weight: 700; box-shadow: 0 4px 12px rgba(15,118,110,.28); }
    .stats { grid-template-columns: repeat(4, 1fr); }
    .quick-grid { grid-template-columns: repeat(4, 1fr); }
    .grid-2 { grid-template-columns: 1fr 1fr; }
    .sticky-actions { position: static; box-shadow: none; border: 0; background: none; padding: 0; margin-top: 16px; }
    .row-item .r1 { flex-wrap: nowrap; }
}

@media (max-width: 859px) {
    .brand span:not(.brand-dot) { display: none; }
    .topbar-in { gap: 10px; padding: 9px 12px; }
    .menu summary { padding: 8px 10px; }
    .menu summary { font-size: 0; }
    .menu summary::before { content: "☰"; font-size: 18px; }
}

/* ===== نوار ورود مدیر سامانه به پنل تعمیرگاه ===== */
.impersonate-bar {
    background: #78350f; color: #fde68a; text-align: center;
    padding: 8px 14px; font-size: 13px; font-weight: 600;
    position: sticky; top: 0; z-index: 50;
}
.impersonate-bar a { color: #fff; text-decoration: underline; margin-inline-start: 8px; }
.impersonate-bar + .topbar { top: 36px; }

/* ===== تقویم شمسی ===== */
.jpop {
    position: absolute; z-index: 100; width: 288px; background: #fff;
    border-radius: 14px; box-shadow: 0 10px 40px rgba(16,32,44,.22); border: 1px solid var(--line);
    padding: 10px; user-select: none;
}
.jhead { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.jtitle { display: flex; gap: 6px; flex: 1; }
.jtitle select { padding: 6px 8px; font-size: 13px; border-radius: 9px; padding-left: 26px; background-position: left 6px center; background-size: 15px; }
.jnav { border: 1px solid var(--line); background: #f7fafc; border-radius: 9px; width: 32px; height: 32px; font-size: 18px; cursor: pointer; color: var(--ink-2); flex: none; }
.jnav:hover { background: var(--brand-soft); color: var(--brand); }
.jweek { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 11.5px; color: var(--ink-2); margin-bottom: 4px; }
.jgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.jd { border: 0; background: none; border-radius: 9px; height: 34px; font: inherit; font-size: 13.5px; cursor: pointer; color: var(--ink); }
.jd:hover { background: var(--brand-soft); }
.jd.today { border: 1.5px solid var(--brand); color: var(--brand); font-weight: 700; }
.jd.sel { background: var(--brand); color: #fff; font-weight: 700; }
.jd.empty { pointer-events: none; }
.jfoot { display: flex; gap: 8px; margin-top: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.jfoot button { flex: 1; border: 1px solid var(--line); background: #f7fafc; border-radius: 9px; padding: 7px; font: inherit; font-size: 12.5px; cursor: pointer; color: var(--ink-2); }
.jfoot button:hover { background: var(--brand-soft); color: var(--brand); }

/* ===== انتخاب مشتری ===== */
.cpick { position: relative; }
.cpick-list {
    display: none; position: absolute; inset-inline: 0; top: calc(100% + 4px); z-index: 60;
    background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
    max-height: 280px; overflow: auto; padding: 5px;
}
.cpick-list button {
    display: block; width: 100%; text-align: right; border: 0; background: none;
    padding: 10px 12px; border-radius: 9px; font: inherit; cursor: pointer;
}
.cpick-list button:hover { background: var(--brand-soft); }
.cpick-list button b { display: block; font-size: 14.5px; }
.cpick-list button small { color: var(--ink-2); font-size: 12px; }
.cpick-none { padding: 14px; font-size: 13.5px; color: var(--ink-2); text-align: center; }
.cpick-none a { color: var(--brand); font-weight: 700; }

/* ===== چاپ ===== */
@media print {
    .topbar, .bottomnav, .sidebar, .btn-row, .sticky-actions, .no-print { display: none !important; }
    body { background: #fff; }
    .card { box-shadow: none; border: 1px solid #ccc; }
    .shell { padding: 0; }
}
