/* تساهيل المجد — لوحة إدارة نظيفة واحترافية v2 */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&display=swap');

:root {
    --tm-primary: #1d6fd8;
    --tm-primary-hover: #1558b0;
    --tm-primary-soft: #e8f2fc;
    --tm-accent: #0d9488;
    --tm-accent-soft: #ccfbf1;

    --tm-bg: #f1f5f9;
    --tm-surface: #ffffff;
    --tm-border: #e2e8f0;
    --tm-border-light: #f1f5f9;

    --tm-text: #0f172a;
    --tm-text-secondary: #475569;
    --tm-muted: #94a3b8;

    --tm-success: #059669;
    --tm-success-bg: #ecfdf5;
    --tm-danger: #dc2626;
    --tm-danger-bg: #fef2f2;
    --tm-warning: #d97706;
    --tm-warning-bg: #fffbeb;

    --tm-radius: 10px;
    --tm-radius-lg: 14px;
    --tm-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --tm-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
    --tm-shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.08);

    --tm-sidebar-w: 280px;
    --tm-topbar-h: 64px;
    --tm-font: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body.tm-admin {
    font-family: var(--tm-font);
    font-size: 15px;
    line-height: 1.6;
    background: var(--tm-bg);
    color: var(--tm-text);
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

/* ─── Sidebar ─── */
.tm-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--tm-sidebar-w);
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    background: var(--tm-surface);
    border-left: 1px solid var(--tm-border);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.25s ease;
    transform: translateX(100%);
    width: min(var(--tm-sidebar-w), 92vw);
}

.tm-sidebar.open {
    transform: translateX(0);
    box-shadow: var(--tm-shadow-lg);
}

body.tm-sidebar-open {
    overflow: hidden;
}

.tm-sidebar-top {
    flex-shrink: 0;
    border-bottom: 1px solid var(--tm-border-light);
}

.tm-sidebar-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.tm-sidebar-scroll::-webkit-scrollbar {
    width: 6px;
}

.tm-sidebar-scroll::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 6px;
}

.tm-sidebar-brand {
    padding: 1rem 1rem 0.5rem;
}

.tm-sidebar-brand-inner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.tm-sidebar-logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 10px;
    background: var(--tm-primary-soft);
    padding: 4px;
}

.tm-brand-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--tm-primary) 0%, #3b82f6 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.tm-brand-text {
    min-width: 0;
    flex: 1;
}

.tm-sidebar-brand h1 {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0;
    color: var(--tm-text);
    line-height: 1.35;
    word-break: break-word;
}

.tm-sidebar-brand span {
    display: block;
    font-size: 0.7rem;
    color: var(--tm-muted);
    font-weight: 400;
    margin-top: 2px;
    line-height: 1.3;
}

.tm-user-chip {
    margin: 0.5rem 1rem 0.75rem;
    padding: 0.65rem 0.75rem;
    background: var(--tm-bg);
    border-radius: var(--tm-radius);
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.tm-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--tm-primary-soft);
    color: var(--tm-primary);
    font-weight: 700;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tm-user-chip strong {
    display: block;
    font-size: 0.88rem;
    color: var(--tm-text);
    font-weight: 600;
}

.tm-user-chip small {
    color: var(--tm-muted);
    font-size: 0.75rem;
}

.tm-nav {
    padding: 0.35rem 0.65rem 1rem;
}

.tm-nav-label {
    padding: 0.65rem 0.85rem 0.25rem;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--tm-muted);
    letter-spacing: 0.03em;
}

.tm-nav-label:first-child {
    padding-top: 0.35rem;
}

.tm-nav a {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.85rem;
    margin-bottom: 2px;
    color: var(--tm-text-secondary);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.88rem;
    line-height: 1.35;
    transition: background 0.15s, color 0.15s;
}

.tm-nav a span {
    flex: 1;
    line-height: 1.4;
}

.tm-nav a i {
    font-size: 1.15rem;
    width: 1.35rem;
    text-align: center;
    opacity: 0.85;
}

.tm-nav a:hover {
    background: var(--tm-bg);
    color: var(--tm-text);
}

.tm-nav a.active {
    background: var(--tm-primary-soft);
    color: var(--tm-primary);
    font-weight: 600;
}

