/* CEN Foundation — design system.
   ---------------------------------------------------------------------------
   The brand colours come from /theme.css (--color-primary, --color-accent and
   their automatic contrast colours).  Everything else is derived here so that
   an admin can change the brand without touching a line of markup.

   Rules of the house:
   - no inline styles and no inline scripts (strict CSP),
   - every colour is a token, every spacing a step of the scale,
   - the layout works from 320 px up to 1600 px.
   */

/* --- 1. Tokens ----------------------------------------------------------- */

:root {
  /* brand (overridden by /theme.css) */
  --color-primary: #1f6feb;
  --color-accent: #f59e0b;
  --on-primary: #ffffff;
  --on-accent: #1b1f24;

  --brand: var(--color-primary);
  --brand-ink: var(--on-primary);
  --accent: var(--color-accent);
  --accent-ink: var(--on-accent);

  /* brand tints */
  --brand-soft: #eaf1fd;
  --brand-soft: color-mix(in srgb, var(--brand) 9%, #ffffff);
  --brand-soft-strong: #d8e6fb;
  --brand-soft-strong: color-mix(in srgb, var(--brand) 16%, #ffffff);
  --brand-line: #c3d8f6;
  --brand-line: color-mix(in srgb, var(--brand) 30%, #ffffff);
  --brand-deep: #1a5dc0;
  --brand-deep: color-mix(in srgb, var(--brand) 78%, #000000);
  --brand-ring: rgba(31, 111, 235, 0.22);
  --brand-ring: color-mix(in srgb, var(--brand) 22%, transparent);

  /* neutrals */
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eef1f4;
  --border: #e4e8ec;
  --border-strong: #cfd6dd;
  --text: #16191d;
  --text-2: #4d5763;
  --text-3: #78838f;

  /* semantic */
  --danger: #c0392b;
  --danger-soft: #fdf0ee;
  --success: #157347;
  --success-soft: #ecf7f0;
  --warning-bg: #fff8e8;
  --warning-border: #f0d9a4;

  /* shape */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-full: 999px;

  /* spacing scale */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-7: 32px;
  --s-8: 40px;
  --s-9: 56px;

  /* elevation */
  --shadow-1: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-2: 0 2px 6px rgba(16, 24, 40, 0.07), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-3: 0 12px 32px rgba(16, 24, 40, 0.14);

  /* layout */
  --content-width: 1280px;
  --header-height: 58px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* icons (inline SVG data URIs, painted with currentColor through the mask) */
  --icon-external: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M6.5 2.5H3.2A1.2 1.2 0 0 0 2 3.7v9.1A1.2 1.2 0 0 0 3.2 14h9.1a1.2 1.2 0 0 0 1.2-1.2V9.5M9.5 2.5H13.5V6.5M13.5 2.5 7.8 8.2'/%3E%3C/svg%3E");
}

/* --- 2. Reset and base --------------------------------------------------- */

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

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  margin: 0 0 var(--s-2);
  line-height: 1.25;
  letter-spacing: -0.011em;
  color: var(--text);
}

h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.0625rem; font-weight: 650; }
h3 { font-size: 0.95rem; font-weight: 650; }

p { margin: 0 0 var(--s-3); }
p:last-child { margin-bottom: 0; }

a {
  color: var(--brand-deep);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

img { max-width: 100%; }

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--s-5) 0;
}

::selection {
  background: var(--brand-soft-strong);
  color: var(--text);
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

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

/* The JavaScript hides a part of the page with this name.  The name is not
   `hidden` on purpose: `hidden` is an attribute of the HTML and the two
   must not be mixed up. */
.is-hidden {
  display: none !important;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--brand);
  color: var(--brand-ink);
  padding: var(--s-2) var(--s-4);
  border-radius: 0 0 var(--r-sm) 0;
}
.skip-link:focus { left: 0; }

/* --- 3. Layout ----------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border-top: 3px solid var(--brand);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-1);
}

.topbar-inner {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 var(--s-5);
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  gap: var(--s-4);
}

.brand {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}
.brand:hover { text-decoration: none; }
.brand img {
  display: block;
  height: 32px;
  width: auto;
}

.nav {
  display: flex;
  align-items: center;
  gap: var(--s-1);
}

.nav a {
  display: inline-block;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-full);
  color: var(--text-2);
  font-weight: 550;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.nav a:hover {
  background: var(--surface-3);
  color: var(--text);
  text-decoration: none;
}
.nav a[aria-current="page"] {
  background: var(--brand-soft);
  color: var(--brand-deep);
}

/* The square button of the bar: it opens the modal of a new production.
   The label stays in the aria-label and in the title, the sign is the
   picture. */
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.user-name {
  font-size: 0.875rem;
  color: var(--text-2);
  white-space: nowrap;
}

.lang-toggle {
  margin: 0;
}

.lang-toggle-group {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
}

.lang-toggle-option {
  min-width: 40px;
  height: 32px;
  padding: 0 var(--s-3);
  border: 0;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.lang-toggle-option + .lang-toggle-option {
  border-left: 1px solid var(--border-strong);
}

.lang-toggle-option:hover {
  background: var(--surface-2);
  color: var(--text);
}

.lang-toggle-option.is-active {
  background: var(--accent);
  color: var(--accent-ink);
}

.plain-top {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: var(--s-4) var(--s-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
}

.plain-top-name {
  font-size: 0.875rem;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: var(--s-6) var(--s-5) var(--s-9);
}

.footer {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: var(--s-5);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  flex-wrap: wrap;
  color: var(--text-3);
  font-size: 0.8125rem;
}
.footer-name { font-weight: 600; color: var(--text-2); }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-4);
  flex-wrap: wrap;
  margin-bottom: var(--s-5);
}
.page-head h1 { margin: 0; }
.page-head p { margin: var(--s-1) 0 0; color: var(--text-2); }
.page-actions {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
  align-items: center;
}

/* --- 4. Buttons ---------------------------------------------------------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 38px;
  padding: 0 var(--s-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease,
    box-shadow 0.15s ease;
}
.button:hover {
  background: var(--surface-2);
  border-color: var(--brand-line);
  color: var(--brand-deep);
  text-decoration: none;
}
.button:active { transform: translateY(1px); }

.button.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
  box-shadow: var(--shadow-1);
}
.button.primary:hover {
  background: var(--brand-deep);
  border-color: var(--brand-deep);
  color: var(--brand-ink);
}

.button.danger {
  color: var(--danger);
  border-color: #e6c4c0;
  background: var(--surface);
}
.button.danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.button.small {
  min-height: 30px;
  padding: 0 var(--s-3);
  font-size: 0.8125rem;
  border-radius: var(--r-xs);
}

.button.block { display: flex; width: 100%; }

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

.link-button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.875rem;
  color: var(--brand-deep);
  cursor: pointer;
}
.link-button:hover { text-decoration: underline; }
.link-button.danger { color: var(--danger); }

/* --- 5. Forms ------------------------------------------------------------ */

.field { margin-bottom: var(--s-4); }
.field:last-child { margin-bottom: 0; }
.field.grow { flex: 1 1 220px; min-width: 0; }

.field label,
.field > label {
  display: block;
  margin-bottom: var(--s-1);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-2);
}
.field.checkbox label {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-weight: 500;
  color: var(--text);
  font-size: 0.9rem;
  margin-bottom: 0;
  cursor: pointer;
}

/* A label that looks like a button (the file choosers) keeps the button size. */
label.button {
  display: inline-flex;
  width: auto;
  margin-bottom: 0;
  font-weight: 550;
  font-size: 0.9375rem;
  color: var(--text);
}

