@layer legacy;
@import url("../app.css") layer(legacy);

/* Existing demo CSS provides the layout, editor, cards and Safari date sizing. */
:root {
  /* Scale rem-based typography as well as the pixel-based legacy labels. */
  font-size: calc(16px * var(--erp-font-scale, 1));
}
body {
  font-family: var(--erp-body-font-family, var(--erp-font-family, system-ui, -apple-system, "Segoe UI", sans-serif));
  font-size: calc(15px * var(--erp-font-scale, 1));
  font-weight: var(--erp-body-font-weight, revert-layer);
}
/* The administrator can set each text role independently. */
h1, h2, .brand {
  font-family: var(--erp-heading-font-family, inherit);
  font-weight: var(--erp-heading-font-weight, revert-layer);
}
h1 { font-size: clamp(calc(26px * var(--erp-heading-font-scale, 1)), 3vw, calc(35px * var(--erp-heading-font-scale, 1))); }
h2 { font-size: calc(20px * var(--erp-heading-font-scale, 1)); }
.brand { font-size: calc(21px * var(--erp-heading-font-scale, 1)); }
h3, h4, .eyebrow {
  font-family: var(--erp-subheading-font-family, inherit);
  font-weight: var(--erp-subheading-font-weight, revert-layer);
}
h3 { font-size: calc(17px * var(--erp-subheading-font-scale, 1)); }
h4 { font-size: calc(15px * var(--erp-subheading-font-scale, 1)); }
.eyebrow { font-size: calc(11px * var(--erp-subheading-font-scale, 1)); }
button, .btn, .erp-theme-preview__button {
  font-family: var(--erp-button-font-family, inherit);
  font-weight: var(--erp-button-font-weight, revert-layer);
  font-size: calc(15px * var(--erp-button-font-scale, 1));
}
input,
select,
textarea {
  /* At least 16px on iOS prevents the automatic focus-zoom effect. */
  font-size: max(16px, calc(15px * var(--erp-field-font-scale, 1)));
  font-family: var(--erp-field-font-family, inherit);
  font-weight: var(--erp-field-font-weight, revert-layer);
}
label {
  font-family: var(--erp-field-font-family, inherit);
  font-size: calc(13px * var(--erp-field-font-scale, 1));
  font-weight: var(--erp-field-font-weight, revert-layer);
}
[hidden] {
  display: none !important;
}
.erp-offline-banner {
  padding: 12px 20px;
  border-bottom: 1px solid #a97725;
  background: #fff0d0;
  color: #442900;
  text-align: center;
  font-weight: 650;
  line-height: 1.4;
}
.login-panel {
  max-width: 520px;
  margin: 24px auto;
}
.panel:not(.form-panel) {
  padding: 22px;
}
.login-panel input {
  width: 100%;
}
.login-panel .field {
  margin-bottom: 18px;
}
.document-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.busy-note {
  color: var(--muted);
}
td,
#identity {
  overflow-wrap: anywhere;
}
.receipt-time {
  font-variant-numeric: tabular-nums;
}
@media (max-width: 600px) {
  .brand {
    font-size: calc(18px * var(--erp-font-scale, 1));
  }
  .topbar {
    padding: 16px;
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .form-actions .btn {
    width: 100%;
  }
  /* Narrow iPad/Safari viewport: buttons must not retain intrinsic width
     or shrink into tall, irregular shapes in wrapped navigation rows. */
  .time-tabs {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }
  .time-tabs .btn,
  .pagehead .btn,
  .form-actions .btn {
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    min-height: 48px;
    height: auto;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
    flex-shrink: 1;
    text-align: center;
  }
  .pagehead > .row {
    width: 100%;
    min-width: 0;
  }
  .pagehead > .row .btn {
    flex: 1 1 100%;
  }
}

.erp-module-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.pagehead {
  flex-wrap: wrap;
}
.pagehead > div:first-child {
  flex: 1 1 320px;
  min-width: 0;
}
.pagehead > .row {
  max-width: 100%;
}
.pagehead .btn {
  white-space: nowrap;
  overflow-wrap: normal;
  flex-shrink: 0;
}
.erp-module {
  min-height: 160px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 10px;
  padding: 22px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  white-space: normal;
}
.erp-module:hover {
  border-color: var(--brand);
  background: #fffaf6;
}
.erp-module-icon {
  font-size: calc(26px * var(--erp-font-scale, 1));
  color: var(--brand);
}
.erp-review {
  min-width: 200px;
  margin-top: 12px;
}
.erp-review input {
  width: 100%;
  margin-bottom: 8px;
}
.work-entry-table td {
  overflow-wrap: anywhere;
  vertical-align: top;
}
.work-entry-table td:nth-child(5) {
  white-space: nowrap;
}
/* At iPad widths, or when the page is zoomed, show labeled entries instead
   of clipping the rightmost customer, reference or approval controls. */
@media screen and (max-width: 1420px) {
  .work-entry-table,
  .work-entry-table tbody,
  .work-entry-table tr,
  .work-entry-table td {
    display: block;
    box-sizing: border-box;
    width: 100%;
  }
  .work-entry-table thead { display: none; }
  .work-entry-table tr {
    border: 1px solid var(--line);
    border-radius: 10px;
    margin: 12px 0;
    padding: 12px;
  }
  .work-entry-table td {
    min-width: 0 !important;
    padding: 8px 4px;
    border: 0;
    white-space: normal;
  }
  .work-entry-table td::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 5px;
  }
  .work-entry-table td[data-empty]::before { display: none; }
  .work-entry-table .erp-review { min-width: 0; }
}
.form-panel fieldset {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.erp-report h2 {
  margin-top: 22px;
}
#calculatedTime {
  display: block;
  font-size: calc(24px * var(--erp-font-scale, 1));
}
@media (max-width: 1000px) {
  .erp-module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 600px) {
  .erp-module-grid {
    grid-template-columns: 1fr;
  }
  .metrics {
    grid-template-columns: 1fr;
  }
  .erp-module {
    min-height: 130px;
  }
}
@media print {
  .topbar,
  aside,
  .demo-banner,
  footer,
  .erp-no-print,
  .pagehead button,
  #feedback {
    display: none !important;
  }
  .layout {
    display: block;
  }
  main {
    padding: 0;
  }
  .panel {
    border: 0;
  }
  .table-scroll {
    overflow: visible;
  }
  table {
    font-size: 10pt;
  }
  tr {
    break-inside: avoid;
  }
}

/* Reuse existing field sizing for iPad native date/time/file controls. */
.material-lines {
  display: grid;
  gap: 16px;
  margin: 16px 0;
}
.material-line {
  min-width: 0;
}
.receipt-list {
  list-style: none;
  padding: 0;
}
.receipt-list li {
  border-top: 1px solid var(--line);
  padding: 16px 0;
}
.receipt-hash {
  overflow-wrap: anywhere;
}
#receiptForm input[type="file"] {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 48px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface, #fff);
  color: inherit;
  font: inherit;
}
#receiptForm {
  max-width: 680px;
}
#receiptForm .btn {
  margin: 12px 0;
}
.material-line .btn {
  margin-top: 12px;
}

