/* Spark Agency HR — Forms & letters (v49) */
@media screen {
  .fm-wrap { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 22px; align-items: start; }
  @media (max-width: 1050px) { .fm-wrap { grid-template-columns: 1fr; } }
  .fm-list { background: #fff; border: 1px solid #d9e4e3; border-radius: 18px; padding: 18px; display: grid; gap: 16px; position: sticky; top: 16px; }
  .fm-list-head h2 { margin: 0 0 4px; }
  .fm-list-head p { margin: 0 0 12px; }
  .fm-list-head button { display: inline-flex; align-items: center; gap: 8px; width: 100%; justify-content: center; }
  .fm-group { display: grid; gap: 6px; }
  .fm-group h3 { margin: 0 0 2px; font-size: 12.5px; color: #5b7178; font-weight: 700; display: flex; justify-content: space-between; gap: 8px; }
  .fm-group h3 small { letter-spacing: 0; font-size: 12px; text-transform: none; color: #8aa0a6; }
  .fm-item {
    display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
    padding: 9px 12px; margin: 0; border: 1px solid transparent; border-radius: 12px;
    background: transparent; color: #10262f; box-shadow: none; font-weight: 400;
    transition: background-color 0.15s, border-color 0.15s;
  }
  .fm-item:hover { background: #f3f8f8; }
  .fm-item.is-on { background: #21345a; color: #fff; }
  .fm-item svg { flex: none; color: #4a90bf; }
  .fm-item.is-on svg { color: #9cc8e6; }
  .fm-item span { display: grid; min-width: 0; }
  .fm-item b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .fm-item small { font-size: 12.5px; letter-spacing: 0; text-transform: none; color: inherit; opacity: 0.75; text-align: left; }

  .fm-main { min-width: 0; }
  .fm-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
  .fm-bar button { display: inline-flex; align-items: center; gap: 7px; }
  .fm-bar [data-tools] { display: inline-flex; gap: 8px; flex-wrap: wrap; align-items: center; }
  .fm-spacer { flex: 1; }
  .fm-seg { display: inline-flex; padding: 4px; border-radius: 12px; background: #e9f0ef; gap: 2px; }
  .fm-seg button { margin: 0; min-height: 34px; padding: 6px 16px; border: 0; border-radius: 9px; background: transparent; color: #47616b; box-shadow: none; font-weight: 700; }
  .fm-seg button[aria-pressed="true"] { background: #fff; color: #21345a; box-shadow: 0 1px 3px #0f2a361f; }
  .fm-emp { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-weight: 600; white-space: nowrap; }
  .fm-emp select { min-width: 220px; }
  .fm-hint { margin: 0 0 14px; font-size: 13px; }
  .fm-preview { max-width: 820px; }

  /* builder */
  dialog.fm-builder { width: min(1500px, calc(100vw - 24px)); height: calc(100vh - 24px); max-height: none; padding: 0; border: 0; border-radius: 20px; overflow: hidden; }
  dialog.fm-builder::backdrop { background: #0f2a36b3; backdrop-filter: blur(3px); }
  dialog.fm-builder[open] { animation: fm-pop 0.28s cubic-bezier(.22,.8,.3,1); }
  .fm-b { height: 100%; display: grid; grid-template-rows: auto 1fr auto; }
  .fm-b-head { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid #e3ecea; background: #fff; flex-wrap: wrap; }
  .fm-b-head h2 { margin: 0; }
  .fm-b-cols { display: grid; grid-template-columns: minmax(380px, 1fr) minmax(0, 1fr); min-height: 0; }
  @media (max-width: 1000px) { .fm-b-cols { grid-template-columns: 1fr; overflow: auto; } .fm-b-side { display: none; } }
  .fm-b-edit { overflow: auto; padding: 18px 20px 40px; background: #f4f7f7; display: grid; gap: 14px; align-content: start; }
  .fm-b-side { overflow: auto; padding: 22px; background: #e8eef0; }
  .fm-b-err { margin: 0; padding: 10px 20px; color: #b42318; font-weight: 700; background: #fff4f2; }
  .fm-card { background: #fff; border: 1px solid #d9e4e3; border-radius: 14px; padding: 14px; display: grid; gap: 10px; }
  .fm-pair { display: grid; grid-template-columns: 110px 1fr 1fr; gap: 8px; align-items: start; }
  .fm-pl { font-weight: 700; font-size: 13px; color: #47616b; padding-top: 9px; }
  .fm-pair input, .fm-pair textarea { padding: 8px 10px; }
  .fm-pair textarea { height: auto; resize: vertical; }
  @media (max-width: 600px) { .fm-pair { grid-template-columns: 1fr; } }
  .fm-scope { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
  .fm-scope label { display: inline-flex; gap: 6px; align-items: center; margin: 0; font-weight: 600; }
  .fm-sec-head, .fm-row-head { display: flex; align-items: center; gap: 6px; }
  .fm-sec-head b { font-size: 15px; }
  .fm-ic { display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; margin: 0; border-radius: 8px; background: #eef3f3; color: #47616b; box-shadow: none; }
  .fm-ic:disabled { opacity: 0.35; cursor: default; }
  .fm-row { border: 1px dashed #c9d8d6; border-radius: 12px; padding: 10px; display: grid; gap: 8px; }
  .fm-kind { font-size: 12px; font-weight: 800; color: #21345a; background: #e7eef8; padding: 3px 9px; border-radius: 999px; }
  .fm-it-wrap { position: relative; }
  .fm-it-wrap + .fm-it-wrap { border-top: 1px solid #eef3f2; padding-top: 8px; }
  .fm-it { display: grid; gap: 8px; }
  .fm-it-x { position: absolute; right: 0; top: -2px; width: 24px; height: 24px; }
  .fm-it-opts { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; padding-left: 118px; }
  @media (max-width: 600px) { .fm-it-opts { padding-left: 0; } }
  .fm-it-opts label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; font-weight: 600; }
  .fm-it-opts select, .fm-it-opts input[type="number"] { width: auto; padding: 6px 8px; }
  .fm-chk { display: inline-flex !important; align-items: center; gap: 6px; margin: 0; font-weight: 600; font-size: 13px; }
  .fm-chk input { width: auto; margin: 0; accent-color: #21345a; }
  .fm-tip { font-size: 12px; }
  .fm-add { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
  .fm-add button { padding: 6px 12px; min-height: 32px; font-size: 13px; }
  .fm-addsec { justify-self: start; display: inline-flex; align-items: center; gap: 6px; }
  .fm-b-prev { max-width: 760px; margin: 0 auto; }
  @keyframes fm-pop { from { opacity: 0; transform: translateY(10px) scale(0.99); } }
  @media (prefers-reduced-motion: reduce) { dialog.fm-builder[open] { animation: none; } }

  /* old documents shown on the Spark paper */
  #document-content .fm-doc-prev { max-width: 100%; }
}
@media screen {
  .fm-scope input { width: auto; margin: 0; accent-color: #21345a; }
  .fm-scope label { white-space: nowrap; }
  .fm-it-wrap:has(> .fm-it-x) { padding-right: 34px; }
  .fm-it-x { right: 0; top: 4px; }

  /* v56: uploaded templates */
  .fm-make { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .fm-make button { padding-inline: 8px; }
  .fm-upl-tag { margin-inline-start: auto; flex: none; font-style: normal; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: #e5f1f9; color: #21345a; }
  .fm-item.is-on .fm-upl-tag { background: #ffffff26; color: #fff; }
  .fm-upl-file { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 14px; background: #f3f8f8; border: 1px dashed #b8cfd0; animation: fm-in .35s ease both; }
  .fm-upl-file svg { flex: none; color: #4a90bf; }
  .fm-upl-file div { display: grid; gap: 2px; min-width: 0; }
  .fm-upl-file b { overflow-wrap: anywhere; }
  .fm-upl-file .muted { font-size: 13px; }
  .fm-upl-note { margin: 4px 0 10px; font-size: 13px; }
  .fm-upl-signers { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-bottom: 10px; }
  .fm-loading { padding: 40px; text-align: center; }
  @keyframes fm-in { from { opacity: 0; transform: translateY(6px); } }
  @media (prefers-reduced-motion: reduce) { .fm-upl-file { animation: none; } }

  /* v57: the list in groups, with a search */
  .fm-find { display: flex; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid #d9e4e3; border-radius: 12px; background: #f7fafa; color: #6b7f86; }
  .fm-find input { border: 0; background: transparent; box-shadow: none; padding: 10px 0; margin: 0; min-height: 0; width: 100%; }
  .fm-find:focus-within { border-color: #4a90bf; background: #fff; }
  details.fm-group { display: grid; gap: 2px; }
  details.fm-group > summary { display: flex; align-items: center; gap: 8px; padding: 6px 4px; cursor: pointer; list-style: none; border-radius: 10px; }
  details.fm-group > summary::-webkit-details-marker { display: none; }
  details.fm-group > summary:hover { background: #f3f8f8; }
  details.fm-group > summary b { font-size: 13px; color: #21345a; }
  details.fm-group > summary small { color: #6b7f86; font-size: 12px; }
  details.fm-group > summary em { margin-inline-start: auto; font-style: normal; font-size: 11px; font-weight: 800; min-width: 22px; text-align: center; padding: 1px 6px; border-radius: 99px; background: #eef3f8; color: #21345a; }
  details.fm-group > summary::after { content: ""; width: 7px; height: 7px; border: solid #8aa0ad; border-width: 0 2px 2px 0; transform: rotate(-45deg); transition: transform .2s; margin: 0 4px; }
  details.fm-group[open] > summary::after { transform: rotate(45deg); }
  .fm-cat-ico { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: #21345a; color: #fff; flex: none; }
  .fm-group-list { display: grid; gap: 2px; padding-inline-start: 6px; border-inline-start: 2px solid #e5edf5; margin-inline-start: 16px; }
  details.fm-group[open] .fm-group-list { animation: fm-in .25s ease both; }
  .fm-src { display: block; font-style: normal; font-size: 11px; color: #4a90bf; margin-top: 1px; }
  .fm-item.is-on .fm-src { color: #9cc8e6; }
  .fm-item[hidden], .fm-group[hidden] { display: none; }
  .fm-catpick { display: grid; gap: 4px; margin-top: 10px; }
  /* v57: upload — Spark design or the original look */
  .fm-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
  @media (max-width: 700px) { .fm-modes { grid-template-columns: 1fr; } }
  .fm-mode { position: relative; display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 2px solid #d9e4e3; border-radius: 14px; cursor: pointer; transition: border-color .15s, background-color .15s; }
  .fm-mode input { position: absolute; opacity: 0; pointer-events: none; }
  .fm-mode:has(input:checked) { border-color: #21345a; background: #f2f6fc; }
  .fm-mode:has(input:focus-visible) { outline: 2px solid #4a90bf; outline-offset: 2px; }
  .fm-mode.is-off { opacity: .55; cursor: not-allowed; }
  .fm-mode > span:last-child { display: grid; gap: 3px; }
  .fm-mode small { color: #6b7f86; font-size: 12px; line-height: 1.4; }
  .fm-mode-pic { flex: none; display: grid; align-content: start; gap: 3px; width: 44px; height: 58px; padding: 5px; border-radius: 6px; background: #fff; box-shadow: 0 0 0 1px #d9e4e3; }
  .fm-mode-pic i { display: block; height: 5px; border-radius: 1px; background: #cfdcf4; }
  .fm-mode-pic.is-spark i:first-child { height: 9px; background: linear-gradient(90deg, #21345a 70%, #4a90bf 70%); }
  .fm-mode-pic.is-spark i:nth-child(2) { background: #21345a; height: 4px; margin-top: 2px; }
  .fm-mode-pic.is-look i:first-child { height: 7px; background: linear-gradient(90deg, #21345a 70%, #4a90bf 70%); }
  .fm-mode-pic.is-look i:last-child { height: 34px; background: repeating-linear-gradient(#e7ecf2 0 2px, #fff 2px 5px); }
}