input[type="text"],
input[type="email"],
input[type="url"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="date"],
textarea,
select {
  width: 100%;
  min-height: 38px;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea {
  resize: vertical;
  min-height: 96px;
  line-height: 1.5;
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2378838f' d='M1.4 0 6 4.6 10.6 0 12 1.4 6 7.4 0 1.4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--s-3) center;
  padding-right: var(--s-7);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}

input[readonly] {
  background: var(--surface-2);
  color: var(--text-3);
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
  flex: 0 0 auto;
}

fieldset.field {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-4);
  margin: 0 0 var(--s-4);
  background: var(--surface-2);
}
legend {
  font-weight: 650;
  font-size: 0.9rem;
  padding: 0 var(--s-2);
  color: var(--text);
}

.form-actions {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
  align-items: center;
  margin-top: var(--s-5);
  padding-top: var(--s-4);
  border-top: 1px solid var(--border);
}

.filter-form {
  display: flex;
  gap: var(--s-3);
  flex-wrap: wrap;
  align-items: flex-end;
}
.filter-form .field { margin-bottom: 0; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0 var(--s-4);
}

.hint,
.field-hint,
small {
  display: block;
  margin-top: var(--s-1);
  color: var(--text-3);
  font-size: 0.8125rem;
  line-height: 1.45;
}

/* --- 6. Messages --------------------------------------------------------- */

.messages {
  list-style: none;
  margin: 0 0 var(--s-4);
  padding: 0;
  display: grid;
  gap: var(--s-2);
}

.message {
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.message.success { border-color: #bfe3cd; background: var(--success-soft); color: var(--success); }
.message.error { border-color: #e6c4c0; background: var(--danger-soft); color: var(--danger); }
.message.warning { border-color: var(--warning-border); background: var(--warning-bg); }

.notice {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: #6b4e12;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-sm);
  font-size: 0.9rem;
}

.error { color: var(--danger); }
.error-list { color: var(--danger); padding-left: var(--s-5); }
.empty {
  color: var(--text-3);
  font-style: normal;
  text-align: center;
  padding: var(--s-6) var(--s-4);
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
}

/* --- 7. Panels ----------------------------------------------------------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  margin-bottom: var(--s-5);
  box-shadow: var(--shadow-1);
}
.panel:last-child { margin-bottom: 0; }
.panel > h2:first-child { margin-top: 0; }
.panel.narrow {
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}

/* --- 8. Tables ----------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  -webkit-overflow-scrolling: touch;
}

/* The table keeps its columns readable and scrolls sideways on a small screen. */
.table-wrap .table {
  min-width: 720px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.9rem;
}
.table th,
.table td {
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
.table th {
  background: var(--surface-2);
  font-size: 0.75rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
  white-space: nowrap;
}
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table td small { margin-top: 2px; }

.thumb-cell {
  width: 88px;
}
.thumb-cell img {
  width: 56px;
  height: 56px;
  max-width: none;
  object-fit: cover;
  border-radius: var(--r-sm);
  display: block;
  background: var(--surface-3);
}

/* --- 9. Records grid and cards ----------------------------------------- */

.toolbar {
  display: flex;
  gap: var(--s-4);
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: var(--s-4);
}

.filter-panel {
  flex: 1 1 520px;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  box-shadow: var(--shadow-1);
}

.filter-search {
  display: flex;
  gap: var(--s-3);
  align-items: flex-end;
  margin-bottom: var(--s-4);
}
.filter-search .field { flex: 1 1 auto; margin-bottom: 0; min-width: 0; }
.filter-search input[type="search"] {
  height: 42px;
  font-size: 1rem;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%2378838f' stroke-width='1.6' d='M11.3 11.3 15 15M7 12.5a5.5 5.5 0 1 1 0-11 5.5 5.5 0 0 1 0 11z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left var(--s-3) center;
  padding-left: var(--s-8);
}
/* The button sits next to the search box, not next to its label. */
.filter-search .button { min-height: 42px; }

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--s-3);
  align-items: end;
}
.filter-grid .field { margin-bottom: 0; }
.filter-grid select[multiple] {
  min-height: 38px;
  max-height: 116px;
  padding: var(--s-1);
}
.filter-grid select[multiple] option {
  padding: var(--s-1) var(--s-2);
  border-radius: var(--r-xs);
}

.filter-actions {
  display: flex;
  gap: var(--s-2);
  align-items: center;
}

.filter-more {
  border: none;
  padding: 0;
  margin: var(--s-4) 0 0;
}
.filter-more summary {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) 0;
  cursor: pointer;
  list-style: none;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-2);
}
.filter-more summary::-webkit-details-marker { display: none; }
.filter-more summary::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.15s ease;
}
.filter-more[open] summary::before { transform: rotate(90deg); }
.filter-more summary:hover { color: var(--text); }
.filter-more-count {
  background: var(--brand-soft-strong);
  color: var(--brand-deep);
  border-radius: var(--r-full);
  padding: 0 var(--s-2);
  font-size: 0.75rem;
  font-weight: 700;
}
.filter-more .chip-group { padding-bottom: var(--s-2); }

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 5px var(--s-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-full);
  background: var(--surface);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.chip input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--brand);
}
.chip:hover {
  border-color: var(--brand-line);
  background: var(--surface-2);
  color: var(--text);
}
.chip.is-on,
.chip:has(input:checked) {
  background: var(--brand-soft);
  border-color: var(--brand-line);
  color: var(--brand-deep);
  font-weight: 600;
}
.chip:has(input:focus-visible) {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.filter-foot {
  margin-top: var(--s-4);
  padding-top: var(--s-3);
  border-top: 1px solid var(--border);
}
.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
}
.switch input { width: 16px; height: 16px; accent-color: var(--brand); }

.nowrap { white-space: nowrap; }

.result-count {
  color: var(--text-2);
  font-size: 0.875rem;
  margin: 0 0 var(--s-3);
}
.result-count strong { color: var(--text); font-weight: 650; }

.grid {
  display: grid;
  gap: var(--s-4);
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: var(--s-6);
}
.grid[data-cols="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid[data-cols="5"] { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid[data-cols="7"] { grid-template-columns: repeat(7, minmax(0, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-1);
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.card:hover {
  box-shadow: var(--shadow-2);
  border-color: var(--brand-line);
  transform: translateY(-2px);
}

.card-media {
  display: block;
  position: relative;
  background: var(--surface-3);
  overflow: hidden;
}
.card-media img,
.card video {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  transition: transform 0.25s ease;
}
.card:hover .card-media img { transform: scale(1.04); }

.card-body {
  padding: var(--s-3) var(--s-4) var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  flex: 1 1 auto;
}
.card-body h2 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
}
.card-body h2 a { color: var(--text); }
.card-body h2 a:hover { color: var(--brand-deep); text-decoration: none; }

/* The row of the card that holds the download of the picture. */
.card-actions {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-top: auto;
  padding-top: var(--s-2);
}

.media-download {
  color: var(--text-2);
}

.media-download:hover {
  color: var(--text);
}

