:root {
    --blue: #174ea6;
    --blue-2: #2563eb;
    --blue-3: #eaf1ff;
    --orange: #f97316;
    --bg: #f4f7fb;
    --card: #fff;
    --text: #111827;
    --muted: #6b7280;
    --line: #e5e7eb;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --sidebar: #0f2d5c;
    --shadow: 0 18px 45px rgba(17,24,39,.08);
    --shadow-soft: 0 10px 28px rgba(17,24,39,.07);
    --radius: 22px;
    --radius-sm: 14px;
    --sidebar-w: 280px;
    --topbar-h: 92px;
}

* {
    box-sizing: border-box
}

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

body {
    margin: 0;
    font-family: Tahoma,Arial,"Segoe UI",sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.8;
    overflow-x: hidden
}

body.no-scroll {
    overflow: hidden
}

a {
    color: inherit;
    text-decoration: none
}

button,input,select,textarea {
    font: inherit
}

button {
    touch-action: manipulation
}

img,svg,canvas {
    max-width: 100%
}

.svg-defs {
    display: none
}

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0,1fr);
    min-height: 100vh;
    width: 100%;
    max-width: 100vw
}

.app-main {
    min-width: 0;
    width: 100%
}

.content-wrap {
    padding: 28px;
    display: grid;
    gap: 24px;
    min-width: 0;
    width: 100%
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: var(--sidebar);
    color: #fff;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    z-index: 40;
    overflow-y: auto;
    overscroll-behavior: contain
}

.sidebar::-webkit-scrollbar {
    width: 6px
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.22);
    border-radius: 20px
}

.brand-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 18px;
    background: rgba(255,255,255,.08);
    justify-content: center;
}

.brand-mark {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 16px;
    background: linear-gradient(135deg,var(--blue-2),var(--orange));
    display: grid;
    place-items: center;
    font-weight: 900;
    font-size: 22px
}

.brand-box strong {
    display: block;
    font-size: 16px;
    line-height: 1.5
}

.brand-box span {
    display: block;
    color: #cbd5e1;
    font-size: 12px
}

.sidebar-nav {
    display: grid;
    gap: 8px
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 16px;
    color: #e5edf9;
    transition: .2s;
    min-height: 48px
}

.nav-item svg,.logout-btn svg,.btn svg,.icon-button svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    flex: none
}

.nav-item:hover,.nav-item.active {
    background: rgba(255,255,255,.13);
    color: #fff
}

.nav-item.active {
    box-shadow: inset -3px 0 0 var(--orange)
}

.sidebar-footer {
    margin-top: auto;
    display: grid;
    gap: 12px
}

.user-chip {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 12px;
    border-radius: 18px;
    background: rgba(255,255,255,.08);
    min-width: 0
}

.avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 14px;
    background: #fff;
    color: var(--blue);
    display: grid;
    place-items: center;
    font-weight: 800
}

.user-chip div {
    min-width: 0
}

.user-chip b,.user-chip small {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.user-chip small {
    color: #cbd5e1
}

.logout-btn {
    width: 100%;
    border: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #fff;
    background: rgba(249,115,22,.22);
    border-radius: 16px;
    padding: 12px;
    min-height: 46px
}

.sidebar-close {
    position: absolute;
    left: 14px;
    top: 14px;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 14px;
    background: rgba(255,255,255,.12);
    color: #fff;
    font-size: 25px;
    line-height: 1;
    cursor: pointer;
    display: grid;
    place-items: center
}

.mobile-backdrop {
    display: none
}

.hide-desktop {
    display: none!important
}

.topbar {
    min-height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 20px 28px;
    background: rgba(244,247,251,.88);
    backdrop-filter: blur(14px);
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid rgba(229,231,235,.75);
    min-width: 0
}

.page-meta {
    min-width: 0;
    flex: 1
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
    flex-wrap: wrap
}

.breadcrumb a {
    color: var(--blue)
}

.page-meta h1 {
    margin: 2px 0 0;
    font-size: 24px;
    letter-spacing: -.5px;
    line-height: 1.45;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.top-actions,.page-actions,.export-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    min-width: 0
}

.top-actions {
    justify-content: flex-end
}

.icon-button {
    border: 0;
    background: #fff;
    border-radius: 14px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    display: grid;
    place-items: center;
    color: var(--blue);
    box-shadow: var(--shadow-soft);
    cursor: pointer
}

.btn {
    border: 0;
    border-radius: 14px;
    padding: 10px 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 700;
    transition: .2s;
    white-space: nowrap;
    min-height: 42px;
    text-align: center
}

.btn-primary {
    background: var(--blue-2);
    color: #fff;
    box-shadow: 0 12px 22px rgba(37,99,235,.25)
}

.btn-primary:hover {
    transform: translateY(-1px);
    background: var(--blue)
}

.btn-soft {
    background: #fff;
    color: var(--blue);
    border: 1px solid var(--line)
}

.btn-block {
    width: 100%
}

.panel-card,.stat-card,.detail-hero {
    background: var(--card);
    border: 1px solid rgba(229,231,235,.8);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 0
}

.panel-card {
    padding: 22px;
    overflow: hidden
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    min-width: 0
}

.card-head h2,.panel-card h2 {
    margin: 0;
    font-size: 18px;
    line-height: 1.5
}

.card-head a {
    color: var(--blue);
    font-weight: 700;
    white-space: nowrap
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4,minmax(0,1fr));
    gap: 18px;
    min-width: 0
}

