/* App palettes follow the supplied icons; approval status colors stay semantic. */
:root[data-module="purchase"] {
  --brand: #f68c22; --brand-hover: #e97b13; --brand-ink: #252e49;
  --accent: #a54b0b; --accent-soft: #fff0d6; --accent-pale: #fffaf0;
  --page: #f7f7fa; --ink: #343e60; --muted: #676d80; --line: #e3e4ec;
  --tint: #fff6df; --focus: #b7590c; --flow-done: #b16f38;
  --input-border: #cacbd8; --subtle: #f5f4f8; --toast: #343e60;
}
:root[data-module="expense"] {
  --brand: #ffbf00; --brand-hover: #edb000; --brand-ink: #493607;
  --accent: #876000; --accent-soft: #fff1b8; --accent-pale: #fffbed;
  --page: #faf8f1; --ink: #433c28; --muted: #766e59; --line: #e9e2cd;
  --tint: #fff8db; --focus: #967000; --flow-done: #a38229;
  --input-border: #d4cbb0; --subtle: #f7f4e9; --toast: #55441d;
}
:root[data-module="payment"] {
  --brand: #246fa7; --brand-hover: #1a5d90; --brand-ink: #ffffff;
  --accent: #246fa7; --accent-soft: #deedf9; --accent-pale: #f1f8fd;
  --page: #f2f7fa; --ink: #243e52; --muted: #5e7483; --line: #dce6ed;
  --tint: #e2f5ef; --focus: #246fa7; --flow-done: #16816d;
  --input-border: #c1d3df; --subtle: #eff6f9; --toast: #234c68;
}
:root[data-module="approval"] {
  --brand: #be345f; --brand-hover: #a32850; --brand-ink: #ffffff;
  --accent: #ac2e56; --accent-soft: #fce5ed; --accent-pale: #fff6f9;
  --page: #f3f7fc; --ink: #39455c; --muted: #69758a; --line: #dde5f0;
  --tint: #e6f0fd; --focus: #be345f; --flow-done: #aa617c;
  --input-border: #c8d5e5; --subtle: #f0f5fc; --toast: #68344d;
}
:root { --green: var(--accent); }
@media screen {
  :root { color: var(--ink); background: var(--page); }
  button, input, select, textarea, .readonly { color: var(--ink); }
  button:hover { background: var(--accent-pale); }
  button.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
  button.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
  button:focus-visible, a:focus-visible { outline-color: var(--focus); }
  input, select, textarea, .choices, .department-picker { border-color: var(--input-border); }
  input:focus, select:focus, textarea:focus { border-color: var(--focus); box-shadow: 0 0 0 3px var(--accent-soft); }
  input[type="checkbox"] { accent-color: var(--accent); }
  .app-header { border-top: 3px solid var(--brand); }
  .brandmark { color: var(--ink); }
  .brand strong { color: var(--accent); }
  .avatar { background: var(--tint); color: var(--accent); }
  .active .count, .secondary-nav .selected { background: var(--accent-soft); color: var(--accent); }
  .count { background: var(--subtle); }
  .document-row:hover { background: var(--accent-pale); }
  .add-row, .upload { border-color: var(--input-border); background: var(--accent-pale); }
  .upload:focus-within { outline-color: var(--focus); }
  .summary, .group-heading { background: var(--tint); }
  .summary strong, .group-heading { color: var(--accent); }
  .subtle-box, .material-summary { background: var(--subtle); }
  .flow li { border-left-color: var(--line); }
  .flow li:last-child { border-left-color: transparent; }
  .flow li:before { background: var(--input-border); }
  .flow li.current:before { background: var(--accent); box-shadow: 0 0 0 6px var(--accent-soft); }
  .flow li.done:before { background: var(--flow-done); }
  .empty-symbol { color: var(--muted); }
  .history li:before { background: var(--flow-done); }
  .history p, .field label.label { color: var(--ink); }
  .item-heading .text { color: var(--muted); }
  dialog { color: var(--ink); }
  dialog p { color: var(--muted); }
  dialog::backdrop { background: #202b3c66; }
  #toast { background: var(--toast); }
}

/* Extend the sticky form and detail toolbar surface without widening the document. */
@media screen {
  .foot-actions {
    isolation: isolate;
    background: #fff;
    backdrop-filter: none;
    border-top: 0;
  }
  .foot-actions::before,
  .foot-actions::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: #fff;
    box-shadow: 0 0 0 100vmax #fff;
    clip-path: inset(0 -100vmax);
  }
  .foot-actions::after {
    bottom: auto;
    height: 1px;
    background: var(--line);
    box-shadow: 0 0 0 100vmax var(--line);
  }
}
@media screen and (max-width: 760px) {
  .foot-actions {
    margin-bottom: 0;
    padding-bottom: max(13px, env(safe-area-inset-bottom));
  }
}