.tm-nav a.active i {
    color: var(--tm-primary);
    opacity: 1;
}

.tm-sidebar-footer {
    flex-shrink: 0;
    padding: 0.85rem 1rem;
    border-top: 1px solid var(--tm-border-light);
    background: var(--tm-surface);
}

.tm-btn-logout {
    width: 100%;
    padding: 0.6rem 1rem;
    border: 1px solid var(--tm-border);
    background: var(--tm-surface);
    color: var(--tm-text-secondary);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.15s;
}

.tm-btn-logout:hover {
    background: var(--tm-danger-bg);
    border-color: #fecaca;
    color: var(--tm-danger);
}

.tm-sidebar-toggle {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--tm-border);
    background: var(--tm-surface);
    border-radius: 8px;
    color: var(--tm-text);
    cursor: pointer;
    font-size: 1.25rem;
}

.tm-sidebar-overlay.open {
    display: block;
}

.tm-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 1035;
}

/* ─── Main layout ─── */
.tm-main {
    margin-right: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    max-width: 100%;
    overflow-x: hidden;
}

.tm-topbar {
    background: var(--tm-surface);
    border-bottom: 1px solid var(--tm-border);
    padding: 0.65rem max(1rem, env(safe-area-inset-right)) 0.65rem max(1rem, env(safe-area-inset-left));
    min-height: var(--tm-topbar-h);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--tm-shadow-sm);
}

.tm-topbar-start {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.tm-topbar-title,
.tm-topbar h2 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--tm-text);
    line-height: 1.35;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.tm-topbar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    max-width: 100%;
}

.tm-topbar-actions > .btn,
.tm-topbar-actions > a.btn,
.tm-topbar-actions > form {
    flex-shrink: 0;
}

.tm-topbar-actions > form {
    display: inline-flex;
    margin: 0 !important;
}

.tm-topbar-actions .btn {
    white-space: nowrap;
}

.tm-content {
    padding: 1.5rem max(1rem, env(safe-area-inset-right)) 1.75rem max(1rem, env(safe-area-inset-left));
    flex: 1;
    max-width: 1400px;
    width: 100%;
    min-width: 0;
}

/* ─── Cards ─── */
.tm-card {
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius-lg);
    box-shadow: var(--tm-shadow-sm);
    overflow: hidden;
}

.tm-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--tm-border-light);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--tm-text);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: #fafbfc;
}

.tm-card-header > span,
.tm-card-header > :first-child {
    flex: 1 1 auto;
    min-width: 0;
}

.tm-card-header .btn,
.tm-card-header .btn-group {
    flex-shrink: 0;
}

.tm-card-body { padding: 1.25rem; }

/* Stats */
.tm-stat {
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius-lg);
    padding: 1.15rem 1.25rem;
    box-shadow: var(--tm-shadow-sm);
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.tm-stat:hover {
    box-shadow: var(--tm-shadow);
    border-color: #cbd5e1;
}

.tm-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}

.tm-stat-icon.blue { background: var(--tm-primary-soft); color: var(--tm-primary); }
.tm-stat-icon.amber { background: var(--tm-warning-bg); color: var(--tm-warning); }
.tm-stat-icon.red { background: var(--tm-danger-bg); color: var(--tm-danger); }
.tm-stat-icon.teal { background: var(--tm-accent-soft); color: var(--tm-accent); }

.tm-stat-body { min-width: 0; }

.tm-stat-label {
    font-size: 0.8rem;
    color: var(--tm-muted);
    margin-bottom: 0.2rem;
    font-weight: 500;
}

.tm-stat-value {
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--tm-text);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

/* ─── Buttons ─── */
.tm-btn-primary,
.btn.tm-btn-primary {
    background: var(--tm-primary) !important;
    border: none !important;
    color: #fff !important;
    padding: 0.5rem 1.1rem !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    font-family: inherit !important;
    font-size: 0.88rem !important;
    box-shadow: 0 1px 2px rgba(29, 111, 216, 0.2);
    transition: background 0.15s, transform 0.1s !important;
}

.tm-btn-primary:hover,
.btn.tm-btn-primary:hover {
    background: var(--tm-primary-hover) !important;
    color: #fff !important;
    transform: translateY(-1px);
}