.stats-grid.compact {
    grid-template-columns: repeat(auto-fit,minmax(190px,1fr))
}

.stat-card {
    padding: 22px;
    position: relative;
    overflow: hidden;
    min-height: 130px
}

.stat-card:before {
    content: "";
    position: absolute;
    inset: auto -40px -55px auto;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: var(--blue-3)
}

.stat-card.accent:before {
    background: #fff1e8
}

.stat-card span {
    color: var(--muted);
    font-weight: 700;
    position: relative;
}

.stat-card strong {
    display: block;
    font-size: 28px;
    margin-top: 8px;
    letter-spacing: -1px;
    line-height: 1.35;
    word-break: break-word;
    position: relative;
}

.stat-card small {
    color: var(--muted);
    position: relative;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2,minmax(0,1fr));
    gap: 20px;
    min-width: 0
}

.grid-2 .wide {
    grid-column: 1/-1
}

.chart {
    width: 100%;
    height: 280px;
    display: block
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: #fff;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    position: relative
}

.table-wrap:focus-within {
    box-shadow: 0 0 0 4px rgba(37,99,235,.07)
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    min-width: 760px
}

th,td {
    text-align: right;
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle
}

th {
    background: #f8fafc;
    color: #475569;
    font-size: 13px;
    white-space: nowrap
}

td {
    word-break: break-word
}

tbody tr:hover {
    background: #f9fbff
}

tbody tr:last-child td {
    border-bottom: 0
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 74px;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap
}

.status-approved {
    background: #dcfce7;
    color: #166534
}

.status-rejected {
    background: #fee2e2;
    color: #991b1b
}

.status-pending,.status-sent {
    background: #e0f2fe;
    color: #075985
}

.status-draft {
    background: #f1f5f9;
    color: #475569
}

.status-in_progress {
    background: #fef3c7;
    color: #92400e
}

.status-answered {
    background: #ede9fe;
    color: #5b21b6
}

.status-closed {
    background: #e5e7eb;
    color: #374151
}

.priority-low {
    background: #f1f5f9;
    color: #475569
}

.priority-normal {
    background: #e0f2fe;
    color: #075985
}

.priority-high {
    background: #ffedd5;
    color: #9a3412
}

.priority-urgent {
    background: #fee2e2;
    color: #991b1b
}

.actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    min-width: 160px
}

.actions a,.actions button {
    border: 0;
    background: #f1f5f9;
    color: #174ea6;
    border-radius: 10px;
    padding: 7px 10px;
    cursor: pointer;
    font-weight: 700
}

.actions form {
    display: inline-flex
}

.page-actions {
    justify-content: space-between
}

.filter-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    flex: 1;
    min-width: 260px
}

.filter-form input,.filter-form select,.form-control {
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 14px;
    padding: 11px 13px;
    outline: none;
    color: var(--text);
    transition: .2s;
    min-height: 44px
}

.filter-form input {
    max-width: 280px
}

.filter-form select {
    max-width: 190px
}

.form-control:focus,.filter-form input:focus,.filter-form select:focus {
    border-color: var(--blue-2);
    box-shadow: 0 0 0 4px rgba(37,99,235,.09)
}

textarea.form-control {
    resize: vertical;
    min-height: 120px
}

.form-card {
    max-width: 980px;
    width: 100%
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2,minmax(0,1fr));
    gap: 16px
}

.form-grid .form-group:has(textarea),.form-grid .form-group:has(.tall-select) {
    grid-column: 1/-1
}

