:root {
  --navy: #1e3a5f;
  --navy-dark: #142843;
  --gold: #f59e0b;
  --gold-light: #fef3c7;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface2: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --text2: #64748b;
  --text3: #94a3b8;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.18);
  --sidebar-w: 260px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { max-width: 100%; }
body { overflow-x: clip; }
body { font-family: 'Segoe UI', Tahoma, Arial, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
body.has-app-shell { padding-bottom: env(safe-area-inset-bottom, 0); }
a { color: inherit; text-decoration: none; }

/* ================= Sidebar ================= */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(15,30,60,.45); z-index: 190; opacity: 0; transition: opacity .25s; }
.sidebar-overlay.visible { display: block; opacity: 1; }

.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--sidebar-w);
  height: 100%;
  height: 100dvh;
  background: var(--navy-dark);
  color: #fff;
  z-index: 200;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,.2);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.sidebar-logo {
  width: 38px; height: 38px;
  background: var(--gold);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; color: var(--navy-dark);
  flex-shrink: 0;
}
.sidebar-title { font-size: 14px; font-weight: 700; line-height: 1.3; }
.sidebar-sub { font-size: 11px; color: rgba(255,255,255,.5); margin-top: 2px; }
.sidebar-close {
  display: none;
  margin-inline-start: auto;
  background: rgba(255,255,255,.1);
  border: none; color: #fff;
  width: 32px; height: 32px; border-radius: 8px;
  cursor: pointer; font-size: 14px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-section {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
  padding: 16px 14px 6px;
}
.sidebar-section:first-child { padding-top: 8px; }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 14px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255,255,255,.72);
  transition: all .15s;
}
.sidebar-link svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .75; }
.sidebar-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-link.active { background: var(--gold); color: var(--navy-dark); font-weight: 700; }
.sidebar-link.active svg { opacity: 1; }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.sidebar-user { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sidebar-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
}
.sidebar-user-name { font-size: 13px; font-weight: 600; }
.sidebar-user-role { font-size: 11px; color: rgba(255,255,255,.5); }
.sidebar-logout {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  color: rgba(255,255,255,.85);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.sidebar-logout:hover { background: rgba(255,255,255,.14); }

/* ================= Topbar ================= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 56px;
  width: 100%;
  max-width: 100vw;
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  overflow-x: clip;
  overflow-y: visible;
}
.topbar-start, .topbar-end { display: flex; align-items: center; gap: 10px; }
.topbar-page-title { font-size: 15px; font-weight: 700; }
.topbar-brand { display: flex; align-items: center; gap: 8px; }
.topbar-logo {
  width: 30px; height: 30px;
  background: var(--gold);
  border-radius: 8px;
  display: none;
  align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; color: var(--navy-dark);
}
.topbar-title { font-size: 14px; font-weight: 600; display: none; }
.topbar-time { font-size: 12px; color: rgba(255,255,255,.55); white-space: nowrap; }
.topbar-user { display: none; }
.topbar-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}

.btn-menu {
  display: none;
  background: rgba(255,255,255,.1);
  border: none; color: #fff;
  width: 38px; height: 38px; border-radius: 10px;
  cursor: pointer;
  align-items: center; justify-content: center;
}
.btn-menu:hover { background: rgba(255,255,255,.18); }

.bell-wrap { position: relative; cursor: pointer; padding: 6px; }
.bell-dot { position: absolute; top: 2px; left: 2px; width: 8px; height: 8px; border-radius: 50%; background: #ef4444; border: 2px solid var(--navy); }

.notif-dropdown { display: none; position: absolute; left: 0; top: 40px; width: 320px; max-height: 420px; background: var(--surface); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.25); overflow: hidden; z-index: 300; color: var(--text); }
.notif-dropdown.open { display: block; }
.notif-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; background: var(--surface2); border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 700; color: var(--navy); }
.notif-header button { background: none; border: none; font-size: 11px; color: var(--text2); cursor: pointer; font-weight: 500; }
.notif-header button:hover { color: var(--navy); text-decoration: underline; }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-empty { padding: 24px; text-align: center; font-size: 12px; color: var(--text2); }
.notif-item { padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .1s; }
.notif-item:hover { background: var(--surface2); }
.notif-item.unread { background: #eff6ff; }
.notif-item.unread:hover { background: #dbeafe; }
.notif-title { font-size: 12px; font-weight: 700; color: var(--text); }
.notif-body { font-size: 12px; color: var(--text2); margin-top: 2px; }
.notif-time { font-size: 10px; color: var(--text3); margin-top: 4px; }

/* Desktop: sidebar ثابت — المحتوى يتزاح للشمال */
@media (min-width: 1024px) {
  body.has-app-shell {
    padding-right: var(--sidebar-w);
  }
  .sidebar { transform: none; }
  .sidebar-close { display: none; }
  .sidebar-overlay { display: none !important; }
  .btn-menu { display: none !important; }
  .topbar-brand { display: none; }
  .topbar-end { margin-inline-start: auto; }
}

/* Mobile: سايدبار منزلق */
@media (max-width: 1023px) {
  body.has-app-shell { padding-right: 0; }
  .sidebar { transform: translateX(100%); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-close { display: flex; align-items: center; justify-content: center; }
  .btn-menu { display: flex; }
  .topbar-logo, .topbar-title { display: flex; }
  .topbar-time { display: none; }
  .topbar-user { display: flex; }
  .topbar-end { margin-inline-start: auto; }
  .notif-dropdown { position: fixed; left: 12px; right: 12px; top: 60px; width: auto; max-height: calc(100vh - 80px); }
}

/* ================= Layout ================= */
.main {
  max-width: 1160px;
  margin-left: auto;
  margin-right: auto;
  padding: 28px 28px 40px;
  padding-bottom: calc(40px + env(safe-area-inset-bottom, 0));
  width: 100%;
  overflow-x: clip;
}
.page-title { font-size: 21px; font-weight: 700; color: var(--navy); margin-bottom: 5px; }
.page-sub { font-size: 13px; color: var(--text2); margin-bottom: 24px; }
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-header-text .page-sub { margin-bottom: 0; }
.page-header-action { flex-shrink: 0; height: 40px; }
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-header .page-sub { margin-bottom: 0; }
.page-header-action { flex-shrink: 0; height: 40px; }

/* شريط توضيحي */
.info-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 100%);
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.55;
}
.info-banner-icon { font-size: 22px; flex-shrink: 0; line-height: 1; margin-top: 2px; }
.info-banner-body strong { display: block; color: var(--navy); margin-bottom: 4px; font-size: 13.5px; }
.info-banner-body p { margin: 0 0 6px; color: var(--text2); }
.info-banner-body p:last-child { margin-bottom: 0; }
.info-banner-note { font-size: 12px; padding-top: 6px; border-top: 1px dashed #93c5fd; margin-top: 8px !important; }
.info-banner-note a { color: var(--navy); font-weight: 600; text-decoration: underline; }
.info-banner-close {
  flex-shrink: 0;
  background: rgba(30,58,95,.08);
  border: none;
  width: 28px; height: 28px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text2);
  font-size: 12px;
  margin-inline-start: auto;
}
.info-banner-close:hover { background: rgba(30,58,95,.14); color: var(--navy); }

