/*
 * Helpdesk styles.
 * The tokens and base components are those of apps/supplier-portal, so both
 * tools are one family. Every colour, size, radius and shadow comes from the
 * tokens below (docs/ontwerp-en-bouwregels.md, sections 4 to 7); components
 * never use raw values. Light is the default; dark only when chosen in the
 * account menu, directly or as "Same as device".
 */

:root {
  color-scheme: light;

  /* Surfaces */
  --bg: #f1f1f1;
  --surface: #ffffff;
  --surface-2: #f5f5f5;
  --elevated: #ffffff;
  --scrim: rgba(17, 17, 17, 0.45);

  /* Borders: --border-strong is for inputs and controls (3:1 on white) */
  --border: #e1e1e1;
  --border-strong: #8a8a8a;

  /* Text */
  --text-primary: #1a1a1a;
  --text-secondary: #4a4a4a;
  --text-muted: #5f5f5f;
  --text-on-accent: #ffffff;

  /* Accent: the logo's dark grey */
  --accent: #1a1a1a;
  --accent-solid: #262626;
  --accent-hover: #0d0d0d;

  /* Status: -text for words, -solid for filled shapes, -tint for pill backgrounds */
  --success-text: #0b5d34;
  --success-solid: #12804a;
  --success-tint: #dcf2e5;
  --warning-text: #6b4a00;
  --warning-solid: #a87400;
  --warning-tint: #fff0c4;
  --danger-text: #8c1d0e;
  --danger-solid: #c4290f;
  --danger-tint: #fde6e2;
  --info-text: #0a4a86;
  --info-solid: #1c62b3;
  --info-tint: #e1edfc;
  --on-info-solid: #ffffff;
  --progress-text: #8f3a00;
  --progress-tint: #ffe2cc;

  --focus-ring: #1c62b3;

  /* Shopify in its own green, as in apps/supplier-portal */
  --shopify-text: #00634b;
  --shopify-tint: #dff2ea;

  /* Spacing: multiples of 4 only */
  --space-1: 0.25rem; /* 4 */
  --space-2: 0.5rem; /* 8 */
  --space-3: 0.75rem; /* 12 */
  --space-4: 1rem; /* 16 */
  --space-6: 1.5rem; /* 24 */
  --space-8: 2rem; /* 32 */
  --space-12: 3rem; /* 48 */

  /* Type scale (1.2x steps) */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --text-xs: 0.75rem; /* 12 / 16 */
  --text-sm: 0.875rem; /* 14 / 20 */
  --text-md: 1rem; /* 16 / 24 */
  --text-lg: 1.125rem; /* 18 / 28 */
  --text-xl: 1.25rem; /* 20 / 28 */
  --text-2xl: 1.5rem; /* 24 / 32 */
  --text-3xl: 1.875rem; /* 30 / 36 */

  /* Shape */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-full: 999px;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.07);
  --shadow-popup: 0 4px 12px rgba(0, 0, 0, 0.12);
  --shadow-dialog: 0 12px 32px rgba(0, 0, 0, 0.18);

  /* Sizes */
  --topbar-height: 3.5rem; /* 56 */
  --sidebar-width: 14.5rem; /* 232 */
  --control-height: 2.5rem; /* 40 */
  --content-max: 75rem; /* 1200 */

  /* Stacking order, bottom to top */
  --z-dropdown: 10;
  --z-topbar: 20;
  --z-sidebar: 30;
  --z-dialog: 40;
  --z-toast: 50;
  --z-tooltip: 60;

  --duration-fast: 150ms;
  --duration-panel: 250ms;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    color-scheme: dark;
    --bg: #161616;
    --surface: #1f1f1f;
    --surface-2: #2a2a2a;
    --elevated: #2f2f2f;
    --scrim: rgba(0, 0, 0, 0.6);
    --border: #353535;
    --border-strong: #7a7a7a;
    --text-primary: #e8eaed;
    --text-secondary: #c4c4c4;
    --text-muted: #a3a3a3;
    --text-on-accent: #161616;
    --accent: #e8eaed;
    --accent-solid: #e8eaed;
    --accent-hover: #ffffff;
    --success-text: #7dd8a3;
    --success-solid: #3fa96c;
    --success-tint: rgba(63, 169, 108, 0.18);
    --warning-text: #f2cd6b;
    --warning-solid: #c99a1e;
    --warning-tint: rgba(201, 154, 30, 0.2);
    --danger-text: #ff9c8a;
    --danger-solid: #e0533a;
    --danger-tint: rgba(224, 83, 58, 0.2);
    --info-text: #9cc6f7;
    --info-solid: #4a8ad6;
    --info-tint: rgba(74, 138, 214, 0.2);
    --on-info-solid: #161616;
    --progress-text: #ffb27a;
    --progress-tint: rgba(232, 120, 40, 0.22);
    --focus-ring: #7fb3f2;
    --shopify-text: #7fd8b8;
    --shopify-tint: rgba(0, 128, 96, 0.24);
    --shadow-card: none;
    --shadow-popup: none;
    --shadow-dialog: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #161616;
  --surface: #1f1f1f;
  --surface-2: #2a2a2a;
  --elevated: #2f2f2f;
  --scrim: rgba(0, 0, 0, 0.6);
  --border: #353535;
  --border-strong: #7a7a7a;
  --text-primary: #e8eaed;
  --text-secondary: #c4c4c4;
  --text-muted: #a3a3a3;
  --text-on-accent: #161616;
  --accent: #e8eaed;
  --accent-solid: #e8eaed;
  --accent-hover: #ffffff;
  --success-text: #7dd8a3;
  --success-solid: #3fa96c;
  --success-tint: rgba(63, 169, 108, 0.18);
  --warning-text: #f2cd6b;
  --warning-solid: #c99a1e;
  --warning-tint: rgba(201, 154, 30, 0.2);
  --danger-text: #ff9c8a;
  --danger-solid: #e0533a;
  --danger-tint: rgba(224, 83, 58, 0.2);
  --info-text: #9cc6f7;
  --info-solid: #4a8ad6;
  --info-tint: rgba(74, 138, 214, 0.2);
  --on-info-solid: #161616;
  --progress-text: #ffb27a;
  --progress-tint: rgba(232, 120, 40, 0.22);
  --focus-ring: #7fb3f2;
  --shopify-text: #7fd8b8;
  --shopify-tint: rgba(0, 128, 96, 0.24);
  --shadow-card: none;
  --shadow-popup: none;
  --shadow-dialog: none;
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: 1.4286; /* 20px on 14px */
  min-height: 100dvh;
}