.tm-btn-gold,
.btn.tm-btn-gold {
    background: var(--tm-accent) !important;
    color: #fff !important;
    border: none !important;
    padding: 0.5rem 1.1rem !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    font-family: inherit !important;
    font-size: 0.88rem !important;
}

.tm-btn-gold:hover,
.btn.tm-btn-gold:hover {
    background: #0f766e !important;
    color: #fff !important;
}

.tm-btn-outline,
.btn.tm-btn-outline {
    border: 1px solid var(--tm-border) !important;
    background: var(--tm-surface) !important;
    color: var(--tm-text-secondary) !important;
    padding: 0.5rem 1.1rem !important;
    border-radius: 8px !important;
    font-weight: 500 !important;
    font-family: inherit !important;
    font-size: 0.88rem !important;
}

.tm-btn-outline:hover,
.btn.tm-btn-outline:hover {
    background: var(--tm-bg) !important;
    border-color: #cbd5e1 !important;
    color: var(--tm-text) !important;
}

/* ─── Tables ─── */
.tm-table-scroll,
.table-responsive.tm-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

.tm-table-scroll > .table,
.table-responsive.tm-table-scroll > .table {
    min-width: 36rem;
    margin-bottom: 0;
}

.tm-table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    justify-content: flex-end;
}

.tm-table-actions .btn,
.tm-table-actions form {
    margin: 0 !important;
}

.tm-table-actions form {
    display: inline-flex;
}

.tm-table { margin: 0; font-size: 0.9rem; }

.tm-table thead th {
    background: #f8fafc;
    color: var(--tm-muted);
    font-weight: 600;
    font-size: 0.75rem;
    border-bottom: 1px solid var(--tm-border);
    padding: 0.75rem 1rem;
    white-space: nowrap;
}

.tm-table tbody td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
    border-color: var(--tm-border-light);
    color: var(--tm-text);
}

.tm-table tbody tr {
    transition: background 0.1s;
}

.tm-table tbody tr:hover {
    background: #f8fafc;
}

.table.tm-table > :not(caption) > * > * {
    border-bottom-color: var(--tm-border-light);
}

/* ─── Badges ─── */
.tm-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.4;
}

.tm-badge-pending { background: var(--tm-warning-bg); color: #b45309; }
.tm-badge-progress { background: var(--tm-primary-soft); color: var(--tm-primary); }
.tm-badge-done { background: var(--tm-success-bg); color: var(--tm-success); }
.tm-badge-due { background: #fef3c7; color: #92400e; }

/* ─── Forms ─── */
.tm-form-label,
.form-label.tm-form-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--tm-text);
    margin-bottom: 0.35rem;
}

.tm-form-control,
.form-control.tm-form-control,
.form-select.tm-form-control {
    border: 1px solid var(--tm-border) !important;
    border-radius: 8px !important;
    padding: 0.55rem 0.85rem !important;
    font-family: inherit !important;
    font-size: 0.9rem !important;
    background: var(--tm-surface) !important;
    color: var(--tm-text) !important;
    transition: border-color 0.15s, box-shadow 0.15s !important;
}

.tm-form-control:focus,
.form-control:focus,
.form-select:focus {
    border-color: var(--tm-primary) !important;
    box-shadow: 0 0 0 3px rgba(29, 111, 216, 0.12) !important;
    outline: none !important;
}

.form-check-input:checked {
    background-color: var(--tm-primary);
    border-color: var(--tm-primary);
}

/* Nav tabs */
.nav-tabs {
    border-bottom: 1px solid var(--tm-border);
    gap: 0.25rem;
}

