/**
 * Session 18 dashboards, pipeline board, and calendar.
 * ----------------------------------------------------
 * Shared look for the Manager, Training, and Executive dashboards, the Kanban
 * pipeline board, and the follow-up calendar. Builds only on design-system tokens
 * (colors, radius, fonts) from csw-design-system.css; no raw hex here.
 */

/* ---------- Shell ---------- */
/* Width is owned by the design system's screen shell (--csw-screen-max). */
.csw-dashboard {
	font-family: var(--csw-font-body);
	color: var(--csw-ink);
	padding: 24px 16px 48px;
}

.csw-dashboard__header {
	margin-bottom: 20px;
}

.csw-dashboard__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 14px;
}

.csw-dashboard__section {
	background: var(--csw-surface);
	border: 1px solid var(--csw-line);
	border-radius: var(--csw-card-radius);
	padding: 20px 22px;
	margin: 0 0 20px;
	scroll-margin-top: 24px;
}

.csw-empty {
	color: var(--csw-muted);
	font-style: italic;
	margin: 8px 0 0;
}

.csw-hint {
	color: var(--csw-muted);
	font-size: 0.9rem;
	margin: 6px 0 14px;
}

.csw-hint--lock::before {
	content: "\1F512"; /* padlock */
	margin-right: 6px;
}

/* ---------- Period selector ---------- */
.csw-period {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0 0 20px;
	flex-wrap: wrap;
}

.csw-period label {
	font-weight: 600;
	color: var(--csw-navy);
}

.csw-period select {
	padding: 8px 12px;
	border: 1px solid var(--csw-line);
	border-radius: 4px;
	font: inherit;
	background: var(--csw-surface);
}

/* ---------- Stat tiles ---------- */
.csw-stat-row {
	display: flex;
	flex-wrap: wrap;
	gap: 14px;
	margin: 4px 0 14px;
}