h1,
h2,
h3 {
  margin: 0;
  color: var(--text-primary);
  font-weight: 600;
  text-wrap: balance;
}

h1 {
  font-size: var(--text-xl);
  line-height: 1.4;
  letter-spacing: -0.01em;
}

h2,
h3 {
  font-size: var(--text-sm);
  line-height: 1.4286;
}

p {
  margin: 0;
  text-wrap: pretty;
}

a {
  color: var(--accent);
  text-underline-offset: 2px;
}

img {
  display: block;
  max-width: 100%;
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -100px;
  z-index: var(--z-tooltip);
  padding: var(--space-2) var(--space-4);
  background: var(--elevated);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popup);
}

.skip-link:focus {
  top: var(--space-2);
}

.icon {
  width: 1.25rem;
  height: 1.25rem;
  flex: none;
}

.icon-sm {
  width: 1rem;
  height: 1rem;
  flex: none;
}

.num {
  font-variant-numeric: tabular-nums;
}

.mono {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.muted {
  color: var(--text-muted);
}

.secondary {
  color: var(--text-secondary);
}

.small {
  font-size: var(--text-xs);
  line-height: 1.3333;
}

.nowrap {
  white-space: nowrap;
}

/* ---------- App shell ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: var(--topbar-height);
  padding: 0 var(--space-4);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  text-decoration: none;
  color: var(--text-secondary);
}

/* The logo PNG has a white background; on the dark theme it sits on its own
   white plate instead of being recoloured (house rule: never alter the logo). */
.topbar__logo {
  flex: none;
  height: 2rem;
  width: auto;
  border-radius: var(--radius-sm);
}

.topbar__product {
  font-weight: 500;
  white-space: nowrap;
}

.topbar__end {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.demo-label {
  display: inline-flex;
  align-items: center;
  height: 1.5rem;
  padding: 0 var(--space-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 500;
}

.viewing-as-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-2) var(--space-4);
  background: var(--warning-tint);
  color: var(--warning-text);
  border-bottom: 1px solid var(--border);
}

.viewing-as-bar p {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 500;
}

.layout {
  display: flex;
  min-height: calc(100dvh - var(--topbar-height));
}

/* The menu stays in place while the page scrolls (owner, 23 October). */
.sidebar {
  position: sticky;
  top: var(--topbar-height);
  align-self: flex-start;
  flex: none;
  width: var(--sidebar-width);
  height: calc(100dvh - var(--topbar-height));
  overflow-y: auto;
  padding: var(--space-3);
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav__link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 2.25rem;
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 500;
  text-decoration: none;
}

.nav__link:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

.nav__link[aria-current="page"] {
  background: var(--surface-2);
  color: var(--text-primary);
  font-weight: 600;
}

.main {
  flex: 1;
  min-width: 0;
  padding: var(--space-6) var(--space-8) var(--space-12);
}

.container {
  max-width: var(--content-max);
  margin: 0 auto;
}

/* Narrow pages keep the same left edge as every other page. */
.container--narrow > * {
  max-width: 40rem;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
}

.page-header__title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.page-header__meta {
  margin-top: var(--space-1);
  color: var(--text-secondary);
}

.page-header__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

/* A button wrapped in its own form still lines up with the other actions. */
.page-header__actions > form {
  display: contents;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 2rem;
  margin-bottom: var(--space-1);
  color: var(--text-secondary);
  font-weight: 500;
  text-decoration: none;
}

.back-link:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

.stack > * + * {
  margin-top: var(--space-4);
}

.stack-sm > * + * {
  margin-top: var(--space-2);
}

.section-gap {
  margin-top: var(--space-4);
}

.layout-2col {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: var(--space-4);
  align-items: start;
}

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}

.card__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-3);
  min-height: 3.25rem;
  padding: var(--space-3) var(--space-4);
}

.card__heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.card__section {
  padding: var(--space-4);
}

.card__header + .card__section {
  padding-top: 0;
}

.card__section + .card__section,
.card__header + .card__section--ruled,
.card__footer {
  border-top: 1px solid var(--border);
}