.compact-grid {
    grid-template-columns: repeat(4,minmax(0,1fr))
}

.form-group {
    display: grid;
    gap: 7px;
    min-width: 0
}

.form-group label {
    font-weight: 800;
    color: #374151
}

.required,.field-error {
    color: var(--danger)
}

.help-text {
    color: var(--muted)
}

.has-error .form-control {
    border-color: var(--danger)
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap
}

.filter-panel {
    margin-bottom: 18px
}

.note-box {
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    color: #475569;
    border-radius: 16px;
    padding: 12px 14px;
    margin-top: 14px
}

.messages {
    display: grid;
    gap: 10px
}

.alert {
    border-radius: 16px;
    padding: 12px 14px;
    font-weight: 700;
    border: 1px solid transparent
}

.alert-success {
    background: #ecfdf5;
    color: #047857;
    border-color: #a7f3d0
}

.alert-error {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fecaca
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border-color: #fde68a
}

.alert-info {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #bfdbfe
}

.empty-state {
    text-align: center;
    padding: 34px;
    color: var(--muted)
}

.empty-state h3,.empty-state h2 {
    margin: 8px 0;
    color: var(--text)
}

.empty-icon {
    width: 64px;
    height: 64px;
    border-radius: 24px;
    background: var(--blue-3);
    color: var(--blue);
    font-size: 30px;
    display: grid;
    place-items: center;
    margin: 0 auto 10px
}

.pagination-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 18px;
    flex-wrap: wrap
}

.page-btn {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 8px 14px;
    color: var(--blue);
    font-weight: 700
}

.page-info {
    color: var(--muted)
}

.segmented {
    display: flex;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 4px;
    gap: 4px;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch
}

.segmented a {
    padding: 8px 12px;
    border-radius: 12px;
    color: var(--muted);
    font-weight: 800;
    white-space: nowrap
}

.segmented a.active {
    background: var(--blue-3);
    color: var(--blue)
}

.detail-hero {
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px
}

.detail-hero>div {
    min-width: 0
}

.detail-hero h2 {
    font-size: 24px;
    margin: 0 0 6px;
    line-height: 1.45;
    word-break: break-word
}

.detail-hero p {
    margin: 0;
    color: var(--muted);
    word-break: break-word
}

.hero-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap
}

.detail-list {
    display: grid;
    grid-template-columns: 150px minmax(0,1fr);
    gap: 12px;
    margin: 0
}

.detail-list dt {
    color: var(--muted);
    font-weight: 800
}

.detail-list dd {
    margin: 0;
    font-weight: 700;
    min-width: 0;
    word-break: break-word
}

.attachment-list {
    display: grid;
    gap: 10px
}

.attachment-list a {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 11px 13px;
    color: var(--blue);
    font-weight: 700;
    min-width: 0
}

.attachment-list a small {
    color: var(--muted);
    white-space: nowrap
}

.attachment-list.mini {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap
}

.attachment-list.mini a {
    display: inline-flex;
    margin-left: 6px
}

.timeline {
    display: grid;
    gap: 14px
}

.timeline-item {
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 16px;
    background: #fcfdff;
    min-width: 0
}

.timeline-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 13px
}

.timeline-item p {
    margin: 10px 0 0;
    word-break: break-word
}

.inline-status {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap
}

.inline-status select {
    flex: 1;
    min-width: 180px
}

.tall-select {
    min-height: 140px
}

.muted {
    color: var(--muted)
}

.small {
    font-size: 12px
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at 80% 10%,#dbeafe 0,#f4f7fb 35%,#fff 100%);
    padding: 20px
}

.login-card {
    width: min(460px,100%);
    background: #fff;
    border-radius: 28px;
    box-shadow: var(--shadow);
    padding: 30px;
    border: 1px solid var(--line)
}

.login-brand {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 24px;
    justify-content: center;
}

.login-brand span {
    width: 58px;
    height: 58px;
    min-width: 58px;
    border-radius: 20px;
    background: linear-gradient(135deg,var(--blue-2),var(--orange));
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 26px;
    font-weight: 900
}

.login-brand h1 {
    font-size: 20px;
    margin: 0
}

.login-brand p {
    margin: 0;
    color: var(--muted)
}

.auth-form {
    display: grid;
    gap: 14px
}

.auth-form label {
    display: grid;
    gap: 8px;
    font-weight: 800
}

.auth-form input {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 14px;
    min-height: 46px
}

.js-jalali-date {
    text-align: center;
    direction: ltr
}

