/* Final, screen-only component mechanics. Skin colors/radii remain with each skin;
   invoice paper and native multiple-selection lists are deliberately excluded. */
@media screen {
  :root {
    --component-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%23515e70' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
  :root[data-theme="dark"] {
    --component-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%23c8d2e2' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }

  /* Keep 18px between the arrow and edge, plus a separate text clearance. */
  :root body select:not([multiple]):is(:not([size]), [size="1"]):not(.paper *) {
    appearance: none;
    -webkit-appearance: none;
    background-image: var(--component-chevron);
    background-repeat: no-repeat;
    background-size: 16px 16px;
    background-position: right 18px center;
    padding-inline: 12px 46px;
    min-width: 0;
    max-width: 100%;
    text-overflow: ellipsis;
    line-height: 1.4;
  }
  :root body select:not([multiple]):is(:not([size]), [size="1"]):not(.paper *):dir(rtl) {
    background-position: left 18px center;
  }
  :root body :is(.form-grid, .fields, .item-row, .stack, .company-picker, .mobile-menu-footer) > label:not(.paper *) {
    min-width: 0;
    gap: 7px;
    line-height: 1.4;
    overflow-wrap: anywhere;
  }
  :root body :is(input, select, textarea):not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not(.paper *) {
    min-height: 42px;
    max-width: 100%;
  }
  :root body textarea:not(.paper *) { line-height: 1.5; resize: vertical; }
  :root body .form-grid { align-items: start; }
  :root body .item-row { align-items: end; }
  :root body .inline { min-width: 0; }
  :root body label.inline { align-items: center; }

  /* Neutral, offset focus works against all ten light/dark skin surfaces and
     remains distinguishable even when a button has the skin's accent fill. */
  :root body :is(a, button, input, select, textarea, summary, [tabindex]):not(.paper *):focus-visible {
    outline: 3px solid var(--ink);
    outline-offset: 3px;
  }
  :root body .search:focus-within { outline-color: var(--ink); }
  :root body .search input:focus-visible { outline: 0; }
  :root body :is(.button, .profile button, .mobile-menu-toggle, .mobile-menu-close, .command-palette header button):not(.paper *) {
    min-height: 42px;
    line-height: 1.35;
    text-align: center;
    touch-action: manipulation;
  }
  :root body .button:not(.paper *) { max-width: 100%; }
  :root body .button:not(.primary):not(.secondary):not(.paper *) {
    background: transparent;
    color: var(--ink);
    border-color: transparent;
    box-shadow: none;
  }
  :root body .button:not(.primary):not(.secondary):not(.paper *):hover { background: var(--soft); }
  :root body .button.danger:not(.primary):not(.secondary):not(.paper *) { color: var(--danger, #aa2845); }
  :root[data-theme="dark"] body .button.danger:not(.primary):not(.secondary):not(.paper *) { color: var(--danger, #ffacb6); }
  :root body :is(.actions, .appearance-controls) > .button:not(.paper *) {
    white-space: normal;
    overflow-wrap: anywhere;
  }
  :root body :is(.link-button, .number-link):not(.paper *) {
    border-radius: 4px;
    line-height: 1.45;
    text-underline-offset: 3px;
  }
  :root body :is(.link-button, .number-link):not(.paper *):hover { text-decoration: underline; }
  :root body .document-open.link-button { display: inline-flex; flex-direction: column; align-items: flex-start; justify-content: center; }
  :root body :is(button, input, select, textarea):not(.paper *):disabled,
  :root body button[aria-disabled="true"]:not(.paper *) {
    cursor: not-allowed;
    opacity: .58;
  }
  :root body :is(button, form)[aria-busy="true"]:not(.paper *) { cursor: progress; }
  :root body button[aria-busy="true"]:not(.paper *) { opacity: .78; }

  :root body :is(.mobile-menu-header, .mobile-menu-footer, .command-palette header) { min-width: 0; }
  :root body .mobile-menu-footer > label { min-width: 0; }
  :root body .mobile-menu-footer .profile { gap: 10px; }
  :root body .mobile-menu-footer .profile > span { flex: 1 1 100%; }
  :root body :is(.mobile-menu-close, .mobile-menu-toggle, .command-palette header button) { min-width: 44px; flex-shrink: 0; }
  :root body .company-picker select { width: 100%; }
  :root body .command-palette header h2 { min-width: 0; overflow-wrap: anywhere; }
  :root body .command-palette-option { min-width: 0; }
  :root body .company-choice { gap: 8px 14px; }
  :root body .company-choice > :is(strong, span) { min-width: 0; overflow-wrap: anywhere; }
  :root body #modal > form > .actions { margin-bottom: 0; padding-top: 8px; }
  :root body .modal-error { margin: 0; color: var(--danger, #a3213d); overflow-wrap: anywhere; }
  :root[data-theme="dark"] body .modal-error { color: var(--danger, #ffacb6); }
  :root body .modal-error:empty { display: none; }
  :root body .invoice-settings { min-inline-size: 0; }
  :root body #activity-filter { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin-bottom: 20px; }
  :root body #activity-filter > label { flex: 1 1 180px; max-width: 340px; }
  :root body #desktop-appearance { position: relative; flex-shrink: 0; }
  :root body .topbar:has(#desktop-appearance[open]) { position: relative; z-index: 12; }
  :root body .appearance-panel {
    position: absolute;
    inset-inline-end: 0;
    inset-block-start: calc(100% + 8px);
    width: min(420px, calc(100vw - 28px));
    max-height: min(72dvh, 590px);
    overflow: auto;
    overscroll-behavior: contain;
    display: grid;
    gap: 16px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--control-radius, 15px);
    background: var(--surface);
    box-shadow: 0 16px 36px #0005;
  }
  :root body #desktop-appearance:not([open]) .appearance-panel { display: none; }
  :root[data-ui-design-preview="true"] body .appearance-settings > summary { border-color: var(--blue); }
  :root body :is(#language, [data-currency]) { padding-inline: 10px 31px; background-position: right 9px center; }

  @media (max-width: 900px), (pointer: coarse) {
    :root body :is(input, select, textarea):not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not(.paper *) {
      min-height: 44px;
      font-size: max(16px, 1em);
    }
    :root body :is(.button, .link-button, .number-link, .row-action button, .profile button, .nav a, .nav button):not(.paper *) { min-height: 44px; }
    :root body :is(.link-button, .number-link):not(.paper *) { display: inline-flex; align-items: center; }
  }
  @media (max-width: 420px) {
    :root body #modal { padding: 18px; }
    :root body #modal > form > .actions > .button { flex: 1 1 100%; }
    :root body .topbar .header-actions .primary { padding-inline: 10px; white-space: normal; }
    :root body .mobile-menu-footer .button { white-space: normal; }
    :root body .command-palette { padding: 16px; }
    :root body .command-palette header { gap: 8px; }
  }
  @media (max-width: 560px) {
    :root body .form-grid { grid-template-columns: minmax(0, 1fr); }
    :root body .form-grid > .wide { grid-column: auto; }
    :root body .login .button { min-height: 44px; }
  }
  @media (forced-colors: active) {
    :root body select:not([multiple]):is(:not([size]), [size="1"]):not(.paper *) {
      appearance: auto;
      -webkit-appearance: auto;
      background-image: none;
      padding-inline: 12px;
    }
    :root body :is(a, button, input, select, textarea, summary, [tabindex]):not(.paper *):focus-visible {
      outline-color: Highlight;
    }
  }
}
/* Dialogs and service status stay reachable on narrow screens. */
.invoice-preview-dialog { width: min(74rem, calc(100% - 1rem)); max-height: 92dvh; overflow: auto; }
.invoice-preview-dialog h2 { margin: 0; }
.invoice-preview-dialog > .stack { min-width: 0; }
.session-warning { position: fixed; inset-block-end: 1rem; inset-inline-end: 1rem; z-index: 10; }
.document-action-tooltip {
  position: fixed;
  z-index: 26;
  max-width: min(18rem, calc(100vw - 1.5rem));
  padding: .45rem .7rem;
  border: 1px solid var(--line);
  border-radius: .55rem;
  background: var(--surface, Canvas);
  color: var(--ink, CanvasText);
  box-shadow: 0 5px 16px #0003;
  font-size: .85rem;
  overflow-wrap: anywhere;
  pointer-events: none;
}
