:root {
  --brand-yellow: #F2DC29;
  --brand-orange: #F57200;
  --brand-ink: #484C52;
  --brand-ink-dark: #2B2E33;
  --surface: #F6F6F3;
  --card: #FFFFFF;
  --line: #E6E4DC;
  --sidebar-w: 248px;
}

html, body { font-family: "Tajawal", system-ui, sans-serif; }
body { background: var(--surface); color: #23262A; font-size: .95rem; }

/* ---------- الهيكل ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--brand-ink-dark); color: #C9CCD1;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
}
.sidebar::before { content: ""; display: block; height: 4px; background: linear-gradient(90deg, var(--brand-yellow), var(--brand-orange)); }
.sidebar .brand { padding: 1.1rem 1.2rem .9rem; border-bottom: 1px solid rgba(255,255,255,.07); }
.sidebar .brand img { width: 100%; max-width: 190px; display: block; }
.sidebar .section { font-size: .72rem; letter-spacing: .02em; color: #8B9098; padding: 1rem 1.2rem .35rem; font-weight: 700; }
.sidebar a.nav-item {
  display: flex; align-items: center; gap: .6rem; padding: .48rem 1.2rem; color: #D5D8DC; text-decoration: none;
  border-inline-start: 3px solid transparent; font-size: .92rem;
}
.sidebar a.nav-item i { font-size: 1.05rem; color: #9BA1A9; width: 1.2rem; text-align: center; }
.sidebar a.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.sidebar a.nav-item.active { background: rgba(242,220,41,.10); color: #fff; border-inline-start-color: var(--brand-yellow); }
.sidebar a.nav-item.active i { color: var(--brand-yellow); }
.sidebar .foot { margin-top: auto; padding: 1rem 1.2rem; font-size: .8rem; color: #8B9098; border-top: 1px solid rgba(255,255,255,.07); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--card); border-bottom: 1px solid var(--line); padding: .6rem 1.5rem;
  display: flex; align-items: center; gap: 1rem; position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 1.15rem; margin: 0; font-weight: 700; color: var(--brand-ink-dark); }
.content { padding: 1.5rem; }

/* ---------- عناصر ---------- */
.card { border: 1px solid var(--line); border-radius: 10px; box-shadow: none; }
.card-header { background: transparent; border-bottom: 1px solid var(--line); font-weight: 700; }
.table { --bs-table-bg: transparent; margin: 0; }
.table thead th { font-size: .8rem; color: #6B7078; font-weight: 700; background: #FAFAF7; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { vertical-align: middle; }
.table-hover tbody tr:hover { --bs-table-hover-bg: #FFFBE3; }
.num { font-variant-numeric: tabular-nums; direction: ltr; text-align: end; white-space: nowrap; }
.neg { color: #B42318; }

.btn-brand { background: var(--brand-ink-dark); color: #fff; border: 0; }
.btn-brand:hover, .btn-brand:focus { background: #000; color: var(--brand-yellow); }
.btn-accent { background: var(--brand-yellow); color: var(--brand-ink-dark); border: 0; font-weight: 700; }
.btn-accent:hover { background: #E5CE10; color: #000; }
.bg-brand { background: linear-gradient(90deg, var(--brand-orange), var(--brand-yellow)) !important; }
.form-control:focus, .form-select:focus { border-color: var(--brand-yellow); box-shadow: 0 0 0 .2rem rgba(242,220,41,.3); }
.form-label { font-weight: 500; font-size: .88rem; margin-bottom: .25rem; }

.content a:not(.btn):not(.badge) { color: var(--brand-ink-dark); text-decoration: none; border-bottom: 1px dotted #C9B200; }
.content a:not(.btn):not(.badge):hover { color: var(--brand-orange); border-bottom-color: var(--brand-orange); }
bdi { unicode-bidi: isolate; }

/* بطاقات المؤشرات */
.kpi { padding: 1rem 1.15rem; }
.kpi .label { color: #6B7078; font-size: .82rem; }
.kpi .value { font-size: 1.45rem; font-weight: 800; color: var(--brand-ink-dark); font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .78rem; color: #8B9098; }
.kpi.accent { border-top: 3px solid var(--brand-yellow); }
.kpi.warn { border-top: 3px solid var(--brand-orange); }

/* كانبان */
.board { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 1rem; overflow-x: auto; }
.board-col { background: #EDECE6; border-radius: 10px; padding: .6rem; min-height: 60vh; }
.board-col h6 { font-weight: 700; padding: .25rem .35rem .6rem; display: flex; justify-content: space-between; }
.board-col.drag-over { outline: 2px dashed var(--brand-orange); }
.task-card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: .6rem .7rem; margin-bottom: .55rem; cursor: grab; }
.task-card:active { cursor: grabbing; }
.task-card a { color: inherit; text-decoration: none; font-weight: 600; }
.task-card .meta { font-size: .76rem; color: #6B7078; margin-top: .35rem; display: flex; gap: .5rem; flex-wrap: wrap; }
.task-card.overdue { border-inline-start: 3px solid #D92D20; }

/* شاشة الدخول */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--surface); }
.login-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 2rem; }
.login-card::before { content: ""; display: block; height: 4px; margin: -2rem -2rem 1.6rem; border-radius: 14px 14px 0 0; background: linear-gradient(90deg, var(--brand-yellow), var(--brand-orange)); }

/* الطباعة */
.print-head { display: none; }
@media print {
  .sidebar, .topbar, .no-print, .messages { display: none !important; }
  .content { padding: 0; }
  body { background: #fff; }
  .card { border: 0; }
  .print-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 3px solid var(--brand-yellow); padding-bottom: .6rem; margin-bottom: 1rem; }
  .print-head img { height: 54px; }
}

/* الشاشات الصغيرة */
@media (max-width: 991px) {
  .sidebar { position: fixed; inset-inline-start: 0; z-index: 1040; transform: translateX(100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .content { padding: 1rem; }
  .board { grid-template-columns: repeat(4, 260px); }
}