.nav-tabs .nav-link {
    border: none;
    color: var(--tm-text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.65rem 1rem;
    border-radius: 8px 8px 0 0;
    margin-bottom: -1px;
}

.nav-tabs .nav-link:hover {
    color: var(--tm-text);
    background: var(--tm-bg);
}

.nav-tabs .nav-link.active {
    color: var(--tm-primary);
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-bottom-color: var(--tm-surface);
    font-weight: 600;
}

/* ─── Alerts ─── */
.tm-alert {
    border-radius: var(--tm-radius);
    padding: 0.85rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.tm-alert-success {
    background: var(--tm-success-bg);
    color: #047857;
    border: 1px solid #a7f3d0;
}

.tm-alert-danger {
    background: var(--tm-danger-bg);
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.tm-alert-info {
    background: var(--tm-primary-soft);
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* Upload / GPS / Gallery (unchanged structure, refreshed colors) */
.tm-upload-zone {
    border: 2px dashed var(--tm-border);
    border-radius: var(--tm-radius-lg);
    padding: 2rem;
    text-align: center;
    background: #fafbfc;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.tm-upload-zone:hover,
.tm-upload-zone.dragover {
    border-color: var(--tm-primary);
    background: var(--tm-primary-soft);
}

.tm-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.tm-preview-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 1;
    border: 1px solid var(--tm-border);
}

.tm-preview-item img { width: 100%; height: 100%; object-fit: cover; }

.tm-preview-remove {
    position: absolute;
    top: 4px;
    left: 4px;
    background: var(--tm-danger);
    color: #fff;
    border: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
}

.tm-gps-box {
    background: var(--tm-accent-soft);
    border: 1px solid #99f6e4;
    border-radius: var(--tm-radius);
    padding: 1rem 1.25rem;
}

.tm-gps-box.captured {
    background: var(--tm-primary-soft);
    border-color: #93c5fd;
}

.tm-gps-coords {
    font-family: ui-monospace, monospace;
    font-size: 0.85rem;
    color: var(--tm-text);
    direction: ltr;
    text-align: left;
}

.tm-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
}

.tm-gallery a {
    display: block;
    border-radius: var(--tm-radius);
    overflow: hidden;
    border: 1px solid var(--tm-border);
    transition: transform 0.2s, box-shadow 0.2s;
}

.tm-gallery a:hover {
    transform: translateY(-2px);
    box-shadow: var(--tm-shadow);
}

.tm-gallery img { width: 100%; height: 120px; object-fit: cover; }

.tm-map {
    border-radius: var(--tm-radius);
    overflow: hidden;
    border: 1px solid var(--tm-border);
    height: 280px;
}

.tm-map iframe { width: 100%; height: 100%; border: 0; }

/* Role guide / permissions */
.tm-role-guide .perm-summary {
    background: var(--tm-primary-soft);
    border-right: 3px solid var(--tm-primary);
    border-radius: 8px;
    padding: 0.75rem;
}

/* Chat */
.tm-chat-list .list-group-item.active {
    background: var(--tm-primary);
    border-color: var(--tm-primary);
}

/* Login */
.tm-login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tm-bg);
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

.tm-login-wrap::before {
    content: '';
    position: absolute;
    top: -30%;
    left: -20%;
    width: 60%;
    height: 80%;
    background: radial-gradient(circle, rgba(29, 111, 216, 0.08) 0%, transparent 70%);
    pointer-events: none;
}

.tm-login-card {
    width: 100%;
    max-width: 400px;
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius-lg);
    padding: 2.25rem;
    box-shadow: var(--tm-shadow-lg);
    position: relative;
    z-index: 1;
}

.tm-login-card .tm-login-logo {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--tm-primary), #3b82f6);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 1rem;
}

.tm-login-card h1 {
    font-weight: 700;
    font-size: 1.35rem;
    color: var(--tm-text);
    text-align: center;
    margin-bottom: 0.25rem;
}

.tm-login-card .subtitle {
    text-align: center;
    color: var(--tm-muted);
    font-size: 0.88rem;
    margin-bottom: 1.75rem;
}

/* Bootstrap overrides */
.card.border-0.shadow-sm {
    border: 1px solid var(--tm-border) !important;
    border-radius: var(--tm-radius-lg) !important;
    box-shadow: var(--tm-shadow-sm) !important;
}

.pagination { font-size: 0.88rem; }

.page-link {
    border-radius: 6px !important;
    margin: 0 2px;
    color: var(--tm-text-secondary);
}

.page-item.active .page-link {
    background: var(--tm-primary);
    border-color: var(--tm-primary);
}

h1.h3, .h3 {
    font-weight: 700;
    color: var(--tm-text);
    font-size: 1.35rem;
}