.card__header + .card__section--ruled {
  padding-top: var(--space-4);
}

.card__footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
}

/* A small heading inside a card section ("Shipping address") */
.label-heading {
  margin-bottom: var(--space-1);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.3333;
}

.address {
  font-style: normal;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.link-list > * + * {
  margin-top: var(--space-1);
}

.link-list a {
  overflow-wrap: anywhere;
}

/* Key and value rows with a line between them (supplier details, order details) */
.kv {
  margin: 0;
}

/* Label left, value right; a long label wraps instead of pushing the value down. */
.kv__row {
  display: grid;
  grid-template-columns: minmax(6rem, 1fr) minmax(0, max-content);
  align-items: baseline;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--border);
}

.kv__row--stacked {
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-2);
}

.kv .kv__row--stacked dd {
  margin: 0;
  text-align: left;
}

.kv__row:first-child {
  border-top: 0;
  padding-top: 0;
}

.kv__row:last-child {
  padding-bottom: 0;
}

.kv dt {
  color: var(--text-secondary);
}

.kv dd {
  margin: 0 0 0 auto;
  text-align: right;
  overflow-wrap: anywhere;
}


/* Order timeline: the shop's events and the portal's own, newest first */
.timeline {
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline__item {
  position: relative;
  display: grid;
  grid-template-columns: 1rem minmax(0, 1fr) auto;
  gap: var(--space-3);
  padding-bottom: var(--space-4);
}

.timeline__item::before {
  content: "";
  position: absolute;
  left: calc(0.5rem - 1px);
  top: 1rem;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline__item:last-child {
  padding-bottom: 0;
}

.timeline__item:last-child::before {
  display: none;
}

.timeline__dot {
  width: 0.625rem;
  height: 0.625rem;
  margin: 0.3125rem 0 0 0.1875rem;
  border-radius: var(--radius-full);
  background: var(--border-strong);
}

.timeline__body p + p {
  margin-top: 2px;
}


/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 2.25rem;
  padding: 0 var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font: inherit;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--duration-fast) ease-out, border-color var(--duration-fast) ease-out;
}

.btn--primary {
  background: var(--accent-solid);
  color: var(--text-on-accent);
}

.btn--primary:hover {
  background: var(--accent-hover);
}

.btn--secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn--secondary:hover {
  background: var(--surface-2);
}

.btn--tertiary {
  background: transparent;
  color: var(--text-primary);
  padding: 0 var(--space-2);
}

.btn--tertiary:hover {
  background: var(--surface-2);
}

.btn--danger {
  background: var(--danger-solid);
  color: #ffffff;
}

.btn--danger:hover {
  background: var(--danger-text);
}

.btn--icon {
  width: 2.25rem;
  padding: 0;
}

.btn--small {
  height: 2rem;
  padding: 0 var(--space-3);
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.is-loading {
  pointer-events: none;
}

.btn .spinner {
  display: none;
}

.btn.is-loading .spinner {
  display: inline-block;
}

.btn.is-loading .btn__icon {
  display: none;
}

.spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: var(--radius-full);
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* ---------- Forms ---------- */

.field + .field {
  margin-top: var(--space-4);
}

.label {
  display: block;
  margin-bottom: var(--space-1);
  font-weight: 500;
}

.hint {
  margin-top: var(--space-1);
  color: var(--text-muted);
  font-size: var(--text-xs);
  line-height: 1.3333;
}

.input,
.select {
  width: 100%;
  height: 2.25rem;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-primary);
  font: inherit;
}

.select {
  appearance: none;
  padding-right: var(--space-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a8a8a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
}

.input--mono {
  font-family: var(--font-mono);
}

.input--narrow {
  width: 6rem;
}

.input--file {
  height: auto;
  padding: var(--space-1) var(--space-2);
}

/* A small form on one line: fields side by side, the button at the end. */
.card__section--row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
}

.card__section--row .field {
  flex: 1 1 12rem;
  margin: 0;
}

.input--tracking {
  min-width: 14rem;
}

.input[aria-invalid="true"] {
  border-color: var(--danger-solid);
}

.field-error {
  display: flex;
  align-items: flex-start;
  gap: var(--space-1);
  margin-top: var(--space-1);
  color: var(--danger-text);
  font-size: var(--text-xs);
  line-height: 1.3333;
}

.field-intro {
  margin-bottom: var(--space-4);
}

.checkbox {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--accent-solid);
  cursor: pointer;
}

.check-target {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  cursor: pointer;
}

.toggle {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  cursor: pointer;
}

.toggle .checkbox {
  margin-top: 2px;
}

.toggle__text strong {
  display: block;
  font-weight: 500;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-6);
}

.form-error {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3);
  margin-bottom: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--danger-tint);
  color: var(--danger-text);
}

/* ---------- Status badges, channel tags and plain tags ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: 1.375rem;
  padding: 0 var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 0.375rem;
  height: 0.375rem;
  border-radius: var(--radius-full);
  background: currentColor;
}


/* A pill with an icon has no dot. */
.pill--icon::before {
  content: none;
}

.pill--icon svg {
  width: 0.875rem;
  height: 0.875rem;
}

.pill--warning {
  background: var(--warning-tint);
  color: var(--warning-text);
}

