/* =========================================================
   BME CRM — design system (Fluent / Dynamics 365 inspired)
   ========================================================= */
:root {
    --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
    --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;
    --series-other: #9aa4b2;
    --track: #edf0f5;
    --card: #ffffff;
    --card-border: #e3e7ee;
    --muted: #5b6472;
    --soft: #f6f8fb;
    --brand: #0f6cbd;
    --brand-soft: #e8f1fb;
    --ok: #107c41; --ok-soft: #e6f4ea;
    --warn: #b25e00; --warn-soft: #fff4e0;
    --bad: #c42b1c; --bad-soft: #fde8e6;
    --info: #2a78d6; --info-soft: #e8f1fb;
    --shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
    --shadow-lg: 0 10px 30px rgba(16,24,40,.08);
    --radius: 10px;
}
.mud-theme-dark, body:has(.mud-theme-dark) {
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #0ca30c; --series-7: #9085e9; --series-8: #e66767;
    --track: #232b38; --card: #171d27; --card-border: #263040; --muted: #9aa4b2; --soft: #131922;
    --brand-soft: #16263b; --ok-soft: #12291c; --warn-soft: #2e2210; --bad-soft: #301617; --info-soft: #16263b;
    --ok: #54b054; --warn: #f2a33a; --bad: #f1707b; --info: #479ef5;
}