.text-navy { color: var(--tm-primary) !important; }

/* ─── Hub (الصفحة الرئيسية — كاردات) ─── */
.tm-hub-welcome-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, var(--tm-primary-soft) 0%, var(--tm-surface) 55%);
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius-lg);
}

.tm-hub-title {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
    color: var(--tm-text);
}

.tm-hub-subtitle {
    color: var(--tm-text-secondary);
    font-size: 0.92rem;
}

.tm-menu-section {
    margin-bottom: 1.75rem;
}

.tm-menu-section--analytics {
    margin-top: 0.5rem;
    padding-top: 0.25rem;
}

.tm-menu-divider {
    border: 0;
    border-top: 2px solid var(--tm-border-light);
    opacity: 0.85;
}

.tm-sidebar-divider {
    border: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    margin: 0.75rem 1rem 0.5rem;
}

.tm-menu-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
    color: var(--tm-muted);
    margin: 0 0 0.85rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--tm-border-light);
}

.tm-hub-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem 1.15rem;
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius-lg);
    text-decoration: none;
    color: inherit;
    height: 100%;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
    box-shadow: var(--tm-shadow-sm);
}

.tm-hub-card:hover {
    border-color: var(--tm-primary);
    box-shadow: var(--tm-shadow);
    transform: translateY(-2px);
    color: inherit;
}

.tm-hub-card.is-active {
    border-color: var(--tm-primary);
    background: var(--tm-primary-soft);
}

.tm-hub-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}