.jalali-picker {
    position: absolute;
    z-index: 9999;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: 0 25px 60px rgba(15,23,42,.18);
    padding: 12px;
    direction: rtl
}

.jalali-picker[hidden] {
    display: none!important
}

.jp-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px
}

.jp-head button,.jp-foot button {
    border: 0;
    border-radius: 12px;
    background: #eff6ff;
    color: var(--blue);
    font-weight: 900;
    cursor: pointer;
    padding: 8px 12px
}

.jp-week,.jp-days {
    display: grid;
    grid-template-columns: repeat(7,1fr);
    gap: 6px;
    text-align: center
}

.jp-week span {
    font-size: 12px;
    color: var(--muted);
    font-weight: 800
}

.jp-days button {
    height: 36px;
    border: 0;
    border-radius: 12px;
    background: #f8fafc;
    color: var(--text);
    cursor: pointer
}

.jp-days button:hover,.jp-days button.selected {
    background: var(--blue-2);
    color: #fff
}

.jp-days button.today {
    box-shadow: inset 0 0 0 2px var(--orange)
}

.jp-foot {
    display: flex;
    gap: 8px;
    margin-top: 10px
}

.jp-foot button {
    flex: 1
}

@media (max-width: 1180px) {
    :root {
        --sidebar-w:244px
    }

    .sidebar {
        padding: 16px
    }

    .stats-grid {
        grid-template-columns: repeat(2,minmax(0,1fr))
    }

    .compact-grid {
        grid-template-columns: repeat(2,minmax(0,1fr))
    }

    .topbar {
        padding: 18px 22px
    }

    .content-wrap {
        padding: 22px
    }

    .grid-2 {
        gap: 18px
    }
}

@media (max-width: 1024px) {
    .hide-desktop {
        display:grid!important
    }

    .app-shell {
        display: block;
        min-height: 100vh
    }

    .app-main {
        width: 100%
    }

    .sidebar {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        width: min(320px,86vw);
        height: 100dvh;
        transform: translateX(110%);
        transition: transform .25s ease;
        padding: 18px;
        box-shadow: -24px 0 70px rgba(15,23,42,.28);
        z-index: 60
    }

    .brand-box {
        padding-left: 54px
    }

    .app-shell.sidebar-open .sidebar {
        transform: translateX(0)
    }

    .app-shell.sidebar-open + .mobile-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15,23,42,.42);
        z-index: 50;
        backdrop-filter: blur(2px)
    }

    .topbar {
        display: grid;
        grid-template-columns: 44px minmax(0,1fr);
        align-items: start;
        gap: 12px;
        min-height: auto
    }

    .topbar .top-actions {
        grid-column: 1/-1;
        justify-content: flex-start;
        width: 100%;
        padding-top: 4px
    }

    .page-meta h1 {
        font-size: 21px
    }

    .breadcrumb {
        font-size: 12px
    }

    .content-wrap {
        gap: 20px
    }

    .filter-form {
        display: grid;
        grid-template-columns: repeat(2,minmax(0,1fr));
        width: 100%;
        flex-basis: 100%
    }

    .filter-form input,.filter-form select,.filter-form .btn {
        max-width: none;
        width: 100%
    }

    .page-actions {
        display: grid;
        grid-template-columns: 1fr;
        align-items: stretch
    }

    .page-actions>.btn,.page-actions>.segmented,.page-actions>.export-actions {
        width: 100%
    }

    .export-actions {
        justify-content: flex-start
    }

    .panel-card {
        padding: 18px
    }

    .chart {
        height: 250px
    }
}

