/* Email workspace: same hierarchy as technical demands, without changing other panels. */
@media screen {
  :is(#demandForm, #dashboardView .demand-thread-form) .email-attachment-picker {
    display: grid; gap: 8px; min-width: 0; margin-top: 12px; padding: 12px;
    border: 1px dashed var(--vc-standard-line, #c4d1e2); border-radius: 4px; background: var(--card, #fff);
  }
  :is(#demandForm, #dashboardView .demand-thread-form) .email-attachment-picker.is-dragging {
    border-color: #287a70; background: #f0f8f7; outline: 2px solid #287a70;
  }
  :is(#demandForm, #dashboardView .demand-thread-form) .email-attachment-toolbar {
    display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  }
  :is(#demandForm, #dashboardView .demand-thread-form) .email-attachment-toolbar span,
  :is(#demandForm, #dashboardView .demand-thread-form) .email-attachment-picker small {
    color: var(--muted, #5d6f87); font-size: 12px; line-height: 1.5;
  }
  :is(#demandForm, #dashboardView .demand-thread-form) .email-attachment-toolbar button {
    width: auto !important; min-height: 38px !important; padding: 8px 12px !important;
  }
  :is(#demandForm, #dashboardView .demand-thread-form) .email-attachment-list {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 8px;
  }
  :is(#demandForm, #dashboardView .demand-thread-form) .email-attachment-item {
    display: flex; align-items: center; gap: 10px; min-width: 0; padding: 8px;
    border: 1px solid var(--vc-standard-line, #d8e0ea); border-radius: 4px;
  }
  :is(#demandForm, #dashboardView .demand-thread-form) .email-attachment-item img,
  :is(#demandForm, #dashboardView .demand-thread-form) .email-attachment-extension {
    width: 36px !important; height: 36px !important; flex: 0 0 36px; object-fit: contain;
    border-radius: 3px; display: grid; place-items: center;
    background: #eef3f9; color: #143454; font-size: 10px; font-weight: 700;
  }
  :is(#demandForm, #dashboardView .demand-thread-form) .email-attachment-caption {
    display: grid; min-width: 0; flex: 1; gap: 2px; overflow-wrap: anywhere; font-size: 13px;
  }
  :is(#demandForm, #dashboardView .demand-thread-form) .email-attachment-remove {
    width: 40px !important; flex: 0 0 40px; min-height: 40px !important; padding: 4px !important; font-size: 22px !important;
  }
  :is(#demandForm, #dashboardView .demand-thread-form) .email-attachment-picker [hidden] { display: none !important; }
  #dashboardView #demandsList .email-recipient-verification { grid-column: 1 / -1; display: grid; gap: 12px; }
}

@media screen {
  #dashboardView#dashboardView #demandsPanel .filter-command-bar { justify-content: flex-start; }
  #dashboardView#dashboardView #syncDemandEmailsButton { margin-left: auto; }
  #dashboardView#dashboardView #demandsPanel .demand-metrics {
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)) !important;
    gap: 12px !important;
  }

  #dashboardView#dashboardView #demandsList {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    align-items: start;
    gap: 16px !important;
    min-width: 0;
  }

  #dashboardView#dashboardView #demandsPanel .email-demand-card {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    min-width: 0 !important;
    gap: 0 !important;
    padding: 0 !important;
    border: 1px solid var(--vc-standard-line, #d8e0ea) !important;
    border-radius: 4px !important;
    background: var(--card, #fff) !important;
    box-shadow: none !important;
    overflow-wrap: anywhere;
  }

  #dashboardView#dashboardView #demandsPanel .technical-demand-main {
    display: grid !important;
    gap: 0 !important;
    min-width: 0;
  }

  #dashboardView#dashboardView #demandsPanel .technical-demand-header {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: start !important;
    gap: 16px !important;
    padding: 18px 20px !important;
    border-bottom: 1px solid var(--vc-standard-line, #d8e0ea);
  }

  #dashboardView#dashboardView #demandsPanel .technical-demand-heading { min-width: 0; }
  #dashboardView#dashboardView #demandsPanel .technical-demand-title-row h3 {
    margin: 0 0 5px !important;
    font-size: 21px !important;
    line-height: 1.25 !important;
  }
  #dashboardView#dashboardView #demandsPanel .technical-demand-title {
    font-weight: 700;
    font-size: 15px;
    line-height: 1.45;
  }
  #dashboardView#dashboardView #demandsPanel .technical-demand-description {
    margin-top: 4px !important;
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
  }
  #dashboardView#dashboardView #demandsPanel .technical-demand-header-meta {
    display: grid;
    justify-items: end;
    gap: 8px;
    font-size: 13px;
  }
  #dashboardView#dashboardView #demandsPanel .technical-demand-opened {
    display: grid;
    text-align: right;
    font-weight: 700;
    line-height: 1.4;
  }
  #dashboardView#dashboardView #demandsPanel .technical-demand-opened strong {
    color: var(--muted, #5d6f87);
    font-size: 10px;
    text-transform: uppercase;
  }
  #dashboardView#dashboardView #demandsPanel .technical-demand-badges {
    display: flex;
    justify-content: end;
    gap: 5px;
    flex-wrap: wrap;
  }
  #dashboardView#dashboardView #demandsPanel .record-status { white-space: normal !important; }
  #dashboardView#dashboardView #demandsPanel .email-status-pending { background: #fff3d1; color: #875a05; }
  #dashboardView#dashboardView #demandsPanel .email-status-responded { background: #e1f1f5; color: #07586b; }
  #dashboardView#dashboardView #demandsPanel .email-status-completed { background: #e1f1e9; color: #24634f; }
  #dashboardView#dashboardView #demandsPanel .email-status-disregarded { background: #edf0f4; color: #546174; }
  /* O lado da demanda: azul saiu, verde chegou. Mesma ideia da conversa,
     onde a mensagem enviada e navy e a recebida e verde. A faixa serve para
     varrer a lista de relance; o selo ao lado diz o nome, para quem precisa
     de certeza e para quem nao separa azul de verde. */
  #dashboardView#dashboardView #demandsPanel .email-origin-enviada { background: #e3edf9; color: #1d4677; }
  #dashboardView#dashboardView #demandsPanel .email-origin-recebida { background: #e1f1ee; color: #1f6b60; }
  #dashboardView#dashboardView #demandsPanel .email-demand-origem-enviada { border-left: 4px solid #2a63a2; }
  #dashboardView#dashboardView #demandsPanel .email-demand-origem-recebida { border-left: 4px solid #287a70; }
  #dashboardView#dashboardView #demandsPanel .email-demand-info { padding: 16px 20px; min-width: 0; }
  #dashboardView#dashboardView #demandsPanel .td-atributos { gap: 12px 24px; padding-bottom: 12px; }
  #dashboardView#dashboardView #demandsPanel .td-atributos span { flex: 1 1 135px; }
  #dashboardView#dashboardView #demandsPanel .email-demand-addresses { margin: 12px 0 0; display: grid; gap: 6px; font-size: 14px; }
  #dashboardView#dashboardView #demandsPanel .email-demand-addresses > div { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 10px; }
  #dashboardView#dashboardView #demandsPanel .email-demand-addresses dt { color: var(--muted, #5d6f87); font-weight: 700; }
  #dashboardView#dashboardView #demandsPanel .email-demand-addresses dd { margin: 0; overflow-wrap: anywhere; line-height: 1.5; }
  #dashboardView#dashboardView #demandsPanel .email-demand-activity { margin-top: 12px !important; font-size: 12px; line-height: 1.5; }
  #dashboardView#dashboardView #demandsPanel .technical-demand-footer {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
    padding: 12px 20px !important;
    border-top: 1px solid var(--vc-standard-line, #d8e0ea);
  }
  #dashboardView#dashboardView #demandsPanel .email-demand-author { font-size: 12px; color: var(--muted, #5d6f87); }
  #dashboardView#dashboardView #demandsPanel .email-demand-actions {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: flex-end !important;
    gap: 8px !important;
    margin-left: auto;
    min-width: 0;
  }
  #dashboardView#dashboardView #demandsPanel .email-demand-actions button { width: auto !important; flex: 0 1 auto !important; }
  #dashboardView#dashboardView #demandsPanel .demand-card-attachment { margin-top: 12px; }

  #dashboardView#dashboardView .demand-thread-form { display: block !important; max-width: 1100px !important; margin: 0 auto; }
  #dashboardView#dashboardView .email-conversation { padding: 20px; border: 1px solid var(--vc-standard-line, #d8e0ea); border-radius: 4px; background: var(--card, #fff); }
  #dashboardView#dashboardView .email-conversation-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
  #dashboardView#dashboardView .email-conversation-header > div { display: grid; gap: 4px; }
  #dashboardView#dashboardView #demandThreadStatus { font-size: 13px; color: var(--muted, #5d6f87); }
  #dashboardView#dashboardView .email-conversation-subject { overflow-wrap: anywhere; margin: 16px 0; font-size: 14px; font-weight: 700; }
  #dashboardView#dashboardView .email-original-content { margin-bottom: 16px; font-size: 14px; }
  #dashboardView#dashboardView .email-original-content summary { cursor: pointer; color: var(--muted, #5d6f87); }
  #dashboardView#dashboardView .email-original-content pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; line-height: 1.6; }
  #dashboardView#dashboardView .demand-thread-item { padding: 14px 16px; border-radius: 4px; border: 1px solid var(--vc-standard-line, #d8e0ea); }
  #dashboardView#dashboardView .demand-thread-item.outbound { background: #f2f6fa; border-left: 3px solid #143454; }
  #dashboardView#dashboardView .demand-thread-item.inbound { background: #f0f8f7; border-left: 3px solid #287a70; }
  #dashboardView#dashboardView .demand-thread-item pre { font: inherit; font-size: 14px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
  #dashboardView#dashboardView #demandThreadComposer { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--vc-standard-line, #d8e0ea); }
  #dashboardView#dashboardView #demandThreadComposer[hidden] { display: none !important; }
  #dashboardView#dashboardView #demandThreadComposer label { display: grid; gap: 8px; font-weight: 700; }
  #dashboardView#dashboardView #demandReplyMessage { width: 100%; box-sizing: border-box; min-height: 100px; resize: vertical; }
  #dashboardView#dashboardView .email-reply-actions { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; }
  #dashboardView#dashboardView .email-reply-actions small { color: var(--muted, #5d6f87); }
}