/* Links that open the product page in a new browser tab. */
.link-newtab {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3em;
}
.link-newtab::after {
  content: "";
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  align-self: center;
  background-color: currentColor;
  -webkit-mask: var(--icon-external) center / contain no-repeat;
  mask: var(--icon-external) center / contain no-repeat;
  opacity: 0.65;
}
.link-newtab:hover::after { opacity: 1; }
.card-name {
  color: var(--text-2);
  margin: 0;
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-tags {
  margin: var(--s-2) 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
  align-items: center;
}
.no-media {
  display: block;
  padding: 2.5rem var(--s-3);
  text-align: center;
  color: var(--text-3);
  font-size: 0.8125rem;
  aspect-ratio: 4 / 3;
}

.tag {
  display: inline-block;
  background: var(--surface-3);
  color: var(--text-2);
  border-radius: var(--r-full);
  padding: 2px var(--s-2);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.5;
}

.badge {
  display: inline-block;
  border-radius: var(--r-xs);
  padding: 2px var(--s-2);
  font-size: 0.6875rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--accent);
  color: var(--accent-ink);
}
.badge.public {
  background: var(--brand-soft-strong);
  color: var(--brand-deep);
  vertical-align: middle;
}
.badge.video {
  position: absolute;
  right: var(--s-2);
  bottom: var(--s-2);
  background: rgba(0, 0, 0, 0.68);
  color: #fff;
}

/* --- 10. Product page ---------------------------------------------------- */

.product-header {
  display: flex;
  gap: var(--s-4);
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--s-5);
}
.product-header h1 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
}
.product-name {
  font-size: 1.0625rem;
  color: var(--text-2);
  margin: var(--s-1) 0 0;
}
.product-updated {
  color: var(--text-3);
  font-size: 0.8125rem;
  margin: var(--s-1) 0 0;
}
/* The author of the product and the number of its edits. */
.product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  color: var(--text-3);
  font-size: 0.8125rem;
  margin: var(--s-1) 0 0;
}
/* The same information on the card of the list. */
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  color: var(--text-3);
  font-size: 0.75rem;
  margin: var(--s-1) 0 0;
}
.product-actions {
  display: flex;
  gap: var(--s-2);
  align-items: center;
  flex-wrap: wrap;
}
.product-actions form { margin: 0; }

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  grid-template-areas:
    "gallery side"
    "tabs   side";
  gap: var(--s-5);
  align-items: start;
}
.detail-gallery { grid-area: gallery; margin-bottom: 0; }
.detail-side { grid-area: side; }
.detail-tabs { grid-area: tabs; }
.detail-side {
  display: grid;
  gap: var(--s-4);
  align-content: start;
}
.detail-side .panel { margin-bottom: 0; }

.description {
  white-space: pre-wrap;
  color: var(--text-2);
  margin: 0;
}

.gallery-main {
  background: #101418;
  border-radius: var(--r-md);
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.gallery-main img,
.gallery-main video {
  max-width: 100%;
  max-height: 70vh;
  display: block;
}
.gallery-item[hidden] { display: none; }
.placeholder {
  color: #fff;
  text-align: center;
  padding: var(--s-5);
}
.gallery-nav {
  display: flex;
  gap: var(--s-2);
  margin: var(--s-3) 0;
  justify-content: center;
}
.thumbs {
  list-style: none;
  display: flex;
  gap: var(--s-2);
  padding: var(--s-1);
  margin: 0;
  overflow-x: auto;
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.thumb-button {
  border: 2px solid transparent;
  padding: 0;
  background: none;
  cursor: pointer;
  border-radius: var(--r-sm);
  display: block;
  line-height: 0;
}
.thumb-button img {
  width: 76px;
  height: 76px;
  max-width: none;
  object-fit: cover;
  border-radius: var(--r-xs);
  display: block;
}
.thumb-button.active {
  border-color: var(--brand);
}

.attachments {
  list-style: none;
  padding: 0;
  margin: 0;
}
.attachments li {
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: var(--s-3);
  flex-wrap: wrap;
  align-items: center;
}
.attachments li:last-child { border-bottom: none; }
.attachment-description { color: var(--text-2); font-size: 0.875rem; }
.file-size {
  color: var(--text-3);
  font-size: 0.8125rem;
  margin-left: auto;
  white-space: nowrap;
}

.tabs { margin-top: 0; }
.tab-bar {
  display: flex;
  gap: var(--s-5);
  margin-bottom: var(--s-4);
  border-bottom: 1px solid var(--border);
}
.tab-button {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: var(--s-2) var(--s-1) var(--s-3);
  margin-bottom: -1px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  color: var(--text-3);
}
.tab-button:hover { color: var(--text); }
.tab-button.active {
  color: var(--brand-deep);
  border-bottom-color: var(--brand);
}
[data-tab-panel][hidden] { display: none; }

.comments {
  list-style: none;
  padding: 0;
  margin: 0;
}
.comment {
  border-left: 2px solid var(--border);
  padding: var(--s-2) 0 var(--s-3) var(--s-4);
  margin-bottom: var(--s-2);
}
.comment.depth-1 { margin-left: var(--s-4); }
.comment.depth-2 { margin-left: var(--s-6); }
.comment.depth-3 { margin-left: var(--s-7); }
.comments.nested { margin-top: var(--s-2); }
.comment-head {
  display: flex;
  gap: var(--s-2);
  align-items: baseline;
  font-size: 0.8125rem;
  color: var(--text-3);
  flex-wrap: wrap;
}
.comment-author { font-weight: 650; color: var(--text); }
.comment-edited { font-style: italic; }
.comment-body p { margin: var(--s-1) 0; color: var(--text-2); }
.comment-actions {
  display: flex;
  gap: var(--s-4);
  font-size: 0.875rem;
  margin-top: var(--s-1);
}
.comment-actions form { margin: 0; }
.deleted { color: var(--text-3); font-style: italic; }

.history {
  list-style: none;
  padding: 0;
  margin: 0;
}
.history > li {
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--border);
}
.history > li:last-child { border-bottom: none; }
.history-head {
  display: flex;
  gap: var(--s-1) var(--s-3);
  font-size: 0.8125rem;
  color: var(--text-3);
  flex-wrap: wrap;
}
.history-action { font-weight: 650; color: var(--text); }
.changes {
  margin: var(--s-2) 0 0 var(--s-4);
  font-size: 0.8125rem;
  list-style: none;
  padding: 0;
}
.change-field { font-weight: 650; color: var(--text-2); }
.change-old {
  color: var(--text-3);
  text-decoration: line-through;
  margin-right: var(--s-1);
}
.change-new { color: var(--success); }
.change-note { color: var(--text-3); margin-right: var(--s-1); }

/* --- 11. Product form ---------------------------------------------------- */

.upload-list {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--s-3);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
}
.upload-item {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-2);
  background: var(--surface);
  width: 152px;
  box-shadow: var(--shadow-1);
}
.upload-item img {
  width: 100%;
  height: 92px;
  object-fit: cover;
  border-radius: var(--r-xs);
  display: block;
}
.upload-item .upload-name {
  font-size: 0.75rem;
  word-break: break-all;
  margin-top: var(--s-1);
  color: var(--text-2);
}
.upload-item .upload-actions {
  display: flex;
  gap: var(--s-1);
  align-items: center;
  margin-top: var(--s-2);
}
.upload-item input[type="text"] { font-size: 0.75rem; min-height: 28px; }

.suggestions {
  list-style: none;
  padding: 0;
  margin: var(--s-2) 0 0;
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
}
.suggestions button {
  background: var(--surface-3);
  border: none;
  border-radius: var(--r-full);
  padding: var(--s-1) var(--s-3);
  cursor: pointer;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--text-2);
}
.suggestions button:hover { background: var(--brand-soft-strong); color: var(--brand-deep); }

/* The product form: two columns, the sections and the upload list. */
.product-form-panel { padding: var(--s-5); }
.product-form-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: var(--s-5);
  align-items: start;
}
.product-form-main { display: flex; flex-direction: column; gap: var(--s-5); }
.product-form-side { position: sticky; top: calc(var(--header-height) + var(--s-4)); }