.breadcrumb { font-size: 12px; color: var(--text2); margin-bottom: 10px; }
.breadcrumb a:hover { color: var(--navy); text-decoration: underline; }

@media (max-width: 1023px) {
  .main { padding: 20px 16px 32px; }
}

/* ================= Stats ================= */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 16px 18px 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-align: start;
  position: relative;
  overflow: hidden;
  transition: box-shadow .15s, transform .15s;
}
.stat-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.stat-card::before { content: ''; position: absolute; top: 0; right: 0; left: 0; height: 3px; background: var(--border); }
.stat-card:has(.s-total)::before { background: var(--navy); }
.stat-card:has(.s-new)::before { background: #2563eb; }
.stat-card:has(.s-wait)::before { background: #d97706; }
.stat-card:has(.s-active)::before { background: #0891b2; }
.stat-card:has(.s-done)::before { background: #16a34a; }
.stat-card:has(.s-cancel)::before { background: #dc2626; }
.stat-val { font-size: 26px; font-weight: 700; margin-bottom: 3px; line-height: 1.2; }
.stat-lbl { font-size: 12px; color: var(--text2); font-weight: 500; }
.s-total { color: var(--navy); }
.s-new { color: #2563eb; }
.s-wait { color: #d97706; }
.s-active { color: #0891b2; }
.s-done { color: #16a34a; }
.s-cancel { color: #dc2626; }

/* ================= Toolbar ================= */
.toolbar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.search-wrap { position: relative; flex: 1; min-width: 200px; }
.search-wrap svg { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--text3); pointer-events: none; }
.search-input { width: 100%; height: 40px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-size: 13px; padding: 0 36px 0 12px; color: var(--text); outline: none; transition: border .15s; }
.search-input:focus { border-color: var(--navy); }
select.filter { height: 40px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-size: 13px; padding: 0 10px; color: var(--text); outline: none; min-width: 150px; cursor: pointer; }
select.filter:focus { border-color: var(--navy); }
.btn-add { height: 40px; padding: 0 18px; background: var(--gold); color: var(--navy-dark); font-size: 13px; font-weight: 600; border: none; border-radius: var(--radius); cursor: pointer; display: flex; align-items: center; gap: 6px; white-space: nowrap; transition: background .15s; }
.btn-add:hover { background: #e88f00; }
.btn-outline { height: 40px; padding: 0 16px; background: transparent; color: var(--navy); font-size: 13px; font-weight: 600; border: 1px solid var(--navy); border-radius: var(--radius); cursor: pointer; display: flex; align-items: center; gap: 6px; }
.btn-outline:hover { background: var(--navy); color: #fff; }

/* ================= Table ================= */
.table-wrap { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { background: var(--surface2); font-size: 11px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .06em; padding: 12px 16px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); cursor: pointer; }
td { padding: 13px 16px; vertical-align: middle; }
.order-num { font-weight: 600; color: var(--navy); font-size: 13px; }
.client-name { font-weight: 500; }
.company-name { font-size: 11px; color: var(--text2); margin-top: 2px; }
.phone { font-family: monospace; font-size: 13px; direction: ltr; display: inline-block; }
.date-cell { font-size: 12px; color: var(--text2); }
.price-cell { font-weight: 600; color: var(--navy); font-family: monospace; }

/* ================= Badges ================= */
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 20px; white-space: nowrap; }
.b-new { background: #dbeafe; color: #1e40af; }
.b-active { background: #cffafe; color: #0e7490; }
.b-wait { background: #fef3c7; color: #92400e; }
.b-done { background: #dcfce7; color: #15803d; }
.b-cancel { background: #fee2e2; color: #b91c1c; }

.priority-pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; }
.p-low::before, .p-normal::before, .p-high::before, .p-urgent::before { content:''; width:7px; height:7px; border-radius:50%; display:inline-block; }
.p-low::before { background:#94a3b8; }
.p-normal::before { background:#3b82f6; }
.p-high::before { background:#f59e0b; }
.p-urgent::before { background:#dc2626; }

.tag-chip { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px; background: var(--gold-light); color: #92400e; margin: 2px; }

/* ================= Actions ================= */
.actions { display: flex; gap: 4px; justify-content: center; }
.act-btn { width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 7px; background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text2); transition: all .12s; }
.act-btn:hover { background: var(--surface2); border-color: var(--text3); color: var(--text); }
.act-btn.del:hover { background: #fee2e2; border-color: #fca5a5; color: #dc2626; }
.act-btn svg { width: 14px; height: 14px; }

/* ================= Empty / Loading ================= */
.empty { text-align: center; padding: 60px 20px; color: var(--text2); }
.empty svg { width: 48px; height: 48px; margin: 0 auto 12px; display: block; opacity: .3; }
.empty .btn-add { margin: 14px auto 0; }
.loading-row td { text-align: center; padding: 30px; color: var(--text2); font-size: 13px; }

/* ================= Pagination ================= */
.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 14px; border-top: 1px solid var(--border); }
.page-btn { min-width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); cursor: pointer; font-size: 13px; color: var(--text2); }
.page-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ================= Modal ================= */
.overlay { display: none; position: fixed; inset: 0; background: rgba(15,30,60,.5); z-index: 200; align-items: center; justify-content: center; padding: 20px; }
.overlay.open { display: flex; }
.modal { background: var(--surface); border-radius: 14px; width: min(560px, 100%); max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.modal-lg { width: min(760px, 100%); }
.modal-header { background: var(--navy); color: #fff; padding: 18px 22px; border-radius: 14px 14px 0 0; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; }
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-close { background: rgba(255,255,255,.15); border: none; color: #fff; width: 28px; height: 28px; border-radius: 6px; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; }
.modal-close:hover { background: rgba(255,255,255,.25); }
.modal-body { padding: 22px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.form-row.full { grid-template-columns: 1fr; }
.form-row.three { grid-template-columns: 1fr 1fr 1fr; }
.field label { font-size: 12px; font-weight: 600; color: var(--text2); display: block; margin-bottom: 5px; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; padding: 9px 11px; color: var(--text); background: var(--surface); outline: none; transition: border .15s; font-family: inherit; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--navy); }
.field textarea { resize: vertical; min-height: 70px; }
.field-hint { font-size: 11px; color: var(--text3); margin-top: 4px; }
.branch-checkboxes { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 6px; }
.branch-check-label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 6px 10px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.branch-check-label input { accent-color: var(--navy); }
.client-autocomplete { position: relative; }
.client-suggestions { display: none; position: absolute; top: calc(100% + 4px); right: 0; left: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 220px; overflow-y: auto; z-index: 400; }
.client-suggestions.open { display: block; }
.client-suggestion { padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--border); transition: background .1s; }
.client-suggestion:last-child { border-bottom: none; }
.client-suggestion:hover, .client-suggestion.active { background: var(--surface2); }
.client-suggestion-name { font-size: 13px; font-weight: 600; color: var(--text); }
.client-suggestion-meta { font-size: 11px; color: var(--text2); margin-top: 2px; }
.client-suggestion-empty { padding: 12px; font-size: 12px; color: var(--text2); text-align: center; }
.client-selected-badge { display: none; margin-top: 6px; font-size: 11px; color: #16a34a; font-weight: 600; }
.client-selected-badge.visible { display: block; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; position: sticky; bottom: 0; background: var(--surface); }
.btn-primary { height: 38px; padding: 0 20px; background: var(--navy); color: #fff; font-size: 13px; font-weight: 600; border: none; border-radius: 8px; cursor: pointer; }
.btn-primary:hover { background: var(--navy-dark); }
.btn-sec { height: 38px; padding: 0 16px; background: transparent; color: var(--text2); font-size: 13px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.btn-sec:hover { background: var(--surface2); }
.btn-danger { height: 38px; padding: 0 16px; background: #dc2626; color: #fff; font-size: 13px; font-weight: 600; border: none; border-radius: 8px; cursor: pointer; }
.btn-danger:hover { background: #b91c1c; }

/* ================= Tabs (order/client details) ================= */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
.tab-btn { padding: 10px 16px; font-size: 13px; font-weight: 600; color: var(--text2); background: none; border: none; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; flex-shrink: 0; }
.tab-btn.active { color: var(--navy); border-bottom-color: var(--gold); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ================= Cards (details pages) ================= */
.card { background: var(--surface); border-radius: 12px; border: 1px solid var(--border); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 18px; }
.card h4 { font-size: 13.5px; font-weight: 700; color: var(--navy); margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.card h4.no-border { border-bottom: none; padding-bottom: 0; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.detail-item .lbl { font-size: 11px; color: var(--text2); margin-bottom: 3px; text-transform: uppercase; letter-spacing: .04em; }
.detail-item .val { font-size: 14px; font-weight: 600; }

/* ================= Timeline ================= */
.timeline { position: relative; padding-inline-start: 22px; }
.timeline::before { content:''; position: absolute; right: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding-bottom: 18px; }
.timeline-item::before { content:''; position: absolute; right: 0; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); border: 2px solid var(--surface); box-shadow: 0 0 0 2px var(--gold); }
.timeline-item .t-action { font-size: 13px; font-weight: 600; }
.timeline-item .t-meta { font-size: 11px; color: var(--text2); margin-top: 2px; }
.timeline-item .t-note { font-size: 12px; color: var(--text2); margin-top: 4px; background: var(--surface2); padding: 8px 10px; border-radius: 8px; }

/* ================= Login Page ================= */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%); padding: 20px; }
.login-card { background: var(--surface); border-radius: 16px; width: min(400px, 100%); padding: 36px 32px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-logo { width: 56px; height: 56px; background: var(--gold); border-radius: 14px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 22px; color: var(--navy-dark); margin: 0 auto 16px; }
.login-title { text-align: center; font-size: 17px; font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.login-sub { text-align: center; font-size: 13px; color: var(--text2); margin-bottom: 24px; }
.login-field { margin-bottom: 16px; }
.login-field label { font-size: 12px; font-weight: 600; color: var(--text2); display: block; margin-bottom: 6px; }
.login-field input { width: 100%; height: 44px; border: 1px solid var(--border); border-radius: 10px; padding: 0 14px; font-size: 14px; outline: none; }
.login-field input:focus { border-color: var(--navy); }
.login-btn { width: 100%; height: 44px; background: var(--navy); color: #fff; font-size: 14px; font-weight: 700; border: none; border-radius: 10px; cursor: pointer; margin-top: 6px; }
.login-btn:hover { background: var(--navy-dark); }
.login-error { background: #fee2e2; color: #b91c1c; font-size: 12px; padding: 10px 12px; border-radius: 8px; margin-bottom: 16px; display: none; }
.login-error.show { display: block; }

/* ================= Toast ================= */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px); background: var(--navy); color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 13px; font-weight: 500; z-index: 999; transition: transform .3s; pointer-events: none; }
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { background: #dc2626; }

/* ================= Misc ================= */
.chart-wrap { background: var(--surface); border-radius: 12px; border: 1px solid var(--border); box-shadow: var(--shadow); padding: 20px 22px; }
.chart-canvas-wrap { position: relative; height: 260px; }
.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1023px) {
  .two-col { grid-template-columns: 1fr; }
  .form-row, .form-row.three { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat-val { font-size: 22px; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .page-title { font-size: 18px; }
  .toolbar { gap: 8px; }
  .search-wrap { flex: 1 1 100%; min-width: 0; order: -2; }
  select.filter { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .btn-add, .btn-outline { flex: 1 1 auto; justify-content: center; font-size: 12px; padding: 0 12px; }
  .overlay { padding: 0; align-items: flex-end; }
  .modal { width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; }
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn-primary, .modal-footer .btn-sec { width: 100%; height: 44px; }
  .toast { bottom: calc(16px + env(safe-area-inset-bottom, 0)); width: calc(100% - 32px); text-align: center; }

  /* جداول ككروت على الموبايل */
  .responsive-table thead { display: none; }
  .responsive-table tbody tr {
    display: block;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 4px 0;
  }
  .responsive-table tbody tr:hover { background: var(--surface); }
  .responsive-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    text-align: left;
  }
  .responsive-table td:last-child { border-bottom: none; }
  .responsive-table td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 700;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: .04em;
    flex-shrink: 0;
  }
  .responsive-table td .actions { justify-content: flex-end; width: 100%; }
  .responsive-table .loading-row td { display: block; text-align: center; }
  .responsive-table .loading-row td::before { display: none; }
}

@media (max-width: 480px) {
  .stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card { padding: 12px 10px; }
  .detail-grid { grid-template-columns: 1fr; }
  .kanban-col { flex: 0 0 min(88vw, 300px); }
}

/* ================= Mobile polish ================= */
@media (max-width: 600px) {
  .topbar {
    height: 56px;
    padding: 0 8px;
    gap: 6px;
  }
  .topbar-start {
    min-width: 0;
    flex: 1;
    gap: 8px;
  }
  .topbar-end {
    gap: 4px;
    flex-shrink: 0;
  }
  .btn-menu {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    order: 3;
  }
  .topbar-brand {
    min-width: 0;
    flex: 1;
  }
  .topbar-logo {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
  }
  .topbar-title {
    min-width: 0;
    max-width: 190px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
  }
  .topbar-page-title {
    display: none;
  }
  .bell-wrap {
    padding: 4px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .topbar-user {
    display: none;
  }

  .main {
    padding: 18px 12px 28px;
  }
  .page-title {
    font-size: 20px;
    margin-bottom: 4px;
  }
  .page-sub {
    font-size: 12px;
    margin-bottom: 18px;
  }

  .stats {
    gap: 10px;
    margin-bottom: 18px;
  }
  .stat-card {
    min-height: 76px;
    padding: 13px 14px 11px;
    border-radius: 13px;
  }
  .stat-val {
    font-size: 22px;
  }
  .stat-lbl {
    font-size: 12px;
    line-height: 1.35;
  }

  .chart-wrap,
  .card,
  .table-wrap {
    border-radius: 13px;
  }
  .chart-wrap {
    padding: 18px 14px 14px;
  }
  .chart-wrap > div:first-child {
    flex-direction: column;
    align-items: stretch !important;
    margin-bottom: 12px !important;
  }
  .chart-wrap h4 {
    text-align: center;
    line-height: 1.5;
  }
  .chart-wrap .chip-toggle {
    flex: 1;
    justify-content: center;
    min-width: 0;
  }
  .chart-canvas-wrap {
    height: 280px;
    margin: 0 -4px;
  }

  .card {
    padding: 18px 14px;
  }
  .card h4 {
    margin-bottom: 12px;
    padding-bottom: 10px;
  }

  .responsive-table tbody tr {
    border-radius: 13px;
  }
}

@media (max-width: 380px) {
  .topbar-title {
    max-width: 150px;
    font-size: 13px;
  }
  .main {
    padding-inline: 10px;
  }
  .stats {
    gap: 8px;
  }
  .stat-card {
    padding: 12px 11px 10px;
  }
  .stat-lbl {
    font-size: 11px;
  }
}

/* ================= Comments ================= */
.comment-box { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 16px; }
.comment-box textarea { flex: 1; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; padding: 9px 11px; font-family: inherit; resize: vertical; outline: none; }
.comment-box textarea:focus { border-color: var(--navy); }

/* ================= WhatsApp templates modal ================= */
.wa-modal-overlay { display: none; position: fixed; inset: 0; background: rgba(15,30,60,.5); z-index: 500; align-items: center; justify-content: center; padding: 16px; }
.wa-modal-overlay.open { display: flex; }
.wa-modal { background: var(--surface); border-radius: 14px; width: min(440px, 100%); max-height: 80vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.wa-modal-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; background: #25d366; color: #fff; font-size: 14px; font-weight: 700; border-radius: 14px 14px 0 0; position: sticky; top: 0; }
.wa-modal-header button { background: rgba(255,255,255,.2); border: none; color: #fff; width: 28px; height: 28px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.wa-modal-body { padding: 10px; }
.wa-template { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; cursor: pointer; transition: all .12s; }
.wa-template:hover { border-color: #25d366; background: #f0fdf4; }
.wa-template-recommended { border-color: #86efac; background: #f0fdf4; }
.wa-rec-badge { display: inline-block; font-size: 10px; font-weight: 700; color: #15803d; background: #dcfce7; padding: 2px 6px; border-radius: 6px; margin-right: 6px; }
.wa-template-label { font-size: 13px; font-weight: 700; color: var(--navy); }
.wa-template-preview { font-size: 11px; color: var(--text2); margin-top: 4px; line-height: 1.6; }

/* ================= FAB (زر عائم للموبايل) ================= */
.fab { display: none; position: fixed; bottom: calc(20px + env(safe-area-inset-bottom, 0)); left: 20px; width: 54px; height: 54px; border-radius: 50%; background: var(--gold); color: var(--navy-dark); border: none; cursor: pointer; box-shadow: 0 6px 20px rgba(0,0,0,.3); z-index: 150; align-items: center; justify-content: center; transition: transform .15s; }
.fab:active { transform: scale(.92); }
.fab svg { width: 24px; height: 24px; }
@media (max-width: 1023px) {
  .fab { display: flex; }
}

/* ================= Sortable table headers ================= */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--navy); }
th.sortable .sort-arrow { font-size: 9px; margin-inline-start: 3px; opacity: .5; }
th.sortable.sorted .sort-arrow { opacity: 1; color: var(--gold); }

/* ================= Overdue highlight ================= */
tr.row-overdue td:first-child { box-shadow: inset 3px 0 0 #dc2626; }
.due-overdue { color: #dc2626 !important; font-weight: 700; }

/* ================= Empty states (rich) ================= */
.empty-state-rich {
  text-align: center;
  padding: 48px 24px 56px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 16px;
  margin-top: 8px;
}
.empty-state-icon {
  width: 56px; height: 56px; margin: 0 auto 16px;
  background: #ecfdf5; color: #16a34a;
  border-radius: 50%; font-size: 26px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.empty-state-rich h3 { font-size: 17px; color: var(--navy); margin-bottom: 8px; }
.empty-state-rich > p { font-size: 13px; color: var(--text2); max-width: 420px; margin: 0 auto 18px; line-height: 1.6; }
.empty-state-steps {
  list-style: none; text-align: right; max-width: 360px; margin: 0 auto 22px;
  font-size: 13px; color: var(--text2); line-height: 1.8;
}
.empty-state-steps li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.empty-state-steps li:last-child { border-bottom: none; }
.empty-state-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ================= Info banner ================= */
.info-banner {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; margin-bottom: 18px;
  background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 100%);
  border: 1px solid #bfdbfe; border-radius: 12px;
  font-size: 13px; color: var(--text);
}
.info-banner-icon { font-size: 20px; line-height: 1; flex-shrink: 0; margin-top: 2px; }
.info-banner-body { flex: 1; line-height: 1.65; }
.info-banner-body strong { color: var(--navy); display: block; margin-bottom: 4px; }
.info-banner-body p { margin: 0 0 6px; color: var(--text2); }
.info-banner-body em { font-style: normal; font-weight: 600; color: var(--navy); }
.info-banner-note { font-size: 12px !important; padding-top: 6px; border-top: 1px solid rgba(59,130,246,.2); margin-top: 8px !important; }
.info-banner-note a { color: var(--navy); font-weight: 700; text-decoration: underline; }
.info-banner-close {
  background: rgba(30,58,95,.08); border: none; color: var(--text2);
  width: 28px; height: 28px; border-radius: 8px; cursor: pointer; flex-shrink: 0;
  font-size: 12px; transition: background .12s;
}
.info-banner-close:hover { background: rgba(30,58,95,.14); color: var(--navy); }

/* ================= Task page stats ================= */
.task-stat-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.task-stat-card {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 4px; padding: 14px 8px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  cursor: pointer; transition: all .15s; font-family: inherit;
  box-shadow: var(--shadow);
}
.task-stat-card:hover:not(:disabled) { border-color: var(--navy); transform: translateY(-2px); box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.task-stat-card.has-items { border-color: #cbd5e1; }
.task-stat-card.urgent.has-items { border-color: #fecaca; background: #fffbfb; }
.task-stat-card.is-zero { opacity: .55; cursor: default; }
.task-stat-card:disabled { cursor: default; }
.task-stat-icon { font-size: 18px; line-height: 1; }
.task-stat-val { font-size: 22px; font-weight: 800; color: var(--navy); line-height: 1.1; }
.task-stat-card.urgent.has-items .task-stat-val { color: #dc2626; }
.task-stat-lbl { font-size: 11px; color: var(--text2); font-weight: 600; }

.task-loading { margin-bottom: 16px; }
.skeleton-card {
  height: 72px; border-radius: 12px; margin-bottom: 10px;
  background: linear-gradient(90deg, var(--surface2) 25%, #eef2f7 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
}
.skeleton-card.short { height: 48px; width: 60%; }
@keyframes skeleton-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* ================= Task cards (مهامي) ================= */
.task-group { margin-bottom: 16px; padding: 0; overflow: hidden; }
.task-group-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.task-group-head h4 { font-size: 14px; font-weight: 700; color: var(--navy); margin: 0; display: flex; align-items: center; gap: 8px; }
.task-group-sub { font-size: 12px; color: var(--text2); margin: 4px 0 0; }
.task-group-count {
  min-width: 28px; height: 28px; padding: 0 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  font-size: 13px; font-weight: 700; color: var(--navy);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.task-group-head.tone-danger { background: #fef2f2; }
.task-group-head.tone-danger h4 { color: #b91c1c; }
.task-group-head.tone-wait { background: #fffbeb; }
.task-group-head.tone-active { background: #ecfeff; }
.task-group-list { padding: 12px 14px 14px; }
.task-group-flash { animation: task-flash .9s ease; }
@keyframes task-flash {
  0%, 100% { box-shadow: var(--shadow); }
  40% { box-shadow: 0 0 0 3px rgba(245,158,11,.45); }
}

.task-card { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; cursor: pointer; transition: all .12s; background: var(--surface); }
.task-card:last-child { margin-bottom: 0; }
.task-card:hover { border-color: var(--navy); box-shadow: var(--shadow); }
.task-card:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.task-card.overdue { border-inline-start: 3px solid #dc2626; background: #fffbfb; }
.task-card-title { font-size: 13px; font-weight: 600; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.task-card-client { font-weight: 600; }
.task-card-meta { font-size: 12px; color: var(--text2); margin-top: 4px; line-height: 1.5; }
.task-card-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.task-due { font-size: 11px; color: var(--text2); }
.task-due.overdue { color: #dc2626; font-weight: 700; }
.task-card-go { font-size: 14px; color: var(--text3); opacity: 0; transition: opacity .12s; }
.task-card:hover .task-card-go { opacity: 1; }
.task-priority { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 10px; }
.task-priority.priority-high { background: #ffedd5; color: #c2410c; }
.task-priority.priority-urgent { background: #fee2e2; color: #b91c1c; }

@media (max-width: 900px) {
  .task-stat-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 540px) {
  .task-stat-grid { grid-template-columns: repeat(2, 1fr); }
  .task-card-go { opacity: 1; }
  .info-banner { flex-direction: column; }
  .empty-state-rich { padding: 32px 16px 40px; }
}

/* ================= Toggle chip (طلباتي فقط) ================= */
.chip-toggle { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-size: 13px; font-weight: 600; color: var(--text2); cursor: pointer; transition: all .12s; white-space: nowrap; }
.chip-toggle.active { background: var(--navy); border-color: var(--navy); color: #fff; }

/* ================= WhatsApp button ================= */
.btn-whatsapp { height: 38px; padding: 0 16px; background: #25d366; color: #fff; font-size: 13px; font-weight: 600; border: none; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.btn-whatsapp:hover { background: #1ebd5a; }
.btn-whatsapp.sm { height: 30px; padding: 0 10px; font-size: 12px; }

/* ================= Kanban Board ================= */
.kanban-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
  scrollbar-width: thin;
}
.kanban-board {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  width: max-content;
  min-width: 100%;
  padding-bottom: 4px;
}
.kanban-col {
  flex: 0 0 260px;
  background: var(--surface2);
  border-radius: 12px;
  border: 1px solid var(--border);
  min-height: 200px;
  display: flex;
  flex-direction: column;
}
.kanban-col-header { padding: 12px 14px; font-size: 12px; font-weight: 700; border-bottom: 2px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.kanban-col-body { padding: 10px; flex: 1; display: flex; flex-direction: column; gap: 8px; min-height: 120px; transition: background .15s; }
.kanban-col-body.drag-over { background: var(--gold-light); }
.kanban-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: grab; box-shadow: var(--shadow); font-size: 12px; }
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging { opacity: .4; }
.kanban-card .kc-num { font-weight: 700; color: var(--navy); }
.kanban-card .kc-client { font-weight: 600; margin-top: 4px; }
.kanban-card .kc-meta { color: var(--text2); font-size: 11px; margin-top: 4px; }
.kanban-card-actions { display: none; gap: 6px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); }
.kanban-card-actions button, .kanban-card-actions a {
  flex: 1;
  height: 32px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--navy);
  font-family: inherit;
}
.kanban-card-actions .kc-change { background: var(--navy); color: #fff; border-color: var(--navy); }

/* Bottom sheet: تغيير الحالة على الموبايل */
.kanban-sheet-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,30,60,.45);
  z-index: 500;
  align-items: flex-end;
  justify-content: center;
}
.kanban-sheet-overlay.open { display: flex; }
.kanban-sheet {
  background: var(--surface);
  width: 100%;
  max-height: 75vh;
  border-radius: 16px 16px 0 0;
  overflow: hidden;
  animation: kanbanSheetUp .25s ease;
}
@keyframes kanbanSheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.kanban-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.kanban-sheet-header h4 { font-size: 14px; font-weight: 700; color: var(--navy); }
.kanban-sheet-header button {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text2);
  cursor: pointer;
  width: 32px;
  height: 32px;
}
.kanban-sheet-sub { font-size: 12px; color: var(--text2); padding: 0 18px 10px; }
.kanban-sheet-list { padding: 8px 12px 20px; overflow-y: auto; max-height: 50vh; }
.kanban-status-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  transition: background .12s;
}
.kanban-status-opt:hover { background: var(--surface2); }
.kanban-status-opt.current { border-color: var(--navy); background: #eff6ff; }
.kanban-status-opt:disabled { opacity: .5; cursor: not-allowed; }

@media (max-width: 768px) {
  .kanban-scroll {
    margin: 0 -12px;
    padding: 0 12px 12px;
    scroll-snap-type: x proximity;
  }
  .kanban-col {
    flex: 0 0 min(86vw, 300px);
    scroll-snap-align: start;
    min-height: 280px;
  }
  .kanban-card {
    cursor: default;
    -webkit-user-drag: none;
    user-select: none;
  }
  .kanban-card-actions { display: flex; }
  .kanban-col-body.drag-over { background: transparent; }
}

@media (min-width: 1200px) {
  .kanban-col { flex: 0 0 calc((100% - 56px) / 5); max-width: none; }
  .kanban-board { width: 100%; }
}

.kanban-toolbar { flex-wrap: wrap; align-items: center; gap: 10px; }
.kanban-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.kanban-col-body { max-height: min(70vh, 640px); overflow-y: auto; }
.kanban-empty { color: var(--text3); font-size: 11px; text-align: center; padding: 16px 0; }
.kanban-more-btn {
  width: 100%;
  margin-top: 4px;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--navy);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.kanban-more-btn:hover { background: var(--surface2); }
.kanban-meta { margin-bottom: 4px; }

@media (max-width: 768px) {
  .kanban-filters { width: 100%; }
  .kanban-col-body { max-height: 50vh; }
}

/* ================= Print / PDF export ================= */
@media print {
  .sidebar, .sidebar-overlay, .topbar, .toolbar, .pagination, .no-print, .btn-add, .btn-outline, .act-btn, .modal-footer, .bell-wrap { display: none !important; }
  body, body.has-app-shell { background: #fff; padding-right: 0 !important; }
  .main { max-width: 100%; padding: 0; margin: 0; }
  .table-wrap { box-shadow: none; border: 1px solid #000; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  table { font-size: 11px; }
  a { text-decoration: none; color: inherit; }
}

/* ================= Global search ================= */
.global-search-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: none;
  background: rgba(255,255,255,.1);
  color: #fff;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.global-search-toggle:hover { background: rgba(255,255,255,.18); }

.global-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 10px;
  padding: 0 10px;
  height: 36px;
  min-width: 0;
  max-width: 220px;
  width: 200px;
  flex-shrink: 1;
}
.global-search-wrap svg { color: rgba(255,255,255,.55); flex-shrink: 0; }
.global-search-form { flex: 1; min-width: 0; display: flex; margin: 0; }
.global-search-wrap input {
  border: none; background: none; outline: none;
  font-size: 12px; font-family: inherit; width: 100%; min-width: 0;
  color: #fff;
}
.global-search-wrap input::placeholder { color: rgba(255,255,255,.45); }

.global-search-results {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: auto;
  width: min(320px, calc(100vw - 24px));
  min-width: 0;
  max-width: calc(100vw - 24px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  max-height: min(360px, 60vh);
  overflow-y: auto;
  z-index: 400;
  -webkit-overflow-scrolling: touch;
}
.global-search-results.open { display: block; }
.gs-section { font-size: 10px; font-weight: 700; color: var(--text3); padding: 8px 12px 4px; text-transform: uppercase; }
.gs-item {
  display: block;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--navy);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  word-break: break-word;
}
.gs-item:hover { background: var(--surface2); }
.gs-meta { color: var(--text2); font-size: 11px; font-weight: 400; }
.gs-empty { padding: 16px; text-align: center; color: var(--text2); font-size: 12px; }

/* موبايل: أيقونة بحث + لوحة ثابتة تحت الهيدر */
@media (max-width: 768px) {
  .global-search-toggle { display: inline-flex; }

  .global-search-wrap {
    display: none;
    position: fixed;
    top: 56px;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100vw;
    height: 48px;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    background: var(--navy-dark);
    z-index: 360;
    padding: 0 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
  }

  body.global-search-open .global-search-wrap { display: flex; }

  .global-search-results {
    position: fixed;
    top: 104px;
    right: 12px;
    left: 12px;
    width: auto;
    max-width: none;
    max-height: min(55vh, 420px);
    z-index: 365;
  }

  body.global-search-open { overflow: hidden; }

  .topbar-end {
    min-width: 0;
    flex-shrink: 0;
    gap: 6px;
  }
}

@media (min-width: 769px) and (max-width: 1023px) {
  .global-search-wrap {
    width: 150px;
    max-width: 150px;
  }
  .global-search-results {
    position: fixed;
    top: 60px;
    right: 12px;
    left: 12px;
    width: auto;
    max-width: none;
  }
}
.pwa-install-btn {
  height: 36px; width: 36px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface2);
  cursor: pointer; font-size: 16px; align-items: center; justify-content: center;
}

/* ================= Bulk actions ================= */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 13px;
  flex-wrap: wrap;
}
.bulk-bar select { height: 34px; border-radius: 8px; border: 1px solid var(--border); padding: 0 10px; font-family: inherit; }

/* ================= Follow-up badge ================= */
.follow-up-badge {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

/* ================= Attachment preview ================= */
.preview-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,30,60,.55);
  z-index: 600;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.preview-overlay.open { display: flex; }
.preview-modal {
  background: var(--surface);
  border-radius: 12px;
  width: min(90vw, 900px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 13px;
}
.preview-header button { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text2); }
.preview-body { flex: 1; overflow: auto; display: flex; align-items: center; justify-content: center; min-height: 300px; background: #f8fafc; }
.preview-body img { max-width: 100%; max-height: 75vh; object-fit: contain; }
.preview-body iframe { width: 100%; height: 75vh; border: none; }

@media (max-width: 768px) {
  .topbar-page-title { display: none; }
  .kanban-scroll { margin: 0; padding: 0 0 12px; }
}

.dash-sub-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.dash-customize-btn { height: 34px; font-size: 12px; }
.dash-customize-hint {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.6;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--surface2);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.dash-check-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.dash-check-label:last-child { border-bottom: none; }

/* ================= Calendar ================= */
.calendar-legend { display: flex; flex-wrap: wrap; gap: 12px 18px; font-size: 12px; color: var(--text2); margin-bottom: 8px; }
.calendar-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-left: 6px; vertical-align: middle; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-head { text-align: center; font-size: 11px; font-weight: 700; color: var(--text2); padding: 6px; }
.cal-cell { min-height: 72px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 6px; font-size: 12px; }
.cal-cell.empty { background: transparent; border-color: transparent; }
.cal-cell.today { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.cal-cell.has-events { background: #fafbfc; }
.cal-day { font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.cal-dots { display: flex; gap: 3px; flex-wrap: wrap; }
.cal-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.cal-more { font-size: 10px; color: var(--text3); margin-top: 2px; }
.cal-event-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text); text-decoration: none; }
.cal-event-row:hover { color: var(--navy); }
@media (max-width: 640px) { .cal-cell { min-height: 52px; padding: 4px; } }

/* ================= Checklist ================= */
.checklist-progress { margin-bottom: 14px; }
.checklist-bar-wrap { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--text2); }
.checklist-bar { flex: 1; height: 8px; background: var(--surface2); border-radius: 8px; overflow: hidden; }
.checklist-bar-fill { height: 100%; background: linear-gradient(90deg, #16a34a, #22c55e); border-radius: 8px; transition: width .3s; }
.checklist-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; cursor: pointer; font-size: 13px; transition: background .12s; }
.checklist-item:hover { background: var(--surface2); }
.checklist-item.done { background: #f0fdf4; border-color: #bbf7d0; }
.checklist-item.done span { text-decoration: line-through; color: var(--text2); }
.checklist-item .req { color: #dc2626; font-style: normal; }
.checklist-item input { margin-top: 3px; accent-color: var(--navy); }

/* ================= Welcome / Onboarding ================= */
.welcome-page { max-width: 960px; margin: 0 auto; }
.welcome-hero { text-align: center; margin-bottom: 28px; }
.welcome-icon { font-size: 48px; margin-bottom: 8px; }
.welcome-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; margin-bottom: 28px; }
.welcome-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.welcome-card-highlight { border-color: var(--gold); background: linear-gradient(180deg, #fffbeb 0%, #fff 100%); }
.welcome-card-icon { font-size: 28px; }
.welcome-card h3 { font-size: 15px; font-weight: 700; color: var(--navy); margin: 0; }
.welcome-card p { font-size: 13px; color: var(--text2); line-height: 1.7; margin: 0; flex: 1; }
.welcome-card .btn-sec, .welcome-card .btn-add { align-self: flex-start; margin-top: 8px; }
.welcome-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; padding-bottom: 32px; }