.pill--neutral {
  background: var(--surface-2);
  color: var(--text-secondary);
  box-shadow: inset 0 0 0 1px var(--border);
}

.pill--success {
  background: var(--success-tint);
  color: var(--success-text);
}

.pill--info {
  background: var(--info-tint);
  color: var(--info-text);
}

.pill--danger {
  background: var(--danger-tint);
  color: var(--danger-text);
}

.channel {
  display: inline-flex;
  align-items: center;
  height: 1.375rem;
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.channel--shopify {
  background: var(--shopify-tint);
  color: var(--shopify-text);
}

.channel--bol {
  background: var(--info-tint);
  color: var(--info-text);
}

.channel--email {
  background: var(--surface-2);
  color: var(--text-secondary);
  box-shadow: inset 0 0 0 1px var(--border);
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 1.375rem;
  padding: 0 var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 500;
  white-space: nowrap;
}


/* ---------- Inline notices (next to the thing they are about) ---------- */

.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-weight: 500;
}

.notice--danger {
  background: var(--danger-tint);
  color: var(--danger-text);
}

.notice--warning {
  background: var(--warning-tint);
  color: var(--warning-text);
}

.notice--info {
  background: var(--info-tint);
  color: var(--info-text);
}

.notice--neutral {
  background: var(--surface-2);
  color: var(--text-secondary);
  font-weight: 400;
}

/* A notice with its fix next to it, such as "Fix address". */
.notice--action {
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.notice--action > span {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--space-2);
  flex: 1 1 16rem;
}

.notice .icon-sm {
  margin-top: 2px;
}

/* ---------- Tabs and segmented control ---------- */

.tabs {
  display: flex;
  gap: var(--space-1);
  margin: 0;
  padding: 0 var(--space-3);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs__tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 2.75rem;
  padding: 0 var(--space-2);
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.tabs__tab:hover {
  color: var(--text-primary);
}

.tabs__tab[aria-selected="true"] {
  border-bottom-color: var(--accent-solid);
  color: var(--text-primary);
  font-weight: 600;
}

.count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 var(--space-1);
  border-radius: var(--radius-full);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.segmented {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.segmented__option {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: 1.75rem;
  padding: 0 var(--space-3);
  border-radius: 6px;
  color: var(--text-secondary);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.segmented__option[aria-current="true"] {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-card);
  font-weight: 600;
}

/* ---------- Data tables ---------- */

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  height: 2.25rem;
  padding: 0 var(--space-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}

.data-table td {
  padding: var(--space-2) var(--space-3);
  height: 3rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.card > .data-table:first-child thead tr:first-child th:first-child {
  border-top-left-radius: calc(var(--radius-md) - 1px);
}

.card > .data-table:first-child thead tr:first-child th:last-child {
  border-top-right-radius: calc(var(--radius-md) - 1px);
}

.data-table tr[data-href] {
  cursor: pointer;
}

.data-table tr[data-href]:hover td {
  background: var(--surface-2);
}

.data-table .col-check {
  width: 2.75rem;
  padding: 0 0 0 var(--space-2);
}

.data-table .col-menu {
  width: 3rem;
  padding: 0 var(--space-2) 0 0;
  text-align: right;
}

.data-table .col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table .col-status {
  text-align: center;
}

.data-table .col-thumb {
  width: 3.5rem;
  padding-right: 0;
}

.cell-title {
  color: var(--text-primary);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.cell-title:hover {
  text-decoration: underline;
}


/* Less important columns step aside on smaller laptops; the order page shows everything. */
@media (max-width: 1279px) {
  .data-table .hide-lg-cell {
    display: none;
  }

  .data-table th,
  .data-table td {
    padding-left: var(--space-2);
    padding-right: var(--space-2);
  }
}

@media (max-width: 1099px) {
  .data-table .hide-md-cell {
    display: none;
  }
}

/* Bulk actions take the place of the column headings while orders are selected. */
.thead-bulk {
  display: none;
}

.is-selecting .thead-default {
  display: none;
}

.is-selecting .thead-bulk {
  display: table-row;
}

.bulk-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.bulk-bar__count {
  color: var(--text-primary);
  font-weight: 600;
  font-size: var(--text-sm);
  margin-right: auto;
}

.thead-bulk th {
  padding-top: var(--space-1);
  padding-bottom: var(--space-1);
}

.only-mobile-cell {
  display: none;
}


/* ---------- Menus (details/summary) ---------- */

.menu {
  position: relative;
  display: inline-block;
}

.menu > summary {
  list-style: none;
}

.menu > summary::-webkit-details-marker {
  display: none;
}

.menu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + var(--space-1));
  z-index: var(--z-dropdown);
  min-width: 13rem;
  padding: var(--space-1);
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popup);
  text-align: left;
}

.menu__label {
  padding: var(--space-2) var(--space-3) var(--space-1);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 500;
  white-space: normal;
}

.menu__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 2.25rem;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-weight: 400;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.menu__item:hover {
  background: var(--surface-2);
}

.menu__item[aria-current="true"] {
  font-weight: 600;
}

.menu__item[aria-disabled="true"] {
  color: var(--text-muted);
  cursor: not-allowed;
}

.menu__item .check {
  margin-left: auto;
}

.menu__divider {
  height: 1px;
  margin: var(--space-1) 0;
  background: var(--border);
}

.menu__button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 2.25rem;
  padding: 0 var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.menu__button:hover {
  background: var(--surface-2);
}

.menu__button--outlined {
  border-color: var(--border-strong);
}

.menu form {
  margin: 0;
}

/* ---------- Dialogs ---------- */

.dialog {
  width: min(32rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-dialog);
}

.dialog::backdrop {
  background: var(--scrim);
}

/* A photo from a mail, over the ticket */
.lightbox {
  width: min(72rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: var(--space-4) var(--space-12);
  border: 0;
  border-radius: var(--radius-md);
  background: var(--elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-dialog);
}

.lightbox::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.lightbox__figure {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  margin: 0;
}

.lightbox__img {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 8rem);
  object-fit: contain;
}

.lightbox__close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
}

