.awp-portal {
	--awp-accent: #2271b1;
	--awp-border: #dcdcde;
	--awp-button-bg: #2271b1;
	--awp-button-border: #2271b1;
	--awp-button-hover-bg: #135e96;
	--awp-button-hover-text: #fff;
	--awp-button-radius: var(--awp-radius);
	--awp-button-text: #fff;
	--awp-field-border: #878c91;
	--awp-font: inherit;
	--awp-heading-font: var(--awp-font);
	--awp-muted: #646970;
	--awp-radius: 0.375rem;
	--awp-surface: #fff;
	--awp-surface-alt: #f6f7f7;
	--awp-text: inherit;
	box-sizing: border-box;
	color: var(--awp-text);
	container: awp-portal / inline-size;
	font-family: var(--awp-font);
	margin-inline: auto;
	max-width: 56rem;
	padding-inline: clamp(1rem, 3vw, 1.5rem);
	width: 100%;
}

.awp-portal *,
.awp-portal *::before,
.awp-portal *::after {
	box-sizing: inherit;
}

.awp-portal__header {
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
	justify-content: space-between;
}

.awp-portal__table-wrap {
	background: var(--awp-surface);
	border: 1px solid var(--awp-border);
	border-radius: var(--awp-radius);
	margin: 1.5rem 0;
	min-width: 0;
	overflow-x: auto;
	width: 100%;
}

.awp-portal__table {
	border-collapse: collapse;
	margin: 0;
	table-layout: fixed;
	width: 100%;
}

/* Fixed layout keeps the table inside its card at any width: the columns below
   get a stable share and long text wraps instead of pushing the last column
   out of view. The date column gets a stable share, so the localized date
   wraps onto a second line rather than being cut off at the card edge. The
   class comes from the column key, so the customer column can appear or
   disappear without shifting the rest. */
.awp-portal__col--reference {
	width: 9.5rem;
}

.awp-portal__col--status {
	width: 6.5rem;
}

.awp-portal__col--priority {
	width: 6.5rem;
}

.awp-portal__col--customer {
	width: 8rem;
}

.awp-portal__col--last_update {
	width: 11rem;
}

.awp-portal__table th,
.awp-portal__table td {
	border-bottom: 1px solid var(--awp-border);
	padding: 0.75rem 0.85rem;
	text-align: left;
	vertical-align: top;
}

.awp-portal__table tbody tr:last-child td {
	border-bottom: 0;
}

.awp-portal__table th {
	background: var(--awp-surface-alt);
	font-weight: 600;
}

/* Reference codes are single unbreakable tokens; with fixed columns a very
   long one would spill into the next column. */
.awp-portal__table td code {
	overflow-wrap: anywhere;
}

/* Over the theme's own background a fixed accent cannot guarantee 4.5:1, so the
   link inherits the theme text colour and stays identifiable by its underline.
   Block themes override this with the AA-checked accent in the inline styles. */
.awp-portal a:not(.button) {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 0.15em;
}

/* Inside the surfaces the portal paints, the AA accent is safe. */
.awp-portal .awp-portal__table a,
.awp-portal .awp-portal__message a,
.awp-portal .awp-portal__notice a {
	color: var(--awp-accent);
}

.awp-portal__meta {
	color: inherit;
}

.awp-portal__thread {
	display: grid;
	gap: 1rem;
	margin: 1.5rem 0;
}

.awp-portal__message {
	background: var(--awp-surface);
	border: 1px solid var(--awp-border);
	border-radius: var(--awp-radius);
	padding: 1rem;
}

.awp-portal__message--customer {
	background: var(--awp-surface-alt);
}

.awp-portal__message header {
	color: var(--awp-muted);
	font-size: 0.875rem;
	margin-bottom: 0.5rem;
}

.awp-portal__body {
	overflow-wrap: anywhere;
}

.awp-portal__form {
	display: grid;
	gap: 0.9rem;
	margin: 1.5rem 0;
}

.awp-portal__form label {
	display: block;
	font-weight: 600;
	margin-bottom: 0.35rem;
}

.awp-portal__form input[type="text"],
.awp-portal__form input[type="email"],
.awp-portal__form input[type="number"],
.awp-portal__form input[type="password"],
.awp-portal__form input[type="search"],
.awp-portal__form input[type="tel"],
.awp-portal__form input[type="url"],
.awp-portal__form select,
.awp-portal__form textarea {
	background: var(--awp-surface);
	border: 1px solid var(--awp-field-border);
	border-radius: var(--awp-radius);
	color: var(--awp-text);
	font: inherit;
	line-height: 1.5;
	max-width: 100%;
	padding: 0.55rem 0.7rem;
	width: 100%;
}