.csw-stat {
	flex: 1 1 150px;
	background: var(--csw-surface-alt);
	border: 1px solid var(--csw-line);
	border-radius: var(--csw-card-radius);
	border-left: 4px solid var(--csw-teal);
	padding: 14px 16px;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.csw-stat__value {
	font-family: var(--csw-font-display);
	font-size: 1.7rem;
	font-weight: 800;
	color: var(--csw-navy);
	line-height: 1.1;
}

.csw-stat__label {
	font-size: 0.82rem;
	color: var(--csw-muted);
}

.csw-stat--good { border-left-color: var(--csw-green); }
.csw-stat--warn { border-left-color: var(--csw-olive); }
.csw-stat--bad  { border-left-color: var(--csw-red); }

/* ---------- Meters ---------- */
.csw-meter-row {
	display: flex;
	flex-wrap: wrap;
	gap: 18px;
}

.csw-meter {
	flex: 1 1 260px;
}

.csw-meter__head {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	margin-bottom: 6px;
}

.csw-meter__label { font-weight: 600; color: var(--csw-navy); }
.csw-meter__pct   { font-family: var(--csw-font-display); font-weight: 800; }

.csw-meter__track {
	height: 12px;
	background: var(--csw-surface-alt);
	border: 1px solid var(--csw-line);
	border-radius: 999px;
	overflow: hidden;
}

.csw-meter__fill {
	display: block;
	height: 100%;
	background: var(--csw-teal);
	transition: width 0.3s ease;
}

.csw-meter__fill--good  { background: var(--csw-green); }
.csw-meter__fill--warn  { background: var(--csw-olive); }
.csw-meter__fill--bad   { background: var(--csw-red); }
.csw-meter__fill--muted { background: var(--csw-muted); }

.csw-meter__caption {
	display: block;
	margin-top: 4px;
	font-size: 0.82rem;
	color: var(--csw-muted);
}

/* ---------- Charts ---------- */
.csw-chart {
	position: relative;
	height: 280px;
	margin: 10px 0 16px;
}

.csw-split {
	display: grid;
	grid-template-columns: minmax(0, 2fr) minmax(160px, 1fr);
	gap: 20px;
	align-items: center;
}

.csw-split .csw-chart { margin: 0; }

/* ---------- Legend / swatches ---------- */
.csw-legend {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.csw-legend--inline {
	flex-direction: row;
	flex-wrap: wrap;
	gap: 16px;
	margin: 0 0 16px;
}

.csw-legend__row {
	display: flex;
	align-items: center;
	gap: 8px;
}

.csw-legend__label { flex: 1; }
.csw-legend__val   { font-weight: 700; color: var(--csw-navy); }

.csw-swatch {
	width: 14px;
	height: 14px;
	border-radius: 3px;
	background: var(--csw-teal);
	display: inline-block;
	flex: none;
}

.csw-swatch--teal  { background: var(--csw-teal); }
.csw-swatch--plum  { background: var(--csw-plum); }
.csw-swatch--coral { background: var(--csw-coral); }
.csw-swatch--olive { background: var(--csw-olive); }
.csw-swatch--red   { background: var(--csw-red); }
.csw-swatch--green { background: var(--csw-green); }

/* ---------- Tables ---------- */
.csw-table {
	width: 100%;
	border-collapse: collapse;
	margin: 12px 0 0;
	font-size: 0.92rem;
}

.csw-table th,
.csw-table td {
	text-align: left;
	padding: 10px 12px;
	border-bottom: 1px solid var(--csw-line);
}

.csw-table thead th {
	font-family: var(--csw-font-display);
	font-size: 0.78rem;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	color: var(--csw-muted);
}

.csw-table .csw-num { text-align: right; font-variant-numeric: tabular-nums; }

.csw-table tbody tr:hover { background: var(--csw-surface-alt); }

/* A wide table cannot shrink past its content, so on a phone it scrolls inside
   its own box instead of stretching the page. Scoped to small screens: an
   overflow container on desktop would clip the tooltips that sit in sections. */
@media (max-width: 640px) {
	.csw-table {
		display: block;
		width: 100%;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}

	.csw-table thead th,
	.csw-table td { white-space: nowrap; }
}

/* ---------- Pills (status chips) ---------- */
.csw-pill {
	display: inline-block;
	padding: 2px 10px;
	border-radius: 999px;
	font-size: 0.78rem;
	font-weight: 600;
	background: var(--csw-surface-alt);
	color: var(--csw-ink);
	border: 1px solid var(--csw-line);
}

.csw-pill--active        { background: rgba(73, 170, 91, 0.15); color: #276b34; border-color: rgba(73, 170, 91, 0.4); }
.csw-pill--expiring_soon { background: rgba(185, 179, 76, 0.18); color: #6d6a1c; border-color: rgba(185, 179, 76, 0.5); }
.csw-pill--expired       { background: rgba(160, 67, 67, 0.14); color: #7a2f2f; border-color: rgba(160, 67, 67, 0.4); }

/* ---------- Small button variant ---------- */
.csw-btn--small {
	padding: 8px 18px;
	font-size: 0.85rem;
}

/* ============================================================= *
 * Pipeline Kanban board
 * ============================================================= */
.csw-pipeline__status {
	min-height: 1.2em;
	margin: 0 0 10px;
	color: var(--csw-plum);
	font-weight: 600;
}

/* Seventeen stages in one row is a horizontal scrollbar by construction, and a
   client should never have to drag sideways to find a case. The lanes wrap
   instead: as many per row as fit, one column on a phone, page scrolls down. */
.csw-pipeline__board {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
	gap: 12px;
	padding-bottom: 16px;
	align-items: start;
}

.csw-lane {
	background: var(--csw-surface-alt);
	border: 1px solid var(--csw-line);
	border-radius: var(--csw-card-radius);
	display: flex;
	flex-direction: column;
	min-width: 0;
}

/* Most of the pipeline is empty for any one caseload, so empty stages are out
   of the way until asked for. A lane that gains a card reveals itself (the
   script clears the flag), so a move never lands somewhere invisible. */
.csw-pipeline__board--hide-empty .csw-lane.is-empty { display: none; }

.csw-pipeline__controls {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0 0 12px;
	font-size: 0.88rem;
	color: var(--csw-muted);
}

.csw-pipeline__controls label {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	cursor: pointer;
}

.csw-pipeline__controls input:focus-visible {
	outline: 2px solid var(--csw-teal);
	outline-offset: 2px;
}

.csw-lane.is-over {
	outline: 2px dashed var(--csw-teal);
	outline-offset: -2px;
}

.csw-lane__head {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 10px 12px;
	border-bottom: 2px solid var(--csw-teal);
}

.csw-lane__title {
	font-family: var(--csw-font-display);
	font-size: 0.82rem;
	font-weight: 800;
	text-transform: uppercase;
	color: var(--csw-navy);
	margin: 0;
	line-height: 1.2;
}

.csw-lane__count {
	background: var(--csw-teal);
	color: var(--csw-btn-text);
	border-radius: 999px;
	padding: 1px 9px;
	font-size: 0.78rem;
	font-weight: 700;
	flex: none;
}

.csw-lane__cards {
	padding: 10px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	overflow-y: auto;
	min-height: 40px;
	/* A busy stage scrolls inside its own lane rather than stretching the row. */
	max-height: 46vh;
}

.csw-card--consumer {
	background: var(--csw-surface);
	border: 1px solid var(--csw-line);
	border-left: 4px solid var(--csw-plum);
	border-radius: 4px;
	padding: 10px 12px;
	cursor: grab;
	display: flex;
	flex-direction: column;
	gap: 3px;
}

.csw-card--consumer:active { cursor: grabbing; }
.csw-card--consumer.is-dragging { opacity: 0.5; }
.csw-card--consumer.is-pending  { opacity: 0.6; }

.csw-card__ref  { font-weight: 700; color: var(--csw-navy); }
.csw-card__meta { font-size: 0.8rem; color: var(--csw-muted); }

/* ---- Keyboard + touch moves, FLIP motion (csw-pipeline-board.js) ---- */
.csw-card--consumer {
	position: relative;
	transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.csw-card--consumer:focus-visible,
.csw-card--consumer.is-lifted {
	outline: none;
	border-color: var(--csw-teal);
	box-shadow: 0 0 0 2px var(--csw-teal), 0 10px 22px rgba(26, 33, 72, 0.16);
	z-index: 2;
}

/* Card controls. The primary button names the stage it will advance to, so a
   phone user gets there in one tap and can read the destination first; the
   Move menu stays for reaching a later stage. */
.csw-card__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	margin-top: 6px;
}

.csw-card__next {
	flex: 1 1 auto;
	min-width: 0;
	padding: 6px 10px;
	border: 1px solid var(--csw-teal);
	border-radius: 999px;
	background: var(--csw-teal);
	color: var(--csw-btn-text);
	font: 700 0.76rem/1.4 var(--csw-font-body);
	text-align: center;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	cursor: pointer;
}

.csw-card__next:hover { filter: brightness(1.06); }

.csw-card__next:focus-visible,
.csw-card__move:focus-visible {
	outline: 2px solid var(--csw-navy);
	outline-offset: 2px;
}

.csw-card__next[hidden] { display: none; }

/* The JS-injected "Move" control. Always visible on touch; on pointer
   devices it appears on hover or when the card holds focus. */
.csw-card__move {
	align-self: flex-start;
	padding: 2px 10px;
	border: 1px solid var(--csw-line);
	border-radius: 999px;
	background: var(--csw-surface);
	color: var(--csw-navy);
	font: 600 0.75rem/1.6 var(--csw-font-body);
	cursor: pointer;
}

.csw-card__move:focus-visible {
	outline: 2px solid var(--csw-teal);
	outline-offset: 2px;
}

/* Pointer devices keep the card quiet until it is hovered or focused. Touch
   devices have no hover, so the controls are always there. */
@media (hover: hover) and (pointer: fine) {
	.csw-card__actions { opacity: 0; transition: opacity 0.18s ease; }
	.csw-card--consumer:hover .csw-card__actions,
	.csw-card--consumer:focus-within .csw-card__actions { opacity: 1; }
}

/* In-flow inside the card: lanes scroll, so an absolute popover would clip. */
.csw-move-menu {
	margin: 4px 0 0;
	padding: 4px;
	list-style: none;
	background: var(--csw-surface);
	border: 1px solid var(--csw-line);
	border-radius: var(--csw-card-radius);
	box-shadow: 0 12px 28px rgba(26, 33, 72, 0.18);
}

.csw-move-menu button {
	display: block;
	width: 100%;
	padding: 7px 10px;
	border: 0;
	border-radius: 4px;
	background: none;
	color: var(--csw-ink);
	font: inherit;
	font-size: 0.85rem;
	text-align: left;
	cursor: pointer;
}

.csw-move-menu button:hover,
.csw-move-menu button:focus-visible {
	background: var(--csw-surface-alt);
	outline: none;
	box-shadow: inset 3px 0 0 var(--csw-teal);
}

.csw-move-menu__opt {
	display: block;
	font-size: 0.72rem;
	color: var(--csw-muted);
}

/* An option that will cost a reason reads differently from one that will not,
   so the two are not confused at a glance in a seventeen-stage list. */
.csw-move-menu__override {
	color: var(--csw-muted);
}

.csw-move-menu__override:hover,
.csw-move-menu__override:focus-visible {
	box-shadow: inset 3px 0 0 var(--csw-coral);
}

.csw-move-menu__override .csw-move-menu__opt {
	color: var(--csw-coral);
}

/* ============================================================= *
 * Move confirmation dialog (Csw_Pipeline_Board::move_confirmations)
 * A real <dialog>, so focus trapping, Escape and top-layer
 * stacking come from the browser rather than from script.
 * ============================================================= */
.csw-modal {
	width: min(30rem, calc(100vw - 32px));
	padding: 0;
	border: 1px solid var(--csw-line);
	border-radius: var(--csw-card-radius);
	background: var(--csw-surface);
	color: var(--csw-ink);
	font-family: var(--csw-font-body);
	box-shadow: 0 24px 60px rgba(26, 33, 72, 0.28);
}

.csw-modal::backdrop {
	background: rgba(26, 33, 72, 0.55);
}

.csw-modal__form {
	padding: 22px;
}

.csw-modal__title {
	margin: 0 0 10px;
	color: var(--csw-navy);
	font-family: var(--csw-font-display);
	font-size: 1.15rem;
	line-height: 1.3;
}

.csw-modal__body {
	margin: 0 0 12px;
	font-size: 0.92rem;
	line-height: 1.5;
}

.csw-modal__note {
	margin: 0 0 12px;
	padding: 10px 12px;
	border-left: 3px solid var(--csw-coral);
	background: var(--csw-surface-alt);
	font-size: 0.85rem;
	line-height: 1.45;
}

.csw-modal__subhead {
	margin: 0 0 6px;
	color: var(--csw-navy);
	font-size: 0.8rem;
	font-weight: 600;
}

.csw-modal__list {
	margin: 0 0 14px;
	padding-left: 18px;
	font-size: 0.85rem;
	line-height: 1.5;
}

.csw-modal__label {
	display: block;
	margin-bottom: 4px;
	font-size: 0.82rem;
	font-weight: 600;
}

.csw-modal__reason {
	width: 100%;
	padding: 8px 10px;
	border: 1px solid var(--csw-line);
	border-radius: 4px;
	background: var(--csw-surface);
	color: var(--csw-ink);
	font: inherit;
	font-size: 0.9rem;
	resize: vertical;
}

.csw-modal__reason:focus-visible {
	outline: 2px solid var(--csw-teal);
	outline-offset: 1px;
}

.csw-modal__error {
	margin: 6px 0 0;
	color: var(--csw-red);
	font-size: 0.82rem;
}

.csw-modal__actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	gap: 8px;
	margin-top: 18px;
}

.csw-modal__btn {
	padding: 9px 18px;
	border: 1px solid transparent;
	border-radius: 4px;
	font: inherit;
	font-size: 0.88rem;
	font-weight: 600;
	cursor: pointer;
}

.csw-modal__btn--ghost {
	border-color: var(--csw-line);
	background: var(--csw-surface);
	color: var(--csw-ink);
}

.csw-modal__btn--go {
	background: var(--csw-teal);
	color: var(--csw-btn-text);
}

.csw-modal__btn:focus-visible {
	outline: 2px solid var(--csw-navy);
	outline-offset: 2px;
}

/* On a phone the two buttons get a full row each, so neither is a
   thumb-width target sitting next to the other one. */
@media (max-width: 400px) {
	.csw-modal__actions {
		flex-direction: column-reverse;
	}

	.csw-modal__btn {
		width: 100%;
		min-height: 44px;
	}
}

/* ============================================================= *
 * Breadcrumbs (Csw_Breadcrumbs)
 * Chevrons draw once on load. Nothing loops, so there is no
 * motion to pause.
 * ============================================================= */
.csw-breadcrumbs {
	margin: 0 0 14px;
	font-family: var(--csw-font-body);
}

.csw-breadcrumbs__list {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 2px;
	margin: 0;
	padding: 0;
	list-style: none;
	font-size: 0.85rem;
}

.csw-breadcrumbs__item {
	display: flex;
	align-items: center;
	min-width: 0;
}

.csw-breadcrumbs__link,
.csw-breadcrumbs__here {
	padding: 4px 8px;
	border-radius: 4px;
	max-width: 32ch;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.csw-breadcrumbs__link {
	color: var(--csw-muted);
	text-decoration: none;
	transition: color 0.2s ease, background-color 0.2s ease;
}

.csw-breadcrumbs__link:hover,
.csw-breadcrumbs__link:focus-visible {
	color: var(--csw-navy);
	background: var(--csw-surface-alt);
}

.csw-breadcrumbs__link:focus-visible {
	outline: 2px solid var(--csw-teal);
	outline-offset: 1px;
}

.csw-breadcrumbs__here {
	color: var(--csw-teal);
	font-weight: 700;
}

.csw-breadcrumbs__chev {
	width: 14px;
	height: 14px;
	flex: none;
	fill: none;
	stroke: var(--csw-line);
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
	/* pathLength="1" keeps the dash maths independent of the icon size. */
	stroke-dasharray: 1;
	stroke-dashoffset: 1;
	animation: csw-crumb-draw 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
	animation-delay: calc(var(--csw-crumb-i, 0) * 110ms);
}

@keyframes csw-crumb-draw {
	to { stroke-dashoffset: 0; }
}

/* ============================================================= *
 * Tooltip (Csw_Dashboard_Render::tip + csw-toast.js bindings)
 * Dismissible with Escape, hoverable because the bubble is a
 * child of the trigger, and persistent while hovered or focused.
 * ============================================================= */
.csw-tip {
	position: relative;
	display: inline-grid;
	place-items: center;
	width: 17px;
	height: 17px;
	margin-inline-start: 6px;
	padding: 0;
	border: 1px solid var(--csw-muted);
	border-radius: 50%;
	background: none;
	color: var(--csw-muted);
	font: 700 0.62rem/1 var(--csw-font-body);
	cursor: help;
	vertical-align: middle;
}

.csw-tip:hover,
.csw-tip:focus-visible { color: var(--csw-navy); border-color: var(--csw-navy); }

.csw-tip:focus-visible {
	outline: 2px solid var(--csw-teal);
	outline-offset: 2px;
}

.csw-tip__bubble {
	position: absolute;
	left: 50%;
	bottom: calc(100% + 9px);
	z-index: 60;
	width: max-content;
	max-width: min(260px, 70vw);
	padding: 8px 11px;
	border-radius: var(--csw-card-radius);
	background: var(--csw-navy);
	color: #fff;
	font: 400 0.8rem/1.4 var(--csw-font-body);
	text-align: left;
	white-space: normal;
	box-shadow: 0 10px 24px rgba(26, 33, 72, 0.32);
	/* Opacity, never visibility or display: aria-describedby points here, and
	   hiding it the other way would take the text from a screen reader. */
	opacity: 0;
	pointer-events: none;
	transform: translateX(-50%) translateY(5px);
	transition: opacity 0.16s ease, transform 0.22s cubic-bezier(0.34, 1.3, 0.64, 1);
}

/* Notch, plus the invisible bridge across the gap that keeps it hoverable. The
   notch backs out the nudge so it keeps pointing at the trigger. */
.csw-tip__bubble::after,
.csw-tip__bubble::before {
	content: "";
	position: absolute;
	left: 50%;
	top: 100%;
	transform: translateX(-50%);
}

.csw-tip__bubble::after {
	border: 6px solid transparent;
	border-top-color: var(--csw-navy);
}

.csw-tip__bubble::before {
	width: 100%;
	height: 11px;
}

.csw-tip:hover .csw-tip__bubble,
.csw-tip:focus-visible .csw-tip__bubble,
.csw-tip.is-open .csw-tip__bubble {
	opacity: 1;
	pointer-events: auto;
	transform: translateX(-50%);
}

/* Near the right edge the bubble anchors to the trigger instead of centring on
   it. Centred, it would hang past the viewport and give the page a sideways
   scroll even while hidden, because a hidden bubble still takes up layout.
   The script adds the class; the notch moves with it. */
.csw-tip--end .csw-tip__bubble {
	left: auto;
	right: -4px;
	transform: translateY(5px);
}

.csw-tip--end:hover .csw-tip__bubble,
.csw-tip--end:focus-visible .csw-tip__bubble,
.csw-tip--end.is-open .csw-tip__bubble {
	transform: translateY(0);
}

.csw-tip--end .csw-tip__bubble::after,
.csw-tip--end .csw-tip__bubble::before {
	left: auto;
	right: 6px;
	transform: none;
}

.csw-tip--end .csw-tip__bubble::before { width: 24px; }

.csw-tip.is-dismissed .csw-tip__bubble {
	opacity: 0;
	pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
	.csw-breadcrumbs__chev { animation: none; stroke-dashoffset: 0; }
	.csw-tip__bubble { transition: none; transform: translateX(-50%); }
	.csw-tip--end .csw-tip__bubble { transform: none; }
}

@media (forced-colors: active) {
	.csw-breadcrumbs__chev { stroke: CanvasText; }
	.csw-tip__bubble { border: 1px solid CanvasText; background: Canvas; color: CanvasText; }
	.csw-tip__bubble::after { border-top-color: CanvasText; }
}

/* ============================================================= *
 * Toasts (csw-toast.js): shared notifier for the front-end
 * surfaces. The toast IS the live region, so callers must not
 * announce the same words twice.
 * ============================================================= */
.csw-toasts {
	position: fixed;
	z-index: 9999;
	right: max(16px, env(safe-area-inset-right));
	bottom: max(16px, env(safe-area-inset-bottom));
	display: flex;
	flex-direction: column-reverse;
	gap: 10px;
	width: min(380px, calc(100vw - 32px));
	pointer-events: none;
}

.csw-toast {
	position: relative;
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: start;
	gap: 12px;
	padding: 13px 14px 15px;
	border: 1px solid var(--csw-line);
	border-left: 4px solid var(--csw-toast-tone, var(--csw-teal));
	border-radius: var(--csw-card-radius);
	background: var(--csw-surface);
	color: var(--csw-ink);
	font-family: var(--csw-font-body);
	box-shadow: 0 16px 36px -18px rgba(26, 33, 72, 0.55);
	pointer-events: auto;
	overflow: hidden;
	opacity: 0;
	transform: translate3d(0, 12px, 0);
	transition: opacity 0.2s ease, transform 0.28s cubic-bezier(0.34, 1.3, 0.64, 1);
}

.csw-toast.is-in  { opacity: 1; transform: none; }
.csw-toast.is-out { opacity: 0; transform: translate3d(22px, 0, 0); }

.csw-toast--success { --csw-toast-tone: var(--csw-green); }
.csw-toast--error   { --csw-toast-tone: var(--csw-red); }
.csw-toast--warn    { --csw-toast-tone: var(--csw-olive); }
.csw-toast--info    { --csw-toast-tone: var(--csw-teal); }

.csw-toast__icon {
	display: grid;
	place-items: center;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	background: var(--csw-toast-tone, var(--csw-teal));
	color: var(--csw-btn-text);
}

.csw-toast__icon svg { width: 13px; height: 13px; }

.csw-toast__body  { min-width: 0; }
.csw-toast__title { font-weight: 700; color: var(--csw-navy); line-height: 1.3; }
.csw-toast__text  { margin-top: 2px; font-size: 0.85rem; color: var(--csw-muted); }

.csw-toast__actions { display: flex; align-items: center; gap: 6px; }

.csw-toast__action,
.csw-toast__close {
	border: 0;
	background: none;
	font: inherit;
	cursor: pointer;
	border-radius: 6px;
	color: var(--csw-navy);
}

.csw-toast__action {
	padding: 6px 11px;
	font-size: 0.83rem;
	font-weight: 700;
	color: var(--csw-toast-tone, var(--csw-teal));
	background: var(--csw-surface-alt);
}

.csw-toast__action:hover { background: var(--csw-line); }

.csw-toast__close {
	width: 28px;
	height: 28px;
	display: grid;
	place-items: center;
	font-size: 18px;
	line-height: 1;
	color: var(--csw-muted);
}

.csw-toast__close:hover { color: var(--csw-ink); }

.csw-toast__action:focus-visible,
.csw-toast__close:focus-visible {
	outline: 2px solid var(--csw-teal);
	outline-offset: 2px;
}

/* The bar is the clock: pausing the animation pauses the dismissal. */
.csw-toast__life {
	position: absolute;
	left: 0;
	bottom: 0;
	height: 3px;
	width: 100%;
	transform-origin: left center;
	background: var(--csw-toast-tone, var(--csw-teal));
	opacity: 0.5;
	animation: csw-toast-life var(--csw-toast-life, 5000ms) linear forwards;
}

.csw-toast:hover .csw-toast__life,
.csw-toast:focus-within .csw-toast__life,
.csw-toast.is-paused .csw-toast__life { animation-play-state: paused; }

@keyframes csw-toast-life {
	from { transform: scaleX(1); }
	to   { transform: scaleX(0); }
}

@media (prefers-reduced-motion: reduce) {
	.csw-toast { transition: none !important; opacity: 1; transform: none; }
	.csw-toast.is-out { opacity: 0; }
	.csw-toast__life { animation-timing-function: step-end; }
}

@media (forced-colors: active) {
	.csw-toast { border-color: CanvasText; }
	.csw-toast__icon { background: CanvasText; color: Canvas; }
	.csw-toast__life { background: Highlight; }
}

/* ============================================================= *
 * Case checklist ([csw_case_checklist], csw-checklist.js)
 * Server renders the final state; .is-replaying only exists while
 * the script replays it, so no-JS always shows the truth.
 * ============================================================= */
.csw-checklist {
	position: relative;
	background: var(--csw-surface);
	border: 1px solid var(--csw-line);
	border-radius: var(--csw-card-radius);
	padding: 20px 22px 22px;
	margin: 0 0 20px;
	font-family: var(--csw-font-body);
	color: var(--csw-ink);
}

.csw-checklist__head {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	gap: 12px;
	margin-bottom: 12px;
}

.csw-checklist__title {
	font-family: var(--csw-font-display);
	font-size: 1rem;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	color: var(--csw-navy);
	margin: 0;
}

.csw-checklist__ref {
	margin: 2px 0 0;
	font-size: 0.82rem;
	color: var(--csw-muted);
}

.csw-checklist__pct {
	font-family: var(--csw-font-display);
	font-size: 1.5rem;
	font-weight: 800;
	line-height: 1;
	color: var(--csw-teal);
	font-variant-numeric: tabular-nums;
}

.csw-checklist__track {
	height: 10px;
	margin-bottom: 16px;
	background: var(--csw-surface-alt);
	border: 1px solid var(--csw-line);
	border-radius: 999px;
	overflow: hidden;
}

.csw-checklist__fill {
	display: block;
	height: 100%;
	background: var(--csw-teal);
	border-radius: 999px;
	transform-origin: left center;
	transform: scaleX(var(--csw-pct, 0));
}

.is-complete .csw-checklist__fill,
.is-complete .csw-checklist__ring,
.is-complete .csw-checklist__mark { --csw-check: var(--csw-green); }
.is-complete .csw-checklist__fill { background: var(--csw-green); }
.is-complete .csw-checklist__pct  { color: var(--csw-green); }

.csw-checklist__list {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.csw-checklist__item {
	display: grid;
	grid-template-columns: 24px 1fr;
	align-items: center;
	column-gap: 12px;
	padding: 8px 12px;
	background: var(--csw-surface-alt);
	border-left: 3px solid var(--csw-line);
	border-radius: 4px;
	color: var(--csw-muted);
	transition: color 0.3s ease, border-color 0.3s ease;
}

.csw-checklist__item.is-done {
	color: var(--csw-ink);
	border-left-color: var(--csw-check, var(--csw-teal));
}

.csw-checklist__note {
	grid-column: 2;
	font-size: 0.78rem;
	color: var(--csw-muted);
}

/* Tick: a grey track ring (box-shadow) under a drawn ring + checkmark.
   pathLength="1" on both paths makes the dash maths length-independent. */
.csw-checklist__tick {
	width: 24px;
	height: 24px;
	border-radius: 50%;
	box-shadow: inset 0 0 0 2px var(--csw-line);
}

.csw-checklist__ring,
.csw-checklist__mark {
	fill: none;
	stroke: var(--csw-check, var(--csw-teal));
	stroke-linecap: round;
	stroke-linejoin: round;
	stroke-dasharray: 1;
	stroke-dashoffset: 1;
}

.csw-checklist__ring { stroke-width: 2; transform: rotate(-90deg); transform-origin: 50% 50%; }
.csw-checklist__mark { stroke-width: 2.6; }

.is-done .csw-checklist__ring,
.is-done .csw-checklist__mark { stroke-dashoffset: 0; }

.csw-checklist__stamp {
	display: inline-block;
	margin: 14px 0 0;
	padding: 4px 14px;
	border: 2px solid var(--csw-green);
	border-radius: 999px;
	color: var(--csw-green);
	font: 800 0.8rem/1.4 var(--csw-font-display);
	letter-spacing: 0.14em;
	text-transform: uppercase;
	transform: rotate(-6deg);
	background: var(--csw-surface);
}

/* ---- Replay states (only while csw-checklist.js runs) ---- */
.is-replaying .csw-checklist__fill {
	transform: scaleX(var(--csw-play, 0));
	transition: transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.is-replaying .csw-checklist__item.is-done:not(.is-on) {
	color: var(--csw-muted);
	border-left-color: var(--csw-line);
}

.is-replaying .csw-checklist__item.is-done:not(.is-on) .csw-checklist__ring,
.is-replaying .csw-checklist__item.is-done:not(.is-on) .csw-checklist__mark {
	stroke-dashoffset: 1;
	transition: none;
}

.is-replaying .is-on .csw-checklist__ring { transition: stroke-dashoffset 0.4s cubic-bezier(0.2, 0.7, 0.2, 1); }
.is-replaying .is-on .csw-checklist__mark { transition: stroke-dashoffset 0.3s 0.2s cubic-bezier(0.2, 0.8, 0.3, 1); }

.is-replaying .csw-checklist__stamp:not(.is-on) { opacity: 0; transform: rotate(-6deg) scale(0.5); }
.is-replaying .csw-checklist__stamp.is-on {
	transition: opacity 0.2s ease, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (prefers-reduced-motion: reduce) {
	.csw-card--consumer,
	.csw-checklist *,
	.csw-checklist__fill {
		transition: none !important;
	}
}

@media (forced-colors: active) {
	.csw-checklist__fill { background: Highlight; }
	.csw-checklist__tick { box-shadow: inset 0 0 0 2px CanvasText; }
	.csw-checklist__ring,
	.csw-checklist__mark { stroke: CanvasText; }
}

@media (max-width: 480px) {
	.csw-checklist { padding: 16px 14px 18px; }
}

/* ============================================================= *
 * Follow-up calendar
 * ============================================================= */
.csw-calendar__nav {
	display: flex;
	gap: 8px;
	margin-top: 12px;
	flex-wrap: wrap;
}

.csw-calendar__weekdays {
	display: grid;
	grid-template-columns: repeat(7, 1fr);
	gap: 6px;
	margin-bottom: 6px;
}

.csw-calendar__weekday {
	font-family: var(--csw-font-display);
	font-size: 0.72rem;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	color: var(--csw-muted);
	text-align: center;
	padding: 4px 0;
}

.csw-calendar__grid {
	display: grid;
	grid-template-columns: repeat(7, 1fr);
	gap: 6px;
}

.csw-calendar__cell {
	background: var(--csw-surface);
	border: 1px solid var(--csw-line);
	border-radius: 4px;
	min-height: 96px;
	padding: 6px;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.csw-calendar__cell--empty {
	background: transparent;
	border: none;
}

.csw-calendar__cell.is-today {
	border-color: var(--csw-teal);
	box-shadow: inset 0 0 0 1px var(--csw-teal);
}

.csw-calendar__daynum {
	font-weight: 700;
	color: var(--csw-navy);
	font-size: 0.82rem;
}

.csw-calendar__cell.has-items .csw-calendar__daynum { color: var(--csw-plum); }

.csw-calendar__items {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.csw-calendar__item {
	border-left: 3px solid var(--csw-teal);
	background: var(--csw-surface-alt);
	border-radius: 3px;
	padding: 3px 6px;
	font-size: 0.74rem;
	line-height: 1.2;
	display: flex;
	flex-direction: column;
}

.csw-calendar__item-title { font-weight: 600; color: var(--csw-navy); }
.csw-calendar__item-sub   { color: var(--csw-muted); }

.csw-calendar__item--teal  { border-left-color: var(--csw-teal); }
.csw-calendar__item--plum  { border-left-color: var(--csw-plum); }
.csw-calendar__item--coral { border-left-color: var(--csw-coral); }
.csw-calendar__item--olive { border-left-color: var(--csw-olive); }

/* ---------- Responsive ---------- */
@media ( max-width: 640px ) {
	.csw-split { grid-template-columns: 1fr; }
	.csw-calendar__cell { min-height: 70px; }
	.csw-calendar__item-sub { display: none; }
}