.tm-hub-card--blue .tm-hub-card-icon { background: #dbeafe; color: #1d4ed8; }
.tm-hub-card--indigo .tm-hub-card-icon { background: #e0e7ff; color: #4338ca; }
.tm-hub-card--teal .tm-hub-card-icon { background: #ccfbf1; color: #0f766e; }
.tm-hub-card--amber .tm-hub-card-icon { background: #fef3c7; color: #b45309; }
.tm-hub-card--slate .tm-hub-card-icon { background: #f1f5f9; color: #475569; }
.tm-hub-card--violet .tm-hub-card-icon { background: #ede9fe; color: #6d28d9; }
.tm-hub-card--cyan .tm-hub-card-icon { background: #cffafe; color: #0e7490; }
.tm-hub-card--rose .tm-hub-card-icon { background: #ffe4e6; color: #be123c; }
.tm-hub-card--green .tm-hub-card-icon { background: #dcfce7; color: #15803d; }
.tm-hub-card--gray .tm-hub-card-icon { background: #f3f4f6; color: #4b5563; }
.tm-hub-card--emerald .tm-hub-card-icon { background: #d1fae5; color: #047857; }
.tm-hub-card--stone .tm-hub-card-icon { background: #e7e5e4; color: #57534e; }

.tm-hub-card-body {
    flex: 1;
    min-width: 0;
}

.tm-hub-card-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--tm-text);
}

.tm-hub-card-desc {
    font-size: 0.78rem;
    color: var(--tm-muted);
    margin-top: 0.15rem;
    line-height: 1.4;
}

.tm-hub-card-arrow {
    color: var(--tm-muted);
    font-size: 0.9rem;
    flex-shrink: 0;
}

/* ─── Hub dashboard (لوحة التحكم) ─── */
body.tm-is-hub {
    background: linear-gradient(180deg, #e8eef5 0%, var(--tm-bg) 320px);
}

body.tm-is-hub .tm-topbar {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

body.tm-is-hub .tm-content {
    padding-top: 1.75rem;
}

.tm-hub-hero {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.25rem;
    padding: 1.5rem 1.75rem;
    background: linear-gradient(135deg, #1d6fd8 0%, #2563eb 45%, #0d9488 100%);
    border-radius: calc(var(--tm-radius-lg) + 2px);
    color: #fff;
    box-shadow: 0 12px 32px rgba(29, 111, 216, 0.22);
    position: relative;
    overflow: hidden;
}

.tm-hub-hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 10% 20%, rgba(255,255,255,0.12) 0%, transparent 45%),
                radial-gradient(circle at 90% 80%, rgba(255,255,255,0.08) 0%, transparent 40%);
    pointer-events: none;
}

.tm-hub-hero-main,
.tm-hub-hero-aside {
    position: relative;
    z-index: 1;
}

.tm-hub-hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    font-weight: 600;
    opacity: 0.92;
    margin-bottom: 0.5rem;
}

.tm-hub-hero .tm-hub-title {
    font-size: 1.55rem;
    font-weight: 700;
    margin: 0 0 0.35rem;
    color: #fff;
}

.tm-hub-hero .tm-hub-subtitle {
    margin: 0;
    font-size: 0.92rem;
    color: rgba(255, 255, 255, 0.88);
    max-width: 36rem;
}

.tm-hub-hero-aside {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.55rem;
}

.tm-hub-role-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.28);
    font-size: 0.8rem;
    font-weight: 600;
    color: #fff;
    backdrop-filter: blur(4px);
}

.tm-hub-date {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.85);
}

.tm-kpi-grid {
    margin-top: -0.25rem;
}

.tm-kpi {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.15rem 1.2rem;
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius-lg);
    box-shadow: var(--tm-shadow-sm);
    height: 100%;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    position: relative;
    overflow: hidden;
}

.tm-kpi::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    border-radius: 0 4px 4px 0;
}

.tm-kpi--blue::before { background: var(--tm-primary); }
.tm-kpi--amber::before { background: var(--tm-warning); }
.tm-kpi--red::before { background: var(--tm-danger); }
.tm-kpi--teal::before { background: var(--tm-accent); }

.tm-kpi:hover {
    transform: translateY(-2px);
    box-shadow: var(--tm-shadow);
    border-color: #cbd5e1;
}

.tm-kpi-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.tm-kpi--blue .tm-kpi-icon { background: var(--tm-primary-soft); color: var(--tm-primary); }
.tm-kpi--amber .tm-kpi-icon { background: var(--tm-warning-bg); color: var(--tm-warning); }
.tm-kpi--red .tm-kpi-icon { background: var(--tm-danger-bg); color: var(--tm-danger); }
.tm-kpi--teal .tm-kpi-icon { background: var(--tm-accent-soft); color: var(--tm-accent); }

.tm-kpi-value {
    font-size: 1.55rem;
    font-weight: 700;
    line-height: 1.15;
    color: var(--tm-text);
    letter-spacing: -0.02em;
}

.tm-kpi-label {
    font-size: 0.78rem;
    color: var(--tm-muted);
    font-weight: 500;
    margin-top: 0.15rem;
}

.tm-menu-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--tm-border-light);
}

.tm-menu-section-title {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--tm-text);
    margin: 0;
    padding: 0;
    border: 0;
}

.tm-menu-section-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--tm-primary-soft);
    color: var(--tm-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.tm-menu-section-count {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--tm-muted);
    background: var(--tm-bg);
    border: 1px solid var(--tm-border-light);
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    white-space: nowrap;
}

.tm-hub-card {
    border-radius: calc(var(--tm-radius-lg) + 2px);
    padding: 1.15rem 1.2rem;
    min-height: 88px;
}

.tm-hub-card:hover .tm-hub-card-action {
    background: var(--tm-primary);
    color: #fff;
    border-color: var(--tm-primary);
    transform: translateX(-2px);
}

.tm-hub-card-action {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid var(--tm-border);
    background: var(--tm-bg);
    color: var(--tm-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.18s ease;
    font-size: 0.85rem;
}

.tm-hub-card-title {
    font-size: 0.98rem;
}

.tm-dashboard-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.tm-dashboard-panel-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--tm-text);
}

.tm-dashboard-panel-title i {
    color: var(--tm-primary);
}

.tm-dashboard-panel-hint {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--tm-muted);
    background: var(--tm-surface);
    border: 1px solid var(--tm-border-light);
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
}

.tm-card--flat {
    box-shadow: none;
}

