/* ==========================================================================
   IDA Theme — portal dashboard kit (templates/portal/dash.html macros).
   One look for the supplier, customer and dealer dashboards inside the .ddms
   shell (dealer_distribution/partner_portal.css). Tones: brand/info blue,
   ok green, warn amber, warn2 orange, bad red, muted grey.
   ========================================================================== */
.ddms {
	--pd-brand: #0b5fff; --pd-brand-bg: #eaf1ff;
	--pd-info: #2563eb; --pd-info-bg: #e6eeff;
	--pd-ok: #1f9d55; --pd-ok-bg: #e3f6ea;
	--pd-warn: #d97706; --pd-warn-bg: #fff3dc;
	--pd-warn2: #ea580c; --pd-warn2-bg: #ffe9d9;
	--pd-bad: #d7263d; --pd-bad-bg: #fde4e7;
	--pd-muted: #8a97a6; --pd-muted-bg: #eef1f5;
	--pd-violet: #6b3fb5; --pd-violet-bg: #f0e9fb;
}
.pd-tone-brand { --t: var(--pd-brand); --t-bg: var(--pd-brand-bg); }
.pd-tone-info { --t: var(--pd-info); --t-bg: var(--pd-info-bg); }
.pd-tone-ok { --t: var(--pd-ok); --t-bg: var(--pd-ok-bg); }
.pd-tone-warn { --t: var(--pd-warn); --t-bg: var(--pd-warn-bg); }
.pd-tone-warn2 { --t: var(--pd-warn2); --t-bg: var(--pd-warn2-bg); }
.pd-tone-bad { --t: var(--pd-bad); --t-bg: var(--pd-bad-bg); }
.pd-tone-muted { --t: var(--pd-muted); --t-bg: var(--pd-muted-bg); }
.pd-tone-violet { --t: var(--pd-violet); --t-bg: var(--pd-violet-bg); }

.pd-ic { width: 18px; height: 18px; flex: none; }

/* a row whose other cards are switched off (Portal Module Settings) lets the survivor take the width */
.pd-row > :only-child { grid-column: 1 / -1; }
.pd-kpis:empty { display: none; }