.lightbox__step {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox__step--prev {
  left: var(--space-2);
}

.lightbox__step--next {
  right: var(--space-2);
}

.dialog[open] {
  display: flex;
  flex-direction: column;
  animation: dialog-in var(--duration-panel) ease-out;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.dialog__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-6);
  border-bottom: 1px solid var(--border);
}

.dialog__header h2 {
  font-size: var(--text-md);
  line-height: 1.5;
}

.dialog__body {
  padding: var(--space-4) var(--space-6);
  overflow-y: auto;
}

.dialog__footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border-top: 1px solid var(--border);
}

.dialog form {
  display: contents;
}

.dialog__body > .field + .notice {
  margin-top: var(--space-4);
}

/* ---------- Toast ---------- */

.toast-region {
  position: fixed;
  left: 50%;
  bottom: var(--space-6);
  z-index: var(--z-toast);
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 2rem);
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--accent-solid);
  color: var(--text-on-accent);
  box-shadow: var(--shadow-popup);
  animation: toast-in var(--duration-panel) ease-out;
}

.toast p + p {
  margin-top: var(--space-1);
  opacity: 0.85;
}

.toast[hidden] {
  display: none;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ---------- Empty states ---------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-12) var(--space-4);
  text-align: center;
}

.empty .icon {
  width: 1.5rem;
  height: 1.5rem;
  color: var(--text-muted);
}

.empty h2 {
  font-size: var(--text-md);
  line-height: 1.5;
}

.empty p {
  max-width: 28rem;
  color: var(--text-secondary);
}

.empty .btn {
  margin-top: var(--space-2);
}

/* ---------- Login ---------- */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: var(--space-4);
}

.login-card {
  width: min(25rem, 100%);
  padding: var(--space-8) var(--space-6);
}

.login-card__logo {
  height: 2.5rem;
  width: auto;
  margin-bottom: var(--space-6);
}

.login-card h1 {
  margin-bottom: var(--space-6);
}

/* ---------- Filters and search ---------- */

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.search {
  position: relative;
  width: min(20rem, 100%);
}

.search .icon-sm {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search .input {
  padding-left: var(--space-8);
}

.filters {
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.filters__row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: var(--space-3);
  align-items: end;
}

.filters .field + .field {
  margin-top: 0;
}

.filters__actions {
  display: flex;
  gap: var(--space-2);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
}


/* ---------- Helpdesk: shell additions ---------- */

.topbar__search {
  width: min(22rem, 100%);
  margin-left: var(--space-4);
}

.topbar__search .input {
  height: 2.25rem;
  background: var(--surface-2);
  border-color: var(--border);
}

.nav__link .count {
  margin-left: auto;
}

.count--strong {
  background: var(--info-solid);
  color: var(--on-info-solid);
}

.page-header__main {
  min-width: 0;
}

.page-header__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.section-gap-bottom {
  margin-bottom: var(--space-4);
}

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

.tag-row {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
}

.channel--email {
  font-weight: 500;
}

.textarea {
  display: block;
  width: 100%;
  min-height: 5rem;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-primary);
  font: inherit;
  line-height: 1.5;
  resize: vertical;
}

.toast {
  align-items: center;
}

.toast__action {
  margin-left: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border: 1px solid currentColor;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.toast form {
  margin: 0;
}

/* ---------- Statuses and filter reasons: one colour each, everywhere ---------- */

.pill--status-new {
  background: var(--info-tint);
  color: var(--info-text);
}

.pill--status-open {
  background: var(--warning-tint);
  color: var(--warning-text);
}

/* In progress: orange, so it is not mistaken for Open (owner, 23 October). */
.pill--status-in_progress {
  background: var(--progress-tint);
  color: var(--progress-text);
}

/* Resolved: green, as in Zoho; done is the one status that is good news. */
.pill--status-closed {
  background: var(--success-tint);
  color: var(--success-text);
}

.pill--status-waiting_customer,
.pill--status-waiting_supplier,
.pill--reason-notification,
.pill--reason-bol_order,
.pill--reason-blocked,
.pill--reason-supplier,
.pill--reason-vendor,
.pill--reason-deleted {
  background: var(--surface-2);
  color: var(--text-secondary);
  box-shadow: inset 0 0 0 1px var(--border);
}

.pill--reason-spam {
  background: var(--danger-tint);
  color: var(--danger-text);
}

/* Unread: a blue dot and bold text (the dot is never the only sign). */
.unread-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: var(--radius-full);
  background: var(--info-solid);
}

