/* MAESTRO-1 (docs/maestro.md): «المايسترو» — one place for the numbers, engines, AI and policies.
   Design System v1: every colour is a --lm-d-* token (tokens.css); no Tailwind utilities in the view. */

.ms-hub { display: flex; flex-direction: column; gap: 16px; font-family: inherit; color: var(--lm-d-ink); }
.ms-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ms-title { margin: 0; font-size: 26px; font-weight: 700; color: var(--lm-d-ink); }
.ms-sub { margin: 4px 0 0; font-size: 13px; color: var(--lm-d-muted); max-width: 720px; }
.ms-btn {
    display: inline-flex; align-items: center; padding: 8px 14px; border-radius: 10px;
    border: 1px solid var(--lm-d-border); background: var(--lm-d-surface); color: var(--lm-d-ink);
    font-size: 13px; font-weight: 600; text-decoration: none;
}
.ms-btn:hover { background: var(--lm-d-hover); }

.ms-stamp { font-size: 13px; color: var(--lm-d-muted); white-space: nowrap; }

/* MAESTRO-17: the tabs as the canvas draws them — outlined pills, the open one filled */
.ms-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.ms-tab {
    padding: 8px 16px; border-radius: 999px; border: 1px solid var(--lm-d-control-edge); background: var(--lm-d-surface);
    color: var(--lm-d-ink); font-size: 14px; font-weight: 500; cursor: pointer; text-decoration: none; line-height: 1.4;
}
.ms-tab:hover { background: var(--lm-d-hover); }
.ms-tab.is-on { background: var(--lm-d-tab-on-bg); color: var(--lm-d-tab-on-ink); border-color: var(--lm-d-tab-on-bg); }

/* MAESTRO-17: the policies tab — the rail layout inside the hub, its card under a blue line */
.ms-policies .lmp-main .lmc-card { border-top: 3px solid var(--lm-d-info); }
.ms-std-head { display: flex; flex-direction: column; gap: 8px; padding: 12px 0 4px; }
.ms-std-head.is-hidden { display: none; }
.ms-std-title { display: flex; flex-direction: column; gap: 2px; }
.ms-std-title b { font-size: 14px; color: var(--lm-d-ink); }
.ms-std-title small { font-size: 12px; color: var(--lm-d-muted); }
.ms-std-cols {
    display: grid; grid-template-columns: 5fr 2fr 2fr 3fr; gap: 12px; padding: 8px 12px; border-radius: 8px;
    background: var(--lm-d-divider); color: var(--lm-d-muted); font-size: 12px; font-weight: 600;
}
.ms-std-label code { display: block; text-align: start; font-size: 12px; color: var(--lm-d-muted); }
.ms-std-today { display: flex; flex-direction: column; gap: 2px; }
.ms-std-today b { font-size: 15px; font-weight: 700; color: var(--lm-d-muted); }
.ms-std-today small { font-size: 12px; color: var(--lm-d-muted); }
.ms-std-today.is-below_floor b { color: var(--lm-d-danger); }
.ms-std-today.is-between b { color: var(--lm-d-warn); }
.ms-std-today.is-on_target b { color: var(--lm-d-ok); }
.ms-std-cap { display: none; font-size: 12px; color: var(--lm-d-muted); }
@media (max-width: 1023px) {
    .ms-std-cols { display: none; }
    .ms-std-cap { display: block; }
}

.ms-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.ms-card {
    background: var(--lm-d-surface); border: 1px solid var(--lm-d-border); border-radius: 14px;
    padding: 16px; box-shadow: var(--lm-d-shadow); display: flex; flex-direction: column; gap: 10px; min-width: 0;
}
.ms-wide { grid-column: 1 / -1; }
.ms-h2 { margin: 0; font-size: 14px; font-weight: 700; color: var(--lm-d-ink); }
.ms-h3 { margin: 8px 0 0; font-size: 13px; font-weight: 700; color: var(--lm-d-ink); }
.ms-note { margin: 0; font-size: 12px; color: var(--lm-d-muted); }
.ms-muted { color: var(--lm-d-muted); }

.ms-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ms-row {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 7px 0; border-bottom: 1px solid var(--lm-d-divider); font-size: 13px;
}
.ms-row:last-child { border-bottom: 0; }
.ms-num { font-variant-numeric: tabular-nums; font-weight: 600; }

.ms-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; }
.ms-kpi { display: flex; flex-direction: column; gap: 2px; padding: 10px; border-radius: 10px; background: var(--lm-d-quiet-bg); }
.ms-kpi-n { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--lm-d-ink); }
.ms-kpi-l { font-size: 12px; color: var(--lm-d-muted); }

.ms-pill {
    display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600; background: var(--lm-d-chip-bg); color: var(--lm-d-muted); white-space: nowrap;
}
.ms-pill.is-ok { background: var(--lm-d-ok-soft); color: var(--lm-d-ok); }
.ms-pill.is-danger { background: var(--lm-d-danger-soft); color: var(--lm-d-danger); }
.ms-pill.is-warn { background: var(--lm-d-warn-soft); color: var(--lm-d-warn); }
.ms-pill.is-ai { background: var(--lm-d-ai-bg); color: var(--lm-d-ai-ink); }
.ms-pill.is-off { background: var(--lm-d-chip-bg); color: var(--lm-d-muted); }

.ms-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ms-table th {
    text-align: start; font-weight: 600; color: var(--lm-d-muted); font-size: 12px;
    padding: 6px 8px; border-bottom: 1px solid var(--lm-d-divider);
}
.ms-table td { padding: 8px; border-bottom: 1px solid var(--lm-d-divider); }
.ms-table tr:last-child td { border-bottom: 0; }

