/* ===== Tema claro (Windows 11) ===== */
    :root {
      --bg: #f3f3f3;
      --surface: #fff;
      --surface-2: #fbfbfb;
      --surface-3: #f5f5f5;
      --stroke: rgba(0, 0, 0, .08);
      --stroke-2: rgba(0, 0, 0, .15);
      --stroke-3: rgba(0, 0, 0, .24);
      --txt: #1b1b1b;
      --muted: #5d5d5d;
      --dim: #8a8a8a;
      --accent: #0067c0;
      --accent-hover: #005a9e;
      --accent-soft: #eaf2fb;
      --green: #0f7b3f;
      --green-bg: #e9f6ee;
      --green-bd: rgba(15, 123, 63, .25);
      --red: #c42b1c;
      --red-bg: #fdecea;
      --red-bd: rgba(196, 43, 28, .25);
      --amber: #8a5a00;
      --amber-bg: #fff8e6;
      --amber-bd: rgba(138, 90, 0, .25);
      --r: 8px;
      --rc: 5px;
      --shadow: 0 2px 4px rgba(0, 0, 0, .04), 0 0 2px rgba(0, 0, 0, .06);
      --shadow-2: 0 8px 16px rgba(0, 0, 0, .08), 0 0 2px rgba(0, 0, 0, .06);
      --shadow-dlg: 0 32px 64px rgba(0, 0, 0, .22), 0 2px 21px rgba(0, 0, 0, .12);
      --font: 'Segoe UI Variable Text', 'Segoe UI Variable', 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
      --mono: 'Cascadia Mono', 'Consolas', ui-monospace, Menlo, monospace;
    }

    *,
    *::before,
    *::after {
      box-sizing: border-box
    }

    body {
      margin: 0;
      min-height: 100vh;
      background: var(--bg);
      color: var(--txt);
      font-family: var(--font);
      font-size: 14px;
      line-height: 1.5;
      -webkit-font-smoothing: antialiased
    }

    h1,
    h2,
    h3,
    h4,
    p {
      margin: 0
    }

    button,
    input,
    textarea {
      font: inherit;
      color: inherit
    }

    code,
    .mono {
      font-family: var(--mono)
    }

    ::selection {
      background: #cfe4f7
    }

    :focus-visible {
      outline: 2px solid var(--txt);
      outline-offset: 1px;
      border-radius: 3px
    }

    ::-webkit-scrollbar {
      width: 12px;
      height: 12px
    }

    ::-webkit-scrollbar-thumb {
      background: #c8c8c8;
      border: 3px solid var(--bg);
      border-radius: 8px
    }

    .shell {
      max-width: 880px;
      margin: 0 auto;
      padding: 18px 20px 60px
    }

    .reveal {
      opacity: 0;
      transform: translateY(6px)
    }

    .reveal.in {
      opacity: 1;
      transform: none;
      transition: opacity .25s ease-out, transform .25s ease-out
    }

    /* topbar */
    .topbar {
      position: sticky;
      top: 0;
      z-index: 40;
      background: rgba(255, 255, 255, .88);
      backdrop-filter: saturate(180%) blur(20px);
      -webkit-backdrop-filter: saturate(180%) blur(20px);
      border-bottom: 1px solid var(--stroke)
    }

    .topbar-in {
      max-width: 880px;
      margin: 0 auto;
      padding: 10px 20px;
      display: flex;
      align-items: center;
      gap: 12px;
      flex-wrap: wrap
    }

    .brand {
      display: flex;
      align-items: center;
      gap: 10px;
      font-weight: 600
    }

    .logo {
      width: 32px;
      height: 32px;
      border-radius: 6px;
      background: var(--accent);
      color: #fff;
      display: grid;
      place-items: center;
      font-size: 15px
    }

    .brand small {
      display: block;
      font-size: 11.5px;
      font-weight: 400;
      color: var(--muted);
      margin-top: 1px
    }

    .topbar-right {
      margin-left: auto;
      display: flex;
      gap: 8px;
      flex-wrap: wrap
    }

    .pill {
      padding: 4px 10px;
      border-radius: 4px;
      border: 1px solid var(--stroke);
      background: var(--surface);
      font-size: 12px;
      color: var(--muted)
    }

    .pill strong {
      color: var(--txt);
      font-weight: 600
    }

    /* cartão + secção */
    .card {
      background: var(--surface);
      border: 1px solid var(--stroke);
      border-radius: var(--r);
      box-shadow: var(--shadow)
    }

    .card-pad {
      padding: 20px 22px
    }

    .sec-head {
      display: flex;
      align-items: center;
      gap: 10px;
      margin-bottom: 16px
    }

    .sec-head h2 {
      font-size: 15px;
      font-weight: 600
    }

    .sec-ico {
      width: 30px;
      height: 30px;
      border-radius: 6px;
      display: grid;
      place-items: center;
      background: var(--accent-soft);
      font-size: 14px
    }

    /* abas */
    .seg {
      position: relative;
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 4px;
      padding: 3px;
      border-radius: 6px;
      background: var(--surface-3);
      border: 1px solid var(--stroke);
      margin-bottom: 18px
    }

    .seg .glider {
      position: absolute;
      top: 3px;
      left: 3px;
      height: calc(100% - 6px);
      width: calc(50% - 4px);
      border-radius: 4px;
      background: var(--surface);
      box-shadow: var(--shadow);
      transition: transform .2s ease-out
    }

    .seg label {
      position: relative;
      z-index: 1;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 7px;
      padding: 8px;
      border-radius: 4px;
      font-size: 13px;
      font-weight: 600;
      color: var(--muted);
      cursor: pointer;
      user-select: none;
      transition: color .2s
    }

    .seg input {
      position: absolute;
      opacity: 0;
      pointer-events: none
    }

    .seg input:checked+span {
      color: var(--txt)
    }

    .seg label:focus-within {
      outline: 2px solid var(--txt);
      outline-offset: 1px
    }

    /* campos */
    .field {
      margin-bottom: 18px
    }

    .field>.lbl {
      display: flex;
      align-items: baseline;
      justify-content: space-between;
      gap: 10px;
      margin-bottom: 6px;
      flex-wrap: wrap
    }

    .field .lbl b {
      font-size: 13px;
      font-weight: 600
    }

    .field .lbl .tip {
      font-size: 12px;
      color: var(--dim)
    }

    .input,
    .ta {
      width: 100%;
      border-radius: var(--rc);
      border: 1px solid var(--stroke-2);
      border-bottom-color: var(--stroke-3);
      background: var(--surface-2);
      padding: 8px 11px;
      font-size: 13.5px;
      outline: none;
      resize: vertical;
      transition: background .15s, border-color .15s
    }

    .ta {
      min-height: 104px;
      max-height: 220px;
      line-height: 1.55
    }

    .input::placeholder,
    .ta::placeholder {
      color: #9a9a9a
    }

    .input:hover,
    .ta:hover {
      background: var(--surface)
    }

    .input:focus,
    .ta:focus {
      background: var(--surface);
      border-bottom: 2px solid var(--accent);
      padding-bottom: 7px
    }

    .ta[readonly] {
      background: var(--surface-3);
      color: var(--muted);
      cursor: default
    }

    .ta[readonly]:focus {
      border-bottom-width: 1px;
      border-bottom-color: var(--stroke-3);
      padding-bottom: 8px
    }

    .hintline {
      font-size: 12px;
      color: var(--muted);
      margin-top: 6px
    }

    .hintline .mono,
    .mono.t {
      font-size: 11.5px;
      background: var(--surface-3);
      border: 1px solid var(--stroke);
      padding: 1px 5px;
      border-radius: 3px
    }

    .bad {
      border-color: var(--red) !important;
      border-bottom: 2px solid var(--red) !important
    }

    /* contador + métricas */
    .counter {
      display: flex;
      align-items: center;
      gap: 12px;
      margin-top: 10px;
      flex-wrap: wrap
    }

    .ring {
      position: relative;
      width: 40px;
      height: 40px;
      flex: 0 0 auto
    }

    .ring svg {
      transform: rotate(-90deg);
      display: block
    }

    .ring .track {
      stroke: #e6e6e6
    }

    .ring .prog {
      stroke: var(--accent);
      stroke-linecap: round;
      transition: stroke-dashoffset .25s ease-out
    }

    .ring b {
      position: absolute;
      inset: 0;
      display: grid;
      place-items: center;
      font-size: 11px;
      font-weight: 600
    }

    .metrics {
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
      align-items: center
    }

    .metric {
      display: inline-flex;
      align-items: center;
      gap: 5px;
      padding: 3px 9px;
      border-radius: 4px;
      border: 1px solid var(--stroke);
      background: var(--surface-2);
      font-size: 12px;
      color: var(--muted)
    }

    .metric b {
      color: var(--txt);
      font-weight: 600
    }

    .metric.good {
      background: var(--green-bg);
      border-color: var(--green-bd);
      color: var(--green)
    }

    .metric.good b {
      color: var(--green)
    }

    .metric.warn {
      background: var(--amber-bg);
      border-color: var(--amber-bd);
      color: var(--amber)
    }

    .metric.danger {
      background: var(--red-bg);
      border-color: var(--red-bd);
      color: var(--red)
    }

    .metric.danger b {
      color: var(--red)
    }

    /* chips */
    .chips {
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
      align-items: center
    }

    .chip {
      padding: 3px 8px;
      border-radius: 4px;
      border: 1px solid var(--stroke-2);
      background: var(--surface);
      font-family: var(--mono);
      font-size: 11.5px;
      color: var(--accent);
      cursor: pointer;
      transition: background .15s
    }

    .chip:hover {
      background: var(--accent-soft);
      border-color: rgba(0, 103, 192, .35)
    }

    /* ficheiro */
    .drop {
      position: relative;
      border-radius: 6px;
      border: 1px dashed var(--stroke-3);
      background: var(--surface-2);
      padding: 20px;
      text-align: center;
      cursor: pointer;
      transition: background .15s, border-color .15s
    }

    .drop:hover {
      border-color: var(--accent);
      background: var(--accent-soft)
    }

    .drop.drag {
      border-color: var(--accent);
      background: #dfeefb;
      border-style: solid
    }

    .drop.has {
      border-style: solid;
      border-color: var(--green-bd);
      background: var(--green-bg);
      text-align: left
    }

    .drop input[type=file] {
      display: none
    }

    .drop .big {
      font-size: 24px;
      display: block;
      margin-bottom: 6px
    }

    .drop h4 {
      font-size: 13.5px;
      font-weight: 600
    }

    .drop p {
      font-size: 12px;
      color: var(--muted);
      margin-top: 4px
    }

    .filecard {
      display: none;
      align-items: center;
      gap: 12px
    }

    .drop.has .filecard {
      display: flex
    }

    .drop.has .empty {
      display: none
    }

    .fico {
      width: 38px;
      height: 38px;
      border-radius: 6px;
      background: #fff;
      border: 1px solid var(--green-bd);
      display: grid;
      place-items: center;
      font-size: 17px
    }

    .fmeta {
      min-width: 0;
      flex: 1
    }

    .fmeta b {
      display: block;
      font-size: 13.5px;
      font-weight: 600;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap
    }

    .fmeta span {
      font-size: 12px;
      color: var(--muted)
    }

    .fx {
      width: 30px;
      height: 30px;
      border-radius: 4px;
      border: 1px solid var(--stroke-2);
      background: var(--surface);
      color: var(--muted);
      display: grid;
      place-items: center;
      cursor: pointer
    }

    .fx:hover {
      background: var(--red-bg);
      border-color: var(--red-bd);
      color: var(--red)
    }

    /* pré-visualização */
    .preview {
      margin: 0 0 18px;
      border-radius: 6px;
      border: 1px solid var(--stroke);
      background: var(--surface-3);
      padding: 12px 14px
    }

    .preview .ph-head {
      display: flex;
      gap: 8px;
      font-size: 12px;
      color: var(--muted);
      margin-bottom: 8px
    }

    .bubble {
      max-width: 90%;
      margin-left: auto;
      background: var(--accent);
      color: #fff;
      border-radius: 8px 8px 2px 8px;
      padding: 8px 11px;
      font-size: 13px;
      line-height: 1.5;
      word-break: break-word;
      white-space: pre-wrap
    }

    .bubble.empty {
      background: var(--surface);
      color: var(--dim);
      font-style: italic;
      border: 1px solid var(--stroke)
    }

    .bubble .from {
      display: block;
      font-size: 11px;
      font-weight: 600;
      opacity: .85;
      margin-bottom: 3px
    }

    /* botões */
    .actions {
      display: flex;
      gap: 10px;
      flex-wrap: wrap;
      align-items: center
    }

    .btn {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      cursor: pointer;
      border-radius: var(--rc);
      padding: 7px 16px;
      font-size: 13.5px;
      font-weight: 600;
      transition: background .15s, border-color .15s
    }

    .btn-primary {
      flex: 1;
      min-width: 190px;
      background: var(--accent);
      color: #fff;
      border: 1px solid var(--accent)
    }

    .btn-primary:hover {
      background: var(--accent-hover);
      border-color: var(--accent-hover)
    }

    .btn-ghost {
      background: var(--surface);
      border: 1px solid var(--stroke-2);
      border-bottom-color: var(--stroke-3)
    }

    .btn-ghost:hover {
      background: var(--surface-3)
    }

    .btn[disabled] {
      opacity: .5;
      cursor: not-allowed
    }

    .btn .sp {
      display: none;
      width: 14px;
      height: 14px;
      border-radius: 50%;
      border: 2px solid rgba(255, 255, 255, .45);
      border-top-color: #fff;
      animation: spin .8s linear infinite
    }

    .btn.loading .sp {
      display: block
    }

    @keyframes spin {
      to {
        transform: rotate(360deg)
      }
    }

    .resumo {
      margin-top: 12px;
      font-size: 12px;
      color: var(--muted)
    }

    /* resultados */
    .results {
      margin-top: 14px
    }

    .res-tools {
      display: flex;
      gap: 6px;
      flex-wrap: wrap;
      align-items: center;
      margin-left: auto
    }

    .fchip {
      padding: 3px 9px;
      border-radius: 4px;
      border: 1px solid var(--stroke-2);
      background: var(--surface);
      font-size: 12px;
      color: var(--muted);
      cursor: pointer;
      transition: background .15s, color .15s
    }

    .fchip:hover {
      background: var(--surface-3);
      color: var(--txt)
    }

    .fchip.active {
      background: var(--accent-soft);
      border-color: rgba(0, 103, 192, .35);
      color: var(--accent);
      font-weight: 600
    }

    .rlist {
      max-height: min(60vh, 560px);
      overflow-y: auto;
      border-radius: 6px;
      border: 1px solid var(--stroke);
      background: var(--surface)
    }

    .ritem {
      display: flex;
      gap: 12px;
      padding: 12px 14px;
      border-bottom: 1px solid var(--stroke);
      align-items: flex-start
    }

    .ritem:last-child {
      border-bottom: 0
    }

    .ritem:hover {
      background: var(--surface-3)
    }

    .ritem.hide {
      display: none
    }

    .rico {
      width: 28px;
      height: 28px;
      border-radius: 5px;
      display: grid;
      place-items: center;
      font-size: 13px;
      flex: 0 0 auto
    }

    .ritem.ok .rico {
      background: var(--green-bg);
      border: 1px solid var(--green-bd)
    }

    .ritem.no .rico {
      background: var(--red-bg);
      border: 1px solid var(--red-bd)
    }

    .rbody {
      min-width: 0;
      flex: 1
    }

    .rnum {
      font-family: var(--mono);
      font-size: 13px;
      word-break: break-all
    }

    .rnum em {
      font-family: var(--font);
      font-style: normal;
      color: var(--muted);
      font-size: 12.5px
    }

    .rsub {
      font-size: 12px;
      margin-top: 2px;
      color: var(--muted)
    }

    .rsub.good {
      color: var(--green)
    }

    .rsub.err {
      color: var(--red)
    }

    .bdg {
      font-family: var(--mono);
      font-size: 11px;
      padding: 2px 7px;
      border-radius: 4px;
      border: 1px solid var(--stroke);
      background: var(--surface-2);
      color: var(--muted);
      margin-top: 5px;
      display: inline-block
    }

    .bdg.good {
      background: var(--green-bg);
      border-color: var(--green-bd);
      color: var(--green)
    }

    .bdg.err {
      background: var(--red-bg);
      border-color: var(--red-bd);
      color: var(--red)
    }

    .empty-state {
      padding: 24px;
      text-align: center;
      color: var(--muted);
      font-size: 13px
    }

    /* diálogo */
    .overlay {
      position: fixed;
      inset: 0;
      z-index: 80;
      display: grid;
      place-items: center;
      padding: 20px;
      background: rgba(0, 0, 0, .32);
      opacity: 0;
      visibility: hidden;
      transition: opacity .18s ease-out, visibility .18s
    }

    .overlay.open {
      opacity: 1;
      visibility: visible
    }

    .overlay[hidden] {
      display: none
    }

    .hidden {
      display: none !important
    }

    .modal {
      width: 100%;
      max-width: 500px;
      max-height: 88vh;
      overflow-y: auto;
      background: var(--surface);
      border: 1px solid var(--stroke-2);
      border-radius: var(--r);
      box-shadow: var(--shadow-dlg);
      transform: scale(.98);
      opacity: 0;
      transition: transform .18s ease-out, opacity .18s
    }

    .overlay.open .modal {
      transform: none;
      opacity: 1
    }

    .m-head {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 20px 22px 0
    }

    .m-ico {
      width: 34px;
      height: 34px;
      border-radius: 6px;
      background: var(--accent-soft);
      display: grid;
      place-items: center;
      font-size: 16px
    }

    .m-head h3 {
      font-size: 15.5px;
      font-weight: 600
    }

    .m-head p {
      font-size: 12.5px;
      color: var(--muted);
      margin-top: 2px
    }

    .m-body {
      padding: 14px 22px 0
    }

    .mgrid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px
    }

    .mbox {
      border: 1px solid var(--stroke);
      border-radius: 6px;
      background: var(--surface-2);
      padding: 10px 12px
    }

    .mbox .k {
      font-size: 11px;
      color: var(--muted)
    }

    .mbox .v {
      font-size: 13.5px;
      font-weight: 600;
      margin-top: 3px;
      word-break: break-word
    }

    .mbox.wide {
      grid-column: 1/-1
    }

    .mmsg {
      margin-top: 10px;
      border: 1px solid var(--stroke);
      border-radius: 6px;
      background: var(--surface-3);
      padding: 11px 12px;
      font-size: 13px;
      line-height: 1.55;
      white-space: pre-wrap;
      max-height: 150px;
      overflow-y: auto
    }

    .mwarn {
      margin-top: 10px;
      display: flex;
      gap: 10px;
      border: 1px solid var(--amber-bd);
      background: var(--amber-bg);
      border-radius: 6px;
      padding: 11px 13px
    }

    .mwarn p {
      font-size: 12px;
      color: var(--amber);
      line-height: 1.6
    }

    .m-foot {
      display: flex;
      gap: 10px;
      padding: 16px 22px 20px
    }

    .m-foot .btn {
      flex: 1;
      min-width: 130px
    }

    /* a enviar */
    .sending {
      z-index: 95
    }

    .send-card {
      width: 100%;
      max-width: 400px;
      background: var(--surface);
      border: 1px solid var(--stroke-2);
      border-radius: var(--r);
      box-shadow: var(--shadow-dlg);
      padding: 24px;
      text-align: center
    }

    .send-ring {
      width: 32px;
      height: 32px;
      margin: 0 auto 12px;
      border-radius: 50%;
      border: 3px solid #e6e6e6;
      border-top-color: var(--accent);
      animation: spin .9s linear infinite
    }

    .send-card h3 {
      font-size: 15px;
      font-weight: 600
    }

    .send-card p {
      font-size: 12.5px;
      color: var(--muted);
      margin-top: 4px
    }

    .pbar {
      height: 4px;
      border-radius: 2px;
      background: #e6e6e6;
      overflow: hidden;
      margin: 16px 0 8px
    }

    .pbar i {
      display: block;
      height: 100%;
      width: 35%;
      background: var(--accent);
      animation: indet 1.4s ease-in-out infinite
    }

    @keyframes indet {
      0% {
        transform: translateX(-110%)
      }

      100% {
        transform: translateX(320%)
      }
    }

    .send-timer {
      font-family: var(--mono);
      font-size: 12px;
      color: var(--muted)
    }

    .send-tips {
      font-size: 11.5px;
      color: var(--dim);
      margin-top: 12px;
      border-top: 1px solid var(--stroke);
      padding-top: 10px
    }

    /* notificações */
    .toasts {
      position: fixed;
      right: 16px;
      bottom: 16px;
      z-index: 99;
      display: flex;
      flex-direction: column;
      gap: 8px;
      max-width: min(92vw, 340px)
    }

    .toast {
      display: flex;
      gap: 10px;
      align-items: flex-start;
      background: var(--surface);
      border: 1px solid var(--stroke-2);
      border-left: 3px solid var(--accent);
      border-radius: 6px;
      box-shadow: var(--shadow-2);
      padding: 10px 12px;
      animation: tin .2s ease-out both
    }

    .toast.out {
      animation: tout .2s ease-in forwards
    }

    @keyframes tin {
      from {
        opacity: 0;
        transform: translateY(8px)
      }

      to {
        opacity: 1;
        transform: none
      }
    }

    @keyframes tout {
      to {
        opacity: 0;
        transform: translateY(8px)
      }
    }

    .toast b {
      display: block;
      font-size: 13px;
      font-weight: 600
    }

    .toast p {
      font-size: 12px;
      color: var(--muted);
      margin-top: 2px
    }

    .toast.good {
      border-left-color: var(--green)
    }

    .toast.bad {
      border-left-color: var(--red)
    }

    .toast.info {
      border-left-color: var(--accent)
    }

    .foot {
      margin-top: 26px;
      font-size: 12px;
      color: var(--dim);
      text-align: center
    }

    @media (max-width:640px) {
      .shell {
        padding: 14px 14px 50px
      }

      .card-pad {
        padding: 16px
      }

      .mgrid {
        grid-template-columns: 1fr
      }

      .res-tools {
        margin-left: 0;
        width: 100%
      }

      .toasts {
        left: 14px;
        right: 14px;
        bottom: 14px;
        max-width: none
      }
    }

    @media (prefers-reduced-motion:reduce) {

      *,
      *::before,
      *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important
      }

      .reveal {
        opacity: 1;
        transform: none
      }
    }

/* ============================================================
   HISTÓRICO / AUDITORIA
   ============================================================ */
.hlist {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hitem {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid var(--stroke);
  border-radius: 6px;
  background: var(--surface-2);
  padding: 11px 13px;
}

.hitem:hover {
  background: var(--surface-3);
}

.hwhen {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  padding-top: 2px;
}

.hbody {
  min-width: 0;
  flex: 1;
}

.hmeta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}

.hmsg {
  font-size: 12.5px;
  margin-top: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hacoes {
  flex: 0 0 auto;
}

#hDet .ritem:first-child {
  border-top: 0;
}