.stock-panel {
  margin-bottom: 22px;
}
.stock-panel .row,
.report-extra .row {
  flex-wrap: wrap;
}
.stock-panel select {
  max-width: 100%;
  width: 100%;
}
.audit-list {
  padding-left: 22px;
  overflow-wrap: anywhere;
}
.audit-list li {
  margin: 12px 0;
}
.receipt-preview-image {
  max-width: 100%;
  height: auto;
  display: block;
}
.report-company {
  padding: 12px 0;
}
@media (max-width: 600px) {
  .stock-panel .row .btn {
    width: 100%;
    white-space: normal;
  }
  .stock-panel .table-scroll {
    max-width: 100%;
  }
}
@media print {
  .report-extra button,
  .erp-report .toolbar {
    display: none !important;
  }
  .report-company {
    font-size: 12pt;
  }
}

.stock-table td:last-child {
  min-width: 205px;
}
.stock-table .btn {
  white-space: normal;
  overflow-wrap: normal;
}
@media (max-width: 1100px) {
  .stock-panel .stock-table,
  .stock-table tbody,
  .stock-table tr,
  .stock-table td {
    display: block;
    width: 100%;
  }
  .stock-table thead {
    display: none;
  }
  .stock-table tr {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px;
    margin: 14px 0;
  }
  .stock-table td {
    border: 0;
    padding: 8px;
    min-width: 0 !important;
  }
  .stock-table td::before {
    display: block;
    color: var(--muted);
    font-size: calc(11px * var(--erp-font-scale, 1));
    font-weight: 700;
    margin-bottom: 5px;
  }
  .stock-table td:nth-child(1)::before {
    content: "NIMIKE";
  }
  .stock-table td:nth-child(2)::before {
    content: "SALDO";
  }
  .stock-table td:nth-child(3)::before {
    content: "HÄLYTYSRAJA";
  }
  html[lang="en"] .stock-table td:nth-child(1)::before { content: "ITEM"; }
  html[lang="en"] .stock-table td:nth-child(2)::before { content: "BALANCE"; }
  html[lang="en"] .stock-table td:nth-child(3)::before { content: "REORDER LEVEL"; }
  html[lang="sv"] .stock-table td:nth-child(1)::before { content: "ARTIKEL"; }
  html[lang="sv"] .stock-table td:nth-child(2)::before { content: "SALDO"; }
  html[lang="sv"] .stock-table td:nth-child(3)::before { content: "LARMGRÄNS"; }
  html[lang="et"] .stock-table td:nth-child(1)::before { content: "KAUP"; }
  html[lang="et"] .stock-table td:nth-child(2)::before { content: "JÄÄK"; }
  html[lang="et"] .stock-table td:nth-child(3)::before { content: "HOIATUSPIIR"; }
  .stock-table td:last-child .row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 155px), 1fr));
    gap: 8px;
  }
  .stock-table .btn {
    width: 100%;
    min-height: 48px;
  }
}

.report-presets {
  flex-wrap: wrap;
  gap: 8px;
}
.travel-table {
  table-layout: fixed;
  width: 100%;
}
.travel-table th:nth-child(1) {
  width: 34%;
}
.travel-table th:nth-child(2) {
  width: 29%;
}
.travel-table th:nth-child(3) {
  width: 37%;
}
.travel-table td {
  overflow-wrap: break-word;
  word-break: normal;
}
.travel-table .erp-review {
  min-width: 0;
}
.travel-table .check {
  align-items: flex-start;
}
.travel-table .check input {
  flex: 0 0 auto;
  width: 20px;
  min-height: 20px;
  margin-top: 3px;
}
.travel-table .btn {
  min-height: 48px;
  white-space: normal;
  overflow-wrap: normal;
}
.travel-table .erp-review .row {
  display: grid;
  gap: 8px;
}
.policy-list {
  list-style: none;
  padding: 0;
}
.policy-list > li {
  border-top: 1px solid var(--line);
  padding: 16px 0;
  overflow-wrap: anywhere;
}
@media screen and (max-width: 1200px) {
  .travel-table,
  .travel-table tbody,
  .travel-table tr,
  .travel-table td {
    display: block;
    width: 100%;
  }
  .travel-table thead {
    display: none;
  }
  .travel-table tr {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px;
    margin: 14px 0;
  }
  .travel-table td {
    border: 0;
    padding: 10px 4px;
    min-width: 0;
  }
  .travel-table td::before {
    display: block;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 6px;
  }
  .travel-table td:nth-child(1)::before {
    content: "HENKILÖ / MATKA";
  }
  .travel-table td:nth-child(2)::before {
    content: "KORVAUKSET";
  }
  .travel-table td:nth-child(3)::before {
    content: "TILA JA KÄSITTELY";
  }
  html[lang="en"] .travel-table td:nth-child(1)::before { content: "PERSON / TRIP"; }
  html[lang="en"] .travel-table td:nth-child(2)::before { content: "REIMBURSEMENTS"; }
  html[lang="en"] .travel-table td:nth-child(3)::before { content: "STATUS AND ACTIONS"; }
  html[lang="sv"] .travel-table td:nth-child(1)::before { content: "PERSON / RESA"; }
  html[lang="sv"] .travel-table td:nth-child(2)::before { content: "ERSÄTTNINGAR"; }
  html[lang="sv"] .travel-table td:nth-child(3)::before { content: "STATUS OCH ÅTGÄRDER"; }
  html[lang="et"] .travel-table td:nth-child(1)::before { content: "TÖÖTAJA / LÄHETUS"; }
  html[lang="et"] .travel-table td:nth-child(2)::before { content: "HÜVITISED"; }
  html[lang="et"] .travel-table td:nth-child(3)::before { content: "OLEK JA TOIMINGUD"; }
  .travel-table .btn {
    width: 100%;
  }
}

