/* =====================================================================
   Staff dashboard — builds on css/style.css tokens
   Chart colours were checked for colour-blind separation in both themes.
   ===================================================================== */
:root, [data-theme='dark'] { --c-rev: #6c85f5; --c-cost: #e0574d; --c-profit: #22a396; --chart-surface: var(--surface); }
[data-theme='light'] { --c-rev: #2a4fd6; --c-cost: #c82e32; --c-profit: #0f9488; }

.dash-body { min-height: 100dvh; background: var(--bg); }
.dash-top {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 12px; height: 68px; padding: env(safe-area-inset-top, 0px) 16px 0;
  background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
@media (min-width: 640px) { .dash-top { padding-inline: 28px; } }
.dash-top .brand__mark { width: 40px; height: 40px; }
.dash-top__tools { display: flex; align-items: center; gap: 8px; }
.role-chip { display: inline-flex; align-items: center; padding: 6px 10px; border: 1px solid var(--line-2); font-family: var(--font-display); font-size: .66rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); max-width: 30ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-chip--sm { padding: 2px 6px; font-size: .58rem; color: var(--accent); border-color: currentColor; }
@media (max-width: 760px) { .dash-top .role-chip:not(.role-chip--sm) { display: none; } }

.gate { display: grid; place-items: center; min-height: calc(100dvh - 68px); padding: 24px 16px; }
.gate__card { width: min(460px, 100%); padding: 36px 28px; text-align: center; border: 1px solid var(--line-2); background: var(--surface); box-shadow: var(--shadow-lg); animation: fadeup .6s var(--ease); }
.gate__emblem { width: 72px; height: 72px; margin: 0 auto 16px; object-fit: contain; }
.gate__card h1 { font-size: 2rem; }
.gate__card p { margin-top: 10px; color: var(--muted); }
.gate__actions { margin-top: 22px; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

.dash { display: grid; grid-template-rows: auto 1fr; min-height: calc(100dvh - 68px); }
@media (min-width: 1000px) { .dash { grid-template-columns: 236px 1fr; grid-template-rows: 1fr; align-items: start; } }
.dash-nav { display: flex; gap: 4px; padding: 10px 12px; overflow-x: auto; border-bottom: 1px solid var(--line); background: var(--bg-2); scrollbar-width: none; position: sticky; top: 68px; z-index: 30; }
.dash-nav::-webkit-scrollbar { display: none; }
@media (min-width: 1000px) {
  .dash-nav { flex-direction: column; padding: 22px 14px; border-bottom: 0; border-inline-end: 1px solid var(--line); height: calc(100dvh - 68px); overflow: auto; }
}
.dash-nav__item {
  position: relative; display: flex; align-items: center; gap: 10px; flex-shrink: 0; padding: 11px 14px; font-family: var(--font-display); font-size: .74rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .1em; color: var(--muted); transition: background-color .2s, color .2s;
}
html[lang='ar'] .dash-nav__item { letter-spacing: 0; font-size: .86rem; }
.dash-nav__item:hover { color: var(--text); background: var(--surface-2); }
.dash-nav__item.is-active { color: var(--text); background: var(--surface-3); }
.dash-nav__item.is-active::before { content: ''; position: absolute; inset-block: 8px; inset-inline-start: 0; width: 3px; background: var(--primary); }
.badge { min-width: 22px; height: 22px; padding: 0 6px; display: grid; place-items: center; margin-inline-start: auto; border-radius: 11px; background: var(--primary); color: #fff; font-size: .66rem; animation: pop .4s var(--ease); }

.dash-main { min-width: 0; padding: 22px 16px 60px; outline: none; }
@media (min-width: 640px) { .dash-main { padding: 30px 32px 72px; } }
.view { max-width: 1240px; display: grid; gap: 20px; animation: fadeup .45s var(--ease); }
.view-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 20px; }
.view-head h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); }

.kpis { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 900px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { display: grid; gap: 6px; padding: 18px; border: 1px solid var(--line-2); background: var(--surface); animation: fadeup .5s var(--ease) both; }
.kpi:nth-child(2) { animation-delay: .04s; } .kpi:nth-child(3) { animation-delay: .08s; } .kpi:nth-child(4) { animation-delay: .12s; }
.kpi:nth-child(5) { animation-delay: .16s; } .kpi:nth-child(6) { animation-delay: .2s; } .kpi:nth-child(7) { animation-delay: .24s; } .kpi:nth-child(8) { animation-delay: .28s; }
.kpi__label { font-family: var(--font-display); font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }
html[lang='ar'] .kpi__label { letter-spacing: 0; font-size: .78rem; }
.kpi__value { font-family: 'Archivo', 'Cairo', sans-serif; font-weight: 900; font-size: clamp(1.3rem, 2.6vw, 1.9rem); line-height: 1.05; letter-spacing: -.02em; overflow-wrap: anywhere; }
.kpi__sub { font-size: .78rem; color: var(--muted); }
.kpi--alert { border-color: var(--primary); }
.kpi--alert .kpi__value { color: var(--primary); }
.kpi--good .kpi__value::before { content: '▲ '; font-size: .6em; color: var(--c-profit); vertical-align: middle; }
.kpi--bad .kpi__value::before { content: '▼ '; font-size: .6em; color: var(--c-cost); vertical-align: middle; }

.card { padding: clamp(16px, 2.4vw, 24px); border: 1px solid var(--line-2); background: var(--surface); min-width: 0; }
.card__title { margin-bottom: 14px; font-family: var(--font-display); font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .14em; }
html[lang='ar'] .card__title { letter-spacing: 0; font-size: .95rem; }
.card--note p { color: var(--text-2); font-size: .92rem; }
.card--note p + p { margin-top: 10px; }
.cards-2 { display: grid; gap: 20px; }
@media (min-width: 1000px) { .cards-2 { grid-template-columns: 1fr 1fr; } }
.hint { padding: 10px 14px; border-inline-start: 3px solid var(--c-rev); background: color-mix(in srgb, var(--c-rev) 8%, transparent); font-size: .86rem; color: var(--text-2); }
.hint--demo { border-color: #f5a524; background: color-mix(in srgb, #f5a524 9%, transparent); }

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.filters .input { width: auto; min-height: 42px; font-size: .92rem; }
.filters input[type='search'] { flex: 1 1 240px; }
.filters__date { display: grid; gap: 4px; font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; font-weight: 700; }
.seg--sm { margin: 0; }
.seg--sm button { min-height: 36px; padding: 6px 12px; font-size: .68rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line-2); background: var(--surface); }
.card .table-wrap { border: 0; }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th, .table td { padding: 11px 12px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table thead th { position: sticky; top: 0; background: var(--surface-2); font-family: var(--font-display); font-size: .64rem; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); white-space: nowrap; }
html[lang='ar'] .table thead th { letter-spacing: 0; font-size: .78rem; }
.table tbody tr { transition: background-color .15s; }
.table tbody tr:hover { background: var(--surface-2); }
.table a { color: var(--text); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.table .num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table--compact th, .table--compact td { padding: 7px 10px; }
.table--form th[scope='row'] { white-space: nowrap; font-weight: 700; }
.table--form th[scope='row'] .icon { vertical-align: -3px; margin-inline-end: 4px; color: var(--primary); }
.nowrap { white-space: nowrap; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.details { margin-top: 14px; }
.details summary { cursor: pointer; font-size: .86rem; color: var(--muted); }
.details[open] summary { margin-bottom: 10px; }

.req-list { display: grid; gap: 12px; }
.req { display: grid; gap: 16px; padding: 18px; border: 1px solid var(--line-2); border-inline-start: 4px solid #f5a524; background: var(--surface); animation: fadeup .4s var(--ease) both; }
@media (min-width: 760px) { .req { grid-template-columns: 1fr auto; align-items: center; } }
.req__main { display: grid; gap: 10px; min-width: 0; }
.req__when b { display: block; font-family: var(--font-display); font-weight: 900; text-transform: uppercase; font-size: 1.05rem; }
.req__when span, .req__who a, .req__phone { color: var(--text-2); font-size: .9rem; }
.req__who { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; }
.req__who a { text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; overflow-wrap: anywhere; }
.req__note { font-size: .88rem; padding: 8px 10px; background: var(--surface-2); }
.req__side { display: grid; gap: 6px; justify-items: start; font-size: .8rem; }
@media (min-width: 760px) { .req__side { justify-items: end; text-align: end; } }
.req__total { font-family: 'Archivo', 'Cairo', sans-serif; font-weight: 900; font-size: 1.4rem; }

.agenda { display: grid; }
.agenda li { display: grid; grid-template-columns: minmax(130px, auto) 1fr auto; gap: 6px 16px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.agenda li > span:nth-child(3) { grid-column: 2; color: var(--muted); }
.agenda li > .status { grid-row: 1; grid-column: 3; }
.agenda li b { font-family: var(--font-display); font-weight: 800; }
@media (max-width: 560px) { .agenda li { grid-template-columns: 1fr auto; } .agenda li > span:nth-child(2), .agenda li > span:nth-child(3) { grid-column: 1 / -1; } .agenda li > .status { grid-column: 2; } }

.split { display: grid; gap: 12px; }
.split li { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: .9rem; }
.split b { font-variant-numeric: tabular-nums; }
.split__bar { grid-column: 1 / -1; display: block; height: 6px; background: var(--surface-3); }
.split__bar i { display: block; height: 100%; background: var(--c-cost); border-radius: 0 4px 4px 0; animation: grow .9s var(--ease) both; transform-origin: left; }
[dir='rtl'] .split__bar i { transform-origin: right; border-radius: 4px 0 0 4px; }

.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.money-input { position: relative; display: block; min-width: 110px; }
.money-input .input { padding-inline-end: 46px; min-height: 42px; }
.money-input span { position: absolute; inset-inline-end: 10px; top: 50%; transform: translateY(-50%); font-size: .7rem; font-weight: 700; color: var(--muted); pointer-events: none; }
.cost-lines { display: grid; gap: 8px; }
.cost-line { display: grid; grid-template-columns: 1fr minmax(130px, 200px) 42px; gap: 8px; align-items: center; }
.cost-line__name { font-weight: 600; }
.card.form { gap: 16px; }

/* charts */
.chart { position: relative; }
.chart svg { display: block; overflow: visible; }
.chart__grid { stroke: var(--line); stroke-width: 1; }
.chart__base { stroke: var(--line-2); stroke-width: 1; }
.chart__axis { fill: var(--muted); font-size: 11px; font-family: var(--font-body); }
.chart__val { fill: var(--text); font-size: 11px; font-weight: 700; font-family: var(--font-body); }
.chart__cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart__ring { stroke: var(--chart-surface); stroke-width: 2; }
.chart__bar { outline: none; cursor: default; }
.chart__bar-mark { transition: opacity .2s; animation: barup .7s var(--ease) both; }
.chart__bar:hover .chart__bar-mark, .chart__bar:focus .chart__bar-mark { opacity: .78; }
.chart__legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 10px; font-size: .82rem; color: var(--text-2); }
.chart__legend > span { display: inline-flex; align-items: center; gap: 8px; }
.chart__legend .k-line { width: 16px; height: 2px; border-radius: 1px; }
.chart__tip { position: absolute; z-index: 5; min-width: 150px; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line-2); box-shadow: 0 16px 40px -20px rgba(0, 0, 0, .6); pointer-events: none; font-size: .82rem; }
.chart__tip-head { margin-bottom: 6px; color: var(--muted); font-size: .74rem; }
.chart__tip-row { display: grid; grid-template-columns: 12px auto 1fr; gap: 8px; align-items: center; }
.chart__tip-row i { width: 12px; height: 2px; }
.chart__tip-row b { font-variant-numeric: tabular-nums; }
.chart__tip-row span { color: var(--muted); }
@keyframes barup { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