.form-section {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  margin: 0;
  background: var(--surface);
}
.form-section > legend {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-2);
  padding: 0 var(--s-2);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-4);
}
.form-divider {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--s-5) 0;
}
.form-section h2 {
  font-size: 0.9375rem;
  margin: 0 0 var(--s-3);
}
.hint {
  color: var(--text-2);
  font-size: 0.8125rem;
  margin: 0 0 var(--s-3);
}
.required { color: var(--danger); }
.field-hint { font-size: 0.8125rem; color: var(--text-2); }
.field-hint.error { color: var(--danger); }

.upload-actions-bar {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
  align-items: center;
}
.upload-item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}
.upload-handle {
  cursor: grab;
  color: var(--text-3);
  font-size: 1rem;
  line-height: 1;
  position: absolute;
  top: var(--s-2);
  left: var(--s-2);
  background: rgba(255, 255, 255, 0.85);
  border-radius: var(--r-xs);
  padding: 2px 4px;
  user-select: none;
  touch-action: none;
}
/* Only the handle moves the card; the fields inside it stay quiet. */
.upload-handle:active { cursor: grabbing; }
.upload-item .upload-description,
.upload-item .filter-row input[type="range"] { cursor: auto; }
.upload-item.dragging { opacity: 0.5; }
.upload-item.drag-over { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft-strong); }
.upload-item .badge { align-self: flex-start; }
.upload-item .upload-actions { flex-wrap: wrap; }

/* The tag picker: a search box, a list of suggestions and the chosen tags. */
.tag-picker { position: relative; }
/* The select holds the values that are posted; the chips and the search
   box are what the user sees. */
.tag-select { display: none; }
.tag-picker input {
  width: 100%;
  min-height: 38px;
}
.suggestions {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 220px;
  overflow-y: auto;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
  padding: var(--s-1);
  margin: 0;
}
.suggestions:empty { display: none; }
.suggestions button {
  border-radius: var(--r-sm);
  text-align: left;
  width: 100%;
}
.tag-chips {
  list-style: none;
  padding: 0;
  margin: var(--s-3) 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}
.tag-chips:empty { display: none; }
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  background: var(--brand-soft-strong);
  color: var(--brand-deep);
  border-radius: var(--r-full);
  padding: 3px var(--s-1) 3px var(--s-3);
  font-size: 0.8125rem;
  font-weight: 600;
}
.tag-chip-remove {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 4px;
  border-radius: var(--r-full);
}
.tag-chip-remove:hover { background: rgba(0, 0, 0, 0.08); }

/* The photo viewer: a window over the page. */
.viewer {
  border: none;
  padding: 0;
  background: transparent;
  max-width: min(1200px, 96vw);
  width: 100%;
  max-height: 94vh;
  overflow: visible;
}
.viewer::backdrop { background: rgba(9, 12, 20, 0.86); }
.viewer-inner {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  display: flex;
  flex-direction: column;
  height: 94vh;
  max-height: 94vh;
  overflow: hidden;
}
.viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
}
.viewer-name {
  font-size: 0.875rem;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.viewer-head-actions { display: flex; gap: var(--s-2); flex-shrink: 0; }
.viewer-body {
  display: flex;
  align-items: stretch;
  gap: var(--s-2);
  padding: var(--s-3);
  flex: 1 1 auto;
  min-height: 0;
}
.viewer-stage {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0b0e15;
  border-radius: var(--r-md);
  overflow: hidden;
}
.viewer-stage img,
.viewer-stage video {
  max-width: 100%;
  max-height: 72vh;
  object-fit: contain;
  display: block;
}
.viewer-stage img {
  transform-origin: center center;
  will-change: transform;
  cursor: zoom-in;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}
.viewer-stage.is-zoomable {
  touch-action: none;
}
.viewer-stage.is-zoomed img { cursor: grab; }
.viewer-stage.is-dragging img { cursor: grabbing; }
.viewer-head-actions .button[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}
.viewer-nav {
  flex: 0 0 auto;
  align-self: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.viewer-nav:hover { background: var(--surface-3); }
.viewer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-4);
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-2);
}
.viewer-counter { flex: 1 1 auto; text-align: center; }
.viewer-zoom-level { flex: 0 0 auto; min-width: 44px; text-align: right; }
.viewer-fit-short { display: none; }
.gallery-expand { margin-top: var(--s-2); }
.detail-gallery .gallery-main img { cursor: zoom-in; }

/* The download of a picture, under the picture of the gallery.  It stands
   on the dark ground of the gallery, so it wears the same clothes as the
   buttons of the viewer. */
.gallery-downloads {
  display: flex;
  justify-content: center;
  gap: var(--s-2);
  margin-top: var(--s-2);
  padding-bottom: var(--s-2);
}
.gallery-downloads .media-download {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.32);
  color: #fff;
  backdrop-filter: blur(3px);
}
.gallery-downloads .media-download:hover {
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 255, 255, 0.55);
  color: #fff;
}

/* --- 12. Administration -------------------------------------------------- */

.manage {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  gap: var(--s-6);
  align-items: start;
}

.manage-nav {
  position: sticky;
  top: calc(var(--header-height) + var(--s-4));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-3);
  box-shadow: var(--shadow-1);
  display: grid;
  gap: var(--s-4);
}

.manage-group {
  display: grid;
  gap: 2px;
}

.manage-group-title {
  margin: 0 0 var(--s-1);
  padding: 0 var(--s-3);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
}

.manage-nav a {
  display: block;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 0.9rem;
  font-weight: 500;
}
.manage-nav a:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}
.manage-nav a[aria-current="page"] {
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-weight: 650;
}

.manage-content { min-width: 0; }
.manage-content > h1 { margin-bottom: var(--s-4); }

.stats {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: var(--s-3);
}
.stats li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  box-shadow: var(--shadow-1);
}
.stats a {
  display: block;
  color: inherit;
}
.stats a:hover { text-decoration: none; }
.stats a:hover .stat-value { color: var(--brand-deep); }
.stat-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.stat-label {
  display: block;
  color: var(--text-3);
  font-size: 0.8125rem;
  margin-top: var(--s-1);
}

.test-result { list-style: none; padding: 0; margin: 0; }
.test-result li { padding: var(--s-2) 0; border-bottom: 1px solid var(--border); }
.test-result li:last-child { border-bottom: none; }
.test-result .ok { color: var(--success); }
.test-result .error { color: var(--danger); }
.failed-row { background: var(--danger-soft); }
.job-error { color: var(--danger); font-size: 0.8125rem; }
.preview-logo { max-width: 240px; }
.theme-preview {
  background: var(--surface-2);
  padding: var(--s-3);
  border-radius: var(--r-sm);
  overflow-x: auto;
  font-size: 0.75rem;
  margin: var(--s-3) 0 0;
}
.roles-form { display: flex; align-items: flex-start; gap: var(--s-2); }
.roles-form select { width: auto; min-width: 160px; }

/* The role of a user: a dropdown that lists the roles instead of a small
   list that scrolls.  The panel leaves the flow of the page, so that the
   frame of the table cannot cut it. */