.awp-portal__form select:focus,
.awp-portal__form textarea:focus,
.awp-portal__form input:focus {
	border-color: var(--awp-accent);
}

.awp-portal__form input[type="file"] {
	font: inherit;
	max-width: 100%;
	min-width: 0;
	width: 100%;
}

.awp-portal__form input[type="file"]::file-selector-button {
	background: var(--awp-surface-alt);
	border: 1px solid var(--awp-field-border);
	border-radius: var(--awp-radius);
	color: var(--awp-text);
	cursor: pointer;
	font: inherit;
	margin-right: 0.75rem;
	padding: 0.4rem 0.8rem;
}

/* Ticket filters: a plain GET form. The fieldset groups the controls so the
   legend names the whole widget, and the auto-fit grid folds to one column on
   narrow containers without a media query. */
.awp-portal__filters fieldset {
	border: 1px solid var(--awp-border);
	border-radius: var(--awp-radius);
	margin: 0;
	min-width: 0;
	padding: 0.9rem 1rem;
}

.awp-portal__filters legend {
	font-weight: 600;
	padding-inline: 0.35rem;
}

.awp-portal__filters fieldset > p {
	display: grid;
	gap: 0.9rem;
	grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
	margin: 0.6rem 0 0;
}

.awp-portal__summary {
	color: var(--awp-muted);
	margin: 0.5rem 0 0;
}

/* Shape and rhythm are shared; colors come from the theme when it exposes
   button styles, and from the AA palette in classic themes. */
.awp-portal .button,
.awp-portal button[type="submit"] {
	border-radius: var(--awp-button-radius);
	cursor: pointer;
	display: inline-block;
	font: inherit;
	font-size: var(--awp-button-font-size, 1rem);
	font-weight: var(--awp-button-font-weight, 600);
	line-height: 1.4;
	padding: var(--awp-button-padding, 0.6rem 1.1rem);
	text-align: center;
	text-decoration: none;
	transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.awp-portal .button {
	background: var(--awp-button-bg);
	border: 1px solid var(--awp-button-border);
	color: var(--awp-button-text);
}

.awp-portal .button:hover {
	background: var(--awp-button-hover-bg);
	border-color: var(--awp-button-hover-bg);
	color: var(--awp-button-hover-text);
}

.awp-portal .button:active,
.awp-portal button[type="submit"]:active {
	filter: brightness(0.94);
}

.awp-portal__attachments {
	margin: 0.5rem 0 0;
	padding-left: 1.25rem;
}

.awp-portal__notice {
	background: var(--awp-surface-alt);
	border-left: 4px solid var(--awp-accent);
	border-radius: var(--awp-radius);
	margin: 1rem 0;
	padding: 0.75rem 1rem;
}

.awp-portal__notice--error {
	border-left-color: #d63638;
}

.awp-portal__pagination {
	align-items: center;
	display: flex;
	gap: 0.75rem;
	margin: 1rem 0;
}

/* The active theme provides focus styles, but the portal must stay usable in
   classic themes that remove them. The outline uses the accent token, which
   passes AA on both surfaces. */
.awp-portal :focus-visible {
	outline: 2px solid var(--awp-accent);
	outline-offset: 2px;
}

@container awp-portal (max-width: 48rem) {
	.awp-portal__header {
		align-items: flex-start;
	}

	/* Five columns do not fit a phone: each row becomes a labelled block so
	   nothing is clipped and the table never needs sideways scrolling. */
	.awp-portal__table-wrap {
		overflow: visible;
	}

	.awp-portal__table,
	.awp-portal__table tbody,
	.awp-portal__table tr,
	.awp-portal__table td {
		display: block;
		width: 100%;
	}

	.awp-portal__table thead {
		border: 0;
		clip-path: inset(50%);
		height: 1px;
		overflow: hidden;
		position: absolute;
		white-space: nowrap;
		width: 1px;
	}

	.awp-portal__table tr {
		border-bottom: 1px solid var(--awp-border);
		padding: 0.85rem;
	}

	.awp-portal__table tbody tr:last-child {
		border-bottom: 0;
	}

	.awp-portal__table td {
		border: 0;
		display: grid;
		gap: 0.15rem 0.75rem;
		grid-template-columns: minmax(6.5rem, 38%) minmax(0, 1fr);
		overflow-wrap: break-word;
		padding: 0.2rem 0;
	}

	.awp-portal__table td::before {
		color: var(--awp-muted);
		content: attr(data-label);
		font-weight: 600;
	}

	.awp-portal__table td:first-child code {
		font-weight: 600;
	}
}

@media (prefers-reduced-motion: reduce) {
	.awp-portal .button,
	.awp-portal button[type="submit"] {
		transition: none;
	}
}
