:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --surface-muted: #f8fafc;
  --surface-hover: #f1f4f7;
  --ink: #20262e;
  --muted: #667085;
  --line: #dde3ea;
  --line-strong: #cbd4df;
  --primary: #2563eb;
  --primary-2: #1d4ed8;
  --primary-soft: #eff6ff;
  --green: #18794e;
  --green-soft: #ecfdf3;
  --amber: #9a5b08;
  --amber-soft: #fff8e8;
  --red: #b42318;
  --red-soft: #fff1f0;
  --teal: #0f766e;
  --blue: #2563eb;
  --shadow: 0 10px 28px rgba(32, 38, 46, 0.08);
}

html {
  background: var(--bg);
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd4df;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #a0abb6;
}

button,
input,
select,
textarea,
summary,
a {
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.42);
  outline-offset: 2px;
}

h2 {
  color: var(--ink);
  font-size: 16px;
  line-height: 1.25;
}

.topbar {
  position: relative;
  z-index: 40;
  min-height: 56px;
  padding: 7px 16px;
  flex-wrap: nowrap;
  gap: 12px;
  background: rgba(255, 255, 255, 0.98);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(32, 38, 46, 0.02);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 6px;
  background: #252b33;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
}

.topbar h1,
.admin-page .topbar h1 {
  max-width: 100%;
  overflow: hidden;
  color: var(--ink);
  font-size: 17px;
  font-weight: 720;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-label,
.admin-page .role-label {
  margin-top: 1px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.2;
}

.top-actions {
  align-items: center;
  gap: 6px;
}

.top-actions .button,
.admin-page .top-actions .button {
  min-height: 32px;
  padding: 5px 9px;
  border-color: var(--line);
  background: var(--surface-muted);
  color: #384250;
  font-size: 12px;
  font-weight: 650;
}

.top-actions .button:hover {
  border-color: var(--line-strong);
  background: var(--surface-hover);
}

.top-actions .button.success {
  border-color: #b7e1c8;
  background: var(--green-soft);
  color: var(--green);
}

.top-actions .button.warning {
  border-color: #ead4aa;
  background: var(--amber-soft);
  color: var(--amber);
}

.top-actions #logoutButton {
  border-color: transparent;
  background: transparent;
}

.layout,
.admin-page .layout {
  padding: 10px;
}

.admin-page .topbar {
  min-height: 56px;
  padding: 7px 16px;
}

.admin-page .topbar > .brand-lockup {
  flex: 0 1 260px;
  min-width: 205px;
}