@media (max-width: 760px) {
    body {
        font-size:13.5px
    }

    .content-wrap {
        padding: 16px;
        gap: 16px
    }

    .topbar {
        padding: 14px 16px;
        background: #f8fafc
    }

    .page-meta h1 {
        font-size: 19px;
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical
    }

    .breadcrumb {
        display: none
    }

    .stats-grid,.stats-grid.compact {
        grid-template-columns: 1fr
    }

    .grid-2 {
        grid-template-columns: 1fr
    }

    .detail-hero {
        align-items: stretch;
        flex-direction: column;
        padding: 18px
    }

    .detail-hero h2 {
        font-size: 20px
    }

    .detail-list {
        grid-template-columns: 1fr;
        gap: 4px
    }

    .detail-list dt {
        margin-top: 10px
    }

    .form-grid,.compact-grid {
        grid-template-columns: 1fr!important
    }

    .form-grid .form-group:has(textarea),.form-grid .form-group:has(.tall-select) {
        grid-column: auto
    }

    .form-actions {
        justify-content: stretch
    }

    .form-actions .btn,.form-actions button,.form-actions a {
        flex: 1 1 160px
    }

    .filter-form {
        grid-template-columns: 1fr
    }

    .top-actions .btn {
        flex: 1
    }

    .table-wrap {
        border-radius: 16px;
        margin-inline:0}

    .table-wrap:after {
        content: "برای مشاهده همه ستون‌ها جدول را افقی بکشید";
        display: block;
        padding: 8px 12px;
        color: var(--muted);
        font-size: 12px;
        background: #fff;
        border-top: 1px solid var(--line)
    }

    table {
        min-width: 700px
    }

    th,td {
        padding: 11px 12px
    }

    .actions {
        min-width: 180px
    }

    .attachment-list a {
        flex-direction: column;
        align-items: flex-start
    }

    .timeline-meta {
        flex-direction: column;
        gap: 2px
    }

    .inline-status {
        display: grid;
        grid-template-columns: 1fr
    }

    .inline-status select,.inline-status .btn {
        width: 100%
    }

    .segmented {
        width: 100%
    }

    .segmented a {
        flex: 1;
        text-align: center
    }

    .jalali-picker {
        position: fixed!important;
        left: 12px!important;
        right: 12px!important;
        top: auto!important;
        bottom: 12px!important;
        width: auto!important;
        max-height: 72vh;
        overflow: auto
    }

    .jp-days button {
        height: 40px
    }
}

@media (max-width: 520px) {
    .table-wrap.mobile-cards {
        border:0;
        background: transparent;
        overflow: visible;
        border-radius: 0
    }

    .table-wrap.mobile-cards:after {
        display: none
    }

    .table-wrap.mobile-cards table.has-card-mobile {
        min-width: 0;
        width: 100%;
        display: block;
        background: transparent
    }

    .table-wrap.mobile-cards table.has-card-mobile thead {
        display: none
    }

    .table-wrap.mobile-cards table.has-card-mobile tbody {
        display: grid;
        gap: 12px
    }

    .table-wrap.mobile-cards table.has-card-mobile tr {
        display: grid;
        background: #fff;
        border: 1px solid var(--line);
        border-radius: 18px;
        padding: 10px;
        box-shadow: var(--shadow-soft)
    }

    .table-wrap.mobile-cards table.has-card-mobile td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 16px;
        border-bottom: 1px solid #eef2f7;
        padding: 10px 6px;
        text-align: left;
        word-break: break-word
    }

    .table-wrap.mobile-cards table.has-card-mobile td:before {
        content: attr(data-label);
        font-weight: 800;
        color: #64748b;
        text-align: right;
        min-width: 94px
    }

    .table-wrap.mobile-cards table.has-card-mobile td:last-child {
        border-bottom: 0
    }

    .table-wrap.mobile-cards table.has-card-mobile td.actions {
        display: grid;
        grid-template-columns: 1fr;
        min-width: 0
    }

    .table-wrap.mobile-cards table.has-card-mobile td.actions:before {
        display: none
    }

    .table-wrap.mobile-cards table.has-card-mobile td.actions a,.table-wrap.mobile-cards table.has-card-mobile td.actions button,.table-wrap.mobile-cards table.has-card-mobile td.actions form {
        width: 100%
    }

    .content-wrap {
        padding: 12px
    }

    .topbar {
        padding: 12px;
        grid-template-columns: 42px minmax(0,1fr)
    }

    .icon-button {
        width: 42px;
        height: 42px;
        min-width: 42px
    }

    .panel-card,.stat-card,.detail-hero {
        border-radius: 18px
    }

    .panel-card {
        padding: 14px
    }

    .stat-card {
        padding: 16px;
        min-height: 112px
    }

    .stat-card strong {
        font-size: 24px
    }

    .btn {
        width: 100%;
        padding-inline:12px}

    .top-actions {
        display: grid;
        grid-template-columns: 1fr
    }

    .page-actions>.btn {
        width: 100%
    }

    .actions {
        display: grid;
        grid-template-columns: repeat(2,minmax(0,1fr));
        min-width: 220px
    }

    .actions a,.actions button {
        width: 100%;
        text-align: center
    }

    .export-actions {
        display: grid;
        grid-template-columns: repeat(2,minmax(0,1fr))
    }

    .export-actions .btn {
        width: 100%
    }

    .pagination-wrap {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px
    }

    .page-btn,.page-info {
        text-align: center
    }

    .login-page {
        padding: 12px
    }

    .login-card {
        padding: 22px;
        border-radius: 22px
    }

    .login-brand {
        align-items: flex-start
    }

    .login-brand h1 {
        font-size: 18px
    }

    .chart {
        height: 220px
    }

    table {
        min-width: 660px
    }

    .empty-state {
        padding: 24px 14px
    }

    .jalali-picker {
        border-radius: 20px 20px 0 0;
        left: 0!important;
        right: 0!important;
        bottom: 0!important
    }

    .jp-days {
        gap: 5px
    }

    .jp-days button {
        height: 38px
    }
}