@media screen and (max-width: 1279px) {
  #dashboardView#dashboardView #demandsList { grid-template-columns: minmax(0, 1fr) !important; }
}
@media screen and (max-width: 600px) {
  :is(#demandForm, #dashboardView .demand-thread-form) .email-attachment-item { display: grid; grid-template-columns: 28px minmax(0, 1fr) 40px; gap: 6px; }
  :is(#demandForm, #dashboardView .demand-thread-form) .email-attachment-item img,
  :is(#demandForm, #dashboardView .demand-thread-form) .email-attachment-extension { width: 28px !important; height: 28px !important; }
  :is(#demandForm, #dashboardView .demand-thread-form) .email-attachment-remove { grid-column: 3; }
  #dashboardView#dashboardView #syncDemandEmailsButton { margin-left: 0; }
  #dashboardView#dashboardView #demandsPanel .technical-demand-header { grid-template-columns: minmax(0, 1fr) !important; padding: 16px !important; }
  #dashboardView#dashboardView #demandsPanel .technical-demand-header-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; }
  #dashboardView#dashboardView #demandsPanel .technical-demand-opened { text-align: left; }
  #dashboardView#dashboardView #demandsPanel .email-demand-info { padding: 14px 16px; }
  #dashboardView#dashboardView #demandsPanel .technical-demand-footer { padding: 12px 16px !important; }
  #dashboardView#dashboardView #demandsPanel .email-demand-actions { margin-left: 0; justify-content: flex-start !important; }
  #dashboardView#dashboardView .email-conversation { padding: 16px; }
}