.role-select { position: relative; }
.role-select-summary {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 34px;
  padding: 0 var(--s-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-weight: 550;
  cursor: pointer;
  list-style: none;
}
.role-select-summary::-webkit-details-marker { display: none; }
.role-select-summary::before {
  content: "▸";
  color: var(--text-3);
  transition: transform 0.15s ease;
}
.role-select[open] > .role-select-summary::before { transform: rotate(90deg); }
.role-select-label {
  color: var(--text-3);
  font-weight: 500;
  font-size: 0.8125rem;
}
.role-select-value {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.role-select-panel {
  position: fixed;
  z-index: 320;
  top: auto;
  left: auto;
  min-width: 220px;
  max-height: 260px;
  overflow: auto;
  padding: var(--s-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  box-shadow: var(--shadow-3);
}
.role-select-option {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-1) var(--s-2);
  border-radius: var(--r-sm);
  cursor: pointer;
  white-space: nowrap;
}
.role-select-option:hover { background: var(--surface-3); }
.role-select-option input { margin: 0; }

/* The role of a person who waits for the approval. */
.role-choices {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-1) var(--s-4);
  margin: 0;
  padding: 0;
  border: 0;
}
.role-choices legend {
  padding: 0;
  font-size: 0.8125rem;
  color: var(--text-2);
}

.tag-create-form .field { max-width: 320px; margin-bottom: 0; }
.tag-create-form .form-actions {
  border-top: none;
  margin-top: var(--s-3);
  padding-top: 0;
}

.pagination {
  display: flex;
  gap: var(--s-3);
  align-items: center;
  justify-content: center;
  margin: var(--s-6) 0 0;
}
.page-info { color: var(--text-2); font-size: 0.875rem; }

/* --- 13. Plain pages (login, status, share) ----------------------------- */

.plain-body { background: var(--bg); }
.plain-main {
  max-width: 440px;
  margin: 8vh auto;
  padding: 0 var(--s-4);
}
.login-panel {
  text-align: center;
  padding: var(--s-7) var(--s-6);
}
.login-panel h1 { margin-bottom: var(--s-5); }
.login-logo {
  max-width: 220px;
  height: auto;
  margin-bottom: var(--s-4);
}
.login-panel .field { text-align: left; }
.login-panel .notice { text-align: left; }

/* The public page wears the clothes of the site: the logo on
   top, the product in the middle, the footer at the bottom. */
.shared-body {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.shared-body .plain-main {
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--s-4) var(--s-7);
  flex: 1 1 auto;
}
.share-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  flex-wrap: wrap;
  padding: var(--s-4) 0;
  border-bottom: 1px solid var(--border);
}
.share-head-actions {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  flex-wrap: wrap;
}
.share-head .brand img {
  max-height: 40px;
  width: auto;
}
.shared-product {
  max-width: 960px;
  margin: 0 auto;
}
.shared-product header { margin-bottom: var(--s-5); }
.shared-product .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* --- 14. Responsive ------------------------------------------------------ */

@media (max-width: 1199px) {
  .detail-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "gallery"
      "side"
      "tabs";
  }
  .manage { grid-template-columns: 208px minmax(0, 1fr); gap: var(--s-5); }
  .product-form-columns { grid-template-columns: minmax(0, 1fr); }
  .product-form-side { position: static; }
}

@media (max-width: 1023px) {
  .manage {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--s-4);
  }
  .manage-nav {
    position: static;
    display: flex;
    gap: var(--s-2);
    overflow-x: auto;
    padding: var(--s-2);
    scrollbar-width: thin;
    -webkit-mask-image: linear-gradient(to right, #000 90%, transparent 100%);
    mask-image: linear-gradient(to right, #000 90%, transparent 100%);
  }
  .manage-group {
    display: flex;
    gap: var(--s-1);
  }
  .manage-group-title { display: none; }
  .manage-nav a { white-space: nowrap; }
}

@media (min-width: 900px) and (max-width: 1199px) {
  .grid,
  .grid[data-cols="3"],
  .grid[data-cols="5"],
  .grid[data-cols="7"] {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .shared-product .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 899px) {
  /* The number of columns is forced by the screen width below 900 px (VIEW-4). */
  .filter-cols { display: none; }
  .grid,
  .grid[data-cols="3"],
  .grid[data-cols="5"],
  .grid[data-cols="7"] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .shared-product .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .topbar-inner {
    flex-wrap: wrap;
    padding: var(--s-2) var(--s-4);
    gap: var(--s-2);
    row-gap: var(--s-2);
  }
  .brand { order: 1; }
  .topbar-right { order: 2; }
  .nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .content { padding: var(--s-5) var(--s-4) var(--s-8); }
  .user-name { display: none; }
}

@media (max-width: 599px) {
  .grid,
  .grid[data-cols="3"],
  .grid[data-cols="5"],
  .grid[data-cols="7"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .shared-product .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content { padding: var(--s-4) var(--s-3) var(--s-7); }
  .filter-search { flex-wrap: wrap; }
  .filter-search .field { flex: 1 1 100%; min-width: 100%; }
  .filter-search .filter-actions { width: 100%; }
  .filter-search .filter-actions .button { width: 100%; }
  .panel { padding: var(--s-4); border-radius: var(--r-md); }
  .product-header { flex-direction: column; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-actions .button { flex: 1 1 auto; }
  .button { min-height: 40px; }
  .tab-bar { gap: var(--s-4); }
  .comment.depth-2 { margin-left: var(--s-5); }
  .comment.depth-3 { margin-left: var(--s-6); }
  .stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .product-form-panel { padding: var(--s-4); }
  .upload-item { width: 132px; }
  /* The rules of the viewer for a narrow screen stand in section 16a, after
     the rules of the viewer itself: a rule that comes before them would be
     overwritten by them. */
}

@media (max-width: 419px) {
  .grid,
  .grid[data-cols="3"],
  .grid[data-cols="5"],
  .grid[data-cols="7"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .filter-grid { grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); }
  .topbar-right { gap: var(--s-1); }
}

/* --- 15. Motion and print ------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .card:hover { transform: none; }
  .card:hover .card-media img { transform: none; }
}

@media print {
  .topbar,
  .footer,
  .product-actions,
  .gallery-nav,
  .thumbs,
  .pagination { display: none; }
  body { background: #fff; }
  .panel { box-shadow: none; border-color: #ccc; }
}

/* --- 16. FIX_MODAL_VIEW: the viewer without a frame ------------------------

   The viewer of a product used to open as a framed window with a panel of
   its own behind the picture.  Now the picture lies on the dark ground
   of the screen and the buttons float over it, transparent.  They fade
   away when nothing happens and come back when the mouse moves or when
   the screen is tapped.

   To get the old viewer back, delete this block: the rules of section 11
   still describe the framed window.
   -------------------------------------------------------------------------- */

.viewer {
  max-width: none;
  width: 100%;
  max-height: none;
  /* 100dvh is the height that is really visible.  On a phone the bar of
     the browser takes a part of the screen away; 100vh counts that part
     as if it were there, so the viewer becomes taller than the screen
     and its top edge (where the buttons are) disappears behind the bar.
     100vh stays as the fallback for the browsers that do not know dvh. */
  height: 100vh;
  height: 100dvh;
  /* The browser puts margin:auto around the window of the dialog and
     centres it.  A dialog that is a little too tall then loses its top
     and its bottom; pinned to the top it only loses its bottom. */
  margin: 0;
  inset: 0;
  /* The ground of the viewer is solid: the page behind must not show
     through the bar of the buttons. */
  background: #05070c;
  overflow: hidden;
  overscroll-behavior: contain;
  /* A pinch on the viewer zooms the picture and not the page behind it. */
  touch-action: none;
}
.viewer::backdrop { background: rgba(5, 7, 12, 0.94); }
.viewer-inner {
  position: relative;
  height: 100%;
  max-height: none;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
}
.viewer-body {
  position: absolute;
  inset: 0;
  display: block;
  padding: 0;
}
.viewer-stage {
  width: 100%;
  height: 100%;
  background: transparent;
  border-radius: 0;
}
.viewer-stage img,
.viewer-stage video {
  max-width: 100%;
  max-height: 100%;
}
.viewer-head {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  align-items: flex-start;
  gap: var(--s-2);
  flex-wrap: wrap;
  /* The insets of the screen keep the buttons clear of the notch of the
     phone and of the line at the bottom.  The room on the right is the
     place of the button that closes the viewer. */
  padding: calc(var(--s-3) + env(safe-area-inset-top, 0px))
    calc(56px + var(--s-4) + env(safe-area-inset-right, 0px))
    var(--s-3)
    calc(var(--s-4) + env(safe-area-inset-left, 0px));
  border-bottom: none;
  background: transparent;
  color: #fff;
  pointer-events: none;
}
.viewer-title {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.viewer-name {
  color: rgba(255, 255, 255, 0.86);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
}
.viewer-description {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.8125rem;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.viewer-head-actions {
  pointer-events: auto;
  flex: 0 1 auto;
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}
.viewer-head-actions .button {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.32);
  color: #fff;
  backdrop-filter: blur(3px);
}
.viewer-head-actions .button:hover {
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 255, 255, 0.55);
  color: #fff;
}
.viewer-head-actions .button[disabled] {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.55);
}
/* The button that closes the viewer stands in the corner of the screen:
   it is the one that has to be found without reading. */
.viewer-close {
  position: absolute;
  top: calc(var(--s-3) + env(safe-area-inset-top, 0px));
  right: calc(var(--s-4) + env(safe-area-inset-right, 0px));
  z-index: 4;
  width: 44px;
  height: 44px;
  min-height: 44px;
  min-width: 44px;
  padding: 0;
  border-radius: var(--r-full);
  font-size: 1.25rem;
  line-height: 1;
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.32);
  color: #fff;
  backdrop-filter: blur(3px);
}
.viewer-close:hover {
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 255, 255, 0.55);
  color: #fff;
}
.viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 44px;
  height: 44px;
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  backdrop-filter: blur(3px);
}
.viewer-nav:hover {
  background: rgba(255, 255, 255, 0.28);
  border-color: rgba(255, 255, 255, 0.55);
  color: #fff;
}
.viewer-prev { left: calc(var(--s-4) + env(safe-area-inset-left, 0px)); }
.viewer-next { right: calc(var(--s-4) + env(safe-area-inset-right, 0px)); }
.viewer-foot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  padding: var(--s-2) calc(var(--s-4) + env(safe-area-inset-right, 0px))
    calc(var(--s-2) + env(safe-area-inset-bottom, 0px))
    calc(var(--s-4) + env(safe-area-inset-left, 0px));
  border-top: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.86);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
  pointer-events: none;
}
/* The buttons fade away when nothing happens. */
.viewer-head,
.viewer-foot,
.viewer-nav { transition: opacity 0.25s ease; }
.viewer.is-idle .viewer-head,
.viewer.is-idle .viewer-foot,
.viewer.is-idle .viewer-nav {
  opacity: 0;
  pointer-events: none;
}