.unread-dot--read {
  background: transparent;
}

.unread-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--info-text);
  font-size: var(--text-xs);
  font-weight: 600;
}

/* ---------- Ticket list ---------- */

/* Kinds of question as tabs, the status filter at the end of the same bar. */
.list-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-right: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.list-bar .tabs {
  flex: 1;
  min-width: 0;
  border-bottom: 0;
}

.list-bar__filter {
  flex: none;
}

.list-bar__filter .menu__item .pill {
  pointer-events: none;
}


.ticket-table .col-dot {
  width: 1.5rem;
  padding-left: 0;
  padding-right: 0;
  text-align: center;
}

.ticket-table .col-customer,
.filtered-table .col-customer {
  width: 15rem;
  max-width: 15rem;
}

.cell-customer {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.is-unread .cell-customer,
.is-unread .ticket-line__subject {
  font-weight: 700;
}

.ticket-table .col-tags {
  width: 1%;
  white-space: nowrap;
}

.ticket-table .col-tags .tag-row {
  flex-wrap: nowrap;
}

.ticket-table .col-status,
.filtered-table .col-reason {
  width: 1%;
  white-space: nowrap;
  text-align: left;
}

.ticket-table .col-when,
.filtered-table .col-when {
  width: 1%;
  text-align: left;
}

.ticket-table .col-action {
  width: 1%;
  padding-left: 0;
  text-align: right;
}

.ticket-table .col-action .menu__panel {
  text-align: left;
}

.filtered-table .col-action {
  width: 1%;
  text-align: right;
}

.filtered-table .col-action form {
  margin: 0;
}

/* Subject and the start of the text on one line, as in a mail app. */
.ticket-line {
  display: block;
  max-width: 40rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-line__subject {
  color: var(--text-primary);
  font-weight: 500;
}

.ticket-line__snippet {
  color: var(--text-secondary);
}

.ticket-line__snippet::before {
  content: " · ";
}

.data-table td.col-subject {
  max-width: 0;
  width: 100%;
}

/* ---------- Ticket page: list, conversation, customer ---------- */

.ticket-view {
  display: grid;
  grid-template-columns: 17rem minmax(0, 1fr) 18rem;
  gap: var(--space-4);
  align-items: start;
}

.ticket-view--no-pane {
  grid-template-columns: minmax(0, 1fr) 18rem;
}

.ticket-pane {
  position: sticky;
  top: calc(var(--topbar-height) + var(--space-4));
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - var(--topbar-height) - var(--space-8));
  overflow: hidden;
}

.ticket-pane__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 2.75rem;
  padding: 0 var(--space-3);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-weight: 600;
  text-decoration: none;
}

.ticket-pane__head:hover {
  background: var(--surface-2);
}

.pane-list {
  flex: 1;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.pane-list__empty {
  padding: var(--space-4);
}

.pane-item {
  display: grid;
  gap: 2px;
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-2);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  text-decoration: none;
}

.pane-item:hover {
  background: var(--surface-2);
}

.pane-item[aria-current="page"] {
  background: var(--surface-2);
  box-shadow: inset 2px 0 0 var(--accent-solid);
}

.pane-item__top {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.pane-item__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.pane-item__when {
  flex: none;
  color: var(--text-secondary);
  font-size: var(--text-xs);
}

.pane-item__subject {
  padding-left: calc(0.5rem + var(--space-2));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
}

.pane-item.is-unread .pane-item__name,
.pane-item.is-unread .pane-item__subject {
  color: var(--text-primary);
  font-weight: 700;
}

.pane-item__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  padding-left: calc(0.5rem + var(--space-2));
}

.ticket-center {
  min-width: 0;
}

.hide-with-pane {
  display: none;
}

.ticket-side {
  min-width: 0;
}


.ticket-main {
  min-width: 0;
}

.tab-panel[hidden] {
  display: none;
}

.conversation {
  margin: 0;
  padding: 0;
  list-style: none;
}

.message {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.message--ours {
  background: var(--surface-2);
}

.message__header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: var(--space-3);
  align-items: start;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 600;
}

.avatar--ours {
  background: var(--accent-solid);
  box-shadow: none;
  color: var(--text-on-accent);
}

.message__from {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--space-2);
  overflow-wrap: anywhere;
}

.message__from strong {
  font-weight: 600;
}

.message__to {
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.message__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}



.message__body {
  margin: var(--space-3) 0 0 calc(2rem + var(--space-3));
  max-width: 45rem;
}

/* Mail content keeps its own structure but never our page's layout. */
.mail-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.mail-html {
  overflow-wrap: anywhere;
  line-height: 1.5;
  overflow-x: auto;
}

.mail-html p,
.mail-html ul,
.mail-html ol,
.mail-html blockquote,
.mail-html pre {
  margin: 0 0 var(--space-2);
}

.mail-html h1,
.mail-html h2,
.mail-html h3,
.mail-html h4 {
  margin: 0 0 var(--space-2);
  font-size: var(--text-md);
}

.mail-html img {
  display: inline-block;
  max-width: 100%;
  height: auto;
}

.mail-html table {
  max-width: 100%;
  border-collapse: collapse;
}

.mail-html td,
.mail-html th {
  padding: 2px var(--space-1);
  vertical-align: top;
  text-align: left;
}