@media (max-width: 640px) {
    .ms-grid { grid-template-columns: 1fr; }
    .ms-table { display: block; overflow-x: auto; }
}

/* MAESTRO-6: «الستاندر» in the call-center pulse — each measure against its floor and target, where the leads are
   lost, and every employee red (below the floor) or green (on target). */
.ms-std-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.ms-std-tile {
    display: flex; flex-direction: column; gap: 4px; padding: 12px; border-radius: 12px; min-width: 0;
    border: 1px solid var(--lm-d-border); border-inline-start: 4px solid var(--lm-d-border); background: var(--lm-d-surface);
}
.ms-std-tile.is-below_floor { border-inline-start-color: var(--lm-d-danger); background: var(--lm-d-danger-soft); }
.ms-std-tile.is-between { border-inline-start-color: var(--lm-d-warn); }
.ms-std-tile.is-on_target { border-inline-start-color: var(--lm-d-ok); background: var(--lm-d-ok-soft); }
.ms-std-label { font-size: 13px; font-weight: 600; color: var(--lm-d-ink); }
.ms-std-fig { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--lm-d-ink); }
.ms-std-meta { font-size: 12px; color: var(--lm-d-muted); }
.ms-std-scroll { overflow-x: auto; }
.ms-funnel { display: flex; flex-direction: column; gap: 8px; }
.ms-funnel-row { display: grid; grid-template-columns: minmax(96px, 150px) minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 13px; }
.ms-funnel-track { display: block; height: 12px; border-radius: 999px; background: var(--lm-d-quiet-bg); overflow: hidden; }
.ms-funnel-bar { display: block; height: 100%; border-radius: 999px; background: var(--lm-d-info); }
.ms-funnel-row.is-drop .ms-funnel-bar { background: var(--lm-d-danger); }
.ms-cell-below_floor { color: var(--lm-d-danger); background: var(--lm-d-danger-soft); font-weight: 700; }
.ms-cell-on_target { color: var(--lm-d-ok); background: var(--lm-d-ok-soft); font-weight: 700; }

/* MAESTRO-18: «الملخص» as the canvas draws it — the month's cards, then sections under a blue line */
.ms-kpi-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.ms-kpi-card { gap: 6px; }
.ms-kpi-big { font-size: 30px; font-weight: 700; line-height: 1.2; color: var(--lm-d-ink); font-variant-numeric: tabular-nums; }
.ms-kpi-sub { font-size: 12px; color: var(--lm-d-muted); }
.ms-kpi-l.is-ai { color: var(--lm-d-ai-ink); font-weight: 600; }
.ms-kpi-card .ms-pill { align-self: flex-start; }
.ms-btn.is-danger { border-color: var(--lm-d-danger); color: var(--lm-d-danger); justify-content: center; }
.ms-btn.is-accent { border-color: var(--lm-d-accent-line); background: var(--lm-d-accent-soft); color: var(--lm-d-accent-ink); }
.ms-section { padding: 0; gap: 0; border-top: 3px solid var(--lm-d-info); border-radius: 10px; }
.ms-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--lm-d-divider); }
.ms-sec-t { margin: 0; font-size: 17px; font-weight: 700; color: var(--lm-d-ink); }
.ms-sec-body { padding: 12px 18px; }
.ms-sec-empty { padding: 14px 18px; }
.ms-dec { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--lm-d-divider); }
.ms-dec:last-child { border-bottom: 0; }
.ms-dec-t { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ms-dec-t b { font-size: 14px; color: var(--lm-d-ink); }
.ms-dec-t small { font-size: 12px; color: var(--lm-d-muted); }
.ms-sec-table th, .ms-sec-table td { padding: 10px 18px; }
.ms-sec-table code { font-size: 12px; color: var(--lm-d-muted); }
.ms-end { text-align: end; }
.ms-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.ms-three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1023px) {
    .ms-kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ms-two, .ms-three { grid-template-columns: 1fr; }
}
@media (max-width: 639px) {
    .ms-kpi-row { grid-template-columns: 1fr; }
    /* on a phone the state and its button stay in view: «محتاج إيه» folds away */
    .ms-sec-table th:nth-child(2), .ms-sec-table td:nth-child(2) { display: none; }
}

/* MAESTRO-19: every tab's cards as the canvas's sections — a blue line over a heading; the journey; the standard by week */
/* two columns: a section is half or the whole width, never a lone quarter beside a gap */
.ms-hub .ms-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1023px) {
    .ms-hub .ms-grid { grid-template-columns: 1fr; }
}
.ms-hub .ms-grid > .ms-card { border-top: 3px solid var(--lm-d-info); border-radius: 10px; }
.ms-hub .ms-grid > .ms-card > .ms-h2 { font-size: 16px; }
.ms-link { color: var(--lm-d-info); font-weight: 600; text-decoration: none; }
.ms-link:hover { text-decoration: underline; }
.ms-journey { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.ms-journey-step { display: flex; flex-direction: column; gap: 2px; padding: 12px; border-radius: 10px; background: var(--lm-d-quiet-bg); }
.ms-journey-step small { font-size: 12px; color: var(--lm-d-danger); }
.ms-std-cell.is-below_floor { color: var(--lm-d-danger); font-weight: 700; }
.ms-std-cell.is-between { color: var(--lm-d-warn); font-weight: 700; }
.ms-std-cell.is-on_target { color: var(--lm-d-ok); font-weight: 700; }
@media (max-width: 1023px) {
    .ms-journey { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
