/* ===================== الألوان ===================== */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8ef;
  --border-strong: #cbd5e1;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #0f3d5e;
  --primary-600: #155a87;
  --primary-50: #e8f1f8;
  --accent: #f5b301;
  --accent-50: #fff7db;
  --success: #15803d;
  --success-50: #e7f6ec;
  --warning: #b45309;
  --warning-50: #fff4e0;
  --danger: #b91c1c;
  --danger-50: #fdecec;
  --info: #1d4ed8;
  --info-50: #e8efff;
  --sidebar-bg: #0c2f48;
  --sidebar-text: #c9d7e3;
  --sidebar-active: #f5b301;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 2px 8px rgba(15, 23, 42, .05);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .18);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Segoe UI", Tahoma, "Noto Sans Arabic", "Geeza Pro", system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1520; --surface: #142131; --surface-2: #192a3d; --border: #24384f; --border-strong: #34506d;
    --text: #e5edf5; --muted: #93a7bb; --primary: #5aa9e6; --primary-600: #7dbdf0; --primary-50: #16324a;
    --accent-50: #3a2f0a; --success-50: #0f3320; --warning-50: #3b2a0c; --danger-50: #3d1515; --info-50: #172a52;
    --success: #4ade80; --warning: #fbbf24; --danger: #f87171; --info: #93b4ff;
    --sidebar-bg: #0a1824; --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1520; --surface: #142131; --surface-2: #192a3d; --border: #24384f; --border-strong: #34506d;
  --text: #e5edf5; --muted: #93a7bb; --primary: #5aa9e6; --primary-600: #7dbdf0; --primary-50: #16324a;
  --accent-50: #3a2f0a; --success-50: #0f3320; --warning-50: #3b2a0c; --danger-50: #3d1515; --info-50: #172a52;
  --success: #4ade80; --warning: #fbbf24; --danger: #f87171; --info: #93b4ff;
  --sidebar-bg: #0a1824; --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
}