.mail-html blockquote {
  padding-left: var(--space-3);
  border-left: 2px solid var(--border);
  color: var(--text-secondary);
}


.quoted {
  margin-top: var(--space-2);
}

.quoted > summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 1.25rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--text-secondary);
  font-weight: 700;
  line-height: 1;
  list-style: none;
  cursor: pointer;
}

.quoted > summary::-webkit-details-marker {
  display: none;
}

.quoted[open] > summary {
  margin-bottom: var(--space-2);
}

.quoted > .mail-html,
.quoted > .mail-text {
  color: var(--text-secondary);
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-3) 0 0 calc(2rem + var(--space-3));
}

.attachments__photos {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  width: 100%;
}

.photo {
  display: block;
  cursor: zoom-in;
  width: 7.5rem;
  height: 7.5rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

/* An image from the mail inside its text: a photo stays a reasonable size and opens larger on a click. */
.mail-html img[src^="/attachments/"] {
  max-width: 100%;
  max-height: 16rem;
  width: auto;
  height: auto;
  cursor: zoom-in;
}

/* While the photo comes in from Private Mail (a large one takes seconds). */
.mail-html img[src^="/attachments/"]:not(.is-loaded) {
  display: inline-block;
  min-width: 7.5rem;
  min-height: 7.5rem;
  border-radius: var(--radius-md);
}

.mail-html img[src^="/attachments/"]:not(.is-loaded),
.photo:not(.is-loaded) {
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--border) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: photo-wait 1.4s ease-in-out infinite;
}

@keyframes photo-wait {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: -100% 0;
  }
}

.photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attachments__list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.attachment {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  max-width: 18rem;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-primary);
  text-decoration: none;
}


.attachment__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Reply box under the conversation */
.composer {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4);
}

.composer__text {
  min-height: 9rem;
}

