/* Shared design tokens: keep this block identical in local/dist/ui-system.css
   and labor_system/public/ui-system.css. Component rules reference these names
   only; a new colour, radius or shadow belongs here, not inside a rule. */
:root {
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-display: "SF Pro Display", "Segoe UI Variable Display", var(--font-ui);
  --font-code: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  /* Type scale (rem, so the user's display-size setting scales everything). */
  --text-caption: .8125rem;
  --text-body: .875rem;
  --text-label: 1rem;
  --text-heading: 1.125rem;
  --text-title: 1.25rem;
  --text-display: 1.75rem;
  /* Text. */
  --ink: #142b52;
  --ink-2: #1d3b70;
  --ink-3: #243f6b;
  --text: #414d61;
  --muted: #586b87;
  --faint: #8594ad;
  --on-dark: #ffffff;
  --on-dark-muted: #b8c6dc;
  /* Brand blue. */
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --link: #2158b0;
  --focus: #6395ed;
  --accent-300: #8fb4f1;
  --accent-200: #bfdbfe;
  --accent-100: #dbeafe;
  --accent-soft: #e7f0ff;
  --accent-softer: #f2f6fd;
  --accent-line: #cbdcf6;
  /* Status. */
  --red: #ae4a3e;
  --red-strong: #963c31;
  --danger-soft: #f7e3df;
  --danger-softer: #fff4f3;
  --danger-line: #efd4d0;
  --warn: #ad782c;
  --warn-ink: #8a4b0d;
  --warn-soft: #fff4dd;
  --success: #23734c;
  --success-soft: #e4f3eb;
  /* Surfaces and rules. */
  --paper: #f3f6fc;
  --card: #ffffff;
  --surface-2: #f7f9fd;
  --surface-3: #edf1f8;
  --line: #e3eaf4;
  --line-strong: #cfd8e6;
  /* Shape and elevation. */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-pill: 999px;
  --shadow-1: 0 1px 3px rgba(20, 43, 82, .05);
  --shadow-2: 0 8px 24px rgba(20, 43, 82, .10);
  --shadow-3: 0 24px 64px rgba(20, 43, 82, .22);
  --shadow-card: inset 0 1px 0 rgba(255, 255, 255, .95), inset 0 -1px 0 transparent,
    0 0 0 1px rgba(20, 43, 82, .08),
    0 3px 6px -2px rgba(20, 43, 82, .17), 0 13px 25px -12px rgba(20, 43, 82, .29);
  --shadow-card-compact: inset 0 1px 0 rgba(255, 255, 255, .85), 0 2px 5px rgba(20, 43, 82, .13);
  --shadow-card-dark: inset 0 1px 0 rgba(223, 238, 255, .24), inset 0 -1px 0 transparent,
    0 3px 0 rgba(8, 24, 53, .22), 0 12px 23px -8px rgba(20, 43, 82, .48);
  --shadow-window: inset 0 1px 0 rgba(255, 255, 255, .95), 0 0 0 1px rgba(20, 43, 82, .15),
    0 9px 18px -6px rgba(14, 33, 65, .30), 0 28px 66px -13px rgba(10, 25, 51, .52);
  /* Match the inset and outer layers across states so each shadow interpolates. */
  --shadow-control: inset 0 1px 0 rgba(255, 255, 255, .32), inset 0 -1px 0 transparent,
    0 2px 0 rgba(20, 43, 82, .14), 0 3px 6px rgba(20, 43, 82, .09);
  --shadow-control-raised: inset 0 1px 0 rgba(255, 255, 255, .60), inset 0 -1px 0 transparent,
    0 3px 0 rgba(20, 43, 82, .24), 0 8px 14px -3px rgba(20, 43, 82, .35);
  --shadow-control-pressed: inset 0 2px 5px rgba(12, 30, 61, .28),
    inset 0 -1px 0 rgba(255, 255, 255, .27), 0 1px 2px rgba(20, 43, 82, .12);
  --surface-light: linear-gradient(180deg, rgba(236, 245, 255, .48), transparent 68px);
  --surface-light-dark: linear-gradient(180deg, rgba(143, 180, 241, .15), transparent 86px);
  --surface-control-light: linear-gradient(180deg, rgba(255, 255, 255, .17), rgba(8, 24, 53, .10));
  --workspace-light: linear-gradient(155deg, #e7effb 0, var(--paper) 480px);
  --window-scrim: rgba(13, 24, 46, .63);
  --ease-release: cubic-bezier(.2, .75, .28, 1.28);
  --control-lift: 0 -2px;
  --control-press: 0 1px;
  --ring: 0 0 0 3px rgba(37, 99, 235, .16);
  /* Controls. */
  --control-height: 42px;
  --control-height-sm: 36px;
  --control-radius: var(--radius-md);
  /* Names kept for older rules. */
  --green: var(--link);
  --mint: var(--accent-soft);
  --shadow: var(--shadow-2);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  color-scheme: light;
}
body { font-size: var(--text-body); }
button, input, select, textarea { font-family: var(--font-ui); line-height: 1.5; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
input, select, textarea { min-width: 0; max-width: 100%; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; font-weight: 400; }
small { font-size: var(--text-caption); }
h1, h2, h3, h4 { font-family: var(--font-ui); line-height: 1.4; letter-spacing: normal; }
h1 { font-size: var(--text-display); }
h2 { font-size: var(--text-heading); }
h3 { font-size: var(--text-label); }
:is(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
[hidden] { display: none !important; }

/* Meeting assistant, expert form and browser-local agreement generator. */
body { font-family: var(--font-ui); }
.muted, .small, .helper, .meeting-meta, .form-intro, .number, .secure-note,
.file-limits, .form-footer, .login-note, .app-footer, .cell-secondary, .card-count,
.meeting-card .meta, .eyebrow, #filehint, footer, .options span { color: var(--muted); }
.small, .helper, .meeting-meta, .form-intro, .secure-note, .file-limits,
.form-footer, .login-note, .app-footer, .cell-secondary, footer, #filehint {
  font-size: var(--text-caption); line-height: 1.7;
}
h1, .login-card h1 { font-size: 1.5rem; line-height: 1.5; letter-spacing: normal; }
h2, .detail-heading h2, .dialog-heading h2, .settings-grid h2 { font-size: var(--text-title); line-height: 1.5; }
h3, .meeting-card h3 { font-size: var(--text-label); line-height: 1.6; }
.eyebrow, .brand { letter-spacing: .04em; }
button, .button { min-height: var(--control-height); border-radius: var(--control-radius); font-size: var(--text-body); font-weight: 600; line-height: 1.5; }
.text-button, .text-link, .attachment-link { font-size: var(--text-caption); }
.text-button, .text-link { min-height: 36px; padding-block: 7px; }
.icon-button { font-size: 24px; min-width: 36px; min-height: 36px; padding: 0; }
input, .question > input, .url-field input, input[type=date] {
  min-width: 0; min-height: var(--control-height); font-size: var(--text-body);
  border-radius: var(--control-radius); padding: 10px 12px; line-height: 1.5;
}
input::placeholder, .question > input::placeholder { font-size: inherit; color: var(--muted); }
input[type=checkbox] { width: 18px; min-height: 0; height: 18px; flex-shrink: 0; padding: 0; accent-color: var(--accent); }
label { font-size: var(--text-body); line-height: 1.6; }
.form-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.question > label:first-child { font-size: var(--text-label); }
.number { font-size: var(--text-caption); }
.questionnaire, .workspace, .panel, .share-content, .meeting-card { min-width: 0; }
.page-heading > div, .detail-heading > div, .section-heading > div { min-width: 0; }
.page-heading h1, .detail-heading h2, .meeting-card h3 { overflow-wrap: anywhere; }
.badge, .count { font-size: var(--text-caption); line-height: 1.5; }
.badge { max-width: 100%; white-space: normal; }
.card-count { font-size: var(--text-caption); }
.record-total { font-size: var(--text-display); letter-spacing: normal; }
.record-total small { font-size: var(--text-caption); }
.export-actions .button, .export-actions button, .url-field button { font-size: var(--text-body); }
.export-panel .muted, .cell-secondary, .cell-warning, .permission-note { font-size: var(--text-caption); }
.url-field { flex-wrap: wrap; }
.url-field input { flex: 1 1 150px; }
.sharing-panel { min-width: 0; }
table { font-size: var(--text-body); }
th { font-size: var(--text-caption); font-weight: 600; color: var(--muted); line-height: 1.6; }
td { font-size: var(--text-body); line-height: 1.7; }
.cell-name { font-size: var(--text-body); }
.table-wrap { max-width: 100%; overscroll-behavior-x: contain; }
dialog { max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; }
.dialog-heading { gap: 16px; }
.dialog-actions { flex-wrap: wrap; }
.actions:not(.small-actions), .export-actions, .dialog-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
  grid-auto-rows: 1fr;
  align-items: stretch;
  gap: 10px;
  min-width: 0;
}
.detail-heading > .actions { width: min(100%, 340px); }
.actions:not(.small-actions) > :is(button, a),
.export-actions > :is(button, a), .dialog-actions > :is(button, a) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  width: 100%;
  height: 100%;
  min-height: var(--control-height);
  margin: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
}
.login-card { padding: 32px; }
.login-view { min-height: 100dvh; }
.form-top { min-height: 66px; height: auto; flex-wrap: wrap; padding-block: 14px; white-space: normal; }
.form-top > span { min-width: 0; }
.secure-note { margin-left: 38px; }
.upload-box { min-width: 0; }
.upload-box small { font-size: var(--text-caption); line-height: 1.7; }
.file-list li, .file-list li > span { min-width: 0; overflow-wrap: anywhere; }
.consent { font-size: var(--text-body); line-height: 1.7; }
.options { flex-wrap: wrap; }
.options label { flex: 1 1 200px; }
.options input { flex: 1 1 150px; }
details { font-size: var(--text-caption); }
@media (max-width: 760px) {
  :root { --control-height: 44px; }
  .header-inner { flex-wrap: wrap; gap: 12px; min-height: 74px; height: auto; padding-block: 14px; }
  .account { flex: 1 1 auto; min-width: 0; }
  .workspace { padding: 24px 16px 36px; }
  .section-heading { flex-wrap: wrap; gap: 14px; }
  .section-heading .muted { max-width: none; font-size: var(--text-caption); }
  .section-heading > .primary { font-size: var(--text-body); }
  .ui-responsive-table, .ui-responsive-table tbody { display: block; width: 100%; white-space: normal; }
  .ui-responsive-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .ui-responsive-table tbody { display: grid; gap: 12px; padding: 0 14px 14px; }
  .ui-responsive-table tbody tr {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px;
    padding: 16px; border: 1px solid var(--line); border-radius:var(--radius-md);
  }
  .ui-responsive-table tbody td {
    display: block; min-width: 0; max-width: none; width: auto; padding: 0; border: 0;
    white-space: normal; overflow-wrap: anywhere; font-size: var(--text-body);
  }
  .ui-responsive-table td[data-label]:before {
    content: attr(data-label); display: block; font-size: var(--text-caption);
    font-weight: 600; line-height: 1.6; color: var(--muted); margin-bottom: 4px;
  }
  .ui-responsive-table tbody td:is(.cell-copy, .invoice-buyer-info, .amount, [colspan]),
  .ui-responsive-table tbody td:has(.row-actions), .ui-responsive-table tbody td:has(.cell-warning) { grid-column: 1 / -1; }
  .ui-responsive-table tbody td.amount { white-space: nowrap; }
  .ui-responsive-table tbody td[colspan]:before { content: none; }
  .ui-responsive-table .row-actions { justify-content: flex-start; }
  .attachment-link { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
  .form-row { grid-template-columns: minmax(0, 1fr); }
  input:not([type=checkbox]):not([type=radio]):not([type=file]),
  .question > input, .url-field input, input[type=date] { font-size: 16px; }
  .question { padding: 22px 18px; }
  .form-cover { padding: 24px 18px; }
  .questionnaire { width: calc(100% - 24px); margin-top: 20px; }
  .questionnaire h1 { font-size: var(--text-title); }
  .form-top { padding-inline: 16px; }
  .login-view { padding: 20px 16px; }
  .login-card { padding: 28px 22px; }
  .brand { white-space: normal; }
  .brand a { font-size: var(--text-caption); }
  .export-actions { flex-wrap: wrap; }
  .export-actions > * { flex: 1 1 130px; }
  main:not(.workspace):not(.questionnaire) { width: calc(100% - 32px); margin-top: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *:before, *:after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media screen {
  body { background-image: var(--workspace-light); }
  :is(.page-heading h1, .login-card h1, .dialog-heading h2, #pageTitle) {
    font-family: var(--font-display);
  }
  :is(.panel, .form-cover, .question, .meeting-card) {
    background-image: var(--surface-light);
    box-shadow: var(--shadow-card);
  }
  :is(.login-card, dialog) {
    background-image: var(--surface-light);
    box-shadow: var(--shadow-window);
  }
  dialog::backdrop {
    background: var(--window-scrim);
    backdrop-filter: none;
  }
  dialog[open] { animation: labor-window-in .22s cubic-bezier(.2, .8, .25, 1); }
  @keyframes labor-window-in {
    from { opacity: 0; translate: 0 9px; scale: .98; }
    to { opacity: 1; translate: 0 0; scale: 1; }
  }

  :is(.text-button, .text-link, .attachment-link, .tabs button:not(.active),
      .source-modes button[aria-pressed="false"], summary) {
    --control-rest-shadow: none;
  }
  .meeting-card { --control-rest-shadow: var(--shadow-card); }
  :is(button.primary, button.danger, .agreement-types a[aria-current="page"]):not(:disabled) {
    background-image: var(--surface-control-light);
  }
  summary {
    --control-lift: none;
    --control-press: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
  }
  summary:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
  :is(.text-link, .attachment-link, a[download]:not(.button)) { border-radius: var(--radius-sm); }

  :is(button, summary, [role="button"], .upload-box:where(:has(input[type="file"]:enabled)),
      a:where(.button, .text-link, .attachment-link, [download], .agreement-types a)):not(:where(:disabled, [aria-disabled="true"])) {
    box-shadow: var(--control-rest-shadow, var(--shadow-control));
    transition: box-shadow .18s ease, translate .19s var(--ease-release),
      background-color .15s ease, border-color .15s ease, color .15s ease;
  }

  @media (hover: hover) and (pointer: fine) {
    :is(button, summary, [role="button"], .upload-box:where(:has(input[type="file"]:enabled)),
        a:where(.button, .text-link, .attachment-link, [download], .agreement-types a)):not(:where(:disabled, [aria-disabled="true"])):hover {
      box-shadow: var(--shadow-control-raised);
      translate: var(--control-lift);
    }
  }

  :is(button, summary, [role="button"], .upload-box:where(:has(input[type="file"]:enabled)),
      a:where(.button, .text-link, .attachment-link, [download], .agreement-types a)):not(:where(:disabled, [aria-disabled="true"])):active {
    box-shadow: var(--shadow-control-pressed);
    translate: var(--control-press);
    transition-duration: .045s;
    transition-timing-function: ease-out;
  }

  @media (max-width: 760px) {
    .ui-responsive-table tbody tr { box-shadow: var(--shadow-card-compact); }
  }
  @media (prefers-reduced-motion: reduce) {
    :root { --control-lift: none; --control-press: none; }
  }
}