/* --- 16a. The viewer on a finger ------------------------------------------

   A phone is used with a finger and not with a mouse: the buttons have
   to be big enough for a finger, they may not fade away (a finger does
   not find a button that is not there any more), and they may not go
   under the bar of the browser.  The width of a phone is not the width
   of a computer either, so the row of the buttons wraps.

   -------------------------------------------------------------------------- */

@media (pointer: coarse) {
  .viewer-head-actions .button,
  .viewer-close {
    min-height: 48px;
    min-width: 48px;
  }
  .viewer-nav {
    width: 52px;
    height: 52px;
    font-size: 1.75rem;
  }
  /* A finger does not wait for the browser to decide that a tap was a
     double tap, and it does not want the picture of the button either. */
  .viewer-head-actions .button,
  .viewer-close,
  .viewer-nav {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  .viewer-head,
  .viewer-foot {
    -webkit-user-select: none;
    user-select: none;
  }
  /* The buttons stay where they are: a finger looks for them, it does
     not move the mouse to make them come back. */
  .viewer.is-idle .viewer-head { opacity: 1; }
  .viewer.is-idle .viewer-foot,
  .viewer.is-idle .viewer-nav {
    opacity: 1;
    pointer-events: auto;
  }
}

/* --- 16b. The viewer on a narrow screen -----------------------------------

   The width of a phone is not the width of a computer: the title keeps
   its own row, the buttons wrap under it and the whole bar hugs the
   screen.  These rules stand after the rules of the viewer itself, so
   that they are not overwritten by them.

   -------------------------------------------------------------------------- */

@media (max-width: 599px) {
  .viewer-head {
    flex-wrap: wrap;
    padding: calc(var(--s-2) + env(safe-area-inset-top, 0px))
      calc(48px + var(--s-3) + env(safe-area-inset-right, 0px))
      var(--s-2)
      calc(var(--s-3) + env(safe-area-inset-left, 0px));
    gap: var(--s-2);
  }
  .viewer-title {
    /* The title keeps its own row: the buttons may not push it away. */
    flex: 1 0 100%;
  }
  .viewer-name {
    font-size: 0.8125rem;
  }
  .viewer-close {
    top: calc(var(--s-2) + env(safe-area-inset-top, 0px));
    right: calc(var(--s-3) + env(safe-area-inset-right, 0px));
    /* 44 px is the smallest a finger may hit; under a finger it grows to
       48 px (the rule of the block above). */
    width: 44px;
    height: 44px;
  }
  .viewer-head-actions {
    flex: 1 1 100%;
    flex-wrap: wrap;
    gap: var(--s-1);
  }
  .viewer-head-actions .button {
    flex: 0 1 auto;
    padding: var(--s-1) var(--s-3);
  }
  .viewer-fit-long { display: none; }
  .viewer-fit-short { display: inline; }
}

/* The description of a picture, under the picture in the gallery. */
.gallery-caption {
  margin: var(--s-2) 0 0;
  padding: 0 var(--s-3) var(--s-2);
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.8125rem;
  line-height: 1.4;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
  max-width: 60ch;
}

/* The description of the picture in the viewer, next to its name. */
.viewer-description {
  font-size: 0.8125rem;
  color: rgba(255, 255, 255, 0.72);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* The settings of a picture in the form: the description and the filter. */
.upload-list[data-upload-list="media"] .upload-item { width: 268px; }
.upload-picture {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  margin-top: var(--s-2);
}
.upload-item input[type="text"].upload-description { width: 100%; }
.upload-filter summary {
  font-size: 0.72rem;
  color: var(--text-2);
  cursor: pointer;
}
.upload-filter-body {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  margin-top: var(--s-2);
}
.filter-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "label value" "slider slider";
  gap: 2px var(--s-2);
  align-items: center;
}
.filter-row label {
  grid-area: label;
  font-size: 0.68rem;
  color: var(--text-2);
}
.filter-value {
  grid-area: value;
  font-size: 0.68rem;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.filter-row input[type="range"] {
  grid-area: slider;
  width: 100%;
  margin: 0;
}

/* A person that a comment mentions (CMT-6). */
.mention {
  color: var(--brand);
  font-weight: 600;
  background: var(--brand-soft);
  border-radius: var(--r-xs);
  padding: 0 3px;
}
.comment-mentions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
  margin: var(--s-2) 0 0;
}
.mention-chip {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 999px;
  padding: 2px 10px;
}
/* The box that suggests the persons of a mention. */
.mention-suggestions {
  list-style: none;
  margin: 0;
  padding: var(--s-1);
  z-index: 40;
  min-width: 220px;
  max-width: 340px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
}
.mention-suggestion {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: var(--s-2);
  border-radius: var(--r-xs);
  cursor: pointer;
  font-size: 0.875rem;
}
.mention-suggestion.is-active,
.mention-suggestion:hover {
  background: var(--brand-soft);
}
.mention-suggestion-name { color: var(--text); font-weight: 600; }
.mention-suggestion-username { color: var(--text-3); font-size: 0.75rem; }

/* --- 17. Public browsing -------------------------------------------------- */

.browse-search {
  display: flex;
  gap: var(--s-3);
  align-items: flex-end;
  margin-bottom: var(--s-4);
}
.browse-search .field { flex: 1 1 auto; margin-bottom: 0; min-width: 0; }
.browse-search input[type="search"] {
  height: 42px;
  font-size: 1rem;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%2378838f' stroke-width='1.6' d='M11.3 11.3 15 15M7 12.5a5.5 5.5 0 1 1 0-11 5.5 5.5 0 0 1 0 11z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left var(--s-3) center;
  padding-left: var(--s-8);
}
.browse-search .button { min-height: 42px; }

/* The categories are a row of tabs: one click filters the list. */
.browse-tabs {
  display: flex;
  gap: var(--s-2);
  overflow-x: auto;
  padding-bottom: var(--s-2);
  margin-bottom: var(--s-4);
  border-bottom: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}
.browse-tab {
  flex: 0 0 auto;
  padding: var(--s-2) var(--s-4);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.browse-tab:hover {
  color: var(--text);
  border-color: var(--brand-line);
}
.browse-tab.is-on {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
}

/* The filter options fold away; the view sits beside them on its own. */
.browse-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  flex-wrap: wrap;
  margin-bottom: var(--s-4);
}
.browse-filters {
  flex: 1 1 320px;
  margin: 0;
  padding: var(--s-3) var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.browse-filters .filter-grid { margin-top: var(--s-3); }
.browse-filters .form-actions { margin-top: var(--s-3); }

.view-switch {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.view-switch-button {
  padding: var(--s-2) var(--s-4);
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-2);
  text-decoration: none;
  white-space: nowrap;
}
.view-switch-button:hover { color: var(--text); }
.view-switch-button.is-on {
  background: var(--surface);
  color: var(--brand-deep);
  box-shadow: var(--shadow-1);
}

.link-plain {
  color: inherit;
  text-decoration: none;
}
.link-plain:hover { text-decoration: underline; }

/* --- 12. The QC domain ----------------------------------------------------
   The pages of the QC system: the list of the productions, the page of a
   production with its batches and its timeline, the modals and the history.
   The colours of the statuses come from /status.css and never change with
   the theme.
   ------------------------------------------------------------------------- */

/* The list of the productions */
.qc-table { width: 100%; }
.qc-table td { vertical-align: top; }
.qc-table .qc-value { font-weight: 500; }
.qc-table small { display: block; color: var(--text-3); }
.qc-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  align-items: flex-end;
  margin-bottom: var(--s-4);
}
.qc-filters .field { margin-bottom: 0; }
.qc-inline-form { display: inline; }
.qc-stretch { width: 100%; }

/* The filters of the list: the search box stays open, the other filters
   live in a panel that folds itself away.  The badge tells how many of them
   differ from the defaults. */
.qc-filter-groups {
  flex: 1 1 100%;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2, var(--surface));
}
.qc-filter-summary {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  cursor: pointer;
  font-weight: 550;
  color: var(--text-2);
  list-style: none;
}
.qc-filter-summary::-webkit-details-marker { display: none; }
.qc-filter-summary::before {
  content: "▸";
  display: inline-block;
  color: var(--text-3);
  transition: transform 0.15s ease;
}
.qc-filter-groups[open] > .qc-filter-summary::before { transform: rotate(90deg); }
.qc-filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--r-full);
  background: var(--brand);
  color: var(--brand-ink);
  font-size: 12px;
  font-weight: 650;
}
.qc-filter-group {
  margin: 0;
  padding: var(--s-3);
  border: 0;
  border-top: 1px solid var(--border);
}
.qc-filter-group legend {
  padding: 0 var(--s-2);
  color: var(--text-3);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.qc-filter-fields {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  align-items: flex-end;
}
.qc-filter-fields .field { margin-bottom: 0; }
.qc-field-label {
  display: block;
  margin-bottom: var(--s-1);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 550;
}
.qc-filter-groups .filter-actions {
  display: flex;
  gap: var(--s-2);
  justify-content: flex-end;
  padding: var(--s-3);
  border-top: 1px solid var(--border);
}

/* A late production (PRD-6): a light red ground and a red bar on the left.
   The text of the countdown always says it too, the colour is never the
   only signal. */
.overdue {
  background: #FEE2E2;
}
.overdue > td:first-child { border-left: 4px solid #DC2626; }
.qc-table tbody tr.overdue:hover { background: #fddcdc; }

/* The page of a production */
.qc-layout {
  display: grid;
  grid-template-columns: minmax(240px, 300px) 1fr;
  gap: var(--s-5);
  align-items: start;
}
.qc-batches { position: sticky; top: calc(var(--header-height) + var(--s-4)); }
/* The timeline of the batch that is chosen: the browser puts it here when
   the batch changes, so the page is not loaded again. */
.qc-timeline-slot { min-width: 0; }
.qc-batch-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  /* The list has no bullet of its own: the card of the batch is the mark. */
  list-style: none;
  margin: 0;
  padding: 0;
}
.qc-batch-link {
  display: block;
  padding: var(--s-3);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
}
.qc-batch-link:hover { border-color: var(--brand-line); }
.qc-batch-link.is-selected,
.qc-batch-link[aria-current="true"] {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.qc-batch-code { display: block; font-weight: 600; }
.qc-batch-count,
.qc-batch-time { display: block; font-size: 12px; color: var(--text-3); }
.qc-batch-actions { margin-top: var(--s-2); display: flex; gap: var(--s-2); }
.qc-add-batch { margin-top: var(--s-3); }

/* The timeline of a batch */
.qc-timeline { display: flex; flex-direction: column; gap: var(--s-3); }
.qc-activity-head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
}
.qc-activity-time { font-size: 12px; color: var(--text-3); }
.qc-activity-text { margin: var(--s-2) 0 0; color: var(--text-2); }
/* The activity that is open is written in bold. */
.qc-activity.is-selected .qc-activity-text {
  color: var(--text);
  font-weight: 700;
}
.qc-activity.is-selected .qc-activity-head .status-chip {
  outline: 2px solid var(--brand-line);
  outline-offset: 2px;
}
.qc-assessment { white-space: pre-wrap; }
/* The result of the assessment and the change request stand side by side, so
   that neither of them takes the room of the other. */
.qc-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--s-4);
  align-items: stretch;
}
/* Both blocks wear the same frame, so that they are read as one pair. */
.qc-detail-block {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
/* The title of a block is bigger and bolder than the text under it: the
   reader sees at once what the text is about. */
.qc-detail-block .stat-label {
  margin-bottom: var(--s-2);
  color: var(--text-2);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
/* The pictures of the activity stand a little apart from the text above
   them: the text and the pictures are read as two different things. */
.qc-modal-body .qc-gallery { margin-top: var(--s-4); }
.qc-change-request {
  background: var(--warning-bg);
  border-color: var(--warning-border);
}
/* The white space of the text is kept in the text itself; the frame around
   it keeps none, or the empty lines of the source would take the room. */
.qc-change-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.qc-activity-meta { font-size: 12px; color: var(--text-3); }
.qc-note {
  margin: var(--s-3) 0;
  color: var(--text-3);
  font-size: 13px;
}
/* The days that are left before the packing date, at the head of the page. */
.qc-countdown {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  margin-top: var(--s-2);
  padding: var(--s-1) var(--s-3);
  border-radius: var(--r-full);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 0.8125rem;
  font-weight: 650;
}
.qc-countdown.is-overdue {
  background: var(--danger-soft);
  color: var(--danger);
}
.qc-countdown.is-accepted {
  background: var(--success-soft);
  color: var(--success);
}

/* The gallery of an activity: every picture is a small square, and every
   one of them opens the viewer. */
.qc-gallery { display: flex; flex-direction: column; gap: var(--s-2); }
.qc-gallery-grid {
  background: var(--surface-3);
  border-radius: var(--r-sm);
  padding: var(--s-2);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--s-2);
  align-items: start;
}
.qc-gallery-item { margin: 0; min-width: 0; }
.qc-gallery-item img,
.qc-gallery-item video {
  display: block;
  width: 100%;
  border-radius: var(--r-xs);
  background: var(--surface);
  cursor: pointer;
}
.qc-gallery-item figcaption {
  margin-top: var(--s-1);
  font-size: 11px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.qc-gallery-item .button { margin-top: var(--s-1); }
/* In the window of an activity the pictures lie on the ground of the window:
   the grey panel of the page would show an empty space beside them. */
.qc-modal-body .qc-gallery-grid {
  background: transparent;
  padding: 0;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

/* The sample slab of a production */
.qc-sample-strip {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-top: var(--s-2);
}
.qc-sample-item {
  width: 96px;
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
}
.qc-sample-item img { width: 100%; border-radius: var(--r-xs); }

/* The modals (the HTML dialog element) */
dialog.qc-modal {
  width: min(960px, 94vw);
  max-height: 90vh;
  padding: 0;
  border: none;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  background: var(--surface);
}
dialog.qc-modal::backdrop { background: rgba(16, 24, 40, 0.55); }
.qc-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-4);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
/* The status and the meta of the activity stand together at the left; the
   button that closes the window stands alone at the right. */
.qc-modal-title {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
  min-width: 0;
}
.qc-modal-meta {
  color: var(--text-3);
  font-size: 0.8125rem;
}
.qc-modal-body { padding: var(--s-4); overflow: auto; max-height: 70vh; }
.qc-modal-section { margin: var(--s-5) 0; }
.qc-modal-section h3 { margin: 0 0 var(--s-3); }
.qc-modal-foot {
  display: flex;
  gap: var(--s-2);
  justify-content: flex-end;
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--border);
}

/* The history */
.qc-history-panel { display: flex; flex-direction: column; gap: var(--s-3); }
.qc-history-filters { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* The comments */
.qc-comment-form { margin-top: var(--s-3); }
.qc-reply {
  margin-left: var(--s-4);
  padding-left: var(--s-3);
  border-left: 2px solid var(--border);
}

/* The uploads */
.qc-upload-section { margin-top: var(--s-3); }
.qc-upload-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-top: var(--s-2);
}
.qc-upload-item {
  width: 120px;
  font-size: 11px;
  color: var(--text-3);
  text-align: center;
}
.qc-upload-item img { width: 100%; border-radius: var(--r-xs); }
.qc-form .field { margin-bottom: var(--s-3); }

/* The status of an activity: a dropdown whose rows wear the colour of the
   status they carry.  The panel leaves the flow of the page, because the
   frame of the modal would cut it. */
.qc-status-select { position: relative; }
.qc-status-summary {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  width: 100%;
  min-height: 34px;
  padding: 0 var(--s-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  list-style: none;
}
.qc-status-summary::-webkit-details-marker { display: none; }
.qc-status-summary::after {
  content: "▾";
  margin-left: auto;
  color: var(--text-3);
  font-size: 0.75rem;
}
.qc-status-panel {
  position: fixed;
  z-index: 320;
  top: auto;
  left: auto;
  min-width: 240px;
  max-height: 260px;
  overflow: auto;
  padding: var(--s-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  box-shadow: var(--shadow-3);
}
.qc-status-option {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-1) var(--s-2);
  border-radius: var(--r-sm);
  cursor: pointer;
  white-space: nowrap;
}
.qc-status-option:hover { background: var(--surface-3); }
.qc-status-option input { margin: 0; }

/* The small colour bar of a status */
.status-bar { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }

/* On a narrow screen the batch list becomes a selector above the timeline. */
@media (max-width: 860px) {
  .qc-layout { grid-template-columns: 1fr; }
  .qc-batches { position: static; }
  .qc-batch-list { flex-direction: row; overflow-x: auto; }
  .qc-batch-link { min-width: 200px; }
}

/* On a narrow screen the table of the list becomes stacked rows that still
   show the five values in the same order (LST-7). */
@media (max-width: 599px) {
  .qc-table thead { display: none; }
  .qc-table,
  .qc-table tbody,
  .qc-table tr,
  .qc-table td { display: block; width: 100%; }
  .qc-table tr {
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    margin-bottom: var(--s-3);
    padding: var(--s-2) 0;
  }
  .qc-table td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--s-3);
    padding: var(--s-1) var(--s-3);
    border: 0;
  }
  .qc-table td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    font-weight: 600;
    color: var(--text-3);
  }
}