@media print {
    .sidebar,.topbar,.page-actions,.form-actions,.mobile-backdrop {
        display: none!important
    }

    .app-shell {
        display: block
    }

    .content-wrap {
        padding: 0
    }

    .panel-card,.stat-card,.detail-hero {
        box-shadow: none
    }

    .table-wrap {
        overflow: visible
    }

    table {
        min-width: 0
    }
}

/* Unit extended profile additions */
.profile-grid {
    display: grid;
    grid-template-columns: repeat(2,minmax(0,1fr));
    gap: 20px;
    min-width: 0;
}
.unit-profile-hero .top-actions { justify-content: flex-end; }
.profile-card { display: grid; gap: 16px; }
.profile-photo-row {
    display: grid;
    grid-template-columns: repeat(2,minmax(0,1fr));
    gap: 14px;
}
.photo-box {
    min-height: 180px;
    border: 1px dashed #cbd5e1;
    border-radius: 18px;
    background: #f8fafc;
    display: grid;
    place-items: center;
    overflow: hidden;
    color: var(--muted);
    font-weight: 700;
}
.photo-box img,
.gallery-grid img,
.compact-gallery img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.info-list {
    display: grid;
    gap: 10px;
    margin: 0;
}
.info-list div {
    display: grid;
    grid-template-columns: 150px minmax(0,1fr);
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}
.info-list div:last-child { border-bottom: 0; }
.info-list dt {
    color: var(--muted);
    font-weight: 800;
}
.info-list dd {
    margin: 0;
    min-width: 0;
    word-break: break-word;
}
.compact-info {
    grid-template-columns: repeat(2,minmax(0,1fr));
    display: grid;
    gap: 8px 18px;
}
.compact-info div { grid-template-columns: 130px minmax(0,1fr); }
.section-inline-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 8px 0 10px;
}
.section-inline-head h3 { margin: 0; font-size: 15px; }
.mini-add,
.program-head a {
    color: var(--blue);
    font-weight: 800;
    white-space: nowrap;
}
.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.tag-list span {
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--blue-3);
    color: var(--blue);
    font-weight: 800;
}
.item-list {
    display: grid;
    gap: 10px;
}
.item-row {
    display: grid;
    gap: 4px;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
}
.item-row span,
.muted-text {
    color: var(--muted);
}
.two-list {
    display: grid;
    grid-template-columns: repeat(2,minmax(0,1fr));
    gap: 18px;
}
.two-list ol {
    margin: 0;
    padding: 0 22px 0 0;
}
.two-list li { margin-bottom: 8px; }
.facility-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit,minmax(210px,1fr));
    gap: 12px;
}
.facility-card {
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 14px;
    background: #fff;
    display: grid;
    gap: 5px;
    min-height: 116px;
}
.facility-card.has {
    border-color: rgba(22,163,74,.3);
    background: #f0fdf4;
}
.facility-card strong { font-size: 15px; }
.facility-card span {
    width: fit-content;
    padding: 3px 10px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #475569;
    font-size: 12px;
    font-weight: 800;
}
.facility-card.has span {
    background: #dcfce7;
    color: #166534;
}
.facility-card small,
.facility-card em {
    color: var(--muted);
    font-style: normal;
    word-break: break-word;
}
.facility-card a { color: var(--blue); font-weight: 800; }
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill,minmax(170px,1fr));
    gap: 14px;
}
.gallery-grid figure {
    margin: 0;
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: #fff;
}
.gallery-grid figure img { aspect-ratio: 4/3; }
.gallery-grid figcaption {
    padding: 9px 10px;
    font-size: 12px;
    color: var(--muted);
}
.program-list { display: grid; gap: 16px; }
.program-card {
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 16px;
    background: #fff;
    display: grid;
    gap: 12px;
}
.program-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.program-head h3 { margin: 0; font-size: 17px; }
.compact-gallery { grid-template-columns: repeat(auto-fill,minmax(130px,1fr)); }
.file-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.file-list a {
    padding: 8px 12px;
    border-radius: 12px;
    background: var(--blue-3);
    color: var(--blue);
    font-weight: 800;
}