/* ===================== الأساسيات ===================== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font); font-size: 14.5px; line-height: 1.6; color: var(--text); background: var(--bg);
  direction: rtl; text-align: right; -webkit-font-smoothing: antialiased;
}
a { color: var(--primary-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.35; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; } h4 { font-size: .95rem; }
p { margin: 0 0 .6rem; }
small, .muted { color: var(--muted); }
.mono, .num { font-variant-numeric: tabular-nums; }
.num { direction: ltr; unicode-bidi: plaintext; text-align: left; display: inline-block; }
.ltr { direction: ltr; unicode-bidi: plaintext; }
.text-center { text-align: center !important; }
.text-end { text-align: left !important; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.pos { color: var(--success); } .neg { color: var(--danger); }
svg.icon { width: 18px; height: 18px; flex-shrink: 0; vertical-align: middle; }

.boot { display: grid; place-items: center; min-height: 100vh; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
.spinner.sm { width: 18px; height: 18px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-box { display: grid; place-items: center; padding: 3rem; }

/* ===================== التخطيط ===================== */
.shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.shell.collapsed { grid-template-columns: 68px 1fr; }
.sidebar {
  background: var(--sidebar-bg); color: var(--sidebar-text); position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; scrollbar-width: thin; scrollbar-color: #24445e transparent; z-index: 40;
}
.brand { display: flex; align-items: center; gap: .65rem; padding: 1rem .9rem; border-bottom: 1px solid rgba(255,255,255,.08); min-height: 64px; }
.brand img { width: 38px; height: 38px; border-radius: 9px; object-fit: contain; background: #fff; }
.brand .name { color: #fff; font-weight: 700; font-size: .98rem; line-height: 1.3; }
.brand .sub { font-size: .72rem; opacity: .7; color: var(--sidebar-text); }
.nav { padding: .5rem .5rem 2rem; }
.nav-section { margin-top: .4rem; }
.nav-section-title {
  display: flex; align-items: center; justify-content: space-between; width: 100%; background: none; border: 0; color: #8fa9bf;
  font: inherit; font-size: .74rem; font-weight: 700; letter-spacing: .02em; padding: .55rem .65rem .3rem; cursor: pointer;
}
.nav-section-title svg { width: 14px; height: 14px; transition: transform .2s; }
.nav-section.closed .nav-section-title svg { transform: rotate(90deg); }
.nav-section.closed .nav-items { display: none; }
.nav-item {
  display: flex; align-items: center; gap: .65rem; padding: .5rem .7rem; border-radius: 8px; color: var(--sidebar-text);
  font-size: .9rem; margin: 1px 0; text-decoration: none !important; white-space: nowrap;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(245,179,1,.14); color: #fff; box-shadow: inset -3px 0 0 var(--sidebar-active); }
.nav-item.active svg { color: var(--sidebar-active); }
.shell.collapsed .brand .txt, .shell.collapsed .nav-item span, .shell.collapsed .nav-section-title { display: none; }
.shell.collapsed .nav-item { justify-content: center; padding: .6rem; }
.shell.collapsed .nav-section.closed .nav-items { display: block; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .6rem; padding: .55rem 1.1rem; min-height: 58px;
}
.topbar-title { font-weight: 700; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-spacer { flex: 1; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: var(--text); cursor: pointer; position: relative;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); }
.icon-btn .dot {
  position: absolute; top: 4px; inset-inline-end: 4px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 10px;
  background: var(--danger); color: #fff; font-size: .68rem; font-weight: 700; display: grid; place-items: center;
}
.user-chip { display: flex; align-items: center; gap: .5rem; padding: .25rem .45rem; border-radius: 10px; cursor: pointer; border: 1px solid transparent; background: none; color: inherit; font: inherit; }
.user-chip:hover { background: var(--surface-2); border-color: var(--border); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex-shrink: 0; }
.avatar.lg { width: 52px; height: 52px; font-size: 1.15rem; }
.user-chip .meta { line-height: 1.2; text-align: right; }
.user-chip .meta small { display: block; font-size: .72rem; }
.content { padding: 1.25rem 1.25rem 3rem; max-width: 1500px; width: 100%; margin: 0 auto; }
.backdrop { display: none; }

/* ===================== قوائم منسدلة ===================== */
.dropdown { position: relative; }
.menu {
  position: absolute; top: calc(100% + 6px); inset-inline-end: 0; min-width: 210px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-lg); padding: .35rem; z-index: 60;
}
.menu button, .menu a { display: flex; align-items: center; gap: .55rem; width: 100%; text-align: right; padding: .5rem .65rem; border-radius: 8px; border: 0; background: none; color: var(--text); font: inherit; cursor: pointer; text-decoration: none !important; }
.menu button:hover, .menu a:hover { background: var(--surface-2); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: .3rem 0; }

.bell-panel {
  position: absolute; top: calc(100% + 6px); inset-inline-start: 0; width: min(380px, 92vw); max-height: 70vh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); z-index: 60;
}
.bell-head { display: flex; justify-content: space-between; align-items: center; padding: .7rem .9rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.bell-item { display: flex; gap: .6rem; padding: .7rem .9rem; border-bottom: 1px solid var(--border); cursor: pointer; }
.bell-item:hover { background: var(--surface-2); }
.bell-item.unread { background: var(--primary-50); }
.bell-item .t { font-weight: 600; font-size: .9rem; }
.bell-item .b { font-size: .82rem; color: var(--muted); }
.bell-item .d { font-size: .72rem; color: var(--muted); }
.bell-ico { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }

/* ===================== الأزرار ===================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .48rem .95rem; border-radius: 9px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; font-weight: 600;
  cursor: pointer; white-space: nowrap; text-decoration: none !important; line-height: 1.4; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-600); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #2b2100; }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger-ghost { background: transparent; border-color: transparent; color: var(--danger); }
.btn.danger-ghost:hover { background: var(--danger-50); }
.btn.sm { padding: .3rem .6rem; font-size: .82rem; border-radius: 7px; }
.btn.icon-only { padding: .38rem; }
.btn-group { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }

/* ===================== البطاقات ===================== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 1rem 1.1rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .85rem 1.1rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h3 { margin: 0; display: flex; align-items: center; gap: .45rem; }
.card + .card, .card + .grid, .grid + .card, .grid + .grid, .stack > * + * { margin-top: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.sidebar-layout { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; display: flex; align-items: center; gap: .5rem; }
.page-head .sub { color: var(--muted); margin-top: .2rem; font-size: .9rem; }
.breadcrumb { font-size: .82rem; color: var(--muted); margin-bottom: .3rem; display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; }

.hero {
  background: linear-gradient(135deg, var(--primary) 0%, #1b6596 100%); color: #fff; border-radius: 16px; padding: 1.2rem 1.35rem;
  display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; position: relative; overflow: hidden;
}
.hero::after { content: ""; position: absolute; inset-inline-start: -40px; bottom: -60px; width: 220px; height: 220px; border-radius: 50%; background: rgba(245,179,1,.12); }
.hero .avatar { background: rgba(255,255,255,.15); color: #fff; }
.hero h1 { margin: 0; font-size: 1.35rem; }
.hero .meta { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .35rem; }
.hero .chip { background: rgba(255,255,255,.14); color: #fff; border-color: transparent; }
.hero .actions { margin-inline-start: auto; display: flex; gap: .45rem; flex-wrap: wrap; z-index: 1; }
.hero .btn { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.25); color: #fff; }
.hero .btn:hover { background: rgba(255,255,255,.22); }
.hero .btn.accent { background: var(--accent); color: #2b2100; border-color: var(--accent); }

/* ===================== الإحصائيات ===================== */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .85rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; display: flex; gap: .8rem; align-items: center; box-shadow: var(--shadow); }
.stat .ico { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; background: var(--primary-50); color: var(--primary); }
.stat .ico svg { width: 21px; height: 21px; }
.stat .lbl { font-size: .8rem; color: var(--muted); }
.stat .val { font-size: 1.22rem; font-weight: 700; font-variant-numeric: tabular-nums; direction: ltr; text-align: right; }
.stat .hint { font-size: .75rem; color: var(--muted); }
.stat.success .ico { background: var(--success-50); color: var(--success); }
.stat.warning .ico { background: var(--warning-50); color: var(--warning); }
.stat.danger .ico { background: var(--danger-50); color: var(--danger); }
.stat.accent .ico { background: var(--accent-50); color: #9a6b00; }
a.stat { color: inherit; text-decoration: none !important; }
a.stat:hover { border-color: var(--primary); }

/* ===================== الشارات ===================== */
.chip, .badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 999px; font-size: .76rem; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); white-space: nowrap; line-height: 1.6;
}
.badge.success { background: var(--success-50); color: var(--success); border-color: transparent; }
.badge.warning { background: var(--warning-50); color: var(--warning); border-color: transparent; }
.badge.danger { background: var(--danger-50); color: var(--danger); border-color: transparent; }
.badge.info { background: var(--info-50); color: var(--info); border-color: transparent; }
.badge.primary { background: var(--primary-50); color: var(--primary); border-color: transparent; }
.badge.accent { background: var(--accent-50); color: #8a5d00; border-color: transparent; }
.dot-color { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ===================== الجداول ===================== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th, .table td { padding: .55rem .7rem; border-bottom: 1px solid var(--border); text-align: right; vertical-align: middle; }
.table th { background: var(--surface-2); color: var(--muted); font-weight: 700; font-size: .78rem; white-space: nowrap; position: sticky; top: 0; z-index: 1; }
.table tbody tr:hover { background: color-mix(in srgb, var(--primary-50) 45%, transparent); }
.table tbody tr.clickable { cursor: pointer; }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 2px solid var(--border-strong); }
.table td.money, .table th.money, .table td.number, .table th.number { text-align: left; font-variant-numeric: tabular-nums; white-space: nowrap; direction: ltr; }
.table tr.group-row td { background: var(--surface-2); font-weight: 700; }
.table tr.muted-row td { color: var(--muted); }
.table tr.level-1 td { font-weight: 700; }
.table .actions-cell { white-space: nowrap; text-align: left; }
.table input, .table select { min-width: 70px; }
.table-compact td, .table-compact th { padding: .35rem .5rem; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty svg { width: 42px; height: 42px; opacity: .45; margin-bottom: .4rem; }

/* ===================== الفورم ===================== */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .85rem 1rem; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: .3rem; align-content: start; min-width: 0; }
.field > label { font-size: .82rem; font-weight: 600; color: var(--text); }
.field .req { color: var(--danger); }
.field .hint { font-size: .76rem; color: var(--muted); }
input, select, textarea {
  font: inherit; font-size: .9rem; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: .48rem .65rem; width: 100%; min-height: 38px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary-600); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-600) 18%, transparent); }