.tm-chart-wrap {
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tm-btn-icon {
    display: inline-flex !important;
    align-items: center;
    gap: 0.4rem;
}

.tm-btn-icon i {
    font-size: 0.85rem;
    transition: transform 0.15s;
}

.tm-btn-icon:hover i {
    transform: translateX(-2px);
}

/* محادثات */
.tm-chat-layout {
    --tm-chat-min: 280px;
}

.tm-chat-contacts .tm-card,
.tm-chat-contacts .card,
.tm-chat-panel .tm-card,
.tm-chat-panel .card {
    height: 100%;
    min-height: var(--tm-chat-min);
}

.tm-chat-contacts .list-group {
    max-height: 320px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.tm-chat-messages {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    min-height: 200px;
    max-height: min(50vh, 420px);
}

.tm-chat-panel .card-footer,
.tm-chat-panel .tm-card-footer {
    flex-shrink: 0;
}

/* نماذج وفلاتر */
.tm-filter-bar .col,
.tm-filter-bar [class*="col-"] {
    min-width: 0;
}

.tm-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tm-form-actions .btn {
    margin: 0 !important;
}

/* ترقيم */
.tm-pagination-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.75rem 1rem;
}

.tm-pagination-wrap .pagination {
    flex-wrap: wrap;
    justify-content: center;
    margin: 0;
}

.tm-btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--tm-border);
    background: var(--tm-surface);
    border-radius: 8px;
    color: var(--tm-text-secondary);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    flex-shrink: 0;
    transition: all 0.15s;
}

.tm-btn-back:hover {
    background: var(--tm-primary-soft);
    border-color: var(--tm-primary);
    color: var(--tm-primary);
}

/* ─── تجاوب: تابلت ─── */
@media (max-width: 991.98px) {
    .tm-topbar {
        align-items: stretch;
    }

    .tm-topbar-start {
        width: 100%;
    }

    .tm-topbar-actions {
        width: 100%;
        justify-content: flex-start;
        padding-top: 0.5rem;
        border-top: 1px solid var(--tm-border-light);
    }

    .tm-chat-layout > [class*="col-"] {
        margin-bottom: 0.75rem;
    }

    .tm-chat-contacts .list-group {
        max-height: 200px;
    }

    h1.h3, .h3 {
        font-size: 1.2rem;
    }
}

/* ─── تجاوب: موبايل ─── */
@media (max-width: 767.98px) {
    .tm-content {
        padding: 1rem max(0.75rem, env(safe-area-inset-right)) 1.25rem max(0.75rem, env(safe-area-inset-left));
    }

    .tm-hub-welcome-inner {
        padding: 1rem;
    }

    .tm-hub-hero {
        padding: 1.15rem 1.2rem;
    }

    .tm-hub-hero .tm-hub-title {
        font-size: 1.2rem;
    }

    .tm-hub-hero-aside {
        align-items: flex-start;
        width: 100%;
    }

    .tm-kpi {
        padding: 0.95rem 1rem;
    }

    .tm-kpi-value {
        font-size: 1.3rem;
    }

    .tm-menu-section-head {
        flex-wrap: wrap;
    }

    .tm-hub-card {
        padding: 0.95rem 1rem;
    }

    .tm-card-body {
        padding: 1rem;
    }

    .tm-card-header {
        flex-direction: column;
        align-items: stretch;
    }

    .tm-card-header .btn {
        width: 100%;
    }

    .tm-table thead th,
    .tm-table tbody td {
        padding: 0.65rem 0.75rem;
        font-size: 0.82rem;
    }

    .tm-table-actions {
        flex-direction: column;
        align-items: stretch;
        min-width: 7.5rem;
    }

    .tm-table-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .tm-map {
        height: 220px;
    }

    .tm-gallery {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    }

    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 2px;
    }

    .nav-tabs .nav-link {
        white-space: nowrap;
    }

    .input-group:not(.flex-nowrap) {
        flex-wrap: wrap;
    }

    .input-group:not(.flex-nowrap) > .form-control {
        min-width: 0;
        width: 100%;
        border-radius: 8px !important;
        margin-bottom: 0.5rem;
    }

    .input-group:not(.flex-nowrap) > .btn {
        width: 100%;
        border-radius: 8px !important;
    }
}