/* To: the customer, or another address (a Shopify form came from Shopify, the answer goes to the customer). */
.composer__to {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.composer__to-label {
  flex: none;
  min-width: 2rem;
}

.composer__files {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.composer__files:empty {
  display: none;
}

.btn--danger-icon {
  color: var(--danger-text);
}

.btn--danger-icon:hover {
  background: var(--danger-tint);
}

.other-ticket {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
}

.other-ticket form {
  flex: none;
  margin: 0;
}

.attachment__remove {
  margin-right: calc(var(--space-1) * -1);
}

.composer__signature {
  padding: 0 var(--space-3);
}

.composer__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

.composer__ai {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.split-button {
  display: inline-flex;
  margin-left: auto;
}

.split-button__main {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.split-button__toggle {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left: 1px solid var(--surface);
}

.menu__panel--up {
  top: auto;
  bottom: calc(100% + var(--space-1));
}

.menu__panel--start {
  right: auto;
  left: 0;
}

.note-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.note {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
}

.note__meta {
  margin-bottom: var(--space-1);
}

.timeline__item {
  grid-template-columns: 1rem minmax(0, 1fr) auto;
}

/* Right column: customer and Shopify orders */
.customer__name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.plain {
  margin: 0;
  padding: 0;
  list-style: none;
}

.order-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.order {
  display: grid;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border);
}

.card__header + .order-list .order:first-child {
  border-top: 0;
  padding-top: 0;
}

.order__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
}

.order__name {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.order__head .cell-title {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.order__items {
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.order .small svg {
  vertical-align: -3px;
}

/* ---------- Responsive ---------- */

.only-mobile,
.show-mobile {
  display: none;
}

.drawer-scrim {
  display: none;
}

@keyframes drawer-in {
  from {
    transform: translateX(-16px);
    opacity: 0;
  }
}

@media (max-width: 1439px) {
  .ticket-view {
    grid-template-columns: 15rem minmax(0, 1fr) 16rem;
  }
}

@media (max-width: 1279px) {
  .ticket-view {
    grid-template-columns: minmax(0, 1fr) 16rem;
  }

  .ticket-pane {
    display: none;
  }

  .hide-with-pane {
    display: inline-flex;
  }

  .ticket-table .col-customer,
  .filtered-table .col-customer {
    width: 10rem;
    max-width: 10rem;
  }
}

@media (max-width: 1099px) {
  .ticket-table .col-tags {
    display: none;
  }
}

@media (max-width: 1023px) {
  .main {
    padding: var(--space-6);
  }

  .layout-2col,
  .ticket-view,
  .ticket-view--no-pane {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    display: none;
  }

  .sidebar.is-open {
    position: fixed;
    top: var(--topbar-height);
    bottom: 0;
    height: auto;
    left: 0;
    z-index: var(--z-sidebar);
    display: block;
    width: min(18rem, 85vw);
    box-shadow: var(--shadow-dialog);
    animation: drawer-in var(--duration-panel) ease-out;
  }

  .drawer-scrim.is-open {
    position: fixed;
    inset: var(--topbar-height) 0 0 0;
    z-index: calc(var(--z-sidebar) - 1);
    display: block;
    background: var(--scrim);
  }

  .only-mobile {
    display: inline-flex;
  }
}

@media (max-width: 767px) {
  .main {
    padding: var(--space-4);
  }

  .topbar {
    gap: var(--space-2);
    padding: 0 var(--space-2);
  }

  .topbar__product,
  .hide-mobile {
    display: none;
  }

  .topbar__logo {
    height: 1.5rem;
  }

  .topbar__search {
    flex: 1;
    width: auto;
    min-width: 0;
    margin-left: 0;
  }

  .demo-label {
    display: none;
  }

  .page-header__actions {
    width: 100%;
  }

  .list-bar {
    flex-direction: column-reverse;
    align-items: stretch;
    padding: var(--space-2) 0 0;
  }

  .list-bar__filter {
    padding: 0 var(--space-3);
  }

  .dialog {
    width: 100vw;
    max-width: 100vw;
    max-height: 90dvh;
    margin: auto 0 0;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
  }

  .dialog__footer .btn {
    flex: 1;
  }

  /* Tables become one compact block per row. */
  .data-table,
  .data-table thead,
  .data-table tbody {
    display: block;
    width: 100%;
  }

  .data-table thead tr {
    display: flex;
    align-items: center;
    min-height: 2.75rem;
  }

  .data-table:not(.data-table--selectable) thead {
    display: none;
  }

  .data-table thead tr.thead-bulk,
  .is-selecting thead tr.thead-default {
    display: none;
  }

  .is-selecting thead tr.thead-bulk {
    display: flex;
  }

  .data-table thead th {
    display: flex;
    align-items: center;
    height: auto;
    align-self: stretch;
  }

  .data-table thead .thead-default th:not(.col-check):not(.only-mobile-cell) {
    display: none;
  }

  .data-table thead th.only-mobile-cell {
    display: flex;
    flex: 1;
    padding-left: 0;
  }

  .thead-bulk th[colspan] {
    flex: 1;
    padding-left: 0;
  }

  .bulk-bar {
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .data-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-1) var(--space-2);
    align-items: center;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
  }

  .data-table tbody tr:last-child {
    border-bottom: 0;
  }

  .data-table tbody td {
    height: auto;
    padding: 0;
    border: 0;
  }

  .data-table td.col-subject {
    grid-column: 1 / -1;
    max-width: none;
    width: auto;
  }

  /* Tickets: [box] [dot] customer ... time / subject / status */
  .ticket-table tbody tr {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .ticket-table.data-table--selectable tbody tr {
    grid-template-columns: 2rem 1rem minmax(0, 1fr) auto;
    padding-left: var(--space-2);
  }

  .ticket-table .col-check {
    grid-row: span 3;
    width: auto;
    padding: 0;
  }

  .ticket-table .col-dot {
    width: auto;
  }

  .ticket-table .col-customer,
  .filtered-table .col-customer {
    width: auto;
    max-width: none;
  }

  .ticket-table.data-table--selectable td.col-subject,
  .ticket-table.data-table--selectable td.col-status {
    grid-column: 2 / -1;
  }

  .ticket-table td.col-status {
    grid-column: 1 / -1;
  }

  /* On a phone the actions are on the ticket page. */
  .ticket-table .col-action {
    display: none;
  }

  /* The time sits on the first line, next to the customer. */
  .ticket-table td.col-when {
    grid-column: -2 / -1;
    grid-row: 1;
  }

  .ticket-line {
    max-width: none;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .ticket-line__snippet::before {
    content: "";
    display: block;
  }

  .filtered-table td.col-reason {
    grid-column: 1 / 2;
  }

  .filtered-table td.col-action {
    grid-column: 2 / 3;
    grid-row: 1;
  }

  .filtered-table td.col-when {
    grid-column: 2 / 3;
    text-align: right;
  }

  .message {
    padding: var(--space-3);
  }

  .message__header {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .message__meta {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .message__body,
  .attachments {
    margin-left: 0;
  }

  .composer__footer {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .split-button {
    width: 100%;
  }

  .split-button__main {
    flex: 1;
  }

  .toast-region {
    bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
  }
}

@media (pointer: coarse) {
  .btn,
  .input,
  .select {
    min-height: 2.75rem;
  }

  .btn--small {
    height: 2.75rem;
  }

  .menu__item {
    min-height: 2.75rem;
  }

  .check-target {
    width: 2.75rem;
    height: 2.75rem;
  }

  .input,
  .select,
  .textarea {
    font-size: var(--text-md);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}

/* ---------- Additions of 23 October ---------- */

/* Number of mails in a ticket, next to the customer. */
/* Language of the customer's mail. The hairline keeps white stripes visible on white. */
.flag {
  flex: none;
  width: 1rem;
  height: 0.75rem;
  border-radius: 2px;
  box-shadow: 0 0 0 1px var(--border);
  vertical-align: -1px;
}

.tag--flag {
  gap: var(--space-1);
}

.cell-customer-line {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.mail-count {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 2px;
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 500;
}

.mail-count .icon-sm {
  width: 0.875rem;
  height: 0.875rem;
}

.menu__item--danger {
  color: var(--danger-text);
}

/* Conversation: every mail folds; a folded mail shows the start of its text. */
.conversation__tools {
  display: flex;
  justify-content: flex-end;
  padding: var(--space-2) var(--space-3) 0;
}

.message__fold > summary {
  list-style: none;
  cursor: pointer;
}

.message__fold > summary::-webkit-details-marker {
  display: none;
}

.message__snippet {
  display: none;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message__fold:not([open]) .message__snippet {
  display: block;
}

.message__fold:not([open]) .message__to {
  display: none;
}