input[type="number"], input.num-input { direction: ltr; text-align: right; }
input[type="date"] { direction: ltr; text-align: right; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--primary); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: .45rem; cursor: pointer; font-size: .9rem; user-select: none; }
.error-box { background: var(--danger-50); color: var(--danger); border-radius: 8px; padding: .6rem .8rem; font-size: .88rem; margin-bottom: .8rem; }
.info-box { background: var(--info-50); color: var(--info); border-radius: 8px; padding: .6rem .8rem; font-size: .86rem; }
.warn-box { background: var(--warning-50); color: var(--warning); border-radius: 8px; padding: .6rem .8rem; font-size: .86rem; }
.input-group { display: flex; gap: .4rem; }
.filters { display: flex; flex-wrap: wrap; gap: .55rem; align-items: flex-end; padding: .8rem 1rem; border-bottom: 1px solid var(--border); }
.filters .field { min-width: 150px; flex: 0 1 190px; }
.filters .field.grow { flex: 1 1 220px; }
.search-input { position: relative; }
.search-input svg { position: absolute; inset-inline-start: .6rem; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; }
.search-input input { padding-inline-start: 2rem; }

/* ===================== المودال ===================== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 100; display: flex; align-items: flex-start; justify-content: center;
  padding: 4vh 1rem; overflow-y: auto; animation: fade .15s;
}
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 560px; box-shadow: var(--shadow-lg); animation: pop .18s; }
.modal.lg { max-width: 860px; } .modal.xl { max-width: 1180px; } .modal.sm { max-width: 420px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1.15rem; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 1.1rem 1.15rem; }
.modal-foot { display: flex; justify-content: flex-start; gap: .5rem; padding: .85rem 1.15rem; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 16px 16px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }

/* ===================== التنبيهات ===================== */
#toasts { position: fixed; bottom: 1rem; inset-inline-start: 1rem; z-index: 200; display: flex; flex-direction: column; gap: .5rem; max-width: min(380px, calc(100vw - 2rem)); }
.toast { background: var(--surface); border: 1px solid var(--border); border-inline-start: 4px solid var(--primary); border-radius: 10px; padding: .7rem .9rem; box-shadow: var(--shadow-lg); font-size: .9rem; animation: pop .2s; }
.toast.success { border-inline-start-color: var(--success); }
.toast.error { border-inline-start-color: var(--danger); }
.toast.warning { border-inline-start-color: var(--accent); }