.field,
.form-grid > *,
.check {
  min-width: 0;
}
.check {
  align-items: flex-start;
  width: 100%;
  min-height: 44px;
  gap: 12px;
  line-height: 1.5;
}
.check > span {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: normal;
}
.form-panel .field input[type="checkbox"],
.form-panel input[type="checkbox"],
.check input[type="checkbox"],
.erp-review .check input[type="checkbox"],
input[type="radio"] {
  box-sizing: border-box;
  display: inline-block;
  flex: 0 0 20px;
  width: 20px;
  min-width: 20px;
  max-width: 20px;
  height: 20px;
  min-height: 20px;
  max-height: 20px;
  padding: 0;
  margin: 2px 0 0;
}
.form-grid > .check {
  align-self: center;
}
textarea {
  font-size: calc(16px * var(--erp-font-scale, 1));
}
.audience-options {
  border: 1px solid var(--line);
  padding: 16px;
  border-radius: 8px;
}
.audience-options legend {
  font-weight: 700;
}
.audience-choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
  gap: 16px;
  margin-top: 16px;
}
.audience-checklist {
  max-height: 280px;
  overflow-y: auto;
  padding: 4px;
}
.audience-checklist .check {
  padding: 8px 0;
  margin: 0;
  min-height: 44px;
}
.audience-preview {
  padding: 12px;
  background: #f5f6f2;
  border-radius: 8px;
  margin-top: 14px;
}
.audience-options .check {
  font-size: calc(16px * var(--erp-font-scale, 1));
}

.form-actions {
  align-items: flex-start;
}
.publication-review {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  flex: 1 0 100%;
  min-width: 0;
}
.publication-review > .btn {
  justify-self: start;
  align-self: start;
  min-height: 48px;
  height: auto;
  line-height: 1.2;
  padding: 8px 12px;
  white-space: normal;
  overflow-wrap: break-word;
}
.publication-review .audience-preview {
  margin: 0;
  overflow-wrap: anywhere;
}
.publication-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px;
}
.publication-buttons > .btn {
  min-width: 0;
  max-width: 100%;
  min-height: 48px;
  height: auto;
  white-space: normal;
  overflow-wrap: break-word;
}
@media (max-width: 600px) {
  .publication-review > .btn,
  .publication-buttons > .btn {
    width: 100%;
    justify-self: stretch;
  }
}
.receipt-history table {
  table-layout: fixed;
  width: 100%;
}
.receipt-history th,
.receipt-history td {
  overflow-wrap: anywhere;
  word-break: normal;
  vertical-align: top;
}
.receipt-technical {
  min-width: 0;
  max-width: 100%;
}
.receipt-technical summary {
  white-space: normal;
  overflow-wrap: anywhere;
}
.receipt-technical dl {
  margin: 8px 0;
}
.receipt-technical dd {
  margin: 4px 0 12px;
}
.receipt-technical code {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
@media (max-width: 600px) {
  .receipt-history table {
    min-width: 540px;
  }
}

/* One sizing authority, above legacy specificity and without iOS theme sizing.
   appearance:none changes the chrome, NOT the input type or native picker. */
:root {
  --erp-control-height: 48px;
}
:where(
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not(
      [type="file"]
    ):not([type="range"]):not([type="color"]):not([type="button"]):not(
      [type="submit"]
    ),
  select:not([multiple])
) {
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: var(--erp-control-height);
  min-height: 0;
  margin: 0;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: #fff;
  color: var(--ink);
  font: inherit;
  font-size: calc(16px * var(--erp-font-scale, 1));
  line-height: normal;
  text-align: start;
}
/* Keep the platform menu affordance and interaction on Safari/iPadOS.
   Shared 48px sizing remains; inputs retain their separate date/time styling. */
select:not([multiple]) {
  -webkit-appearance: menulist;
  appearance: auto;
  background-image: none;
}
/* The company panel shares the administration content track. Other compact
   editors intentionally keep the legacy form-panel width cap. */
#companyForm {
  max-width: none;
  width: 100%;
  box-sizing: border-box;
}

input::-webkit-date-and-time-value {
  min-height: 0;
  margin: 0;
  padding: 0;
  text-align: start;
}
/* Center the native shadow content, whether WebKit uses a value div or a
   segmented editor. The existing 48px border box and normal line height stay. */
input:is([type="date"], [type="month"], [type="time"]) {
  display: flex;
  align-items: center;
}
input::-webkit-datetime-edit {
  padding: 0;
}
.registry-field {
  display: block;
  box-sizing: border-box;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 16px 0;
  padding: 16px;
  min-width: 0;
}
.registry-field legend {
  max-width: 100%;
  overflow-wrap: anywhere;
}
.registry-field .field {
  min-width: 0;
}
.registry-records dl,
.registry-records dd {
  margin-inline: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.registry-records dt {
  font-weight: 600;
  margin-top: 12px;
}
.registry-id {
  overflow-wrap: anywhere;
}
.registry-records .row {
  flex-wrap: wrap;
}
/* Shared label/control tracks: end-alignment of whole wrappers hid the
   difference in control sizing and pushed shorter wrappers' labels down. */
.erp-report .toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
  align-items: start;
  column-gap: 18px;
  row-gap: 6px;
}
.erp-report .toolbar > div,
#workPeriodForm > .field:not(.full) {
  display: grid;
  grid-template-rows: minmax(3em, auto) var(--erp-control-height);
  gap: 6px;
  min-width: 0;
  align-content: start;
}
.erp-report .toolbar label,
#workPeriodForm > .field:not(.full) > label {
  margin: 0;
}
@supports (grid-template-rows: subgrid) {
  .erp-report .toolbar > div,
  #workPeriodForm > .field:not(.full) {
    grid-row: span 2;
    grid-template-rows: subgrid;
  }
}
.form-grid {
  align-items: start;
}

/* Register transfers reuse the native controls and full-width content track. */
.registry-transfer {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}
.transfer-value {
  max-width: 32rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.maintenance-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.maintenance-summary {
  border-top: 1px solid var(--border, #c6d3d9);
  margin-top: 1rem;
  padding-top: 1rem;
}
#maintenanceForm .full {
  grid-column: 1 / -1;
  min-width: 0;
}

.clock-panel,
.clock-admin {
  min-width: 0;
  overflow-wrap: anywhere;
}
.clock-panel .full,
.clock-finish .full {
  grid-column: 1 / -1;
}
.clock-admin {
  border-top: 1px solid var(--border, #c6d3d9);
  padding-block: 1rem;
}
.clock-panel button,
.clock-finish button {
  min-height: 48px;
}
@media (max-width: 600px) {
  .clock-panel .form-actions,
  .clock-finish .form-actions {
    display: grid;
    width: 100%;
  }
}

/* Mobile-first, server-backed clock: essential fields always visible, extras optional. */
.clock-panel {
  max-width: 760px;
}
.clock-panel #clockInForm {
  align-items: end;
}
.clock-panel select {
  width: 100%;
  min-height: 48px;
}
.clock-panel .form-actions.clock-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  max-width: 24rem;
  gap: 12px;
}
.clock-panel .clock-actions .btn {
  width: 100%;
  min-height: 60px;
  border-radius: 12px;
  background: #317a25;
  border-color: #317a25;
  color: white;
  font-size: 1.15rem;
  font-weight: 750;
}
/* Keep the one-tap start in reach; all optional fields remain expanded below. */
.clock-panel #clockInForm .clock-actions {
  grid-row: 1;
}
.clock-active {
  padding: 18px;
  background: #f2f7f2;
  border-radius: 12px;
  margin-bottom: 18px;
}
#clockLiveElapsed {
  display: inline-block;
  margin-block: 8px;
  font-size: clamp(24px, 5vw, 38px);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.clock-extra {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 12px;
}
.clock-extra summary {
  cursor: pointer;
  min-height: 36px;
  font-weight: 650;
}
.clock-extra .field {
  margin-top: 14px;
}
@media (max-width: 700px) {
  .clock-panel {
    padding: 18px !important;
  }
  .clock-panel .form-actions .btn {
    width: 100%;
  }
}