/* ---- portal navigation: coloured icon per item (supplier_base.html, partner_base.html) ---- */
.ddms-nav-item { display: flex !important; align-items: center; gap: 10px; padding: 6px 16px 6px 14px !important; }
.ddms-nav-ic { width: 26px; height: 26px; border-radius: 7px; background: var(--t-bg); color: var(--t); display: inline-flex; align-items: center; justify-content: center; flex: none; transition: transform .15s; }
.ddms-nav-ic .pd-ic { width: 15px; height: 15px; }
.ddms-nav-item:hover .ddms-nav-ic { transform: scale(1.06); }
.ddms-nav-item.active .ddms-nav-ic { background: var(--t); color: #fff; }
.ddms-nav-item > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- page header: greeting + context line -------------------------------- */
.pd-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0 0 16px; }
.pd-head h1 { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.pd-head .pd-context { color: var(--d-ink2); font-size: 13px; margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pd-head .pd-context .ddms-chip { font-size: 11px; }
.pd-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- KPI tiles ----------------------------------------------------------- */
.pd-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.pd-kpi { position: relative; display: flex; flex-direction: column; min-height: 128px; padding: 14px 16px 12px; background: #fff; border: 1px solid #e5e8ec; border-radius: 12px;
	box-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 2px 8px rgba(16, 24, 40, .04); overflow: hidden; color: inherit !important; text-decoration: none !important; transition: box-shadow .15s, transform .15s; }
.pd-kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--t); }
a.pd-kpi:hover { box-shadow: 0 6px 18px rgba(16, 24, 40, .12); transform: translateY(-1px); }
.pd-kpi-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pd-kpi-icon { width: 34px; height: 34px; border-radius: 10px; background: var(--t-bg); color: var(--t); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.pd-kpi-label { font-size: 13px; color: #3d4b5a; font-weight: 600; line-height: 1.25; min-width: 0; }
.pd-kpi-value { font-size: 30px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; margin: 12px 0 6px; color: #17222e; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pd-kpi-value .ddms-chip { font-size: 15px; vertical-align: middle; padding: 4px 10px; }
.pd-kpi-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-top: auto; }
.pd-kpi-sub { font-size: 12px; color: var(--d-ink2); line-height: 1.3; }
.pd-spark { display: inline-flex; align-items: flex-end; gap: 2px; height: 26px; flex: none; }
.pd-spark i { display: block; width: 5px; border-radius: 2px 2px 0 0; background: var(--t); opacity: .35; }
.pd-spark i:last-child { opacity: 1; }
.pd-delta { margin-left: auto; font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 999px; white-space: nowrap; }
.pd-delta-ok { background: var(--pd-ok-bg); color: #166534; }
.pd-delta-bad { background: var(--pd-bad-bg); color: #991b1b; }

/* ---- cards --------------------------------------------------------------- */
.pd-row { display: grid; gap: 16px; margin-bottom: 16px; }
.pd-row-21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.pd-row-12 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.pd-row-11 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pd-row-111 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pd-row > * { min-width: 0; margin-bottom: 0; }
.ddms-card.pd-card { border-radius: 12px; padding: 16px 18px 14px; display: flex; flex-direction: column; }
.pd-card .pd-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.pd-card .pd-card-head h2 { border: 0; padding: 0; margin: 0; font-size: 15px; font-weight: 700; color: #17222e; }
.pd-card-sub { font-size: 12px; color: var(--d-ink2); margin-top: 2px; }
.pd-chart-total { text-align: right; flex: 0 1 auto; min-width: 0; }
.pd-chart-total b { font-size: 20px; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.pd-card-link { margin: auto 0 0; padding-top: 10px; font-size: 13px; }
.pd-small { font-size: 11.5px; }
.pd-late { color: var(--pd-bad); font-weight: 600; }
.pd-btn { border-radius: 8px; font-weight: 600; font-size: 12px; padding: 4px 10px; background: var(--t-bg); color: var(--t) !important; border: 1px solid transparent; white-space: nowrap; }
.pd-btn:hover { border-color: var(--t); }

/* ---- 12-month columns ---------------------------------------------------- */
.pd-bars { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 6px; height: 200px; align-items: end; padding-top: 4px; }
.pd-bar-col { display: flex; flex-direction: column; height: 100%; min-width: 0; }
.pd-bar-val { font-size: 10.5px; color: var(--d-ink2); text-align: center; height: 16px; line-height: 16px; white-space: nowrap; overflow: hidden; font-variant-numeric: tabular-nums; }
.pd-bar-track { flex: 1; display: flex; align-items: flex-end; border-bottom: 1px solid #e3e7ec; }
.pd-bar { width: 100%; min-height: 2px; border-radius: 4px 4px 0 0; background: linear-gradient(180deg, #4f8bff, var(--pd-brand)); transition: height .3s; }
.pd-bar.best { background: linear-gradient(180deg, #34c27a, var(--pd-ok)); }
.pd-bar-col:hover .pd-bar { filter: brightness(1.1); }
.pd-bar-label { font-size: 11px; color: var(--d-ink2); text-align: center; margin-top: 6px; white-space: nowrap; }
.pd-bar-label small { display: block; font-size: 9.5px; opacity: .75; }

/* ---- stacked bar + legend ------------------------------------------------ */
.pd-stack { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: #eef1f5; margin: 6px 0 12px; }
.pd-stack span { display: block; height: 100%; background: var(--t); min-width: 3px; }
.pd-legend { list-style: none; margin: 0; padding: 0; }
.pd-legend li { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px dashed #edf0f4; font-size: 13px; }
.pd-legend span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pd-legend li:last-child { border-bottom: 0; }
.pd-legend li.dim { color: var(--d-ink2); }
.pd-legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--t); display: inline-block; }
.pd-legend em { font-style: normal; font-size: 11px; color: var(--d-ink2); min-width: 14px; text-align: right; }
.pd-legend b { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 72px; text-align: right; }
.pd-age-foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding: 8px 10px; border-radius: 8px; font-size: 12.5px; font-weight: 600; }
.pd-age-foot.ok { background: var(--pd-ok-bg); color: #166534; }
.pd-age-foot.bad { background: var(--pd-bad-bg); color: #991b1b; }

/* ---- donut ---------------------------------------------------------------- */
.pd-donut-wrap { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 14px; align-items: center; }
.pd-donut { width: 120px; height: 120px; }
.pd-donut-wrap .pd-legend b { min-width: 0; }
.pd-donut circle.pd-tone-info, .pd-donut circle.pd-tone-ok, .pd-donut circle.pd-tone-muted { stroke: var(--t); }
.pd-donut-n { font-size: 9px; font-weight: 700; text-anchor: middle; fill: #17222e; }
.pd-donut-t { font-size: 3.2px; text-anchor: middle; fill: #5b6b7b; text-transform: uppercase; letter-spacing: .3px; }

/* ---- progress table ------------------------------------------------------- */
.pd-table th, .pd-table td { padding: 8px 10px; }
.pd-table td.nw, .pd-table td.num { white-space: nowrap; }
.pd-table td.nw .pd-small { white-space: normal; }
.pd-prog-col { width: 15%; }
.pd-prog { height: 8px; border-radius: 4px; background: #eef1f5; overflow: hidden; margin-top: 4px; }
.pd-prog span { display: block; height: 100%; background: var(--pd-brand); border-radius: 4px; }
.pd-prog.alt span { background: var(--pd-ok); }

/* ---- attention list ------------------------------------------------------- */
.pd-attn { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.pd-attn li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; background: var(--t-bg); border-left: 4px solid var(--t); }
.pd-attn-icon { width: 30px; height: 30px; border-radius: 8px; background: #fff; color: var(--t); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.pd-attn-text { flex: 1; font-size: 13px; color: #17222e; line-height: 1.3; }
.pd-attn .pd-btn { background: #fff; }

/* ---- top items ------------------------------------------------------------ */
.pd-top { list-style: none; margin: 0; padding: 0; counter-reset: pd; }
.pd-top li { padding: 7px 0; border-bottom: 1px dashed #edf0f4; }
.pd-top li:last-child { border-bottom: 0; }
.pd-top-row { display: flex; align-items: baseline; gap: 10px; font-size: 13px; }
.pd-top-row::before { counter-increment: pd; content: counter(pd); width: 20px; height: 20px; border-radius: 6px; background: var(--pd-brand-bg); color: var(--pd-brand); font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; align-self: center; }
.pd-top-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pd-top-qty { font-size: 11.5px; white-space: nowrap; }
.pd-top-row b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pd-hbar { height: 6px; border-radius: 3px; background: #eef1f5; margin: 5px 0 0 30px; overflow: hidden; }
.pd-hbar span { display: block; height: 100%; background: linear-gradient(90deg, var(--pd-brand), #4f8bff); border-radius: 3px; }

/* ---- quick links ----------------------------------------------------------- */
.pd-quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.pd-quick-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 84px; padding: 12px 8px; border-radius: 12px; background: #f6f8fb; border: 1px solid #e5e8ec; color: #17222e !important; text-decoration: none !important; font-size: 12.5px; font-weight: 600; text-align: center; transition: background .15s, border-color .15s, transform .15s; }
.pd-quick-tile .pd-ic { width: 24px; height: 24px; color: var(--pd-brand); }
.pd-quick-tile:hover { background: var(--pd-brand-bg); border-color: #c7d7ff; transform: translateY(-1px); }

/* ---- account block ---------------------------------------------------------- */
.pd-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
.pd-fact { padding: 8px 0; border-bottom: 1px dashed #edf0f4; min-width: 0; }
.pd-fact small { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--d-ink2); margin-bottom: 2px; }
.pd-fact b { font-weight: 600; font-size: 13.5px; word-break: break-word; }
.pd-credit { margin-top: 12px; }
.pd-credit .ddms-progress { height: 10px; border-radius: 5px; margin: 6px 0; }
.pd-credit-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--d-ink2); }

/* ---- targets (dealer) -------------------------------------------------------- */
.pd-target { padding: 10px 0; border-bottom: 1px dashed #edf0f4; }
.pd-target:last-child { border-bottom: 0; }
.pd-target-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; align-items: baseline; }
.pd-target-row b { font-variant-numeric: tabular-nums; }

/* ---- responsive --------------------------------------------------------------- */
/* With the 232px sidebar beside it a tablet leaves ~560px for the cards: one card per row reads better than
   two squeezed ones; the KPI tiles stay two abreast. */
@media (max-width: 1100px) {
	.pd-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.pd-row-21, .pd-row-12, .pd-row-11, .pd-row-111 { grid-template-columns: 1fr; }
	.pd-bars { height: 180px; }
	.pd-bar-val { display: none; }
}
@media (max-width: 720px) {
	.pd-kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
	.pd-kpi { min-height: 112px; padding: 12px; }
	.pd-kpi-value { font-size: 24px; }
	.pd-kpi-icon { width: 30px; height: 30px; }
	.pd-spark { height: 20px; }
	.pd-row-21, .pd-row-12, .pd-row-11, .pd-row-111 { grid-template-columns: 1fr; }
	.pd-bars { height: 160px; gap: 3px; }
	.pd-bar-val { display: none; }
	.pd-bar-label { font-size: 9.5px; }
	.pd-donut-wrap { grid-template-columns: 110px minmax(0, 1fr); }
	.pd-donut { width: 110px; height: 110px; }
	.pd-facts { grid-template-columns: 1fr; }
	.pd-head h1 { font-size: 19px; }
	.pd-chart-total b { font-size: 17px; }
	.pd-card .pd-card-head { flex-direction: column; align-items: stretch; gap: 6px; }
	.pd-kpi-top { flex-wrap: wrap; }
	.pd-chart-total { text-align: left; }
	.pd-head-actions .btn { flex: 1; }
}
@media (max-width: 420px) {
	.pd-kpi-value { font-size: 21px; }
	.pd-kpi-label { font-size: 12px; }
	.pd-kpi { padding: 10px; min-height: 104px; }
	.pd-kpi-icon { width: 26px; height: 26px; border-radius: 8px; }
	.pd-kpi-icon .pd-ic { width: 15px; height: 15px; }
	.pd-spark { display: none; }
}