/* Taste redesign: retain the four brand palettes and existing form/navigation structure.
   Radius scale: controls 8px, surfaces 14px. Motion is limited to interaction feedback.
   Layering remains the existing flow sidebar / sticky action bar / dialog stack. */
@media screen {
  :root {
    --surface: #fff;
    --page: #f5f6f8;
    --ink: #253146;
    --muted: #5d697b;
    --line: #e1e5ec;
    --subtle: #f5f7fa;
    --input-border: #bcc5d1;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
  }
  body { min-height: 100dvh; }
  button { border-radius: 8px; min-height: 44px; font-weight: 600; white-space: nowrap; }
  button:disabled { cursor: not-allowed; }
  button:active:not(:disabled) { transform: translateY(1px); }
  button.text:hover { background: var(--accent-soft); }
  button.danger { color: #a52e28; }
  button:focus-visible, a:focus-visible, summary:focus-visible, [tabindex="0"]:focus-visible {
    outline: 2px solid var(--focus); outline-offset: 4px;
  }
  input, select, textarea { border-radius: 8px; background: var(--surface); line-height: 1.5; }
  input::placeholder, textarea::placeholder { color: #657185; opacity: 1; }
  input:disabled, select:disabled { background: var(--subtle); }
  h1 { font-size: 32px; font-weight: 700; letter-spacing: -.7px; line-height: 1.35; }
  h2 { font-weight: 650; letter-spacing: -.2px; }
  .app-header { height: 76px; padding-inline: max(28px, calc((100vw - 1144px)/2)); border-top-width: 3px; }
  .brand { gap: 12px; }
  .app-icon { width: 34px; height: 34px; object-fit: contain; flex: none; }
  .brandmark { font-size: 22px; font-weight: 800; padding-right: 16px; }
  .brand strong { color: var(--ink); font-weight: 650; }
  .chip { border-radius: 4px; font-size: 11px; padding: 3px 7px; }
  .identity { padding: 6px 10px; border-radius: 8px; }
  .avatar { border-radius: 10px; width: 34px; height: 34px; font-weight: 650; }
  .switch-label { color: var(--accent); }
  .test-banner { background: #fff8e8; color: #76571f; border-bottom: 1px solid #f0e7d0; padding-block: 7px; }
  .shell { max-width: 1200px; padding: 32px 28px 76px; }
  .page-heading {
    padding: 26px 28px; margin-bottom: 24px; border: 1px solid var(--line);
    border-left: 4px solid var(--brand); border-radius: 14px; background: var(--surface);
    gap: 24px;
  }
  .page-heading > div { min-width: 0; }
  .page-heading p { font-size: 14px; line-height: 1.7; margin-top: 8px; }
  .eyebrow { color: var(--accent); font-size: 11px; letter-spacing: .8px; margin-bottom: 8px; overflow-wrap: anywhere; }
  .page-heading .primary { padding: 12px 21px; min-height: 48px; }
  .tabs {
    gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 12px;
    padding: 6px; margin-bottom: 16px; scrollbar-width: thin;
  }
  .tabs button { padding: 10px 16px; border-radius: 8px; border: 0; min-height: 44px; }
  .tabs button.active { border: 0; background: var(--accent-soft); color: var(--accent); }
  .tabs button:hover:not(.active) { background: var(--subtle); }
  .count { font-variant-numeric: tabular-nums; min-width: 21px; display: inline-block; text-align: center; }
  .active .count { background: var(--surface); }
  .secondary-nav { margin: 0 0 16px; gap: 6px; }
  .secondary-nav button { font-size: 13px; padding-inline: 12px; }
  .toolbar { gap: 10px; margin-bottom: 18px; }
  .toolbar input { min-width: 180px; }
  .toolbar select { width: 150px; }
  .toolbar [data-action="export-list"] { font-size: 13px; }
  .document-list { border-radius: 14px; }
  .document-row { grid-template-columns: minmax(0, 1fr) 160px 180px 18px; gap: 24px; padding: 26px 28px; }
  .document-row > div { min-width: 0; }
  .doc-title { margin: 10px 0 8px; font-size: 17px; font-weight: 650; overflow-wrap: anywhere; }
  .doc-meta { gap: 8px 18px; line-height: 1.6; }
  .doc-node { font-size: 13px; border-left: 1px solid var(--line); padding-left: 22px; }
  .money { font-size: 23px; letter-spacing: -.5px; font-weight: 650; }
  .tag { font-size: 12px; padding: 4px 9px; font-weight: 550; }
  .row-actions { padding: 0 24px 12px; }
  .pagination { color: var(--muted); font-size: 13px; margin-top: 20px; }
  .pagination button { font-size: 13px; }
  .empty { border-radius: 14px; padding: 56px 24px; }
  .empty-symbol { width: 52px; height: 52px; line-height: 52px; margin: 0 auto 18px; border-radius: 14px; background: var(--accent-pale); color: var(--accent); }
  .empty h3 { color: var(--ink); font-size: 17px; margin-bottom: 10px; }
  .back { padding-left: 0; margin-bottom: 14px; }
  .form-layout { grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; }
  .panel { border-radius: 14px; padding: 26px; margin-bottom: 22px; }
  .section-title { padding-bottom: 17px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
  .section-no { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-variant-numeric: tabular-nums; margin-right: 10px; }
  .section-no:empty { display: none; }
  .grid { gap: 22px 24px; }
  .field label.label { font-size: 13px; font-weight: 600; margin-bottom: 9px; }
  .readonly { min-height: 35px; padding-block: 3px; }
  .person-info { background: var(--subtle); padding: 16px 18px; border-radius: 8px; }
  .sidebar .panel { padding: 22px; border-top: 3px solid var(--brand); }
  .sidebar .panel h2 { font-size: 16px; }
  .flow li { padding-bottom: 26px; line-height: 1.6; }
  .flow li.current { font-weight: 600; }
  .flow small { font-weight: 400; line-height: 1.6; }
  .summary { border-radius: 10px; padding: 22px; }
  .summary strong { font-size: 28px; font-variant-numeric: tabular-nums; letter-spacing: -.7px; }
  .summary small { font-size: 12px; }
  .upload { padding: 17px 12px; border-radius: 8px; }
  .upload:hover, .add-row:hover { background: var(--accent-soft); }
  .add-row { min-height: 46px; }
  .org-picker { background: var(--surface); border-color: var(--input-border); }
  .org-tree label:hover { background: var(--accent-pale); border-radius: 6px; }
  .supplier-period > .item-heading { padding: 12px 14px; border-radius: 8px; background: var(--subtle); }
  .expense-table-scroll { border-color: var(--line); }
  .expense-table th { background: var(--subtle); color: var(--muted); font-size: 12px; font-weight: 600; }
  .expense-table td { border-color: var(--line); }
  .note { border-radius: 0 8px 8px 0; padding: 15px 18px; }
  .error-summary { border: 1px solid #eab9b3; border-radius: 8px; }
  .foot-actions { gap: 12px; padding-block: 16px; }
  .foot-actions .primary { padding-inline: 24px; }
  .test-link { border-top: 1px solid var(--line); padding-top: 20px; margin-top: 28px; }
  .page-info { font-size: 12px; }
  dialog { border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: 0 20px 80px #25314626; }
  dialog::backdrop { background: #25314666; }
}
@media screen and (min-width: 761px) and (max-width: 1000px) {
  .document-row { grid-template-columns: minmax(0, 1fr) 140px 18px; }
  .doc-node { display: none; }
  .form-layout { grid-template-columns: minmax(0, 1fr) 230px; gap: 18px; }
  .grid { grid-template-columns: 1fr; }
}
@media screen and (max-width: 760px) {
  .app-header { height: 66px; padding-inline: 16px; gap: 8px; }
  .brand { gap: 8px; }
  .app-icon { width: 28px; height: 28px; }
  .brandmark { font-size: 17px; padding-right: 9px; }
  .brand strong { font-size: 14px; }
  .identity { padding: 6px 0; flex: none; }
  .chip { margin-left: 5px; font-size: 10px; padding: 2px 5px; }
  .test-banner { padding: 8px 16px; font-size: 11px; }
  .shell { padding: 20px 16px 48px; }
  .page-heading { padding: 20px 18px; gap: 16px; flex-wrap: wrap; border-radius: 12px; margin-bottom: 20px; }
  h1 { font-size: 26px; }
  .page-heading p { font-size: 12px; margin-top: 6px; }
  .page-heading .primary { padding: 10px 16px; min-height: 44px; }
  .eyebrow { font-size: 10px; letter-spacing: .5px; }
  .tabs { margin-right: 0; gap: 4px; padding: 5px; }
  .tabs button { padding: 9px 12px; font-size: 13px; }
  .toolbar { gap: 8px; }
  .toolbar input { min-width: 0; flex-basis: 100%; }
  .toolbar select { width: 0; min-width: 0; flex: 1 1 40%; }
  .toolbar > button { flex: 1; }
  .document-row { grid-template-columns: minmax(0, 1fr) 16px; padding: 20px 18px; gap: 16px; }
  .document-row > .muted:last-child { grid-column: 2; grid-row: 1; }
  .doc-title { font-size: 16px; }
  .doc-side { grid-row: 2; grid-column: 1/-1; border-top: 1px solid var(--line); padding-top: 14px; }
  .doc-node { display: none; }
  .money { font-size: 22px; }
  .doc-meta { font-size: 11px; gap: 5px 12px; }
  .panel, .sidebar .panel { padding: 20px 16px; border-radius: 12px; margin-bottom: 16px; }
  .section-title { padding-bottom: 14px; margin-bottom: 18px; }
  .section-title h2 { font-size: 16px; }
  .grid { gap: 20px; }
  .person-info { padding: 14px; }
  .summary { padding: 18px; }
  .summary strong { font-size: 25px; }
  .foot-actions { margin: 0 -16px; padding: 12px 16px max(12px, env(safe-area-inset-bottom)); gap: 8px; }
  .foot-actions button { min-width: 82px; padding-inline: 12px; font-size: 14px; }
  .foot-actions .primary { padding-inline: 14px; }
  .pagination button { min-height: 40px; padding-inline: 10px; font-size: 12px; }
  .test-link { margin-top: 24px; padding-top: 16px; }
  dialog { padding: 22px; }
  dialog .dialog-actions { bottom: -22px; flex-wrap: wrap; }
}
@media screen and (prefers-reduced-motion: no-preference) {
  button, a.document-row, .upload { transition: background-color 150ms ease, border-color 150ms ease, transform 150ms ease; }
}
