:root {
    --bg: #f5f4ef;
    --surface: #ffffff;
    --primary: #1a7f5a;
    --primary-dark: #14654a;
    --primary-light: #e6f3ed;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --danger: #dc2626;
    --danger-light: #fdeaea;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.12);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    min-height: 100%;
}

body {
    font-family: "Segoe UI", Tahoma, "Noto Kufi Arabic", Arial, sans-serif;
    direction: rtl;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-tap-highlight-color: transparent;
}

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

button {
    cursor: pointer;
    border: none;
    background: none;
}

/* ===== Header ===== */
.app-header {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff;
    padding: 18px 16px 20px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 1100px;
    margin: 0 auto;
}

.logo {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 700;
    flex-shrink: 0;
}

.brand-text h1 {
    font-size: 19px;
    font-weight: 700;
    line-height: 1.3;
}

.brand-text p {
    font-size: 13px;
    opacity: 0.9;
}

/* ===== Tabs ===== */
.tabs {
    display: flex;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30;
    overflow-x: auto;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab {
    flex: 1 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    border-bottom: 3px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.tab svg {
    width: 19px;
    height: 19px;
    flex-shrink: 0;
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ===== Layout ===== */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 16px 14px 96px;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

/* ===== Stats ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.stat-card .stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.stat-card .stat-icon svg {
    width: 20px;
    height: 20px;
}

.stat-card .stat-num {
    font-size: 26px;
    font-weight: 800;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--muted);
}

.icon-today    { background: var(--primary-light); color: var(--primary); }
.icon-confirm  { background: #e7f6ec; color: #15803d; }
.icon-upcoming { background: #e8eefb; color: #1d4ed8; }
.icon-clients  { background: #f1ebfd; color: #6d28d9; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    min-height: 46px;
    transition: transform 0.1s, opacity 0.2s, background 0.2s;
}

.btn:active {
    transform: scale(0.98);
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-lg {
    padding: 15px 22px;
    font-size: 16px;
    width: 100%;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-ghost {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: #ecebe6;
}

.icon-btn {
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--muted);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

.icon-btn:hover {
    color: var(--text);
    background: #ecebe6;
}

.icon-btn.success      { background: #e7f6ec; border-color: #bbf7d0; color: #15803d; }
.icon-btn.danger       { background: var(--danger-light); border-color: #fecaca; color: var(--danger); }
.icon-btn.info         { background: #e8eefb; border-color: #bfdbfe; color: #1d4ed8; }
.icon-btn.purple       { background: #f1ebfd; border-color: #ddd6fe; color: #6d28d9; }
.icon-btn.primary      { background: var(--primary-light); border-color: #bbe3d3; color: var(--primary); }

/* ===== Sections ===== */
.dashboard-add {
    margin: 16px 0;
}

.section-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.section-title {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 12px;
}

/* ===== Search & Filters ===== */
.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0 14px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

.search-bar svg {
    width: 18px;
    height: 18px;
    color: var(--muted);
    flex-shrink: 0;
}

.search-bar input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    padding: 14px 0;
    font-size: 15px;
}

.filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.chip {
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    min-height: 38px;
}

.chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* ===== Booking cards ===== */
.booking-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 12px;
}

.booking-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.booking-client {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.booking-client h3 {
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.booking-phone {
    font-size: 13px;
    color: var(--muted);
    direction: ltr;
    text-align: right;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}

.badge-confirmed   { background: #e7f6ec; color: #15803d; }
.badge-pending     { background: #fdf3e3; color: #b45309; }
.badge-completed   { background: #e8eefb; color: #1d4ed8; }
.badge-cancelled   { background: var(--danger-light); color: #b91c1c; }
.badge-rescheduled { background: #f1ebfd; color: #6d28d9; }

.booking-meta {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px 12px;
    margin-bottom: 12px;
}

.booking-meta span {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: var(--text);
}

.booking-meta svg {
    width: 16px;
    height: 16px;
    color: var(--muted);
    flex-shrink: 0;
}

.booking-notes {
    font-size: 13px;
    color: var(--muted);
    background: var(--bg);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 12px;
    white-space: pre-wrap;
    word-break: break-word;
}

.booking-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ===== Empty state ===== */
.empty-state {
    text-align: center;
    padding: 40px 16px;
    color: var(--muted);
}

.empty-state svg {
    width: 44px;
    height: 44px;
    margin-bottom: 10px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 14px;
}

/* ===== Calendar ===== */
.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}

.calendar-nav .btn {
    padding: 10px 14px;
    min-height: 40px;
    font-size: 13px;
}

.week-label {
    font-size: 14px;
    font-weight: 700;
    text-align: center;
}

.week-grid {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 150px;
    grid-template-rows: 1fr;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
}

.day-col {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    min-height: 180px;
    display: flex;
    flex-direction: column;
}

.day-col.today {
    border: 2px solid var(--primary);
}

.day-head {
    background: var(--primary-light);
    color: var(--primary-dark);
    text-align: center;
    padding: 10px 6px;
}

.day-col.today .day-head {
    background: var(--primary);
    color: #fff;
}

.day-name {
    font-size: 14px;
    font-weight: 800;
}

.day-num {
    font-size: 22px;
    font-weight: 800;
    line-height: 1.3;
}

.day-month {
    font-size: 12px;
    opacity: 0.85;
}

.day-body {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.day-slot {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 12px;
}

.day-slot .slot-time {
    font-weight: 800;
    color: var(--primary-dark);
    direction: ltr;
    text-align: right;
    margin-bottom: 2px;
}

.day-slot .slot-name {
    color: var(--text);
    font-weight: 600;
    word-break: break-word;
}

.day-full {
    font-size: 11px;
    font-weight: 700;
    color: var(--danger);
    background: var(--danger-light);
    border-radius: 8px;
    padding: 6px 8px;
    text-align: center;
}

.day-remaining {
    font-size: 11px;
    color: var(--muted);
    text-align: center;
    padding-top: 4px;
}

.day-add {
    margin-top: auto;
    padding: 6px;
    border-radius: 8px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 34px;
}

.day-add svg {
    width: 14px;
    height: 14px;
}

/* ===== FAB ===== */
.fab {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    z-index: 40;
}

.fab svg {
    width: 26px;
    height: 26px;
}

.fab:active {
    transform: scale(0.94);
}

/* ===== Modals ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 50;
    padding: 0;
}

.modal {
    background: var(--surface);
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    border-radius: 20px 20px 0 0;
    padding: 18px;
    animation: slideUp 0.25s ease;
}

.modal-sm {
    max-width: 480px;
    border-radius: 20px;
    margin-bottom: auto;
    margin-top: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 800;
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--bg);
    font-size: 22px;
    line-height: 1;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ===== Form ===== */
.field {
    margin-bottom: 14px;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}

.field input,
.field select,
.field textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 15px;
    background: #fff;
    outline: none;
    min-height: 46px;
    transition: border-color 0.2s;
}

/* حقل كلمة المرور مع زر إظهار/إخفاء */
.pw-wrap {
    position: relative;
    display: block;
}

.pw-wrap input {
    padding-left: 44px;
}

.pw-wrap input[dir="ltr"] {
    padding-left: 14px;
    padding-right: 44px;
}

.pw-wrap input[dir="ltr"] ~ .pw-toggle {
    left: auto;
    right: 6px;
}

.pw-wrap .pw-toggle {
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: var(--text-soft, #64748b);
    cursor: pointer;
    padding: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.pw-wrap .pw-toggle:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text);
}

.caps-hint {
    margin-top: 6px;
    font-size: 12px;
    color: #b45309;
    background: #fef3c7;
    border: 1px solid #fde68a;
    padding: 6px 10px;
    border-radius: 8px;
}

.caps-hint.visible {
    display: block;
}

.field textarea {
    resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 127, 90, 0.15);
}

/* وضوح التركيز (Focus visible) للوحة المفاتيح دون تشويش النقر */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
    outline: none;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

.form-actions .btn {
    flex: 1;
}

/* ===== Details ===== */
.detail-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-row .d-label {
    font-size: 13px;
    color: var(--muted);
    flex-shrink: 0;
}

.detail-row .d-value {
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    word-break: break-word;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 50%;
    transform: translateX(50%);
    background: #1f2937;
    color: #fff;
    padding: 13px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    z-index: 60;
    box-shadow: var(--shadow-md);
    max-width: 90%;
    text-align: center;
}

.toast.error {
    background: var(--danger);
}

/* ===== Utilities ===== */
.hidden {
    display: none !important;
}

/* ============================================================
   المرحلة الثانية: العملاء + المتابعة + واتساب
============================================================ */

/* زر واتساب مصغّر داخل بطاقات الحجز */
.btn-mini {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
    min-height: 38px;
    background: #25d366;
    color: #fff;
    border: 1px solid #1eb356;
}

.btn-mini svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.btn-mini:active {
    transform: scale(0.98);
}

/* زر واتساب عادي */
.btn-wa {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    min-height: 42px;
    background: #25d366;
    color: #fff;
    border: 1px solid #1eb356;
}

.btn-wa svg {
    width: 17px;
    height: 17px;
}

.btn-wa:active {
    transform: scale(0.98);
}

/* ===== بطاقات العملاء ===== */
.client-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 12px;
}

.client-head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
}

.client-info {
    flex: 1;
    min-width: 0;
}

.client-info h3 {
    font-size: 16px;
    font-weight: 700;
}

.client-code {
    font-size: 12px;
    color: var(--primary);
    font-weight: 700;
}

.client-phone {
    font-size: 13px;
    color: var(--muted);
    direction: ltr;
    text-align: right;
}

.client-visits-badge {
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}

.client-meta {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    margin-bottom: 12px;
}

.client-meta span {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: var(--text);
}

.client-meta svg {
    width: 15px;
    height: 15px;
    color: var(--muted);
    flex-shrink: 0;
}

.client-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ===== ملف العميل ===== */
.modal-profile {
    max-width: 100%;
}

.profile-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.profile-head .avatar {
    width: 56px;
    height: 56px;
    font-size: 24px;
}

.profile-head h3 {
    font-size: 18px;
    font-weight: 800;
}

.profile-phone {
    font-size: 14px;
    color: var(--muted);
    direction: ltr;
    text-align: right;
}

.profile-section {
    background: var(--bg);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
}

.profile-sections {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.profile-sections .profile-section {
    margin-bottom: 0;
}

.profile-section h3 {
    font-size: 15px;
    font-weight: 800;
    color: var(--primary-dark);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.profile-section h3 svg {
    width: 16px;
    height: 16px;
}

.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.profile-item .p-label {
    font-size: 12px;
    color: var(--muted);
}

.profile-item .p-value {
    font-size: 14px;
    font-weight: 600;
    word-break: break-word;
}

.profile-item.wide {
    grid-column: 1 / -1;
}

.profile-empty {
    font-size: 13px;
    color: var(--muted);
}

/* سجل الزيارات */
.visit-row {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
}

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

.visit-date {
    font-weight: 700;
    font-size: 13px;
}

.visit-time {
    font-size: 12px;
    color: var(--muted);
}

.visit-row .visit-meta {
    font-size: 12px;
    color: var(--muted);
}

.visit-notes {
    font-size: 12px;
    color: var(--muted);
    background: var(--bg);
    border-radius: 8px;
    padding: 6px 8px;
    margin-top: 6px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* المتابعة */
.followup-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
}

.followup-item.completed {
    opacity: 0.6;
}

.followup-date {
    font-weight: 700;
    font-size: 13px;
}

.followup-note {
    font-size: 13px;
    color: var(--muted);
    margin: 4px 0;
    white-space: pre-wrap;
}

.followup-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.followup-actions .btn-mini,
.followup-actions .btn-wa {
    min-height: 44px;
    font-size: 12px;
    padding: 6px 12px;
}

.fu-completed-tag {
    font-size: 11px;
    font-weight: 700;
    color: #15803d;
    background: #e7f6ec;
    border-radius: 999px;
    padding: 3px 8px;
}

/* صفوف قصيرة للمواعيد القادمة */
.compact-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 8px;
    cursor: pointer;
}

.compact-row:hover {
    border-color: var(--primary);
}

.compact-row .cr-main {
    min-width: 0;
}

.compact-row .cr-name {
    font-weight: 700;
    font-size: 14px;
}

.compact-row .cr-sub {
    font-size: 12px;
    color: var(--muted);
}

.compact-row .cr-when {
    text-align: left;
    flex-shrink: 0;
}

.compact-row .cr-date {
    font-size: 13px;
    font-weight: 700;
}

.compact-row .cr-time {
    font-size: 12px;
    color: var(--muted);
    direction: ltr;
    text-align: left;
}

/* ============================================================
   المرحلة الثالثة: بطاقات الحجوزات + الاتصال + السعة + النسخ الاحتياطي
============================================================ */

/* سطر الوقت والخدمة البارز في بطاقة الحجز */
.booking-main {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin-bottom: 10px;
}

.booking-main .bm-time {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary-dark);
    display: inline-flex;
    align-items: center;
    gap: 7px;
    direction: ltr;
}

.booking-main .bm-time svg {
    width: 18px;
    height: 18px;
    color: var(--muted);
}

.booking-main .bm-service {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    background: var(--primary-light);
    border: 1px solid #bbe3d3;
    border-radius: 999px;
    padding: 5px 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    word-break: break-word;
}

.booking-main .bm-service svg {
    width: 15px;
    height: 15px;
    color: var(--primary);
}

/* رقم الجوال مع أزرار اتصال/واتساب */
.bm-phone {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.bm-phone .bm-phone-num {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-size: 14px;
    direction: ltr;
}

.bm-phone .bm-phone-num svg {
    color: var(--muted);
}

.bm-phone .icon-btn {
    width: 44px;
    height: 44px;
    min-height: 44px;
    border-radius: 8px;
}

.bm-phone .icon-btn svg {
    width: 15px;
    height: 15px;
}

.icon-btn.call { background: #e8eefb; border-color: #bfdbfe; color: #1d4ed8; }
.icon-btn.wa   { background: #e7f6ec; border-color: #bbf7d0; color: #1eb356; }

/* تسمية الأزرار على الكمبيوتر */
.icon-btn .btn-label {
    display: none;
}

/* زر فتح الموقع */
.map-link {
    background: var(--primary-light);
    color: var(--primary-dark);
    border-color: #bbe3d3;
    margin-right: 6px;
}

/* تنبيه الحقول (سعة اليوم / تعارض الموعد) */
.field-hint {
    font-size: 12px;
    color: var(--muted);
    margin-top: 5px;
    min-height: 16px;
}

.field-hint.warn {
    color: var(--danger);
    font-weight: 700;
}

/* عداد السعة في التقويم */
.day-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 6px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--primary-dark);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    padding: 3px 10px;
}

.day-col.today .day-count {
    background: #fff;
    color: var(--primary);
}

.day-count.full {
    background: var(--danger-light);
    color: var(--danger);
}

/* النسخ الاحتياطي */
.backup-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.backup-actions .btn {
    flex: 1;
    min-width: 180px;
}

.backup-import-btn {
    cursor: pointer;
    position: relative;
}

.backup-import-btn input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}

.backup-note {
    font-size: 12px;
    color: var(--muted);
    margin-top: 10px;
}

/* بطاقة العميل: سطر موقع قابل للفتح */
.client-meta span {
    min-width: 0;
    overflow-wrap: anywhere;
}

/* ============================================================
   المرحلة الرابعة: تسجيل الدخول + الإعدادات + الخدمات + التذكيرات + PWA
============================================================ */

/* شاشة تسجيل الدخول */
.login-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(160deg, var(--primary-dark), var(--primary));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
    overflow-y: auto;
}

.login-card {
    background: var(--surface);
    width: 100%;
    max-width: 380px;
    border-radius: 20px;
    padding: 28px 24px;
    box-shadow: var(--shadow-md);
    text-align: center;
}

.login-logo {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    background: var(--primary);
    color: #fff;
    font-size: 32px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
}

.login-card h1 {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 4px;
}

.login-sub {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 18px;
}

.login-card .btn-lg {
    width: 100%;
}

.login-note {
    font-size: 11px;
    color: var(--muted);
    margin-top: 14px;
    line-height: 1.5;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text);
    margin-bottom: 14px;
    justify-content: flex-start;
    cursor: pointer;
}

.checkbox-row input {
    width: 17px;
    height: 17px;
    accent-color: var(--primary);
}

/* عند تسجيل الخروج: إخفاء الواجهة الأساسية */
body.locked .app-header,
body.locked .tabs,
body.locked .container,
body.locked .fab {
    display: none;
}

/* شريط الرأس: الحالة + زر الخروج */
.header-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: auto;
}

.online-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.online-indicator .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.3);
}