/* Native selects and normal document flow remain usable by touch and WebKit. */
.time-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.time-tabs .btn[aria-pressed="true"] {
  background: #27563d;
  color: #fff;
}
.time-card {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.time-card input {
  width: 100%;
  min-height: 44px;
}
#timeReasonsPanel select,
#absenceForm select,
#clockSwitchForm select {
  width: 100%;
  min-height: 48px;
}
.calendar-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 16px 0;
}
.calendar-scroll {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.month-calendar {
  table-layout: fixed;
  width: 100%;
  min-width: 680px;
}
.month-calendar th:first-child {
  width: 42px;
}
.month-calendar td {
  height: 100px;
  vertical-align: top;
  white-space: normal;
  overflow-wrap: anywhere;
  padding: 6px;
}
.month-calendar .other-month {
  background: #f3f3f3;
}
.calendar-event {
  padding: 6px;
  margin: 6px 0;
  border-left: 3px solid #27563d;
  background: #eef5f0;
  font-size: calc(12px * var(--erp-font-scale, 1));
}
.mobile-navigation {
  display: none;
}
[hidden] {
  display: none !important;
}
@media (max-width: 900px) {
  .mobile-navigation:not(:empty) {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 30;
    background: white;
    border-top: 1px solid #bbb;
    padding: 4px 4px max(4px, env(safe-area-inset-bottom));
  }
  .mobile-navigation button {
    min-width: 0;
    min-height: 56px;
    padding: 8px 2px;
    border: 0;
    border-radius: 8px;
    background: white;
    color: #253c30;
    font: inherit;
    font-size: calc(14px * var(--erp-font-scale, 1));
  }
  .mobile-navigation button[aria-current="page"] {
    background: #27563d;
    color: white;
    font-weight: 700;
  }
  body:has(.mobile-navigation:not(:empty)) {
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
  }
  .layout aside {
    display: none;
  }
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .layout main {
    min-width: 0;
  }
  .clock-panel {
    max-width: 100%;
  }
  .time-tabs .btn {
    flex: 1;
    min-height: 48px;
  }
}
@media (max-width: 600px) {
  /* Legacy flex-basis:320px becomes vertical height in a column layout. */
  .pagehead > div:first-child {
    flex: 0 0 auto;
  }
}
@media print {
  .mobile-navigation,
  .time-tabs,
  #authDiagnostics {
    display: none !important;
  }
}
/* 033: no layout-dependent control heights; native selects stay touchable. */
.clock-day {
  display: grid;
  gap: 4px;
  margin-block: 12px;
  font-variant-numeric: tabular-nums;
}
.clock-day strong {
  font-size: clamp(30px, 6vw, 44px);
  font-weight: 600;
}
.clock-day.inactive {
  opacity: 0.6;
}
.mileage-search {
  align-items: end;
}
.mileage-search .field {
  margin: 0;
  flex: 1;
  min-width: 0;
}
.mileage-search input,
.mileage-search .btn {
  height: 48px;
  min-height: 48px;
  box-sizing: border-box;
  margin: 0;
}
.clock-timeline li {
  padding-block: 8px;
  overflow-wrap: anywhere;
}
@media (max-width: 600px) {
  .mileage-search {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }
  .mileage-search .btn {
    width: 100%;
  }
}

/* A purchase table scrolls inside its card; it must not widen the mobile page. */
.purchase-card {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.purchase-card > .table-scroll {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}
.purchase-card > .row {
  min-width: 0;
  max-width: 100%;
}
.purchase-card .row .btn {
  margin-top: 0;
  max-width: 100%;
  white-space: normal;
}

/* 040: every clock action has the same 60px touch area in native Safari. */
.clock-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }
.clock-panel .clock-actions .btn { width: 100%; height: 60px; min-height: 60px; margin: 0; padding: 8px 12px; box-sizing: border-box; }
.clock-actions .btn:only-child { grid-column: 1 / -1; }
.site-selector { grid-column: 1 / -1; min-width: 0; }
.site-selector > [id$="CustomerFields"]:not([hidden]) { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.site-selector > div > p { grid-column: 1 / -1; }
.site-ref-row { padding-block: 10px; overflow-wrap: anywhere; }
.site-admin-list .btn, .site-ref-row .btn { min-height: 48px; margin: 4px; }
.work-conflicts { border: 2px solid #a7412b; padding: 12px; grid-column: 1 / -1; overflow-wrap: anywhere; }
.work-conflicts li { margin-block: 12px; }

/* 017 administrative classification and dated pricing, including narrow touch screens. */
#directoryPanel,
#pricingPanel {
  min-width: 0;
  overflow-wrap: anywhere;
}
#directoryPanel fieldset {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
}
#directoryPanel .check {
  min-height: 44px;
}
#directoryPanel .btn,
#pricingPanel .btn {
  min-height: 44px;
  white-space: normal;
  max-width: 100%;
}
#directoryPanel .field,
#pricingPanel .field {
  min-width: 0;
}
#directoryPanel input:not([type="checkbox"]),
#directoryPanel select,
#pricingPanel input,
#pricingPanel select {
  width: 100%;
  min-width: 0;
}
#pricingPanel .table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