@media (max-width: 575.98px) {
    .tm-topbar-title,
    .tm-topbar h2 {
        font-size: 0.95rem;
        -webkit-line-clamp: 3;
    }

    .tm-btn-back-text {
        display: none;
    }

    .tm-topbar-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .tm-topbar-actions > .btn,
    .tm-topbar-actions > a,
    .tm-topbar-actions > form {
        width: 100%;
    }

    .tm-topbar-actions > form {
        display: block;
        grid-column: 1 / -1;
    }

    .tm-topbar-actions > form .btn {
        width: 100%;
    }

    .tm-topbar-actions .btn {
        font-size: 0.78rem !important;
        padding: 0.45rem 0.5rem !important;
        white-space: normal;
        text-align: center;
        line-height: 1.25;
    }

    .tm-topbar-actions .btn i {
        display: block;
        margin-bottom: 0.15rem;
        font-size: 1rem;
    }

    .tm-form-actions {
        flex-direction: column;
    }

    .tm-form-actions .btn {
        width: 100%;
    }
}

/* ─── تجاوب: شاشات عريضة (تابلت أفقي / سطح مكتب صغير) ─── */
@media (min-width: 768px) and (max-width: 1199.98px) {
    .tm-content {
        padding: 1.25rem;
    }
}

/* ─── جرس التنبيهات + بوب أب ─── */
.tm-notify-wrap {
    position: relative;
    flex-shrink: 0;
}

.tm-notify-btn {
    position: relative;
    width: 42px;
    height: 42px;
    border: 1px solid var(--tm-border);
    border-radius: 10px;
    background: var(--tm-surface);
    color: var(--tm-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.tm-notify-btn:hover {
    background: var(--tm-primary-soft);
    border-color: var(--tm-primary);
}

.tm-notify-badge {
    position: absolute;
    top: -4px;
    left: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--tm-danger);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.45);
}

.tm-notify-menu {
    width: min(360px, calc(100vw - 2rem));
    max-height: min(420px, 70vh);
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius-lg);
    overflow: hidden;
}

.tm-notify-menu-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--tm-border-light);
    background: var(--tm-bg);
}

.tm-notify-menu-list {
    max-height: 300px;
    overflow-y: auto;
}

.tm-notify-item {
    display: flex;
    gap: 0.65rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid var(--tm-border-light);
    transition: background 0.12s;
}

.tm-notify-item:hover {
    background: var(--tm-primary-soft);
}

.tm-notify-item.unread {
    background: #fffbeb;
}

.tm-notify-item.unread strong {
    color: var(--tm-warning);
}

.tm-notify-item-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--tm-primary-soft);
    color: var(--tm-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tm-notify-item-body {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.tm-notify-item-body strong {
    font-size: 0.88rem;
}

.tm-notify-item-body span {
    font-size: 0.8rem;
    color: var(--tm-text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tm-notify-item-body small {
    font-size: 0.72rem;
    color: var(--tm-muted);
}

.tm-notify-menu-foot {
    display: block;
    padding: 0.65rem 1rem;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--tm-primary);
    text-decoration: none;
    border-top: 1px solid var(--tm-border-light);
    background: var(--tm-surface);
}

.tm-notify-menu-foot:hover {
    background: var(--tm-primary-soft);
}

.tm-toast-stack {
    position: fixed;
    top: calc(var(--tm-topbar-h) + 12px);
    left: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: min(380px, calc(100vw - 2rem));
    pointer-events: none;
}

.tm-toast-popup {
    pointer-events: auto;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.85rem 1rem;
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-right: 4px solid var(--tm-primary);
    border-radius: var(--tm-radius-lg);
    box-shadow: var(--tm-shadow-lg);
    cursor: pointer;
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.25s, transform 0.25s;
}

.tm-toast-popup.show {
    opacity: 1;
    transform: translateX(0);
}

.tm-toast-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--tm-primary-soft);
    color: var(--tm-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.tm-toast-body {
    flex: 1;
    min-width: 0;
}

.tm-toast-body strong {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
}

.tm-toast-body p {
    margin: 0;
    font-size: 0.82rem;
    color: var(--tm-text-secondary);
    line-height: 1.4;
}

.tm-toast-close {
    border: none;
    background: transparent;
    font-size: 1.25rem;
    line-height: 1;
    color: var(--tm-muted);
    cursor: pointer;
    padding: 0 0.25rem;
}

@media (max-width: 575.98px) {
    .tm-toast-stack {
        left: 8px;
        right: 8px;
        max-width: none;
    }
}