.online-indicator.offline .dot {
    background: #f87171;
    box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.3);
}

.online-indicator.offline {
    background: rgba(220, 38, 38, 0.92);
    border-color: rgba(220, 38, 38, 0.92);
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 700;
}

.btn-logout svg {
    width: 16px;
    height: 16px;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.28);
}

/* إدارة الخدمات */
.service-manage {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.service-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    margin-bottom: 8px;
}

.service-order {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.service-name {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    word-break: break-word;
    min-width: 0;
}

.service-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.service-actions .icon-btn {
    width: 44px;
    height: 44px;
    min-height: 44px;
    border-radius: 8px;
}

.service-actions .icon-btn svg {
    width: 15px;
    height: 15px;
}

.add-service-row {
    display: flex;
    gap: 10px;
}

.add-service-row input {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 15px;
    outline: none;
    min-height: 46px;
}

.add-service-row input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 127, 90, 0.15);
}

/* قائمة تذكيرات الحجز داخل نافذة التذكير */
.reminder-list {
    margin-top: 16px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.reminder-list h3 {
    font-size: 14px;
    font-weight: 800;
    color: var(--primary-dark);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.reminder-list h3 svg {
    width: 15px;
    height: 15px;
}

/* زر مصغّر محايد / خطير */
.btn-mini.plain {
    background: var(--primary-light);
    color: var(--primary);
    border-color: #bbe3d3;
}

.btn-mini.danger {
    background: var(--danger-light);
    color: var(--danger);
    border-color: #fecaca;
}

/* ملف العميل: رأس مثبت + مساحة سفلية للتمرير */
.modal-profile .modal-header {
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 2;
    padding: 4px 0 14px;
}

.modal-profile #profileBody {
    padding-bottom: 28px;
}

/* ============================================================
   المرحلة السابعة: مركز «اليوم» — التشغيل اليومي
   (Mobile First — بلا Horizontal Scroll)
============================================================ */

/* البحث الشامل في لوحة التحكم */
.global-search-bar {
    margin-bottom: 6px;
}

.global-search-results {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 14px;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.global-search-results.open {
    padding: 8px;
}

.global-search-results .gs-group h4 {
    font-size: 12px;
    font-weight: 800;
    color: var(--muted);
    margin: 8px 6px 4px;
}

.gs-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: right;
    background: transparent;
    border: none;
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
    min-height: 44px;
}

.gs-item:hover {
    background: var(--bg);
}

.gs-item svg {
    width: 18px;
    height: 18px;
    color: var(--primary);
    flex-shrink: 0;
}

.gs-item span {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.gs-item b {
    font-size: 14px;
    font-weight: 700;
}

.gs-item i {
    font-size: 12px;
    color: var(--muted);
    font-style: normal;
    direction: ltr;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gs-empty {
    font-size: 13px;
    color: var(--muted);
    padding: 12px;
    text-align: center;
}

/* رأس اليوم + إحصائيات اليوم */
.today-head {
    margin-bottom: 14px;
}

.today-date {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(160deg, var(--primary-dark), var(--primary));
    color: #fff;
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 12px;
}

.today-date svg {
    flex-shrink: 0;
}

.td-text {
    display: flex;
    flex-direction: column;
}

.td-day {
    font-size: 18px;
    font-weight: 800;
}

.td-date {
    font-size: 13px;
    opacity: 0.9;
}

.today-stats {
    gap: 10px;
}

.today-stat {
    padding: 12px;
}

.today-stat .stat-icon {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    margin-bottom: 6px;
}

.today-stat .stat-icon svg {
    width: 16px;
    height: 16px;
}

.today-stat .stat-num {
    font-size: 20px;
}

.today-stat .stat-label {
    font-size: 11px;
}

.icon-pending    { background: #fdf3e3; color: #b45309; }
.icon-cancelled  { background: var(--danger-light); color: var(--danger); }
.icon-completed  { background: #e8eefb; color: #1d4ed8; }
.icon-followups  { background: #f1ebfd; color: #6d28d9; }
.icon-reminders  { background: #fce7f3; color: #be185d; }

/* بطاقة الموعد القادم */
.next-appt-card {
    background: var(--bg);
    border: 2px solid var(--primary);
    border-radius: 14px;
    padding: 14px;
}

.na-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.na-head .avatar {
    width: 48px;
    height: 48px;
    font-size: 20px;
}

.na-info {
    flex: 1;
    min-width: 0;
}

.na-name {
    font-size: 17px;
    font-weight: 800;
}

.na-service {
    font-size: 13px;
    color: var(--muted);
}

.na-status {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.na-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 10px;
    margin-bottom: 10px;
}

.na-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    min-width: 0;
    overflow-wrap: anywhere;
}

.na-meta svg {
    width: 15px;
    height: 15px;
    color: var(--muted);
    flex-shrink: 0;
}

.na-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.na-quick {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.na-quick .btn-mini {
    min-height: 44px;
    font-size: 12px;
    padding: 6px 12px;
}

/* جدول اليوم */
.tl-row {
    padding: 12px 14px;
}

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

.tl-time {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 18px;
    font-weight: 800;
    color: var(--primary-dark);
    direction: ltr;
}

.tl-time svg {
    width: 15px;
    height: 15px;
    color: var(--muted);
}

.tl-tags {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.tl-marker {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 999px;
    padding: 3px 9px;
    white-space: nowrap;
}

.tl-marker svg {
    width: 12px;
    height: 12px;
}

.tl-marker-past      { background: #f3f4f6; color: #6b7280; }
.tl-marker-current   { background: #e7f6ec; color: #15803d; }
.tl-marker-upcoming  { background: #e8eefb; color: #1d4ed8; }
.tl-marker-cancelled { background: var(--danger-light); color: #b91c1c; }
.tl-marker-completed { background: #f1f5f9; color: #475569; }
.tl-marker-rescheduled { background: #f1ebfd; color: #6d28d9; }

.tl-main {
    display: flex;
    align-items: center;
    gap: 8px 12px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.tl-main strong {
    font-size: 15px;
    font-weight: 800;
}

.tl-service {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-light);
    border: 1px solid #bbe3d3;
    border-radius: 999px;
    padding: 3px 10px;
}

.tl-meta {
    display: flex;
    gap: 6px 14px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
}

.tl-meta span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    overflow-wrap: anywhere;
}

.tl-meta svg {
    width: 14px;
    height: 14px;
    color: var(--muted);
    flex-shrink: 0;
}

.tl-notes {
    font-size: 12px;
    color: var(--muted);
    background: var(--bg);
    border-radius: 8px;
    padding: 6px 8px;
    margin: 4px 0 8px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* يحتاج إجراء */
.na-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.na-item.na-warn {
    border-color: #fca5a5;
    background: #fff7f7;
}

.na-main {
    min-width: 0;
    flex: 1;
}

.na-main strong {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 800;
}

.na-main strong svg {
    width: 15px;
    height: 15px;
    color: var(--primary);
    flex-shrink: 0;
}

.na-sub {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.na-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.na-actions .btn-mini {
    min-height: 44px;
    font-size: 11px;
    padding: 5px 10px;
}

/* مجموعات المتابعات والتذكيرات */
.followup-group {
    margin-bottom: 12px;
}

.fg-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 800;
    color: var(--primary-dark);
    margin-bottom: 6px;
}

.fg-count {
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 999px;
    font-size: 11px;
    padding: 1px 8px;
}

/* ملخص ملف العميل */
.profile-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
}

.ps-item {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ps-label {
    font-size: 11px;
    color: var(--muted);
}

.ps-value {
    font-size: 14px;
    font-weight: 700;
    overflow-wrap: anywhere;
}

/* ============================================================
   المرحلة الخامسة: Supabase / المزامنة / وضع المطور
============================================================ */

/* مؤشر حالة المزامنة في الرأس — قابل للنقر لفتح التفاصيل الآمنة */
.sync-status {
    display: none;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
}

.sync-status.visible {
    display: inline-flex;
}

.sync-status.warn {
    background: rgba(234, 179, 8, 0.9);
    border-color: rgba(234, 179, 8, 0.9);
}

.sync-status.error {
    background: rgba(220, 38, 38, 0.92);
    border-color: rgba(220, 38, 38, 0.92);
}

/* شريط وضع المطور أعلى المحتوى */
.dev-banner {
    background: #fef3c7;
    border: 1px solid #fde68a;
    color: #92400e;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 14px;
}

.dev-banner code {
    background: rgba(146, 64, 14, 0.08);
    border-radius: 6px;
    padding: 1px 6px;
    direction: ltr;
    unicode-bidi: embed;
}

/* رابط نصي (نسيت كلمة المرور؟) */
.link-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 13px;
    font-weight: 700;
    margin-top: 12px;
    padding: 6px 0;
    text-decoration: underline;
}

/* صندوق بيانات المزامنة في الإعدادات */
.sync-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sync-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 14px;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.sync-row span {
    color: var(--muted);
}

.sync-row b {
    font-weight: 700;
}

/* شريط تحديث PWA — يظهر عند توفر نسخة جديدة، مع تفعيل مضبوط بإرادة المستخدم */
.pwa-update-banner {
    position: sticky;
    top: 56px;
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    margin: 0 12px 8px;
    background: linear-gradient(135deg, #eef6ff, #e8f1ff);
    border: 1px solid #bcd6f7;
    border-radius: 12px;
    color: #1a4f8a;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(26, 79, 138, 0.08);
}

.pwa-update-banner.hidden { display: none; }

/* صندوق فشل المزامنة — رسالة إنسانية بلا تفاصيل تقنية، مع زر إعادة المحاولة */
.sync-error-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    margin: 0 12px 8px;
    background: #fff4f0;
    border: 1px solid #f2c4b3;
    border-radius: 12px;
    color: #9a3412;
    font-size: 14px;
    font-weight: 600;
}

.sync-error-box.hidden { display: none; }

/* حالة النظام (صحة التخزين/المزامنة) */
.health-box {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 4px 4px;
    border-top: 1px solid var(--border);
    margin-top: 14px;
}

.health-box .sync-row {
    padding: 7px 12px;
    background: transparent;
    border: none;
    border-bottom: 1px dashed var(--border);
    border-radius: 0;
}

.health-box .sync-row b {
    font-size: 13px;
}

/* ===== شاشات صغيرة جدًا ===== */
@media (max-width: 400px) {
    .tabs {
        gap: 0;
    }

    .tab {
        font-size: 11px;
        padding: 12px 2px;
        gap: 4px;
    }

    .tab svg {
        width: 16px;
        height: 16px;
    }

    .field-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .field-row .field {
        margin-bottom: 14px;
    }

    .profile-grid {
        grid-template-columns: 1fr;
    }

    .booking-main .bm-time {
        font-size: 18px;
    }

    .today-date {
        padding: 12px;
    }

    .td-day {
        font-size: 16px;
    }

    .na-status {
        flex-direction: row;
        align-items: center;
    }

    .na-meta-grid {
        grid-template-columns: 1fr;
    }

    .online-indicator {
        padding: 5px 9px;
        font-size: 11px;
    }

    .btn-logout {
        padding: 7px 9px;
        font-size: 12px;
    }
}

/* ===== Desktop ===== */
@media (min-width: 720px) {
    .today-stats {
        grid-template-columns: repeat(4, 1fr);
    }

    .profile-summary {
        grid-template-columns: repeat(4, 1fr);
    }

    .na-meta-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .app-header {
        padding: 26px 32px;
    }

    .brand-text h1 {
        font-size: 24px;
    }

    .container {
        padding: 24px 20px 96px;
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }

    .stat-card {
        padding: 20px;
    }

    .booking-meta {
        grid-template-columns: repeat(4, 1fr);
    }

    .booking-client h3 {
        max-width: none;
    }

    /* إظهار تسمية أزرار الإجراءات على الكمبيوتر */
    .icon-btn .btn-label {
        display: inline;
    }

    .booking-actions .icon-btn {
        width: auto;
        padding: 0 14px;
        min-height: 44px;
    }

    .btn-lg {
        width: auto;
        min-width: 260px;
    }

    .dashboard-add {
        display: flex;
        justify-content: flex-start;
    }

    .modal {
        max-width: 560px;
        border-radius: 20px;
        margin: auto;
        max-height: 90vh;
    }

    .modal-profile {
        max-width: min(960px, 94vw);
    }

    /* شبكة أقسام ملف العميل على الشاشات الكبيرة */
    .profile-sections {
        grid-template-columns: repeat(2, 1fr);
        align-items: start;
    }

    .profile-section.span-2 {
        grid-column: 1 / -1;
    }

    .week-grid {
        grid-auto-flow: row;
        grid-auto-columns: auto;
        grid-template-columns: repeat(7, 1fr);
        overflow-x: visible;
    }

    .client-meta {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================================
   المرفقات الطبية (المرحلة 8) — جوال أولًا
   ============================================================ */
.att-hint {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 12px;
}

.att-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.att-preview {
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 12px;
}

.att-preview-name {
    font-size: 14px;
    font-weight: 700;
    word-break: break-word;
}

.att-preview-meta {
    font-size: 12px;
    color: var(--muted);
}

.att-status {
    min-height: 20px;
    font-size: 13px;
    margin-bottom: 12px;
    font-weight: 600;
}

.att-status.error {
    color: var(--danger);
}

.att-status.ok {
    color: var(--primary);
}

.att-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.att-thumb {
    flex: 0 0 52px;
    width: 52px;
    height: 52px;
    border-radius: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    cursor: pointer;
    overflow: hidden;
}

.att-thumb svg {
    width: 24px;
    height: 24px;
}

.att-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.att-thumb-loading {
    font-size: 11px;
    color: var(--muted);
    text-align: center;
    padding: 4px;
}

.att-info {
    flex: 1 1 160px;
    min-width: 0;
}

.att-name {
    font-size: 14px;
    font-weight: 700;
    word-break: break-word;
}

.att-meta {
    font-size: 12px;
    color: var(--muted);
}

.att-note {
    font-size: 12px;
    color: var(--text);
    opacity: 0.85;
    margin-top: 2px;
    word-break: break-word;
}

.att-actions {
    display: flex;
    gap: 6px;
    flex: 0 0 auto;
}

.att-actions .btn-mini.danger {
    color: var(--danger);
}

@media (max-width: 420px) {
    .att-actions {
        flex-basis: 100%;
        justify-content: flex-end;
    }
}

/* ===== التقارير ===== */
.report-periods {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.period-chip {
    flex: 1 1 auto;
    min-width: 92px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.period-chip.active {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-dark);
}

.report-custom {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 10px;
    align-items: end;
    margin-bottom: 12px;
}

.report-custom .field {
    margin-bottom: 0;
}

.report-period-label {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 10px;
    font-weight: 600;
}

.report-offline {
    background: #fff8e6;
    border: 1px solid #e7c864;
    color: #7a5c00;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 12px;
}

.report-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.rep-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    min-width: 0;
}

.kpi-label {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
}

.kpi-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    overflow-wrap: break-word;
}

.kpi-sub {
    font-size: 12px;
    color: var(--muted);
    margin-top: 6px;
    overflow-wrap: break-word;
}

.rep-note {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 10px;
}

.rep-svc-row {
    padding: 8px 0;
}

.rep-svc-info {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 4px;
    font-size: 13px;
}

.rep-svc-name {
    font-weight: 600;
    overflow-wrap: break-word;
}

.rep-svc-num {
    color: var(--muted);
    flex-shrink: 0;
}

.rep-dist-row {
    padding: 8px 0;
}

.rep-dist-info {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 4px;
    font-size: 13px;
}

.rep-dist-label {
    font-weight: 600;
}

.rep-dist-num {
    color: var(--muted);
    flex-shrink: 0;
}

.rep-dist-track {
    height: 8px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
}

.rep-dist-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 99px;
    min-width: 2px;
}

.rep-chart-wrap {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    direction: ltr;
}

.rep-svg {
    display: block;
    width: auto;
    max-width: none;
    height: auto;
}

.rep-bar {
    fill: var(--primary);
}

.rep-bar-val {
    font-size: 10px;
    fill: var(--text);
}

.rep-bar-lbl {
    font-size: 10px;
    fill: var(--muted);
}

.rep-fr-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border);
}

.rep-fr-row:last-child {
    border-bottom: none;
}

.rep-fr-label {
    font-weight: 700;
    min-width: 88px;
}

.rep-fr-num {
    font-size: 13px;
    color: var(--muted);
}

.rep-fr-due {
    color: var(--primary-dark);
}

.rep-fr-late {
    color: var(--danger);
}

.rep-financial {
    background: var(--primary-light);
    border: 1px solid var(--primary);
    border-radius: 12px;
    padding: 14px;
    color: var(--primary-dark);
    font-weight: 600;
    text-align: center;
}

.empty-note {
    color: var(--muted);
    font-size: 13px;
    padding: 8px 0;
}

/* ===== الطباعة ===== */
#printReport {
    display: none;
}

@media print {
    html,
    body {
        margin: 0;
        padding: 0;
        min-height: 0;
        height: auto;
    }

    body > *:not(#printReport) {
        display: none !important;
    }

    #printReport {
        display: block !important;
        position: static;
        top: auto;
        left: auto;
        width: 100%;
        margin: 0;
        padding: 10px;
        min-height: 0;
        height: auto;
        direction: rtl;
        font-family: "Segoe UI", Tahoma, "Noto Kufi Arabic", Arial, sans-serif;
        color: #111;
        line-height: 1.4;
    }

    #printReport h1 {
        font-size: 18px;
        margin: 0 0 4px;
        break-after: avoid;
        page-break-after: avoid;
    }

    #printReport .print-meta {
        color: #555;
        margin: 0 0 8px;
        font-size: 12px;
    }

    #printReport h2 {
        font-size: 14px;
        margin: 12px 0 4px;
        border-bottom: 1px solid #ccc;
        padding-bottom: 2px;
        break-after: avoid;
        page-break-after: avoid;
    }

    #printReport table {
        width: 100%;
        border-collapse: collapse;
        font-size: 12px;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    #printReport tr {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    #printReport th,
    #printReport td {
        border: 1px solid #ccc;
        padding: 4px 7px;
        text-align: right;
    }

    #printReport th {
        background: #f0f0f0;
        font-weight: 700;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    #printReport .print-note {
        margin-top: 14px;
        font-size: 12px;
        color: #555;
        font-style: italic;
    }
}