.top-storage {
  grid-template-columns: auto minmax(90px, 1fr) auto;
  flex: 0 1 285px;
  width: min(285px, 24vw);
  min-height: 40px;
  gap: 3px 7px;
  padding: 4px 6px 4px 10px;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.top-storage strong {
  color: #384250;
  font-size: 11.5px;
  font-weight: 700;
}

.top-storage .progress {
  height: 4px;
  background: #e7ebf0;
}

.top-storage .muted {
  font-size: 10.5px;
}

.top-storage .button,
.admin-page .top-storage .button {
  min-height: 28px;
  padding: 3px 7px;
  border-color: var(--line);
  background: #ffffff;
  color: #475467;
  font-size: 11px;
}

.panel,
.task-card,
.viewer {
  border-color: var(--line);
  border-radius: 6px;
  box-shadow: none;
}

.admin-grid,
.normal-grid {
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.admin-grid {
  grid-template-columns: minmax(210px, 230px) minmax(245px, 280px) minmax(240px, 280px);
}

.admin-mobile-nav {
  display: none;
}

.admin-page .admin-grid.viewer-open {
  grid-template-columns: minmax(210px, 230px) minmax(245px, 270px) minmax(430px, 1fr) minmax(240px, 270px);
  gap: 1px;
}

.normal-grid,
.normal-grid.viewer-open {
  grid-template-columns: minmax(230px, 270px) minmax(480px, 1fr) minmax(230px, 270px);
  gap: 1px;
}

.admin-grid > .panel,
.admin-grid > .viewer,
.normal-grid > .panel,
.normal-grid > .viewer {
  border: 0;
  border-radius: 0;
  background: var(--panel);
}

.panel {
  padding: 12px;
}

.admin-left-panel {
  background: #fbfcfd !important;
  gap: 10px;
}

.list-panel.admin-left-panel {
  padding-right: 10px;
}

.panel-header,
.viewer-header,
.list-header {
  gap: 8px;
  margin-bottom: 9px;
}

.list-header {
  min-height: 30px;
}

.list-header h2,
.viewer-header h2 {
  font-size: 16px;
  font-weight: 720;
}

.list-header .muted,
.viewer-header .muted {
  font-size: 11.5px;
}

.admin-tools {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.tool-panel {
  min-width: 0;
  border-color: var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.tool-panel summary {
  min-height: 38px;
  padding: 7px 9px;
  gap: 6px;
  color: #344054;
  font-size: 12.5px;
  font-weight: 700;
  list-style: none;
}

.tool-panel summary::-webkit-details-marker {
  display: none;
}

.tool-panel summary small {
  display: none;
}

.tool-panel summary::after {
  content: "+";
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border-radius: 4px;
  background: var(--surface-muted);
  color: var(--primary);
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
}

.tool-panel:not([open]) summary:hover {
  border-color: var(--line-strong);
  background: var(--surface-hover);
}

.tool-panel summary.is-file-dragging {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px var(--primary);
  color: var(--primary-2);
}

.tool-panel summary.is-file-dragging::after {
  content: "+";
  background: var(--primary);
  color: #ffffff;
}

.tool-panel[open] {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 100;
  width: min(430px, 100vw);
  height: 100dvh;
  overflow-y: auto;
  padding: 0 18px 18px;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  background: #ffffff;
  box-shadow: -18px 0 48px rgba(32, 38, 46, 0.16);
}

.tool-panel[open] summary {
  position: sticky;
  top: 0;
  z-index: 2;
  min-height: 58px;
  margin: 0 -18px 14px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
  color: var(--ink);
  font-size: 16px;
}

.tool-panel[open] summary small {
  display: block;
  margin-left: auto;
  font-size: 11px;
}

.tool-panel[open] summary::after {
  content: "x";
  background: var(--surface-muted);
  color: #475467;
  font-size: 12px;
  font-weight: 700;
}

.tool-panel form,
.tool-panel[open] form {
  max-height: none;
  overflow: visible;
  padding: 0;
}

form {
  gap: 10px;
}

label,
.file-field-label {
  gap: 5px;
  color: #475467;
  font-size: 12.5px;
  font-weight: 650;
}

input,
select,
textarea {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  transition: all 0.2s ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #aeb9c6;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  outline: none;
}

textarea {
  min-height: 82px;
}

.file-drop-zone {
  min-height: 82px;
  padding: 16px;
  border: 2px dashed #cbd4df;
  border-radius: 8px;
  background: var(--surface-muted);
  transition: all 0.2s ease;
}

.file-drop-zone > strong {
  font-size: 13px;
}

.file-drop-zone > span,
.file-drop-zone small {
  font-size: 11.5px;
}

.button {
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.button:active {
  transform: translateY(1px);
  box-shadow: none;
}

.button.compact,
.compact {
  min-height: 28px;
  padding: 4px 10px;
  font-size: 11.5px;
}

.primary {
  background: var(--primary);
  color: #ffffff;
}

.primary:hover {
  background: var(--primary-2);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

.secondary {
  border-color: var(--line-strong);
  background: #ffffff;
  color: #344054;
}

.secondary:hover {
  border-color: #aeb9c6;
  background: var(--surface-hover);
}

.success {
  background: var(--green);
}

.warning {
  background: var(--amber);
}

.danger {
  background: var(--red);
}

.button.danger:hover {
  background: #912018;
}

.button:disabled {
  opacity: 0.45;
}

.selection-note {
  margin: -3px 0 7px;
  font-size: 11.5px;
}

.task-history-header {
  margin-bottom: 6px;
}

.task-history-tabs {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
}

.task-history-tab {
  min-width: 0;
  min-height: 30px;
  padding: 4px 7px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #667085;
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}

.task-history-tab:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.task-history-tab.active {
  background: #ffffff;
  color: var(--primary-2);
  box-shadow: 0 1px 2px rgba(32, 38, 46, 0.1);
}

.selected-task-files {
  display: grid;
  gap: 6px;
  margin-top: 7px;
  color: #475467;
  font-size: 11.5px;
}

.selected-task-files-summary {
  font-weight: 700;
}

.selected-task-files-list {
  display: grid;
  gap: 4px;
}

.selected-task-file {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 6px 5px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-muted);
}

.selected-task-file > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-task-file-remove {
  display: grid;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #ffffff;
  color: #667085;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.selected-task-file-remove:hover {
  border-color: #f0b4ae;
  color: var(--red);
}

.user-list,
.task-list {
  gap: 0;
  margin-top: 0;
  padding-right: 2px;
}

.user-item {
  gap: 7px;
  padding: 10px 8px;
  border: 0;
  border-bottom: 1px solid #e9edf2;
  border-radius: 0;
  background: transparent;
}

.user-item:hover {
  background: var(--surface-hover);
}

.user-item.selected {
  border-color: #dce8ff;
  border-radius: 5px;
  background: var(--primary-soft);
  box-shadow: inset 3px 0 0 var(--primary);
}

.user-item-main {
  gap: 1px;
  min-width: 0;
}

.user-item-main strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-item-main .muted {
  overflow: hidden;
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-item .badge {
  min-height: 19px;
  padding: 1px 6px;
  font-size: 10px;
}

.user-actions {
  gap: 5px;
}

.user-item .button.primary {
  border: 1px solid #bfdbfe;
  background: #ffffff;
  color: var(--primary);
}

.bulk-actions {
  display: grid;
  min-height: 38px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  margin-bottom: 5px;
  padding: 4px 0 8px;
}

.bulk-check,
.task-select {
  gap: 5px;
  font-size: 11.5px;
  font-weight: 650;
}

.bulk-check input,
.task-select input,
.direct-message-select-all input,
.direct-message-selector input {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
}

.task-select {
  width: 16px;
  overflow: hidden;
  font-size: 0;
}

.bulk-actions .bulk-count {
  font-size: 11px;
  text-align: right;
}

.bulk-actions .bulk-delete {
  display: none;
  width: 100%;
  grid-column: 1 / -1;
  justify-content: center;
  margin-left: 0;
}

.bulk-actions.has-selection .bulk-delete {
  display: inline-flex;
}

.task-card,
.task-card.compact {
  padding: 10px 9px;
  border: 0;
  border-bottom: 1px solid #e8edf2;
  border-left: 3px solid var(--primary);
  border-radius: 0;
  background: #ffffff;
}

.task-card.compact:hover {
  background: #fafbfc;
}

.task-card.compact.selected,
.task-card.bulk-selected {
  border-color: #b9d2ff;
  background: var(--primary-soft);
}

.task-card.compact h2,
.task-card.expanded h2 {
  margin-bottom: 3px;
  color: #29313b;
  font-size: 14px;
  font-weight: 720;
}

.task-card.compact .message,
.task-card .message {
  color: #667085;
  font-size: 12.5px;
  line-height: 1.4;
}

.task-recipient {
  margin: 0 0 5px;
  color: #475467;
  font-size: 11.5px;
  font-weight: 650;
}

.task-list-empty {
  display: grid;
  min-height: 110px;
  place-items: center;
  margin: 0;
  padding: 18px 8px;
  text-align: center;
}

.meta,
.board-task .meta {
  gap: 4px;
  margin-bottom: 6px;
  font-size: 10.5px;
}

.badge,
.board-task .badge {
  min-height: 19px;
  padding: 1px 6px;
  border: 1px solid #e1e7ee;
  border-radius: 4px;
  background: #f3f5f7;
  color: #475467;
  font-size: 10px;
  font-weight: 650;
}

.task-summary {
  gap: 4px;
  margin-top: 7px;
}

.board-task .compact-actions,
.compact-actions {
  gap: 5px;
  margin-top: 7px;
}

.board-task .compact-actions .button {
  min-height: 28px;
  padding: 3px 8px;
  font-size: 11.5px;
}

.priority-Baixa {
  border-left-color: var(--teal);
}

.priority-Alta {
  border-left-color: var(--amber);
}

.priority-Urgente,
.task-card.status-call-admin {
  border-left-color: var(--red);
}

.task-card.status-call-admin {
  background: var(--red-soft);
  animation: none;
}

.viewer-header {
  min-height: 54px;
  padding: 9px 12px;
  background: #ffffff;
}

.viewer-header .actions {
  gap: 5px;
  margin-top: 0;
}

.viewer-body {
  padding: 0;
  background: var(--surface-muted);
}

.viewer-body:not(:has(> .persistent-chat)) {
  padding: 12px;
}

.workspace-empty {
  min-height: 220px;
  margin: 12px;
  border-color: var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
}

.workspace-empty strong {
  font-size: 16px;
}

.persistent-chat {
  gap: 0;
  background: var(--surface-muted);
}

.persistent-chat-messages {
  gap: 7px;
  padding: 12px 14px;
}

.direct-message-owner-tools {
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 6px 10px;
  min-height: 42px;
  padding: 6px 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.direct-message-select-all {
  min-width: 0;
  font-size: 11.5px;
  font-weight: 650;
}

.direct-message-owner-tools > .muted {
  font-size: 11px;
}

.direct-message-owner-actions {
  grid-column: 3;
  display: flex;
  justify-content: flex-end;
  gap: 5px;
  flex-wrap: wrap;
  min-width: 0;
  width: auto;
  margin-left: auto;
}

.direct-message-owner-actions .button {
  min-height: 28px;
  padding: 3px 8px;
  border: 1px solid #f0c5c1;
  background: #ffffff;
  color: var(--red);
  font-size: 11px;
  white-space: normal;
}

.direct-message-owner-actions [data-delete-selected-direct-messages]:disabled {
  display: none;
}

.direct-message-selector {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  margin: 0;
  display: flex;
}

.chat-line.mine .direct-message-selector {
  left: -26px;
}

.chat-line:not(.mine) .direct-message-selector {
  right: -26px;
  left: auto;
}

.direct-message-selector > span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.direct-message-select-all input,
.direct-message-selector input {
  appearance: auto;
  -webkit-appearance: checkbox;
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  flex: 0 0 18px;
  margin: 0;
  padding: 0;
  border-radius: 3px;
}

.chat-line,
.persistent-chat .chat-line {
  gap: 4px;
  max-width: min(78%, 580px);
  padding: 10px 14px;
  border-color: transparent;
  border-radius: 14px 14px 14px 2px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: transform 0.15s ease-out;
  position: relative;
}

.chat-line.mine {
  border-color: transparent;
  border-radius: 14px 14px 2px 14px;
  background: var(--primary);
}

.chat-line.mine p {
  color: #ffffff;
}

.chat-line > .muted {
  color: #94a3b8;
  font-size: 9.5px;
  order: 2;
  align-self: flex-end;
  margin-top: 1px;
  margin-bottom: -4px;
  margin-right: -4px;
  line-height: 1;
}

.chat-line.mine > .muted {
  color: rgba(255, 255, 255, 0.75);
}

.chat-line p {
  color: #29313b;
  font-size: 13px;
  line-height: 1.4;
}

.chat-line.selected-for-deletion {
  border-color: #e1a29d;
  background: var(--red-soft);
  box-shadow: 0 0 0 2px rgba(180, 35, 24, 0.08);
}

.chat-compose {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 7px;
  padding: 9px 11px 10px;
  border-top: 1px solid var(--line);
  background: #ffffff;
}

.chat-compose textarea {
  flex: 1 1 200px;
  min-height: 42px;
  max-height: 110px;
  padding: 11px 14px;
  border-radius: 20px;
  margin: 0;
}

.chat-compose > .button {
  flex: 0 0 auto;
  min-width: 74px;
  height: 42px;
  border-radius: 20px;
}

.chat-audio-recorder {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.chat-audio-recorder .button {
  height: 42px;
  border-radius: 20px;
}

.audio-record-button::before {
  width: 7px;
  height: 7px;
  margin-right: 6px;
}

.chat-latest-jump {
  right: 12px;
  bottom: 12px;
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  border-radius: 50%;
  box-shadow: 0 6px 16px rgba(32, 38, 46, 0.16);
  font-size: 17px;
}

.file-row {
  margin-top: 7px;
  padding: 8px;
  border-color: var(--line);
  border-radius: 5px;
  background: var(--surface-muted);
}

.file-preview {
  border-radius: 6px;
  box-shadow: none;
}

.login-wrap {
  min-height: calc(100vh - 56px);
}

.login-card {
  width: min(380px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.login-card h2 {
  margin-bottom: 4px;
  font-size: 19px;
}

.auth-page .layout {
  padding: 20px;
}

.access-page .layout > .panel {
  width: min(680px, 100%);
  margin: 48px auto 0;
  padding: 24px;
  border: 1px solid var(--line);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.access-page .layout > .panel > .muted {
  max-width: 600px;
  margin-top: 8px;
  line-height: 1.6;
}

.toast {
  border: 1px solid #303842;
  border-radius: 6px;
  background: #252b33;
  box-shadow: 0 12px 32px rgba(32, 38, 46, 0.18);
  font-size: 13px;
}

@media (max-width: 1320px) {
  .admin-page .admin-grid.viewer-open {
    grid-template-columns: 210px 235px minmax(390px, 1fr) 235px;
  }

  .admin-page .topbar > .brand-lockup {
    flex-basis: 220px;
  }
}

@media (max-width: 1120px) {
  .admin-page {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .admin-page .topbar {
    flex-wrap: wrap;
  }

  .admin-page .layout {
    overflow: visible;
  }

  .admin-page .admin-grid,
  .admin-page .admin-grid.viewer-open {
    grid-template-columns: 230px minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    height: auto;
    min-height: calc(100vh - 78px);
  }

  .admin-grid > .admin-left-panel {
    grid-column: 1;
    grid-row: 1 / span 2;
    min-height: 650px;
  }

  .admin-grid > .pending-panel {
    grid-column: 2;
    grid-row: 1;
    min-height: 360px;
  }

  .admin-grid > .admin-file-viewer {
    grid-column: 2;
    grid-row: 2;
    min-height: 590px;
  }

  .admin-grid > .completed-panel {
    grid-column: 1 / -1;
    grid-row: 3;
    min-height: 340px;
  }

  .admin-grid:not(.viewer-open) > .completed-panel {
    grid-column: 2;
    grid-row: 2;
  }

  .admin-page .top-storage {
    order: 3;
    flex-basis: 100%;
    width: 100%;
    border: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 980px) {
  .normal-grid,
  .normal-grid.viewer-open {
    grid-template-columns: 1fr;
    height: auto;
  }

  .normal-grid .list-panel,
  .normal-grid .viewer {
    min-height: min(560px, 68vh);
  }
}

@media (max-width: 760px) {
  .topbar,
  .admin-page .topbar {
    align-items: center;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 8px 10px;
  }

  .brand-lockup,
  .admin-page .topbar > .brand-lockup {
    flex: 1 1 210px;
    min-width: 0;
  }

  .topbar h1,
  .admin-page .topbar h1 {
    font-size: 15px;
  }

  .top-actions {
    flex: 1 1 100%;
    justify-content: flex-start;
  }

  .top-actions .button,
  .admin-page .top-actions .button {
    width: auto;
  }

  .layout,
  .admin-page .layout {
    padding: 6px;
  }

  .admin-page .admin-grid,
  .admin-page .admin-grid.viewer-open {
    display: flex;
    flex-direction: column;
  }

  .admin-grid > .admin-left-panel,
  .admin-grid > .pending-panel,
  .admin-grid > .admin-file-viewer,
  .admin-grid > .completed-panel,
  .admin-grid:not(.viewer-open) > .completed-panel {
    min-height: min(580px, 72vh);
  }

  .admin-grid > .admin-left-panel {
    min-height: 520px;
  }

  .admin-grid > .admin-file-viewer {
    min-height: 72vh;
  }

  .tool-panel[open] {
    width: 100vw;
  }

  .direct-message-owner-tools {
    grid-template-columns: 1fr auto;
  }

  .direct-message-owner-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
    width: 100%;
    margin-left: 0;
  }

  .direct-message-owner-actions .button {
    width: auto;
    min-height: 36px;
  }

  .direct-message-selector {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .direct-message-select-all {
    min-height: 36px;
  }

  .persistent-chat .chat-line {
    max-width: 88%;
  }

  .chat-compose {
    /* Flexbox cuidará do layout automático */
  }

  .chat-compose .button,
  .chat-audio-recorder .button {
    width: auto;
  }

  .access-page .layout > .panel {
    margin-top: 18px;
  }
}

@media (max-width: 480px) {
  .brand-mark {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
  }

  .top-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .top-actions .button,
  .admin-page .top-actions .button {
    width: 100%;
    min-width: 0;
    padding-inline: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .top-storage {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .top-storage .button {
    grid-column: 1 / -1;
    grid-row: auto;
    width: 100%;
  }

  .admin-tools {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .login-card,
  .access-page .layout > .panel {
    padding: 18px;
  }

  .bulk-actions {
    align-items: flex-start;
  }

  .bulk-actions .bulk-count {
    margin-left: 0;
  }

  /* Chat flexível cuida da quebra sozinho */
}

@media (max-width: 760px) {
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  .admin-page {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .admin-page .topbar {
    display: grid;
    min-height: 0;
    flex: 0 0 auto;
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    padding: max(7px, env(safe-area-inset-top)) 10px 7px;
  }

  .admin-page .topbar > .brand-lockup {
    grid-row: 1;
    width: 100%;
    min-width: 0;
  }

  .admin-page .brand-mark {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
  }

  .admin-page .topbar h1 {
    overflow: hidden;
    font-size: 16px;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .admin-page .role-label {
    margin-top: 2px;
    font-size: 10.5px;
  }

  .admin-page .top-actions {
    display: grid;
    grid-row: 2;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    width: 100%;
  }

  .admin-page .top-actions .button {
    width: 100%;
    min-width: 0;
    min-height: 30px;
    overflow: hidden;
    padding: 4px 6px;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .admin-page .top-storage {
    grid-row: 3;
    grid-template-columns: auto minmax(0, 1fr) auto;
    width: 100%;
    min-height: 34px;
    margin: 0;
    padding: 5px 0 0;
    border: 0;
    border-top: 1px solid var(--line);
    background: transparent;
  }

  .admin-page .top-storage strong {
    font-size: 10.5px;
  }

  .admin-page .top-storage .progress {
    grid-column: 2;
    grid-row: 1;
  }

  .admin-page .top-storage .muted {
    grid-column: 1 / 3;
    grid-row: 2;
    font-size: 9.5px;
  }

  .admin-page .top-storage .button {
    width: auto;
    grid-column: 3;
    grid-row: 1 / 3;
    min-height: 28px;
    padding: 3px 7px;
  }

  .admin-page .layout {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    padding: 0 0 calc(56px + env(safe-area-inset-bottom));
  }

  .admin-page .admin-grid,
  .admin-page .admin-grid.viewer-open {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background: var(--panel);
  }

  .admin-page .admin-grid > .admin-left-panel,
  .admin-page .admin-grid > .pending-panel,
  .admin-page .admin-grid > .admin-file-viewer,
  .admin-page .admin-grid > .completed-panel,
  .admin-page .admin-grid:not(.viewer-open) > .completed-panel {
    display: none;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    padding: 11px;
    border: 0;
    border-radius: 0;
  }

  .admin-page .admin-grid[data-mobile-view="users"] > .admin-left-panel,
  .admin-page .admin-grid[data-mobile-view="pending"] > .pending-panel,
  .admin-page .admin-grid[data-mobile-view="workspace"] > .admin-file-viewer,
  .admin-page .admin-grid[data-mobile-view="history"] > .completed-panel {
    display: flex;
  }

  .admin-page .admin-grid[data-mobile-view="users"] > .admin-left-panel {
    overflow-y: auto;
  }

  .admin-page .admin-file-viewer {
    padding: 0 !important;
  }

  .admin-page .viewer-header {
    min-height: 52px;
    padding: 8px 10px;
  }

  .admin-page .viewer-header h2,
  .admin-page .list-header h2 {
    font-size: 18px;
  }

  .admin-page .viewer-header .actions,
  .admin-page .user-actions,
  .admin-page .compact-actions,
  .admin-page .workspace-task > .actions {
    flex-wrap: wrap;
  }

  .admin-page .button,
  .admin-page .viewer-header .button,
  .admin-page .user-actions .button,
  .admin-page .compact-actions .button,
  .admin-page .workspace-task > .actions .button {
    width: auto;
  }

  .admin-page .bulk-actions .bulk-delete,
  .admin-page .tool-panel form > .button {
    width: 100%;
  }

  .admin-page .task-list,
  .admin-page .user-list,
  .admin-page .viewer-body {
    min-height: 0;
    overscroll-behavior: contain;
  }

  .admin-page .persistent-chat {
    height: 100%;
  }

  .admin-page .persistent-chat-messages {
    padding: 10px;
  }

  .admin-page .persistent-chat .chat-line {
    max-width: 88%;
  }

  .admin-page .chat-compose {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 8px;
  }

  .admin-page .chat-compose .button {
    width: auto;
    min-width: 70px;
  }

  .admin-page .chat-compose textarea {
    min-height: 42px;
  }

  .admin-page .tool-panel[open] {
    width: 100%;
  }

  .admin-mobile-nav {
    position: fixed;
    z-index: 80;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    min-height: 56px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 3px;
    padding: 6px 7px calc(6px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line-strong);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 -4px 16px rgba(32, 38, 46, 0.08);
  }

  .admin-mobile-nav button {
    min-width: 0;
    min-height: 40px;
    padding: 5px 3px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: #667085;
    font: inherit;
    font-size: 10.5px;
    font-weight: 700;
  }

  .admin-mobile-nav button.active {
    background: var(--primary-soft);
    color: var(--primary-2);
  }
}

@media print {
  .admin-mobile-nav {
    display: none !important;
  }
}

/* --- ETAPA 2: MICRO-INTERAÇÕES --- */

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

[data-file-loading="true"] {
  animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  opacity: 0.7;
}

.skeleton-text {
  animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  background-color: #e2e8f0;
  border-radius: 6px;
  color: transparent !important;
  min-height: 24px;
  pointer-events: none;
}

.empty-state-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 16px;
  margin: 16px;
  background: var(--surface-muted);
  border: 1px dashed #cbd4df;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 500;
  font-size: 13.5px;
}
.empty-state-card::before {
  content: "💬";
  font-size: 28px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.persistent-chat-history, .user-list, .task-list {
  scroll-behavior: smooth;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-line {
  animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.selected-task-file-thumbnail {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
  margin-right: 8px;
}
.selected-task-file {
  display: flex;
  align-items: center;
}

.user-title-wrapper { display: flex; align-items: center; gap: 6px; }
.user-presence-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
  transition: all 0.3s ease;
}
.user-presence-dot.online {
  background: var(--green, #10b981);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

/* Reactions */
.chat-reaction-toggle {
  position: absolute;
  bottom: 6px;
  right: -32px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 2px 6px;
  font-size: 13px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.chat-line.mine .chat-reaction-toggle {
  right: auto;
  left: -32px;
}
.chat-line:hover .chat-reaction-toggle {
  opacity: 1;
}
.chat-reaction-picker {
  position: absolute;
  bottom: 30px;
  right: -10px;
  display: flex;
  background: white;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  padding: 4px;
  gap: 4px;
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.95);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.chat-line.mine .chat-reaction-picker {
  right: auto;
  left: -10px;
}
.chat-reaction-picker.show-picker {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}
.chat-reaction-button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 50%;
  transition: transform 0.1s, background 0.1s;
}
.chat-reaction-button:hover {
  transform: scale(1.3);
  background: #f1f5f9;
}
.chat-reactions-display {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
  user-select: none;
}
.chat-reaction-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 2px 6px;
  font-size: 11.5px;
  color: #475569;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.chat-reaction-badge:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}
.chat-reaction-badge.active {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #2563eb;
}


/* Group Sidebar Styles */
.group-list-heading {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.group-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}
.group-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  background: none;
  border: none;
  text-align: left;
  font-size: 14px;
  color: var(--text);
  transition: background 0.2s;
}
.group-item:hover {
  background: var(--surface);
}
.group-item.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 500;
}
.group-item::before {
  content: "#";
  color: var(--muted);
  font-weight: bold;
}
.group-item.active::before {
  color: var(--primary);
}

/* Modal Creation */
.group-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.group-modal-content {
  background: white;
  padding: 24px;
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.group-modal-members {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.group-modal-members label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.group-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.chat-line .group-sender-name {
  font-size: 11px;
  color: var(--primary);
  font-weight: bold;
  margin-bottom: 2px;
  display: block;
}


/* Global Search Styles */
.global-search-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 10vh;
}
.global-search-content {
  background: white;
  width: 90%;
  max-width: 600px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.global-search-header {
  display: flex;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  gap: 12px;
}
.global-search-input {
  flex: 1;
  font-size: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}
.global-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.global-search-results {
  max-height: 60vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  text-align: left;
  cursor: pointer;
  transition: background 0.2s;
  width: 100%;
}
.search-result-item:hover {
  background: var(--surface);
}
.search-result-icon {
  font-size: 20px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  border-radius: 8px;
}
.search-result-info {
  flex: 1;
  min-width: 0;
}
.search-result-date {
  font-size: 11px;
  white-space: nowrap;
}


.reply-block {
  background: rgba(0,0,0,0.05);
  border-left: 3px solid var(--primary);
  padding: 6px 10px;
  border-radius: 4px;
  margin-bottom: 6px;
  font-size: 0.85em;
  color: var(--text-muted);
}
.reply-block strong { color: var(--primary); }
.reply-preview-container {
  background: var(--surface);
  border-left: 3px solid var(--primary);
  padding: 8px 12px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 4px;
  font-size: 0.9em;
  width: 100%;
}
.action-btn.reply-btn { font-size: 14px; background: transparent; border: none; cursor: pointer; padding: 4px; }
.action-btn.reply-btn:hover { opacity: 1; }


/* Mentions */
.mention-dropdown {
  position: absolute;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  width: 250px;
}
.mention-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
}
.mention-item:last-child { border-bottom: none; }
.mention-item:hover, .mention-item.selected {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 500;
}
.mention-highlight {
  color: var(--primary);
  font-weight: bold;
  background: rgba(var(--primary-rgb, 0,0,0), 0.1);
  padding: 0 4px;
  border-radius: 4px;
}


/* Correcao do botao de responder */
.chat-line {
  position: relative;
}
.action-btn.btn-reply {
  position: absolute;
  top: 5px;
  right: -30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, transform 0.1s;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  z-index: 10;
}
.chat-line.mine .action-btn.btn-reply {
  right: auto;
  left: -30px;
}
.chat-line:hover .action-btn.btn-reply {
  opacity: 1;
}
.action-btn.btn-reply:hover {
  transform: scale(1.1);
}


/* Correcao de cor das mencoes nos baloes azuis */
.chat-line.mine .mention-highlight {
  color: #fff !important;
  background: rgba(255, 255, 255, 0.25) !important;
}


/* Melhoria de organizacao visual: Checkbox e Responder */

@media (hover: hover) {
  .direct-message-selector {
    opacity: 0;
    transition: opacity 0.2s ease;
  }
  .chat-line:hover .direct-message-selector,
  .chat-line.selected-for-deletion .direct-message-selector {
    opacity: 1;
  }
}

/* Re-alocando para nao sobrepor com o botao de responder */
.chat-line.mine .direct-message-selector {
  left: -28px;
}
.chat-line:not(.mine) .direct-message-selector {
  right: -28px;
  left: auto;
}

/* Ajustando a posicao do botao de responder para ficar ao lado do checkbox */
.action-btn.btn-reply {
  right: -58px !important; 
}
.chat-line.mine .action-btn.btn-reply {
  right: auto !important;
  left: -58px !important;
}