/* 042: scoped rental/offer administration on iPad and narrow touch screens. */
#rentalsPanel { min-width: 0; overflow-wrap: anywhere; }
#rentalsPanel .field, #rentalsPanel fieldset { min-width: 0; }
#rentalsPanel input:not([type="checkbox"]), #rentalsPanel select { width: 100%; min-width: 0; }
#rentalsPanel .btn, #rentalsPanel .check { min-height: 44px; }
#rentalsPanel .btn { white-space: normal; max-width: 100%; }
#rentalsPanel .table-wrap { max-width: 100%; overflow-x: auto; }
#rentalsPanel .rental-calendar { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); gap: 6px; }
#rentalsPanel .rental-day { min-width: 0; border: 1px solid var(--line); padding: 8px; }
#rentalsPanel .rental-day h3 { font-size: calc(13px * var(--erp-font-scale, 1)); }
#rentalsPanel .rental-resource-row { display: grid; grid-template-columns: minmax(0,1fr) minmax(80px,1fr); align-items: center; gap: 12px; }
@media(max-width:700px) { #rentalsPanel .rental-calendar { grid-template-columns: 1fr; } }
#rentalsPanel .rental-offer-logo img { display: block; max-width: 160px; max-height: 80px; object-fit: contain; }

/* 043 internal planning only; scoped touch controls and contained calendar. */
#marketingPanel { min-width: 0; overflow-wrap: anywhere; }
#marketingPanel .field, #marketingPanel fieldset { min-width: 0; }
#marketingPanel input:not([type="checkbox"]), #marketingPanel select { width: 100%; min-width: 0; }
#marketingPanel select[multiple] { min-height: 120px; }
#marketingPanel button, #marketingPanel .check { min-height: 44px; white-space: normal; max-width: 100%; overflow-wrap: anywhere; }
#marketingPanel pre { white-space: pre-wrap; overflow-wrap: anywhere; }
#marketingPanel .marketing-calendar { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); gap: 6px; }
#marketingPanel .marketing-calendar article { min-width: 0; border: 1px solid var(--line); padding: 8px; }
#marketingPanel .marketing-calendar h3 { font-size: calc(13px * var(--erp-font-scale, 1)); }
#marketingPanel .marketing-tasks { padding-inline-start: 20px; }
#marketingPanel .marketing-tasks li { margin-block: 16px; }
@media(max-width:700px) { #marketingPanel .marketing-calendar { grid-template-columns: 1fr; } }

/* 044 scoped shift views. Draft controls never appear in worker views. */
#shiftPanel { min-width: 0; overflow-wrap: anywhere; }
#shiftPanel .field, #shiftPanel fieldset { min-width: 0; }
#shiftPanel input:not([type="checkbox"]), #shiftPanel select { width: 100%; min-width: 0; }
#shiftPanel select[multiple] { min-height: 120px; }
#shiftPanel button, #shiftPanel .check { min-height: 44px; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
#shiftPanel pre { white-space: pre-wrap; overflow-wrap: anywhere; }
#shiftPanel .sp-calendar { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); gap: 6px; }
#shiftPanel .sp-calendar article { min-width: 0; border: 1px solid var(--line); padding: 8px; }
#shiftPanel .sp-calendar h3 { font-size: calc(13px * var(--erp-font-scale, 1)); }
#shiftPanel .sp-table { max-width: 100%; overflow-x: auto; }
@media(max-width:700px) { #shiftPanel .sp-calendar { grid-template-columns: 1fr; } }
@media print { body:has(#shiftPanel) .sp-no-print, body:has(#shiftPanel) .topbar, body:has(#shiftPanel) #navigation { display: none !important; } #shiftPanel .sp-table { overflow: visible; } #shiftPanel table { font-size: calc(9px * var(--erp-font-scale, 1)); } }

/* Laskuliitteen valintojen teksti on normaalia leipätekstiä. */
select[data-biz-appendix-group],
select[data-biz-appendix-brand] {
  font-weight: 400;
}


/* ERP045: audited payroll correction controls use consistent dimensions. */
.payroll-fix-actions {
  display: grid;
  grid-template-columns: minmax(0, 28rem) 17rem;
  align-items: end;
  justify-content: start;
  gap: 12px;
  width: 100%;
  max-width: 46rem;
  margin: 12px 0 16px;
}
.payroll-fix-actions > .field {
  min-width: 0;
  width: 100%;
  margin: 0;
}
.payroll-fix-actions select {
  width: 100%;
  min-width: 0;
  min-height: 48px;
}
.payroll-fix-actions > .btn {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  align-self: end;
  margin: 0;
}
@media (max-width: 820px) {
  .payroll-fix-actions {
    grid-template-columns: minmax(0, 1fr);
    max-width: 28rem;
  }
}


/* A narrowed Safari window must switch to mobile navigation before content
   columns become too narrow for Finnish labels. */
@media screen and (max-width: 900px) {
  .layout {
    display: block;
  }
  .layout > aside {
    padding: 10px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .layout > aside .nav {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .layout > aside .nav button {
    flex: 0 0 auto;
    white-space: nowrap;
  }
  .layout > main {
    min-width: 0;
    padding: 24px 16px;
  }
}
@media screen and (max-width: 900px) {
  .btn,
  .payroll-fix-actions > .btn {
    overflow-wrap: normal;
    word-break: normal;
  }
}


/* ERP045: compact-window audit. Never squeeze tab captions into vertical
   letter columns in Safari Split View, narrow desktops or phones. The same
   shared tab class is used by work, directory, rentals, marketing and shifts. */
.time-tabs {
  min-width: 0;
  max-width: 100%;
}
.time-tabs > .btn,
.time-tabs > button {
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
  height: auto;
  min-height: 48px;
  white-space: normal;
  word-break: normal;
  overflow-wrap: normal;
  hyphens: auto;
  text-align: center;
}
@media screen and (max-width: 900px) {
  /* Earlier .time-tabs .btn { flex: 1 } made every tab the same tiny width. */
  .time-tabs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
    align-items: stretch;
    gap: 10px;
    width: 100%;
  }
  .time-tabs > .btn,
  .time-tabs > button {
    flex: none;
    width: 100%;
    min-width: 0;
    padding: 10px 14px;
  }
  /* A heading or action row may wrap, but its buttons must remain readable. */
  #directoryPanel .row > .btn,
  #pricingPanel .row > .btn,
  #rentalsPanel .row > .btn,
  #marketingPanel .row > .btn,
  #shiftPanel .row > .btn {
    flex: 0 1 auto;
    min-width: min(100%, 160px);
    max-width: 100%;
    overflow-wrap: normal;
    word-break: normal;
  }
  /* Data tables stay scrollable instead of forcing button columns narrower. */
  #directoryPanel .table-scroll,
  #pricingPanel .table-scroll,
  #rentalsPanel .table-scroll,
  #marketingPanel .table-scroll,
  #shiftPanel .table-scroll,
  #directoryPanel .table-wrap,
  #pricingPanel .table-wrap,
  #rentalsPanel .table-wrap,
  #marketingPanel .table-wrap,
  #shiftPanel .table-wrap {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}
@media screen and (max-width: 480px) {
  .time-tabs {
    grid-template-columns: minmax(0, 1fr);
  }
  #directoryPanel .row > .btn,
  #pricingPanel .row > .btn,
  #rentalsPanel .row > .btn,
  #marketingPanel .row > .btn,
  #shiftPanel .row > .btn {
    width: 100%;
  }
}

/* ERP045 contextual guide: responsive, separate from edit forms. */
.erp-help-dialog { width: min(720px, calc(100vw - 24px)); max-height: min(86dvh, 900px); border: 1px solid #d8d6cc; border-radius: 14px; padding: 0; color: #202724; background: #fff; box-shadow: 0 20px 65px #0004; }
.erp-help-dialog::backdrop { background: rgb(15 24 20 / .48); }
.erp-help-layout { padding: clamp(18px, 3vw, 30px); overflow: auto; max-height: min(86dvh, 900px); }
.erp-help-layout header { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 12px; }
.erp-help-layout header h2 { margin: 0; line-height: 1.25; font-size: 1.45rem; }
.erp-help-layout header h2 { min-width: 0; overflow-wrap: break-word; }
.erp-help-close {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid #d8d6cc;
  border-radius: 11px;
  color: #202724;
  background: #fff;
  font: 28px/1 system-ui, sans-serif;
  cursor: pointer;
}
.erp-help-close:hover, .erp-help-close:focus-visible {
  border-color: #b94d30;
  outline-offset: 3px;
}
.erp-help-intro { margin: 0 0 18px; color: #58635e; }
.erp-help-topic { padding: 13px 0; border-top: 1px solid #e7e6e0; }
.erp-help-topic h3 { margin: 0 0 5px; font-size: 1rem; }
.erp-help-topic p { margin: 0; line-height: 1.5; }
.erp-help-search { margin: 0 0 18px; }
.erp-help-search label { display: block; margin-bottom: 6px; font-weight: 600; }
.erp-help-search input { box-sizing: border-box; width: 100%; min-width: 0; min-height: 44px; padding: 10px 12px; font: inherit; font-size: calc(16px * var(--erp-font-scale, 1)); border: 1px solid #d8d6cc; border-radius: 9px; }
.erp-help-search input:focus-visible { outline: 2px solid #b64b2d; outline-offset: 1px; }
.erp-help-group { margin: 0 0 18px; min-width: 0; }
.erp-help-group > h3 { margin: 0; padding: 8px 0; font-size: 1.05rem; color: #a84329; }
.erp-help-topic h4 { margin: 0 0 5px; font-size: 1rem; }
.erp-help-dialog [hidden] { display: none !important; }
@media (max-width: 600px) { .erp-help-dialog { width: calc(100vw - 16px); max-height: 90dvh; } .erp-help-layout { max-height: 90dvh; padding: 16px; } .erp-help-layout header h2 { font-size: 1.2rem; } }
@media print { .erp-help-dialog { display: none !important; } }

/* Compact, keyboard-accessible contextual hints beside consequential actions. */
.erp-info-action { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; min-width: 0; vertical-align: middle; }
.erp-info-action > .btn { min-width: 0; white-space: normal; }
.erp-info-icon { flex: none; display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border-radius: 50%; border: 1px solid #b9b8af; color: #475b53; background: #fff; font: 700 18px/1 system-ui, sans-serif; cursor: pointer; }
.erp-info-icon:hover, .erp-info-icon:focus-visible { border-color: #b84c2b; color: #b84c2b; outline-offset: 2px; }
.payroll-fix-actions > .erp-info-action { width: 100%; align-self: end; }
.payroll-fix-actions > .erp-info-action > .btn { min-height: 48px; flex: 1 1 auto; }
@media (max-width: 600px) { .erp-info-action { width: 100%; } .erp-info-action > .btn { flex: 1 1 auto; } }
@media print { .erp-info-icon { display: none !important; } }

/* Same-size approval shortcuts on desktop, stacked at narrow widths. */
.approval-notice-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: 10px;
  width: 100%;
  max-width: 660px;
}
.approval-notice-actions > .btn {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  height: 100%;
  margin: 0;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
}
@media (max-width: 600px) {
  .approval-notice-actions { grid-template-columns: minmax(0, 1fr); }
}

/* Payroll preview: zero-pay warning is a block beneath its own work row. */
.payroll-preview-list { padding-left: 1.5rem; }
.payroll-preview-list > li { padding: 8px 0 14px; }
.payroll-zero-warning {
  display: block;
  position: static;
  clear: both;
  width: fit-content;
  max-width: 100%;
  box-sizing: border-box;
  margin: 10px 0 12px;
  padding: 10px 13px;
  border-left: 3px solid #d9a53b;
  border-radius: 0 5px 5px 0;
  background: #fff5dc;
  color: #3a3324;
  font-weight: 600;
  line-height: 1.45;
  overflow-wrap: break-word;
}
@media (max-width: 600px) {
  .payroll-preview-list { padding-left: 1.2rem; }
  .payroll-zero-warning { width: 100%; }
}

/* Wide homepage: approval shortcuts occupy a separate right-hand column. */
@media screen and (min-width: 1100px) {
  .approval-notice {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(235px, 280px);
    grid-template-rows: repeat(3, auto);
    column-gap: 24px;
    align-items: start;
  }
  .approval-notice > h2,
  .approval-notice > p {
    grid-column: 1;
    min-width: 0;
  }
  .approval-notice > .approval-notice-actions {
    grid-column: 2;
    grid-row: 1 / span 3;
    grid-template-columns: minmax(0, 1fr);
    align-self: center;
    max-width: none;
  }
}

/* Approval decisions: equal-size multilingual action buttons without overflow. */
.row.review-decision-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  max-width: 620px;
  gap: 12px;
  margin: 12px 0;
}
.review-decision-actions > .btn {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  margin: 0;
  white-space: normal;
  overflow-wrap: break-word;
  text-align: center;
}
@media (max-width: 600px) {
  .row.review-decision-actions { grid-template-columns: minmax(0, 1fr); }
}

/* Personnel register rights: consistent actions at every language and screen width. */
.row.registry-manager-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  max-width: 640px;
  gap: 12px;
  margin: 12px 0;
}
.registry-manager-actions > .btn {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 48px;
  margin: 0;
  white-space: normal;
  overflow-wrap: break-word;
  text-align: center;
}
@media (max-width: 600px) {
  .row.registry-manager-actions {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Keep the homepage notification card separated from the metric cards. */
.approval-notice + .metrics {
  margin-top: 14px;
}

/* Keep Help and Refresh at the same vertical position; the version label sits below Refresh. */
.pagehead > .row {
  align-items: flex-start;
}

/* Highlight an available newer build without continuously flashing. */
.pagehead .erp-refresh-version.erp-update-available .erp-version-label {
  color: #bd322b;
  font-weight: 700;
}
.pagehead .erp-refresh-version.erp-update-available [data-refresh] {
  border-color: #bd322b;
  box-shadow: 0 0 0 2px rgb(189 50 43 / 15%);
}
@media (prefers-reduced-motion: no-preference) {
  .pagehead .erp-refresh-version.erp-update-available [data-refresh] {
    animation: erp-new-version-pulse 1.2s ease-in-out 2;
  }
}
@keyframes erp-new-version-pulse {
  50% { box-shadow: 0 0 0 5px rgb(189 50 43 / 20%); }
}

/* Current deployed ERP build, placed directly below the Refresh button. */
.pagehead .erp-refresh-version {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: stretch;
  min-width: 0;
  gap: 3px;
}
.pagehead .erp-update-status {
  display: block;
  max-width: 160px;
  color: var(--muted);
  font-size: calc(10px * var(--erp-font-scale, 1));
  line-height: 1.3;
  text-align: center;
  overflow-wrap: normal;
}
.pagehead .erp-refresh-version.erp-update-available .erp-update-status {
  color: #bd322b;
}
.clock-lunch-reminder[hidden] {
  display: none;
}
.pagehead .erp-refresh-version.erp-update-check-error .erp-update-status {
  color: #85604b;
}
.pagehead .erp-version-label {
  display: block;
  color: var(--muted);
  font-size: calc(11px * var(--erp-font-scale, 1));
  line-height: 1.3;
  text-align: center;
  white-space: nowrap;
}
@media (max-width: 600px) {
  .pagehead .erp-refresh-version {
    flex: 1 1 100%;
    width: 100%;
  }
  .pagehead .erp-refresh-version .btn { width: 100%; }
}


/* Four-language ERP pilot: keep the selector readable in narrow Safari windows. */
.erp-language-picker {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
  min-width: 0;
}
.erp-language-picker label {
  font-size: calc(13px * var(--erp-font-scale, 1));
  line-height: 1.3;
  white-space: nowrap;
}
.erp-language-picker select {
  box-sizing: border-box;
  flex: 0 0 auto;
  width: auto;
  min-width: 118px;
  max-width: 150px;
  min-height: 42px;
  padding: 8px 28px 8px 11px;
  line-height: 1.3;
  white-space: nowrap;
}
footer [data-i18n="shell.footerTitle"] {
  display: block;
}
@media (max-width: 600px) {
  .top-controls {
    width: 100%;
    flex-wrap: wrap;
    align-items: center;
  }
  .erp-language-picker {
    max-width: 100%;
  }
}

/* Keep four bottom navigation labels readable on narrow Safari screens. */
@media (max-width: 900px) {
  .mobile-navigation button {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-wrap: normal;
    word-break: normal;
    hyphens: none;
    line-height: 1.25;
    text-align: center;
  }
}

/* Language-neutral bottom bar: four equal touch targets even with longer translations. */
@media screen and (max-width: 900px) {
  .mobile-navigation > button {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    padding: 8px 4px;
    font-size: clamp(12px, 3.1vw, 14px);
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

/* Keep the four-language header stable as language, names and roles change. */
.topbar > div:first-child,
.top-controls,
.top-controls > *,
#identity {
  min-width: 0;
  max-width: 100%;
}
#identity {
  overflow-wrap: break-word;
  word-break: normal;
}
@media screen and (max-width: 1100px) {
  .topbar { flex-wrap: wrap; }
  .topbar > div:first-child { flex: 1 1 240px; }
  .top-controls { justify-content: flex-end; }
}
@media screen and (max-width: 700px) {
  .topbar > div:first-child { flex: 0 0 auto; width: 100%; }
  .top-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    justify-content: stretch;
    gap: 10px 12px;
  }
  .erp-language-picker { grid-column: 1; grid-row: 1; }
  #logout {
    grid-column: 2;
    grid-row: 1;
    white-space: normal;
    overflow-wrap: normal;
    min-height: 44px;
  }
  #identity { grid-column: 1 / -1; grid-row: 2; }
}
@media screen and (max-width: 440px) {
  .top-controls { grid-template-columns: minmax(0, 1fr); }
  .erp-language-picker { justify-content: space-between; width: 100%; }
  .erp-language-picker select { min-width: 0; max-width: 55%; }
  #logout { grid-column: 1; grid-row: 3; width: 100%; }
  #identity { grid-column: 1; grid-row: 2; }
}

/* Multilingual layout contract: a longer translation may wrap, but must not
   change its neighbour's touch target or force the entire page sideways. */
/* Keep the desktop sidebar readable when an administrator enlarges buttons.
   The legacy 216px column was fixed even at 175% and clipped long Finnish labels. */
@media screen and (min-width: 901px) {
  .layout {
    grid-template-columns: clamp(216px, calc(216px * var(--erp-button-font-scale, 1)), 360px) minmax(0, 1fr);
  }
  .layout > aside,
  .layout > aside .nav {
    min-width: 0;
  }
  .layout > aside .nav button {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
    hyphens: auto;
    line-height: 1.35;
  }
  .layout > aside .aside-note {
    overflow-wrap: anywhere;
  }
}
.topbar,
.pagehead,
.approval-notice,
.approval-notice-actions,
.erp-module-grid,
.time-tabs {
  min-width: 0;
}
.top-controls > #identity {
  flex: 0 1 auto;
}
.approval-notice-actions > .btn,
.registry-manager-actions > .btn,
.review-decision-actions > .btn,
.time-tabs > .btn {
  line-height: 1.35;
  hyphens: auto;
  overflow-wrap: break-word;
}
/* An iPad in Split View has less room for translated navigation than a full
   desktop even when its viewport is slightly wider than 900 CSS pixels. */
@media screen and (min-width: 701px) and (max-width: 1299px) {
  .topbar {
    flex-wrap: wrap;
  }
  .topbar > div:first-child {
    flex: 1 1 240px;
  }
  .top-controls {
    flex: 1 1 auto;
    justify-content: flex-end;
  }
}
@media screen and (min-width: 901px) and (max-width: 1200px) {
  .time-tabs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
    align-items: stretch;
    gap: 10px;
  }
  .time-tabs > .btn,
  .time-tabs > button {
    width: 100%;
    flex: none;
    min-height: 48px;
    padding: 10px 14px;
  }
}
@media screen and (max-width: 900px) {
  .mobile-navigation:not(:empty) {
    grid-auto-rows: minmax(58px, auto);
    align-items: stretch;
  }
  .mobile-navigation > button {
    height: 100%;
    min-height: 58px;
    line-height: 1.25;
    overflow-wrap: break-word;
  }
}
@media screen and (max-width: 600px) {
  .pagehead > .row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 10px;
  }
  .pagehead > .row > .btn,
  .pagehead > .row > .erp-refresh-version {
    width: 100%;
    min-width: 0;
    max-width: none;
  }
}

/* Appearance editor: keep the existing ERP palette as the default. */
:root {
  --surface: #ffffff;
  --button-text: #ffffff;
}
.topbar,
.panel,
.metric,
.doc-card,
.erp-module,
.btn.secondary,
input:not([type="checkbox"]),
select,
textarea {
  background-color: var(--surface);
}
th,
.hint {
  background-color: var(--light);
}
.erp-module:hover {
  background-color: var(--light);
}
.btn:not(.secondary):not(.soft) {
  color: var(--button-text);
}
.erp-theme-panel {
  padding: 22px;
  margin: 22px 0;
  width: 100%;
  min-width: 0;
}
.erp-theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 14px;
  margin: 20px 0;
}
.erp-theme-field {
  min-width: 0;
}
.erp-theme-field__controls {
  display: flex;
  align-items: center;
  gap: 10px;
}
.erp-theme-field__controls input[type="color"] {
  flex: 0 0 54px;
  width: 54px;
  height: 44px;
  padding: 3px;
  cursor: pointer;
}
.erp-theme-field__controls input[type="text"] {
  min-width: 0;
  width: 110px;
  max-width: 100%;
  font: 600 14px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace;
  text-transform: lowercase;
}
.erp-theme-typography {
  box-sizing: border-box;
  display: block;
  width: 100%;
  max-width: none;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.erp-theme-typography legend {
  padding: 0 6px;
  font-weight: 700;
}
.erp-theme-typography .erp-theme-grid {
  margin: 10px 0;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}
.erp-theme-groups {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  gap: 12px;
}
.erp-theme-group {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
}
.erp-theme-group .erp-theme-grid {
  margin-bottom: 0;
  align-items: end;
}
.erp-theme-typography select {
  display: block;
  width: 100%;
  max-width: none;
  min-height: 44px;
  margin-top: 6px;
}
.erp-theme-typography p {
  margin-bottom: 0;
}
.erp-theme-preview {
  padding: 18px;
  margin: 14px 0;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.erp-theme-preview p {
  color: var(--muted);
  margin: 6px 0 14px;
}
.erp-theme-preview__button {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--brand);
  color: var(--button-text);
  font-weight: 700;
}
.erp-theme-preview__field {
  max-width: 430px;
  margin-top: 12px;
}
.erp-theme-preview__field input {
  display: block;
  max-width: 100%;
  width: 100%;
  margin-top: 6px;
}
/* Decoration is a bounded, non-interactive overlay. It never obscures or
   intercepts the navigation, including at 175% typography scaling. */
.layout > aside,
.erp-theme-sidebar-preview {
  position: relative;
  isolation: isolate;
  background-color: var(--erp-sidebar-background, var(--paper));
  color: var(--erp-sidebar-text, var(--muted));
}
.layout > aside::before,
.erp-theme-sidebar-preview::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: var(--erp-sidebar-pattern-image, none);
  background-size: 180px 180px;
  background-repeat: repeat;
  opacity: var(--erp-sidebar-pattern-opacity, 0.1);
}
html[data-erp-sidebar-pattern="christmas"] { --erp-sidebar-pattern-image: url("./patterns/christmas-modern.svg"); }
html[data-erp-sidebar-pattern="winter"] { --erp-sidebar-pattern-image: url("./patterns/winter-modern.svg"); }
html[data-erp-sidebar-pattern="spring"] { --erp-sidebar-pattern-image: url("./patterns/spring-modern.svg"); }
html[data-erp-sidebar-pattern="summer"] { --erp-sidebar-pattern-image: url("./patterns/summer-modern.svg"); }
html[data-erp-sidebar-pattern="autumn"] { --erp-sidebar-pattern-image: url("./patterns/autumn-modern.svg"); }
html[data-erp-sidebar-pattern="geometric"] { --erp-sidebar-pattern-image: url("./patterns/geometric-modern.svg"); }
html[data-erp-sidebar-pattern="none"] { --erp-sidebar-pattern-image: none; }
.layout > aside .eyebrow,
.layout > aside .nav button,
.layout > aside .aside-note {
  color: var(--erp-sidebar-text, var(--muted));
}
.layout > aside > * {
  position: relative;
  z-index: 1;
}
.layout > aside .nav button[aria-current="page"] {
  color: var(--brand);
}
.erp-theme-sidebar-settings {
  width: 100%;
  min-width: 0;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.erp-theme-brand-settings {
  width: 100%;
  min-width: 0;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.erp-theme-brand-settings legend {
  padding: 0 6px;
  font-weight: 700;
}
.erp-theme-brand-settings select {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 6px;
}
.erp-theme-brand-settings .erp-theme-grid { margin: 12px 0; }
.erp-brand-logo,
.erp-theme-brand-preview__logo { display: none; }
/* An absent logo never removes the existing title; the image must load first. */
html[data-erp-brand-mode="logo"][data-erp-logo-ready="yes"] .brand__text,
html[data-erp-brand-mode="logo"][data-erp-logo-ready="yes"] .erp-theme-brand-preview__text { display: none; }
html[data-erp-brand-mode="logo"][data-erp-logo-ready="yes"] .erp-brand-logo,
html[data-erp-brand-mode="logo"][data-erp-logo-ready="yes"] .erp-theme-brand-preview__logo {
  display: block;
  width: auto;
  max-width: min(100%, 360px);
  height: calc(21px * var(--erp-heading-font-scale, 1));
  object-fit: contain;
  object-position: left center;
}
.erp-theme-brand-preview {
  display: flex;
  align-items: center;
  min-height: 58px;
  max-width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow-wrap: anywhere;
}
.erp-theme-brand-preview__text {
  font-family: var(--erp-heading-font-family, inherit);
  font-size: calc(21px * var(--erp-heading-font-scale, 1));
  font-weight: var(--erp-heading-font-weight, 800);
}
.erp-theme-brand-preview__text span { color: var(--brand); }
.brand > .brand__text { color: var(--ink); }
.brand > .brand__text > span { color: var(--brand); }
@media (max-width: 600px) {
  html[data-erp-brand-mode="logo"][data-erp-logo-ready="yes"] .erp-brand-logo {
    height: calc(18px * var(--erp-heading-font-scale, 1));
  }
}
.erp-theme-sidebar-settings legend {
  padding: 0 6px;
  font-weight: 700;
}
.erp-theme-sidebar-settings select {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 6px;
}
.erp-theme-sidebar-settings .erp-theme-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  margin: 12px 0;
}
.erp-theme-sidebar-preview {
  width: min(100%, 340px);
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.erp-theme-sidebar-preview__content {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 8px;
  padding: 20px 16px;
}
.erp-theme-sidebar-preview__title {
  font-size: calc(12px * var(--erp-subheading-font-scale, 1));
  font-weight: 750;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.erp-theme-sidebar-preview__item {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  font-family: var(--erp-button-font-family, inherit);
  font-size: calc(15px * var(--erp-button-font-scale, 1));
  font-weight: var(--erp-button-font-weight, 650);
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.erp-theme-sidebar-preview__item:nth-child(2) {
  background: var(--light);
  color: var(--brand);
}
.erp-theme-warning:not([hidden]) {
  padding: 10px 12px;
  border: 1px solid #b66a23;
  background: #fff0d7;
  color: #713c00;
  border-radius: 8px;
}
@media (max-width: 600px) {
  .erp-theme-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .erp-theme-panel {
    padding: 16px;
  }
}
@media print {
  .erp-theme-panel {
    display: none !important;
  }
}