/* ===================== تبويبات ===================== */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; scrollbar-width: none; }
.tab { padding: .6rem .95rem; border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2.5px solid transparent; white-space: nowrap; text-decoration: none !important; display: inline-flex; gap: .4rem; align-items: center; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--accent); }

/* ===================== قوائم المعلومات ===================== */
.info-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .8rem 1.2rem; }
.info-list .k { font-size: .76rem; color: var(--muted); }
.info-list .v { font-weight: 600; word-break: break-word; }
.kv { display: flex; justify-content: space-between; gap: 1rem; padding: .45rem 0; border-bottom: 1px dashed var(--border); }
.kv:last-child { border-bottom: 0; }
.kv .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.kv.total { border-top: 2px solid var(--border-strong); border-bottom: 0; font-size: 1.05rem; margin-top: .3rem; padding-top: .6rem; }

.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.progress > span { display: block; height: 100%; background: var(--primary-600); border-radius: 99px; }
.progress.warn > span { background: var(--accent); }
.progress.danger > span { background: var(--danger); }

.list { display: flex; flex-direction: column; }
.list-item { display: flex; gap: .75rem; align-items: center; padding: .65rem 1rem; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none !important; }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover { background: var(--surface-2); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===================== كانبان المهام ===================== */
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.board-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: .7rem; min-height: 200px; }
.board-col h4 { display: flex; justify-content: space-between; margin: .2rem .2rem .6rem; }
.task-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .65rem .75rem; margin-bottom: .55rem; cursor: pointer; box-shadow: var(--shadow); }
.task-card:hover { border-color: var(--primary-600); }
.task-card .t { font-weight: 600; margin-bottom: .3rem; }
.task-card .m { display: flex; gap: .35rem; flex-wrap: wrap; font-size: .75rem; }