/* --- 18. The date picker -------------------------------------------------
   The calendar of the application.  It lives at the end of the body (or of
   the dialog that holds the form), so that no frame of the page can cut it,
   and it follows the field it belongs to.
   ------------------------------------------------------------------------- */

.dp {
  position: relative;
  display: block;
}
.dp .dp-field {
  padding-right: 38px;
  cursor: pointer;
  background-image: none;
}
.dp .dp-field:hover {
  border-color: var(--brand-line);
}
.dp .dp-field:focus-visible {
  outline: 2px solid var(--brand-ring);
  outline-offset: 1px;
}
.dp::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  pointer-events: none;
  opacity: 0.6;
  background-repeat: no-repeat;
  background-size: contain;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2378838f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M8 3v4M16 3v4M3 10h18'/%3E%3C/svg%3E");
}

.dp-popover {
  position: fixed;
  z-index: 500;
  width: 288px;
  padding: var(--s-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-3);
  font-size: 0.875rem;
  color: var(--text);
}
.dp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  margin-bottom: var(--s-2);
}
.dp-title {
  font-weight: 650;
  font-size: 0.9375rem;
}
.dp-nav {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.dp-nav:hover {
  background: var(--surface-3);
  color: var(--text);
}
.dp-week,
.dp-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.dp-week {
  margin-bottom: var(--s-1);
}
.dp-weekday {
  padding: var(--s-1) 0;
  text-align: center;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
}
.dp-day {
  height: 34px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.dp-day:hover {
  background: var(--surface-3);
}
.dp-day.dp-outside {
  color: var(--text-3);
  opacity: 0.55;
}
.dp-day.dp-today {
  border-color: var(--brand-line);
  font-weight: 700;
}
.dp-day.dp-selected {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-ink);
  font-weight: 700;
}
.dp-time {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: 1px solid var(--border);
}
.dp-select {
  padding: var(--s-1) var(--s-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-variant-numeric: tabular-nums;
}
.dp-time-sep {
  color: var(--text-3);
}
.dp-foot {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: 1px solid var(--border);
}
.dp-foot button {
  padding: var(--s-1) var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
}
.dp-foot button:hover {
  background: var(--surface-3);
  color: var(--text);
}
.dp-foot .dp-close {
  margin-left: auto;
}