@media (max-width: 900px) {
    .profile-grid,
    .two-list,
    .compact-info {
        grid-template-columns: 1fr;
    }
    .unit-profile-hero {
        display: grid;
        gap: 14px;
    }
    .unit-profile-hero .top-actions,
    .program-head {
        justify-content: stretch;
        align-items: stretch;
        flex-direction: column;
    }
    .unit-profile-hero .top-actions .btn {
        width: 100%;
    }
}

@media (max-width: 560px) {
    .profile-photo-row,
    .info-list div,
    .compact-info div {
        grid-template-columns: 1fr;
    }
    .photo-box { min-height: 150px; }
    .gallery-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .facility-grid { grid-template-columns: 1fr; }
    .section-inline-head {
        align-items: stretch;
        flex-direction: column;
    }
}

/* Panel update: sidebar profile, visible password, members and local map */
.sidebar-profile-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 20px;
    background: rgba(255,255,255,.10);
    border: 1px solid rgba(255,255,255,.10);
}
.sidebar-profile-photo {
    width: 58px;
    height: 58px;
    min-width: 58px;
    border-radius: 20px;
    overflow: hidden;
    background: #fff;
    color: var(--blue);
    display: grid;
    place-items: center;
    font-weight: 900;
    font-size: 24px;
    box-shadow: 0 10px 24px rgba(0,0,0,.15);
}
.sidebar-profile-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.sidebar-profile-info {
    min-width: 0;
    display: grid;
    gap: 2px;
}
.sidebar-profile-info strong,
.sidebar-profile-info small,
.sidebar-profile-info em {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar-profile-info strong {font-size: 14px;color: #fff;}
.sidebar-profile-info small {color: #dbeafe;font-style: normal;}
.sidebar-profile-info em {color: #fed7aa;font-style: normal;font-size: 12px;}
.password-code,
.password-current-box code {
    direction: ltr;
    unicode-bidi: plaintext;
    display: inline-block;
    padding: 5px 9px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid var(--line);
    color: #111827;
    font-family: Consolas, Monaco, monospace;
    font-size: 13px;
}
.password-current-box {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.map-shell {
    overflow: hidden;
}
.map-picker-card {
    margin-top: 20px;
    background: #f8fafc;
    border: 1px solid var(--line);
    padding: 18px;
    border-radius: var(--radius);
}
.local-map {
    position: relative;
    min-height: 430px;
    border-radius: 24px;
    overflow: hidden;
    border: 1px solid #dbeafe;
    background:
        radial-gradient(circle at 24% 58%, rgba(249,115,22,.20) 0 3%, transparent 3.3%),
        radial-gradient(circle at 43% 40%, rgba(37,99,235,.16) 0 2.5%, transparent 2.8%),
        radial-gradient(circle at 62% 55%, rgba(22,163,74,.14) 0 3%, transparent 3.2%),
        linear-gradient(135deg, rgba(219,234,254,.95), rgba(240,253,244,.88));
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.55);
    cursor: crosshair;
}
.local-map:before,
.local-map:after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.local-map:before {
    background-image:
        linear-gradient(rgba(23,78,166,.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(23,78,166,.08) 1px, transparent 1px);
    background-size: 8.333% 12.5%;
}
.local-map:after {
    background:
        linear-gradient(115deg, transparent 0 18%, rgba(255,255,255,.55) 18.2% 21%, transparent 21.2% 100%),
        linear-gradient(35deg, transparent 0 44%, rgba(15,45,92,.08) 44.2% 46%, transparent 46.2% 100%);
}
.map-axis {
    position: absolute;
    z-index: 2;
    color: #174ea6;
    background: rgba(255,255,255,.78);
    border: 1px solid rgba(23,78,166,.12);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    pointer-events: none;
}
.map-axis.north {top: 12px;left: 50%;transform: translateX(-50%);}
.map-axis.south {bottom: 12px;left: 50%;transform: translateX(-50%);}
.map-axis.west {right: 12px;top: 50%;transform: translateY(-50%);}
.map-axis.east {left: 12px;top: 50%;transform: translateY(-50%);}
.map-pin {
    position: absolute;
    z-index: 5;
    transform: translate(-50%, -100%);
    border: 0;
    background: transparent;
    cursor: pointer;
    min-width: 30px;
    min-height: 42px;
}
.map-pin:before {
    content: "";
    display: block;
    width: 28px;
    height: 28px;
    border-radius: 50% 50% 50% 0;
    background: var(--orange);
    transform: rotate(-45deg);
    box-shadow: 0 10px 22px rgba(249,115,22,.35);
    border: 3px solid #fff;
}
.map-pin:after {
    content: "";
    position: absolute;
    right: 50%;
    bottom: -2px;
    width: 18px;
    height: 6px;
    border-radius: 50%;
    background: rgba(15,45,92,.18);
    transform: translateX(50%);
}
.viewer-pin span {
    position: absolute;
    right: 30px;
    top: -34px;
    white-space: nowrap;
    background: #fff;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 5px 9px;
    box-shadow: var(--shadow-soft);
    opacity: 0;
    transform: translateY(4px);
    transition: .18s;
    pointer-events: none;
}
.viewer-pin:hover span,
.viewer-pin:focus span {opacity: 1;transform: translateY(0);}
.map-empty-state {
    position: absolute;
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    background: rgba(255,255,255,.9);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px 22px;
    color: var(--muted);
    z-index: 4;
    text-align: center;
}
.map-shell.is-fullscreen {
    position: fixed !important;
    inset: 18px;
    z-index: 200;
    overflow: auto;
    border-radius: 28px;
    box-shadow: 0 24px 70px rgba(15,23,42,.35);
}
.map-shell.is-fullscreen .local-map {
    min-height: calc(100vh - 150px);
}
.dashboard-local-map {min-height: 500px;}
.unit-profile-map .local-map {min-height: 360px;}
.export-actions {display: flex;gap: 8px;flex-wrap: wrap;}
.file-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}
.file-list a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: 14px;
    background: var(--blue-3);
    color: var(--blue);
    font-weight: 700;
}
@media (max-width: 768px) {
    .local-map {min-height: 320px;border-radius: 18px;}
    .map-shell.is-fullscreen {inset: 8px;border-radius: 20px;}
    .sidebar-profile-card {align-items: flex-start;}
    .password-current-box {align-items: flex-start;}
}

/* Real XYZ tile map */
.local-map.real-map {
    background: #e2e8f0;
    cursor: grab;
    touch-action: none;
    user-select: none;
    isolation: isolate;
}
.local-map.real-map.is-dragging {cursor: grabbing;}
.local-map.real-map:before,
.local-map.real-map:after {display: none;}
.tile-map-layer,
.tile-map-marker-layer {
    position: absolute;
    inset: 0;
    overflow: hidden;
}
.tile-map-layer {z-index: 1;background: #dbeafe;}
.tile-map-marker-layer {z-index: 4;pointer-events: none;}
.tile-map-tile {
    position: absolute;
    width: 256px;
    height: 256px;
    max-width: none;
    user-select: none;
    -webkit-user-drag: none;
    background: #e5e7eb;
}
.tile-map-tile.tile-error {opacity: .15;}
.tile-map-controls {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 7;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.tile-map-controls button {
    width: 38px;
    height: 38px;
    border: 1px solid rgba(15,45,92,.16);
    border-radius: 12px;
    background: rgba(255,255,255,.94);
    color: var(--blue);
    font-size: 22px;
    font-weight: 900;
    line-height: 1;
    box-shadow: 0 12px 30px rgba(15,23,42,.12);
    cursor: pointer;
}
.tile-map-controls button:hover {background: #fff;transform: translateY(-1px);}
.tile-map-attribution {
    position: absolute;
    right: 10px;
    bottom: 8px;
    z-index: 7;
    background: rgba(255,255,255,.86);
    color: #475569;
    border-radius: 10px;
    padding: 4px 8px;
    font-size: 11px;
    direction: ltr;
}
.real-map .map-pin {
    pointer-events: auto;
}
.real-map .map-empty-state {
    z-index: 8;
}
.map-provider-note {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 10px;
    color: var(--muted);
    font-size: 13px;
}
.map-provider-note code {
    direction: ltr;
    unicode-bidi: plaintext;
    background: rgba(15,45,92,.06);
    border: 1px solid rgba(15,45,92,.08);
    border-radius: 9px;
    padding: 2px 7px;
}
@media (max-width: 768px) {
    .tile-map-controls {top: 10px;left: 10px;}
    .tile-map-controls button {width: 34px;height: 34px;border-radius: 10px;font-size: 20px;}
    .tile-map-attribution {font-size: 10px;right: 8px;bottom: 6px;}
}