/* ===================== الرسم البياني ===================== */
.chart { width: 100%; overflow-x: auto; }
.chart svg { display: block; width: 100%; min-width: 520px; height: auto; }
.chart .bar-r { fill: var(--primary-600); }
.chart .bar-e { fill: var(--accent); }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .grid-line { stroke: var(--border); }
.legend { display: flex; gap: 1rem; font-size: .8rem; color: var(--muted); padding: 0 1rem .8rem; }
.legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; margin-inline-end: .3rem; vertical-align: -1px; }

/* ===================== تسجيل الدخول ===================== */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-side { background: linear-gradient(150deg, #0c2f48, #155a87); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.login-side::before { content: ""; position: absolute; width: 420px; height: 420px; border-radius: 50%; background: rgba(245,179,1,.1); top: -120px; left: -120px; }
.login-side h1 { font-size: 2rem; margin-bottom: .6rem; position: relative; }
.login-side p { opacity: .85; max-width: 440px; position: relative; }
.login-side ul { list-style: none; padding: 0; margin: 1.3rem 0 0; position: relative; }
.login-side li { display: flex; gap: .6rem; align-items: center; margin-bottom: .6rem; opacity: .9; }
.login-side li svg { color: var(--accent); }
.login-box { display: grid; place-items: center; padding: 2rem; }
.login-card { width: 100%; max-width: 380px; }
.login-card .logo { width: 64px; height: 64px; border-radius: 16px; margin-bottom: 1rem; object-fit: contain; }

/* ===================== المستند (للطباعة) ===================== */
.doc-paper { background: #fff; color: #111; padding: 1.6rem; border-radius: 12px; border: 1px solid var(--border); }
.doc-paper .doc-header { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #0f3d5e; padding-bottom: .8rem; margin-bottom: 1rem; gap: 1rem; }
.doc-paper .doc-header img { max-height: 70px; max-width: 160px; }
.doc-paper table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.doc-paper th, .doc-paper td { border: 1px solid #cbd5e1; padding: .35rem .45rem; }
.doc-paper th { background: #eef2f7; }
.doc-paper .doc-title { text-align: center; font-size: 1.25rem; font-weight: 800; margin: .5rem 0 1rem; color: #0f3d5e; }
.doc-paper .signs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-top: 2.5rem; text-align: center; font-size: .85rem; }
.doc-paper .signs div { border-top: 1px solid #999; padding-top: .4rem; }

/* ===================== حالات خاصة ===================== */
.row-actions { display: inline-flex; gap: .2rem; }
.tree-toggle { background: none; border: 0; cursor: pointer; color: var(--muted); padding: 0 .2rem; width: 22px; }
.color-input { width: 46px; padding: 2px; height: 36px; }
.scenario-table input { max-width: 120px; }
.sticky-foot { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); padding: .7rem 1rem; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; z-index: 5; border-radius: 0 0 var(--radius) var(--radius); }
.totals-box { min-width: 280px; margin-inline-start: auto; }
.lines-table td { padding: .3rem .35rem; }
.lines-table input, .lines-table select { padding: .35rem .45rem; min-height: 34px; font-size: .86rem; }
.att-status { display: flex; gap: .2rem; }
.att-status button { border: 1px solid var(--border-strong); background: var(--surface); padding: .25rem .5rem; border-radius: 6px; cursor: pointer; font: inherit; font-size: .78rem; }
.att-status button.on.present { background: var(--success); color: #fff; border-color: var(--success); }
.att-status button.on.absent { background: var(--danger); color: #fff; border-color: var(--danger); }
.att-status button.on.leave { background: var(--info); color: #fff; border-color: var(--info); }
.att-status button.on.half { background: var(--accent); color: #2b2100; border-color: var(--accent); }

/* ===================== الشاشات الصغيرة ===================== */
@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.sidebar-layout { grid-template-columns: 1fr; }
  .board { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .shell, .shell.collapsed { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: 270px; transform: translateX(100%); transition: transform .22s; }
  .shell.mobile-open .sidebar { transform: none; }
  .shell.mobile-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }
  .shell.collapsed .brand .txt, .shell.collapsed .nav-item span, .shell.collapsed .nav-section-title { display: revert; }
  .shell.collapsed .nav-item { justify-content: flex-start; padding: .5rem .7rem; }
  .login-page { grid-template-columns: 1fr; }
  .login-side { display: none; }
  .user-chip .meta { display: none; }
}
@media (max-width: 700px) {
  .content { padding: .9rem .75rem 3rem; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .form-grid, .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: .7rem; gap: .55rem; }
  .stat .ico { width: 34px; height: 34px; }
  .stat .val { font-size: 1.02rem; }
  .page-head h1 { font-size: 1.2rem; }
  .modal-backdrop { padding: 0; }
  .modal, .modal.lg, .modal.xl { border-radius: 0; min-height: 100vh; max-width: 100%; }
  .filters .field { flex: 1 1 140px; }
  .doc-paper .signs { grid-template-columns: 1fr; }
}
/* الجداول بتتحول لكروت على الموبايل */
@media screen and (max-width: 700px) {
  table.table.responsive thead { display: none; }
  table.table.responsive, table.table.responsive tbody, table.table.responsive tr, table.table.responsive td { display: block; width: 100%; }
  table.table.responsive tr { border: 1px solid var(--border); border-radius: 10px; margin: .55rem .55rem; width: auto; background: var(--surface); padding: .3rem .1rem; }
  table.table.responsive td { border: 0; display: flex; justify-content: space-between; gap: .8rem; padding: .3rem .7rem; text-align: left; }
  table.table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: .78rem; font-weight: 600; text-align: right; }
  table.table.responsive td.money, table.table.responsive td.number { direction: rtl; }
  table.table.responsive td:empty { display: none; }
  table.table.responsive tfoot tr { background: var(--surface-2); }
}

/* ===================== الطباعة ===================== */
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 12px; }
  .sidebar, .topbar, .no-print, #toasts, .filters, .btn, .tabs, .modal-backdrop .modal-foot { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; }
  .doc-paper { border: 0; padding: 0; }
  .table th { position: static; }
  body.print-modal > #app { display: none; }
  body.print-modal .modal-backdrop { position: static; background: none; padding: 0; display: block; }
  body.print-modal .modal { box-shadow: none; max-width: none; }
  body.print-modal .modal-head { display: none; }
  a { color: inherit; }
}