html, body { font-family: Inter, "Segoe UI", system-ui, sans-serif; }
body.lang-ar, body.lang-ar .mud-typography, body.lang-ar .mud-input, body.lang-ar .mud-button-root, body.lang-ar input, body.lang-ar button {
    font-family: "IBM Plex Sans Arabic", Inter, "Segoe UI", sans-serif !important;
}
h1:focus { outline: none; }
a.link, .link { color: var(--mud-palette-primary); text-decoration: none; font-weight: 500; }
a.link:hover { text-decoration: underline; }
.text-xs { font-size: .75rem; } .text-sm { font-size: .8125rem; }
.num { text-align: end !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.strong { font-weight: 600; }
.muted { color: var(--muted); }
.ok-text { color: var(--ok) !important; } .bad-text { color: var(--bad) !important; }
.w-100 { width: 100%; }

/* ---------- Boot ---------- */
.boot-loader { height: 60vh; display: grid; place-items: center; }
.boot-spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid #d0d7e2; border-top-color: #0f6cbd; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Shell ---------- */
.crm-appbar { background: linear-gradient(90deg, #0b1f3a 0%, #102a4c 55%, #0f3a6b 100%) !important; border-bottom: 1px solid rgba(255,255,255,.06); }
.mud-theme-dark .crm-appbar, body:has(.mud-theme-dark) .crm-appbar { background: #0a0f18 !important; }
.crm-brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; margin-inline-start: 6px; }
.crm-brand-text { font-size: 1.05rem; letter-spacing: .2px; font-weight: 500; }
.crm-brand-text b { font-weight: 800; color: #7cc4ff; }
.crm-tenant { margin-inline-start: 14px; padding: 3px 10px; border-radius: 999px; background: rgba(255,255,255,.1); font-size: .78rem; color: #dbeafe; border: 1px solid rgba(255,255,255,.12); }
.crm-search { width: min(420px, 34vw); margin-inline-end: 8px; }
.crm-search .mud-input-outlined-border { border-color: rgba(255,255,255,.18) !important; }
.crm-search .mud-input, .crm-search input, .crm-search .mud-icon-root { color: #fff !important; }
.crm-search .mud-input-root::placeholder { color: rgba(255,255,255,.65) !important; }
.crm-search .mud-input-control { margin: 0 !important; }
.crm-search .mud-input.mud-input-outlined { background: rgba(255,255,255,.08); border-radius: 8px; }
.crm-lang { min-width: 40px !important; font-weight: 700 !important; font-size: .95rem !important; }
.crm-avatar { background: linear-gradient(135deg, #38bdf8, #6366f1) !important; color: #fff !important; font-weight: 700; font-size: .78rem !important; cursor: pointer; }

.crm-drawer { border-inline-end: 1px solid var(--mud-palette-lines-default) !important; }
.crm-nav { display: flex; flex-direction: column; padding: 8px 8px 0; min-height: 100%; }
.nav-section { font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 16px 12px 6px; }
body.lang-ar .nav-section { letter-spacing: 0; font-size: .74rem; }
.crm-nav .mud-nav-link { border-radius: 8px; margin: 1px 0; padding: 7px 12px; font-size: .875rem; }
.crm-nav .mud-nav-link .mud-nav-link-icon { font-size: 1.2rem; }
.crm-nav .mud-nav-link.active { background: var(--brand-soft) !important; color: var(--mud-palette-primary) !important; font-weight: 600; position: relative; }
.crm-nav .mud-nav-link.active::before { content: ""; position: absolute; inset-inline-start: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--mud-palette-primary); }
.crm-nav .mud-nav-link.active .mud-nav-link-icon { color: var(--mud-palette-primary) !important; }
.nav-footer { margin-top: auto; padding: 18px 12px; font-size: .72rem; color: var(--muted); }

.crm-main { background: var(--mud-palette-background); min-height: 100vh; }
.crm-content { padding: 18px 24px 40px; max-width: 1680px; margin: 0 auto; }
@media (max-width: 700px) { .crm-content { padding: 12px; } }

/* ---------- Page header & command bar ---------- */
.page-header { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; }
.page-header-main { display: flex; align-items: center; gap: 14px; padding: 16px 20px; flex-wrap: wrap; }
.page-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, #6366f1)); box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 35%, transparent); flex-shrink: 0; }
.page-titles { flex: 1; min-width: 200px; }
.page-kicker { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
body.lang-ar .page-kicker { letter-spacing: 0; }
.page-title { font-size: 1.35rem; font-weight: 700; margin: 0; line-height: 1.3; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-sub { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.header-fields { display: flex; gap: 0; flex-wrap: wrap; }
.header-field { padding: 2px 18px; border-inline-start: 1px solid var(--card-border); min-width: 120px; }
.hf-label { font-size: .72rem; color: var(--muted); }
.hf-value { font-weight: 600; font-size: .95rem; margin-top: 2px; }
.command-bar { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; padding: 6px 12px; border-top: 1px solid var(--card-border); background: var(--soft); }
.command-bar .cmd { border-radius: 6px !important; }

/* ---------- Filter bar ---------- */
.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 10px 14px; box-shadow: var(--shadow); }
.filter-bar .mud-input-control { margin: 0 !important; }
.filter-field { min-width: 220px; max-width: 280px; }

/* ---------- Sections ---------- */
.crm-section { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; min-width: 0; }
.crm-section-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--card-border); min-height: 50px; }
.crm-section-head h3 { margin: 0; font-size: .95rem; font-weight: 650; }
.crm-section-body { padding: 16px; flex: 1; }
.crm-section-body.flush { padding: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* ---------- KPIs ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .kpi-grid { grid-template-columns: 1fr; } }
.kpi-card { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; transition: transform .15s, box-shadow .15s; }
.kpi-card::after { content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px; background: var(--accent); border-radius: 0 4px 4px 0; }
.kpi-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.kpi-top { display: flex; justify-content: space-between; align-items: center; }
.kpi-label { color: var(--muted); font-size: .82rem; font-weight: 500; }
.kpi-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.kpi-value { font-size: 1.75rem; font-weight: 750; margin-top: 6px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: .8rem; color: var(--muted); font-weight: 600; margin-inline-start: 4px; }
.kpi-foot { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: .78rem; }
.delta { display: inline-flex; align-items: center; gap: 2px; padding: 1px 7px; border-radius: 999px; font-weight: 600; }
.delta.up { color: var(--ok); background: var(--ok-soft); }
.delta.down { color: var(--bad); background: var(--bad-soft); }
.kpi-note { color: var(--muted); }

.mini-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
@media (max-width: 1200px) { .mini-kpis { grid-template-columns: repeat(2, 1fr); } }
.mini-kpi { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 12px 14px; color: inherit; text-decoration: none; box-shadow: var(--shadow); }
.mini-kpi .mud-icon-root { color: var(--mud-palette-primary); background: var(--brand-soft); padding: 6px; border-radius: 8px; width: 34px; height: 34px; }
.mini-kpi b { display: block; font-size: 1rem; font-variant-numeric: tabular-nums; }
.mini-kpi span { font-size: .75rem; color: var(--muted); }
.mini-kpi.alert .mud-icon-root { color: var(--warn); background: var(--warn-soft); }
a.mini-kpi:hover { border-color: var(--mud-palette-primary); }

.dash-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.dash-grid .span-2 { grid-column: span 2; }
@media (max-width: 1200px) { .dash-grid { grid-template-columns: 1fr; } .dash-grid .span-2 { grid-column: span 1; } }

/* ---------- Charts ---------- */
.chart-legend { display: flex; gap: 16px; font-size: .78rem; color: var(--muted); margin-bottom: 8px; flex-wrap: wrap; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -1px; }
.trend { position: relative; display: flex; flex-direction: column; }
.trend-plot { position: relative; flex: 1; margin-left: 44px; margin-right: 8px; }
.trend-grid .gl { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--card-border); }
.trend-grid .gl span { position: absolute; left: -44px; width: 38px; text-align: right; transform: translateY(-50%); font-size: .7rem; color: var(--muted); }
.trend-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.trend-cols { position: absolute; inset: 0; }
.tc { position: absolute; top: 0; bottom: 0; cursor: crosshair; }
.tc-line { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--muted); opacity: 0; }
.tc-dot { position: absolute; left: 50%; width: 9px; height: 9px; border-radius: 50%; transform: translate(-50%, 50%); box-shadow: 0 0 0 2px var(--card); opacity: 0; }
.tc-tip { position: absolute; top: 4px; left: calc(50% + 10px); background: var(--card); border: 1px solid var(--card-border); box-shadow: var(--shadow-lg); border-radius: 8px; padding: 8px 10px; font-size: .75rem; white-space: nowrap; opacity: 0; pointer-events: none; z-index: 5; min-width: 150px; }
.tc-tip.left { left: auto; right: calc(50% + 10px); }
.tc-tip div { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.tc-tip div span { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; padding-left: 12px; }
.tc-tip i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.tc:hover .tc-line, .tc:hover .tc-dot, .tc:hover .tc-tip { opacity: 1; }
.trend-x { position: relative; height: 22px; margin-left: 44px; margin-right: 8px; }
.trend-x span { position: absolute; transform: translateX(-50%); font-size: .7rem; color: var(--muted); top: 6px; white-space: nowrap; }

.barlist { display: flex; flex-direction: column; gap: 4px; }
.bl-row { display: block; padding: 6px 8px; border-radius: 8px; color: inherit; text-decoration: none; }
.bl-row:hover { background: var(--soft); }
.bl-label { display: flex; justify-content: space-between; gap: 10px; font-size: .82rem; margin-bottom: 5px; }
.bl-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bl-label b { font-variant-numeric: tabular-nums; }
.bl-track { height: 8px; background: var(--track); border-radius: 4px; overflow: hidden; }
.bl-bar { height: 100%; border-radius: 4px; transition: width .6s ease; }

.donut { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: center; }
.donut-svg { width: 170px; height: 170px; }
.donut-seg { transition: opacity .15s; cursor: pointer; }
.donut-svg:hover .donut-seg { opacity: .55; }
.donut-svg .donut-seg:hover { opacity: 1; }
.donut-total { font-size: 17px; font-weight: 750; fill: var(--mud-palette-text-primary); }
.donut-caption { font-size: 8px; fill: var(--muted); }
.donut-legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 160px; }
.donut-legend li { display: flex; align-items: center; gap: 8px; font-size: .8rem; padding: 4px 0; border-bottom: 1px solid var(--card-border); }
.donut-legend li:last-child { border: 0; }
.donut-legend i { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.donut-legend span { flex: 1; }
.donut-legend b { font-variant-numeric: tabular-nums; }

.funnel { display: flex; flex-direction: column; gap: 10px; }
.fn-row { display: grid; grid-template-columns: 96px 1fr 44px; gap: 10px; align-items: center; font-size: .8rem; }
.fn-track { background: var(--track); border-radius: 6px; height: 28px; overflow: hidden; }
.fn-bar { height: 100%; background: var(--series-1); border-radius: 6px; display: flex; align-items: center; padding: 0 10px; color: #fff; font-weight: 600; min-width: 34px; }
.fn-conv { color: var(--muted); text-align: end; font-variant-numeric: tabular-nums; }

/* ---------- Tables ---------- */
.crm-table table { font-size: .84rem; }
.crm-table th, .mud-table-head .mud-table-cell { font-size: .75rem !important; font-weight: 650 !important; color: var(--muted) !important; background: var(--soft); white-space: nowrap; }
.crm-table td { vertical-align: middle; }
.list-card { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list-toolbar { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--card-border); flex-wrap: wrap; }
.list-toolbar .mud-input-control { margin: 0 !important; }
.list-search { max-width: 320px; }
.mud-table-row { cursor: pointer; }
.cell-title { font-weight: 600; color: var(--mud-palette-text-primary); }
.cell-sub { font-size: .74rem; color: var(--muted); }
.avatar-cell { display: flex; align-items: center; gap: 10px; }
.avatar-sq { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; font-size: .75rem; font-weight: 700; color: #fff; flex-shrink: 0; }
.status-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.status-tab { border: 1px solid var(--card-border); background: var(--card); border-radius: 999px; padding: 4px 12px; font-size: .8rem; cursor: pointer; color: inherit; display: inline-flex; gap: 6px; align-items: center; }
.status-tab b { background: var(--soft); border-radius: 999px; padding: 0 7px; font-size: .72rem; }
.status-tab.active { border-color: var(--mud-palette-primary); background: var(--brand-soft); color: var(--mud-palette-primary); font-weight: 600; }

/* ---------- Status chips & pills ---------- */
.status-chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: 999px; font-size: .74rem; font-weight: 600; white-space: nowrap; background: var(--soft); color: var(--muted); border: 1px solid transparent; }
.status-chip i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-success { background: var(--ok-soft); color: var(--ok); }
.status-error { background: var(--bad-soft); color: var(--bad); }
.status-warning { background: var(--warn-soft); color: var(--warn); }
.status-info, .status-primary { background: var(--info-soft); color: var(--info); }
.status-secondary { background: color-mix(in srgb, #6250d6 12%, transparent); color: #6250d6; }
.status-default { background: var(--soft); color: var(--muted); border-color: var(--card-border); }
.pill { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: .7rem; font-weight: 700; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }

/* ---------- Business process flow ---------- */
.bpf { display: flex; background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); margin-bottom: 16px; overflow-x: auto; box-shadow: var(--shadow); }
.bpf-stage { flex: 1; min-width: 150px; display: flex; align-items: center; gap: 10px; padding: 12px 18px; border: 0; background: transparent; cursor: pointer; position: relative; color: var(--muted); font: inherit; text-align: start; }
.bpf-stage:not(:last-child)::after { content: ""; position: absolute; inset-inline-end: -1px; top: 18%; height: 64%; width: 1px; background: var(--card-border); }
.bpf-stage:disabled { cursor: default; }
.bpf-stage:hover:not(:disabled) { background: var(--soft); }
.bpf-dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .78rem; font-weight: 700; border: 2px solid var(--card-border); flex-shrink: 0; }
.bpf-text { display: flex; flex-direction: column; }
.bpf-text b { font-size: .85rem; font-weight: 600; }
.bpf-text small { font-size: .72rem; }
.bpf-stage.done { color: var(--mud-palette-text-primary); }
.bpf-stage.done .bpf-dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.bpf-stage.active { color: var(--mud-palette-primary); background: var(--brand-soft); }
.bpf-stage.active .bpf-dot { border-color: var(--mud-palette-primary); background: var(--mud-palette-primary); color: #fff; box-shadow: 0 0 0 4px color-mix(in srgb, var(--mud-palette-primary) 20%, transparent); }
.bpf-stage.won { color: var(--ok); background: var(--ok-soft); }
.bpf-stage.won .bpf-dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.bpf-stage.lost { color: var(--bad); background: var(--bad-soft); }
.bpf-stage.lost .bpf-dot { background: var(--bad); border-color: var(--bad); color: #fff; }

/* ---------- Form layout ---------- */
.form-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .form-grid { grid-template-columns: 1fr; } }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 16px; }
.fields.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fields .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .fields, .fields.three { grid-template-columns: 1fr; } }
.fields .mud-input-control { margin-top: 10px !important; }
.crm-tabs .mud-tabs-tabbar { background: transparent !important; border-bottom: 1px solid var(--card-border); }
.crm-tabs .mud-tab { text-transform: none; font-weight: 600; min-width: 0; padding: 10px 16px; }
.crm-tabs .mud-tabs-panels { padding-top: 16px; }
.summary-tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.summary-tile { background: var(--soft); border: 1px solid var(--card-border); border-radius: 8px; padding: 10px 12px; }
.summary-tile span { font-size: .72rem; color: var(--muted); display: block; }
.summary-tile b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.info-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: .84rem; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; font-weight: 500; }

/* ---------- Lines editor ---------- */
.lines-wrap { overflow-x: auto; }
.lines-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .84rem; }
.lines-table th { font-size: .72rem; font-weight: 650; color: var(--muted); text-align: start; padding: 8px 6px; background: var(--soft); border-bottom: 1px solid var(--card-border); white-space: nowrap; }
.lines-table td { padding: 4px 6px; border-bottom: 1px solid var(--card-border); vertical-align: middle; }
.lines-table .mud-input-control { margin: 0 !important; }
.lines-table .mud-input-outlined input { padding-top: 7px !important; padding-bottom: 7px !important; }
.lines-table td.num .mud-input input { text-align: end; }
.lines-empty { text-align: center; color: var(--muted); padding: 24px; font-size: .85rem; }
.insights { display: flex; gap: 4px; flex-wrap: wrap; }
.lines-footer { display: flex; justify-content: space-between; gap: 16px; padding-top: 12px; flex-wrap: wrap; align-items: flex-start; }
.totals { min-width: 300px; background: var(--soft); border: 1px solid var(--card-border); border-radius: 10px; padding: 10px 14px; }
.totals > div { display: flex; justify-content: space-between; gap: 24px; padding: 4px 0; font-size: .84rem; }
.totals > div span { color: var(--muted); }
.totals > div b { font-variant-numeric: tabular-nums; }
.totals .grand { border-top: 1px solid var(--card-border); margin-top: 4px; padding-top: 8px; font-size: 1rem; }
.totals .grand span { color: var(--mud-palette-text-primary); font-weight: 600; }
.totals .margin-row { border-top: 1px dashed var(--card-border); margin-top: 4px; padding-top: 8px; }

/* ---------- Timeline ---------- */
.timeline-compose { background: var(--soft); border: 1px solid var(--card-border); border-radius: 10px; padding: 12px; margin-bottom: 14px; }
.timeline-list { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline-list::before { content: ""; position: absolute; inset-inline-start: 15px; top: 8px; bottom: 8px; width: 2px; background: var(--card-border); }
.tl-item { display: flex; gap: 12px; padding: 8px 0; position: relative; }
.tl-icon { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--card); border: 2px solid var(--card-border); color: var(--muted); flex-shrink: 0; z-index: 1; }
.tl-note .tl-icon { color: #b58100; border-color: #f5d27a; }
.tl-call .tl-icon { color: var(--series-3); border-color: var(--series-3); }
.tl-email .tl-icon { color: var(--series-1); border-color: var(--series-1); }
.tl-meeting .tl-icon { color: var(--series-7); border-color: var(--series-7); }
.tl-task .tl-icon { color: var(--series-2); border-color: var(--series-2); }
.tl-system .tl-icon { color: var(--muted); }
.tl-body { flex: 1; background: var(--card); border: 1px solid var(--card-border); border-radius: 10px; padding: 8px 12px; position: relative; }
.tl-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: .84rem; }
.tl-head b.done { text-decoration: line-through; opacity: .6; }
.tl-meta { font-size: .72rem; color: var(--muted); }
.tl-text { font-size: .82rem; margin-top: 4px; white-space: pre-line; }
.tl-actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.tl-del { position: absolute !important; inset-inline-end: 4px; bottom: 2px; opacity: 0; }
.tl-body:hover .tl-del { opacity: 1; }

/* ---------- Attachments ---------- */
.dropzone { border: 2px dashed var(--card-border); border-radius: 12px; padding: 22px; text-align: center; cursor: pointer; transition: all .15s; background: var(--soft); }
.dropzone:hover { border-color: var(--mud-palette-primary); background: var(--brand-soft); }
.file-list { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.file-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--card-border); border-radius: 10px; background: var(--card); }
.file-ext { width: 40px; height: 40px; border-radius: 8px; background: var(--brand-soft); color: var(--mud-palette-primary); display: grid; place-items: center; font-size: .68rem; font-weight: 800; flex-shrink: 0; }
.file-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-name { font-weight: 600; font-size: .84rem; color: inherit; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name:hover { color: var(--mud-palette-primary); }

/* ---------- Misc ---------- */
.empty-state { text-align: center; padding: 32px 16px; color: var(--muted); display: flex; flex-direction: column; align-items: center; }
.recent { list-style: none; margin: 0; padding: 0; }
.recent li a { display: flex; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--card-border); color: inherit; text-decoration: none; border-radius: 6px; }
.recent li:last-child a { border: 0; }
.recent li a:hover { background: var(--soft); }
.recent b { display: block; font-size: .82rem; font-weight: 600; }
.recent span { font-size: .72rem; color: var(--muted); }
.recent-ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; }
.kind-request { background: var(--info-soft); color: var(--info); }
.kind-quotation { background: color-mix(in srgb, #6250d6 12%, transparent); color: #6250d6; }
.kind-salesorder { background: var(--ok-soft); color: var(--ok); }
.kind-purchaseorder { background: var(--warn-soft); color: var(--warn); }
.mud-dialog .mud-dialog-title { font-weight: 700; }
.alert-strip { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-size: .85rem; }
.alert-strip.warn { background: var(--warn-soft); color: var(--warn); }
.alert-strip.info { background: var(--info-soft); color: var(--info); }

/* ---------- Auth (static SSR) ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: #f4f6fa; font-family: Inter, "Segoe UI", sans-serif; }
body.lang-ar .auth { font-family: "IBM Plex Sans Arabic", Inter, sans-serif; }
@media (max-width: 900px) { .auth { grid-template-columns: 1fr; } .auth-hero { display: none; } }
.auth-hero { position: relative; overflow: hidden; color: #fff; background: radial-gradient(1200px 600px at 10% 10%, #1e5fb4 0%, transparent 60%), radial-gradient(900px 600px at 90% 80%, #5b3fd6 0%, transparent 55%), linear-gradient(135deg, #0b1f3a, #0f2f5c); }
.auth-hero::before { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px); background-size: 42px 42px; mask-image: radial-gradient(circle at 30% 30%, #000, transparent 75%); }
.auth-hero-inner { position: relative; padding: 56px 64px; display: flex; flex-direction: column; height: 100%; }
.auth-brand { display: flex; align-items: center; gap: 12px; font-size: 1.35rem; }
.auth-brand b { color: #7cc4ff; }
.auth-hero h1 { font-size: 2.3rem; line-height: 1.25; font-weight: 750; margin: 72px 0 28px; max-width: 560px; letter-spacing: -.02em; }
body.lang-ar .auth-hero h1 { letter-spacing: 0; line-height: 1.5; }
.auth-points { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; font-size: 1rem; color: #dbeafe; }
.auth-points span { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: rgba(255,255,255,.12); margin-inline-end: 12px; font-size: .9rem; }
.auth-glass { margin-top: auto; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.16); border-radius: 16px; padding: 18px 20px; backdrop-filter: blur(8px); max-width: 380px; }
.auth-glass-row { display: flex; justify-content: space-between; font-size: .9rem; color: #c7d7f5; }
.auth-glass-row b { color: #6ee7b7; }
.auth-bars { display: flex; align-items: flex-end; gap: 10px; height: 80px; margin-top: 14px; }
.auth-bars i { flex: 1; background: linear-gradient(180deg, #7cc4ff, #2563eb); border-radius: 4px 4px 2px 2px; }
.auth-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 20px; position: relative; }
.auth-lang { position: absolute; top: 20px; inset-inline-end: 24px; }
.auth-lang a { color: #0f6cbd; text-decoration: none; font-weight: 600; padding: 6px 12px; border-radius: 8px; background: #e8f1fb; }
.auth-card { width: 100%; max-width: 440px; background: #fff; border: 1px solid #e3e7ee; border-radius: 16px; padding: 36px 34px; box-shadow: 0 20px 50px rgba(16,24,40,.08); }
.auth-title { font-size: 1.6rem; margin: 0; color: #1b1f24; font-weight: 750; }
.auth-sub { color: #5b6472; margin: 6px 0 22px; }
.auth-form { display: flex; flex-direction: column; }
.auth-form label { font-size: .82rem; font-weight: 600; color: #24292f; margin: 12px 0 6px; }
.auth-form input[type=text], .auth-form input[type=email], .auth-form input[type=password], .auth-form input:not([type]) { height: 44px; border: 1px solid #d0d7e2; border-radius: 10px; padding: 0 14px; font-size: .95rem; outline: none; transition: border .15s, box-shadow .15s; background: #fff; font-family: inherit; }
.auth-form input:focus { border-color: #0f6cbd; box-shadow: 0 0 0 3px rgba(15,108,189,.15); }
.auth-check { display: flex !important; align-items: center; gap: 8px; font-weight: 500 !important; color: #5b6472 !important; }
.auth-btn { margin-top: 22px; height: 46px; border: 0; border-radius: 10px; background: linear-gradient(135deg, #0f6cbd, #2563eb); color: #fff; font-size: 1rem; font-weight: 700; cursor: pointer; box-shadow: 0 8px 20px rgba(37,99,235,.3); font-family: inherit; }
.auth-btn:hover { filter: brightness(1.06); }
.auth-alt { margin-top: 20px; text-align: center; color: #5b6472; font-size: .9rem; }
.auth-alt a { color: #0f6cbd; font-weight: 600; text-decoration: none; }
.auth-alert { background: #fde8e6; color: #c42b1c; border-radius: 10px; padding: 10px 14px; font-size: .87rem; margin-bottom: 8px; }
.auth-alert.ok { background: #e6f4ea; color: #107c41; }
.auth-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.auth-row > div { display: flex; flex-direction: column; }
.auth-foot { margin-top: 24px; font-size: .78rem; color: #8a94a3; }
.validation-message { color: #c42b1c; font-size: .78rem; margin-top: 4px; }

/* ---------- Print (quotations / POs) ---------- */
.print-page { background: #fff; color: #111; max-width: 900px; margin: 0 auto; padding: 40px; font-size: 13px; }
.print-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid #0f6cbd; padding-bottom: 18px; }
.print-company h2 { margin: 0; color: #0b1f3a; font-size: 22px; }
.print-doc { text-align: end; }
.print-doc h1 { margin: 0; color: #0f6cbd; font-size: 26px; letter-spacing: .04em; }
.print-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin: 22px 0; }
.print-box { border: 1px solid #e3e7ee; border-radius: 8px; padding: 12px 14px; }
.print-box h4 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; color: #5b6472; letter-spacing: .06em; }
.print-table { width: 100%; border-collapse: collapse; }
.print-table th { background: #0b1f3a; color: #fff; padding: 8px; font-size: 11px; text-align: start; }
.print-table td { padding: 8px; border-bottom: 1px solid #e3e7ee; }
.print-totals { margin-inline-start: auto; width: 320px; margin-top: 14px; }
.print-totals div { display: flex; justify-content: space-between; padding: 5px 0; }
.print-totals .grand { border-top: 2px solid #0b1f3a; font-weight: 800; font-size: 15px; margin-top: 4px; padding-top: 8px; }
.print-terms { margin-top: 26px; white-space: pre-line; font-size: 12px; color: #333; border-top: 1px solid #e3e7ee; padding-top: 12px; }
.print-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 50px; }
.print-sign div { border-top: 1px solid #999; padding-top: 6px; text-align: center; color: #5b6472; }
.print-toolbar { position: sticky; top: 0; background: #0b1f3a; color: #fff; padding: 10px 20px; display: flex; gap: 10px; justify-content: center; z-index: 10; }
.print-toolbar button, .print-toolbar a { background: #fff; color: #0b1f3a; border: 0; padding: 8px 18px; border-radius: 8px; font-weight: 700; cursor: pointer; text-decoration: none; font-family: inherit; }
@media print {
    .print-toolbar, .mud-appbar, .mud-drawer, .no-print { display: none !important; }
    .mud-main-content { padding: 0 !important; margin: 0 !important; }
    .crm-content { padding: 0 !important; max-width: none; }
    body, .crm-main { background: #fff !important; }
    .print-page { padding: 0; max-width: none; }
    @page { margin: 14mm; }
}

/* ---------- Reconnect & errors (template) ---------- */
.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "An error has occurred."; }

/* ---------- Kanban board ---------- */
.board { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 12px; padding: 14px; overflow-x: auto; background: var(--soft); }
.board-col { background: var(--card); border: 1px solid var(--card-border); border-radius: 10px; padding: 10px; min-height: 300px; max-height: 70vh; overflow-y: auto; }
.board-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; position: sticky; top: -10px; background: var(--card); padding: 4px 0; }
.board-head span { margin-inline-start: auto; font-size: .75rem; color: var(--muted); }
.board-card { border: 1px solid var(--card-border); border-radius: 8px; padding: 10px; margin-bottom: 8px; cursor: pointer; background: var(--card); transition: box-shadow .15s, transform .15s; font-size: .84rem; }
.board-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); border-color: var(--mud-palette-primary); }
.tl-types { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tl-type { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--card-border); background: var(--card); border-radius: 999px; padding: 4px 11px; font: inherit; font-size: .78rem; cursor: pointer; color: var(--muted); }
.tl-type.active { border-color: var(--mud-palette-primary); color: var(--mud-palette-primary); background: var(--brand-soft); font-weight: 600; }
.lines-table td .mud-input-control { min-width: 70px; }
