:root {
  color-scheme: light;
  --font-ui: "Manrope", ui-sans-serif, system-ui, sans-serif;
  --font-display: "Newsreader", Georgia, serif;

  /* Surfaces — clean cool off-white, lightly tinted by the brand violet */
  --bg: #f6f5fb;
  --surface: #ffffff;
  --surface-2: #eeecf9;
  --surface-3: #e3e0f3;

  /* Text — near-black down to faint */
  --text: #15131f;
  --text-muted: #5d5a72;
  --text-faint: #918da8;

  /* Borders — discrete, soft */
  --border: #e4e1f0;
  --border-strong: #cac5e0;

  /* Accent — Agência Novo Normal: azul → roxo/magenta da marca */
  --primary: #6d28d9;
  --primary-strong: #5b21b6;
  --primary-hover: #4c1d95;
  --primary-soft: #f1e9fd;
  --grad-from: #2541e6;
  --grad-to: #c026d3;
  --gradient: linear-gradient(135deg, var(--grad-from) 0%, var(--grad-to) 100%);
  --gradient-hover: linear-gradient(135deg, #1d34c4 0%, #a01fb0 100%);
  --ring: color-mix(in srgb, var(--primary) 34%, transparent);

  /* Status — cool, muted, sophisticated */
  --green: #2f9461;
  --blue: #0ea5e9;
  --orange: #c2701b;
  --gold: #b08412;
  --red: #d24b52;

  /* Toast — dedicated tokens so dark mode never floats a white box */
  --toast-bg: var(--text);
  --toast-text: var(--bg);

  /* Elevation — layered, soft (cool slate) */
  --shadow-xs: 0 1px 2px rgba(20, 16, 50, 0.06);
  --shadow-soft: 0 1px 2px rgba(20, 16, 50, 0.05), 0 8px 22px rgba(20, 16, 50, 0.09);
  --shadow: 0 4px 12px rgba(20, 16, 50, 0.1), 0 24px 56px rgba(20, 16, 50, 0.18);
  --glow: none;

  --radius-sm: 7px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
  color-scheme: dark;
  /* Near-black, like the brand mark on dark backgrounds */
  --bg: #0b0a13;
  --surface: #15131f;
  --surface-2: #1d1b2c;
  --surface-3: #272438;

  --text: #f4f2fb;
  --text-muted: #b3aec9;
  --text-faint: #7d7896;

  --border: #2c2a40;
  --border-strong: #423e5c;

  --primary: #a78bfa;
  --primary-strong: #8b5cf6;
  --primary-hover: #c4b5fd;
  --primary-soft: #271f42;
  --grad-from: #5169f5;
  --grad-to: #e056ea;
  --gradient: linear-gradient(135deg, var(--grad-from) 0%, var(--grad-to) 100%);
  --gradient-hover: linear-gradient(135deg, #6c80ff 0%, #ec74f0 100%);
  --ring: color-mix(in srgb, var(--primary) 38%, transparent);

  --green: #5cc88c;
  --blue: #38bdf8;
  --orange: #e0a04a;
  --gold: #d6b03a;
  --red: #ef7a80;

  --toast-bg: var(--surface-3);
  --toast-text: var(--text);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.36), 0 10px 28px rgba(0, 0, 0, 0.46);
  --shadow: 0 6px 16px rgba(0, 0, 0, 0.5), 0 26px 64px rgba(0, 0, 0, 0.58);
  --glow: 0 0 0 1px color-mix(in srgb, var(--grad-to) 22%, transparent), 0 0 28px color-mix(in srgb, var(--grad-to) 22%, transparent);
}

[data-theme="dark"] {
  --bg: #080910 !important;
  --surface: #10131c !important;
  --surface-2: #171b27 !important;
  --surface-3: #202636 !important;
  --text: #f7f3ea !important;
  --text-muted: #bbb5a6 !important;
  --text-faint: #827b6b !important;
  --border: #2a3040 !important;
  --border-strong: #3c455b !important;
  --primary: #b99cff !important;
  --primary-strong: #d2c4ff !important;
  --primary-hover: #cbb8ff !important;
  --primary-soft: #241d36 !important;
  --grad-from: #4968ff !important;
  --grad-to: #d84fd7 !important;
  --green: #79d99f !important;
  --blue: #54c7f8 !important;
  --orange: #f2ac54 !important;
  --gold: #e0bf4d !important;
  --red: #ff858b !important;
  --toast-bg: #202636 !important;
  --toast-text: #f7f3ea !important;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(1100px 460px at 88% -10%, color-mix(in srgb, var(--grad-to) 12%, transparent), transparent 68%),
    radial-gradient(900px 420px at 8% -6%, color-mix(in srgb, var(--grad-from) 11%, transparent), transparent 64%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

button:disabled:hover {
  transform: none;
}

.app-shell {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  min-height: 100vh;
  padding: 18px;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 74px;
  padding: 14px 16px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

/* Logo oficial (lockup em fundo escuro): o próprio fundo da arte vira um chip
   arredondado, ficando elegante no tema claro e no escuro. */
.brand-logo {
  height: 46px;
  width: auto;
  display: block;
  border-radius: 11px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition), transform var(--transition);
}

.brand:hover .brand-logo {
  transform: translateY(-1px);
}

[data-theme="dark"] .brand-logo {
  box-shadow: var(--shadow-xs), var(--glow);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 7px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

[data-theme="dark"] .brand-mark {
  box-shadow: var(--shadow-xs), var(--glow);
}

.brand-kicker,
.eyebrow {
  margin: 0 0 2px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.brand h1,
.modal h2,
.drawer-panel h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(23px, 2.5vw, 32px);
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--text);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 1;
  gap: 10px;
}

.search-field {
  display: flex;
  align-items: center;
  flex: 1;
  max-width: 520px;
  min-width: 220px;
  height: 42px;
  gap: 8px;
  padding: 0 12px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  transition: border-color var(--transition), background var(--transition);
}

.search-field:focus-within {
  border-color: var(--primary);
  background: var(--surface);
}

.search-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.search-field svg,
button svg {
  width: 17px;
  height: 17px;
  stroke-width: 2.2;
}

.primary-button,
.ghost-button,
.icon-button,
.stage-action,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 800;
  transition:
    transform var(--transition),
    background var(--transition),
    color var(--transition),
    border-color var(--transition);
}

.primary-button {
  padding: 0 16px;
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 1px 2px rgba(30, 32, 60, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.primary-button:hover {
  background: var(--gradient-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--grad-to) 36%, transparent), var(--glow);
}

.primary-button:active {
  transform: translateY(0);
}

.ghost-button,
.stage-action {
  padding: 0 12px;
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.ghost-button:hover,
.stage-action:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.icon-button {
  width: 40px;
  padding: 0;
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.icon-button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.danger-button {
  padding: 0 12px;
  background: color-mix(in srgb, var(--red) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--red) 30%, var(--border));
  color: var(--red);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  position: relative;
  min-width: 0;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.metric:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-soft);
  transform: translateY(-2px);
}

.metric span {
  display: block;
  margin-bottom: 10px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.metric strong {
  display: block;
  overflow: hidden;
  font-family: var(--font-display);
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.metric:first-child strong {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  background: color-mix(in srgb, var(--surface) 76%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.toolbar label,
.lead-form label {
  display: grid;
  gap: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

select,
input,
textarea {
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  outline: 0;
  padding: 0 12px;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}

select:hover,
input:hover,
textarea:hover {
  border-color: var(--border-strong);
}

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235c6072' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}

textarea {
  min-height: 84px;
  resize: vertical;
  padding: 11px 12px;
  line-height: 1.5;
}

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

.kanban-shell {
  min-height: 0;
  overflow: hidden;
}

.connection-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.connection-panel[hidden] {
  display: none;
}

.state-card {
  display: grid;
  gap: 12px;
  max-width: 720px;
}

.state-card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.05;
}

.state-card p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.55;
}

.auth-form {
  display: grid;
  grid-template-columns: minmax(180px, 280px) minmax(160px, 240px) auto auto;
  gap: 10px;
  align-items: end;
}

.auth-form label {
  display: grid;
  gap: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.loading-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-weight: 800;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

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

.kanban-board {
  display: grid;
  grid-auto-columns: minmax(250px, 1fr);
  grid-auto-flow: column;
  gap: 12px;
  height: calc(100vh - 264px);
  min-height: 560px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.kanban-column {
  display: flex;
  flex-direction: column;
  min-width: 250px;
  overflow: hidden;
  background: color-mix(in srgb, var(--surface-2) 60%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color var(--transition);
}

.column-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 14px 14px 12px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.column-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--text) 5%, transparent);
}

.column-title {
  overflow: hidden;
  font-size: 13px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.column-count {
  min-width: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.column-total {
  grid-column: 2 / 4;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.column-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  min-height: 140px;
  overflow-y: auto;
  padding: 10px;
  transition: background var(--transition);
}

.column-body.drag-over {
  background: color-mix(in srgb, var(--primary) 11%, transparent);
}

.lead-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  cursor: grab;
  transition:
    transform var(--transition),
    box-shadow var(--transition),
    border-color var(--transition);
}

.lead-card:hover {
  border-color: color-mix(in srgb, var(--primary) 34%, var(--border));
  box-shadow: var(--shadow-soft);
  transform: translateY(-2px);
}

.lead-card:active {
  cursor: grabbing;
}

.lead-card:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.lead-card.dragging {
  opacity: 0.5;
  transform: rotate(1.5deg) scale(0.98);
  box-shadow: var(--shadow);
  cursor: grabbing;
}

.card-head {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  gap: 10px;
  align-items: start;
}

.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary-soft);
  border: 1px solid color-mix(in srgb, var(--primary) 16%, transparent);
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
}

.lead-name {
  margin: 0 0 3px;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.25;
}

.lead-company {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.lead-value {
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.lead-note {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}

.pill {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 23px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid color-mix(in srgb, var(--text) 7%, transparent);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1;
}

.priority-baixa {
  background: color-mix(in srgb, var(--blue) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--blue) 24%, transparent);
  color: var(--blue);
}

.priority-normal {
  background: color-mix(in srgb, var(--green) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--green) 24%, transparent);
  color: var(--green);
}

.priority-alta {
  background: color-mix(in srgb, var(--orange) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--orange) 26%, transparent);
  color: var(--orange);
}

.priority-urgente {
  background: color-mix(in srgb, var(--red) 13%, var(--surface));
  border-color: color-mix(in srgb, var(--red) 28%, transparent);
  color: var(--red);
}

.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.phone {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.mini-actions {
  display: flex;
  gap: 6px;
}

.mini-button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.mini-button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.empty-column {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 8px;
  min-height: 120px;
  padding: 16px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface) 40%, transparent);
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
}

.empty-column strong {
  color: var(--text);
  font-size: 13px;
}

.empty-column span {
  max-width: 320px;
}

.empty-action {
  margin-top: 4px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: color-mix(in srgb, #100e0a 46%, transparent);
  backdrop-filter: blur(6px);
  animation: backdrop-in 200ms ease;
}

@keyframes backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-backdrop[hidden],
.detail-drawer[hidden] {
  display: none;
}

.modal {
  width: min(760px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  animation: modal-in 240ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header,
.drawer-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--border);
}

.lead-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.extra-fields-grid[hidden] {
  display: none;
}

.extra-field-wide {
  grid-column: 1 / -1;
}

.modal-actions {
  display: flex;
  justify-content: end;
  gap: 10px;
}

.detail-drawer {
  position: fixed;
  inset: 0;
  z-index: 25;
  pointer-events: none;
}

.drawer-scrim {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, #100e0a 32%, transparent);
  backdrop-filter: blur(3px);
  pointer-events: auto;
  animation: backdrop-in 200ms ease;
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  width: min(440px, 100%);
  height: 100%;
  overflow: hidden;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  pointer-events: auto;
  animation: drawer-in 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes drawer-in {
  from { transform: translateX(24px); opacity: 0.4; }
  to { transform: translateX(0); opacity: 1; }
}

#drawerContent {
  overflow-y: auto;
  padding: 16px;
}

.drawer-section {
  display: grid;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.drawer-section:first-child {
  padding-top: 0;
}

.drawer-section h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 900;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.detail-item {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
}

.detail-item span {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.detail-item strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
}

.drawer-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.drawer-actions .primary-button,
.drawer-actions .ghost-button,
.drawer-actions .danger-button {
  width: 100%;
}

.stage-select-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.note-box {
  display: grid;
  gap: 8px;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  position: relative;
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 12px;
  padding-bottom: 4px;
}

.history-item-with-action {
  grid-template-columns: 10px 1fr 34px;
  align-items: start;
}

.history-item:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 14px;
  bottom: -6px;
  width: 1.5px;
  background: var(--border);
}

.history-dot {
  position: relative;
  z-index: 1;
  width: 9px;
  height: 9px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.history-item strong {
  display: block;
  font-size: 12px;
}

.history-item p {
  margin: 3px 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}

.history-item time {
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 800;
}

.history-delete-button {
  width: 32px;
  height: 32px;
  color: var(--text-faint);
}

.history-delete-button:hover {
  border-color: color-mix(in srgb, var(--danger) 42%, var(--border));
  color: var(--danger);
}

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 36px));
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  background: var(--toast-bg);
  color: var(--toast-text);
  border: 1px solid color-mix(in srgb, var(--toast-text) 10%, transparent);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.005em;
  animation: toast-in 260ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.toast-success {
  background: var(--toast-bg);
  color: var(--toast-text);
}

.toast-error {
  background: var(--red);
  color: #ffffff;
}

.toast-warning {
  background: var(--orange);
  color: #ffffff;
}

/* ============================================================
   Refinements — focus, scrollbars, selection, micro-states
   ============================================================ */

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.primary-button:focus-visible,
.ghost-button:focus-visible,
.icon-button:focus-visible,
.stage-action:focus-visible,
.danger-button:focus-visible,
.mini-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

::selection {
  background: color-mix(in srgb, var(--primary) 24%, transparent);
  color: var(--text);
}

.primary-button:active,
.ghost-button:active,
.icon-button:active,
.stage-action:active,
.danger-button:active,
.mini-button:active {
  transform: translateY(0) scale(0.98);
}

.mini-button {
  transition: border-color var(--transition), color var(--transition), background var(--transition), transform var(--transition);
}

.mini-button:hover {
  background: var(--primary-soft);
}

.detail-item {
  transition: background var(--transition);
}

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

/* Custom scrollbars — discreet and warm */
.column-body,
.kanban-board,
#drawerContent,
.modal {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.column-body::-webkit-scrollbar,
.kanban-board::-webkit-scrollbar,
#drawerContent::-webkit-scrollbar,
.modal::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.column-body::-webkit-scrollbar-thumb,
.kanban-board::-webkit-scrollbar-thumb,
#drawerContent::-webkit-scrollbar-thumb,
.modal::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

.column-body::-webkit-scrollbar-thumb:hover,
.kanban-board::-webkit-scrollbar-thumb:hover,
#drawerContent::-webkit-scrollbar-thumb:hover,
.modal::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
  border: 3px solid transparent;
  background-clip: padding-box;
}

.column-body::-webkit-scrollbar-track,
.kanban-board::-webkit-scrollbar-track,
#drawerContent::-webkit-scrollbar-track,
.modal::-webkit-scrollbar-track {
  background: transparent;
}

[data-theme="dark"] body {
  background:
    radial-gradient(900px 460px at 9% -12%, color-mix(in srgb, var(--grad-from) 18%, transparent), transparent 70%),
    radial-gradient(760px 420px at 94% 0%, color-mix(in srgb, var(--grad-to) 16%, transparent), transparent 72%),
    linear-gradient(180deg, #0b0d15 0%, var(--bg) 42%, #07080d 100%);
}

[data-theme="dark"] .topbar,
[data-theme="dark"] .toolbar,
[data-theme="dark"] .metric,
[data-theme="dark"] .admin-section,
[data-theme="dark"] .settings-panel,
[data-theme="dark"] .settings-hero {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-color: color-mix(in srgb, var(--border-strong) 72%, transparent);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.34);
}

[data-theme="dark"] .kanban-column {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-2) 86%, transparent), color-mix(in srgb, var(--surface) 92%, transparent));
  border-color: color-mix(in srgb, var(--border-strong) 70%, transparent);
}

[data-theme="dark"] .column-header {
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border-bottom-color: color-mix(in srgb, var(--border-strong) 68%, transparent);
}

[data-theme="dark"] .lead-card {
  background: linear-gradient(180deg, #151a26 0%, #11151f 100%);
  border-color: #30384c;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03), 0 12px 28px rgba(0, 0, 0, 0.26);
}

[data-theme="dark"] .lead-card:hover {
  border-color: color-mix(in srgb, var(--primary) 46%, var(--border-strong));
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.36), 0 0 0 1px color-mix(in srgb, var(--primary) 18%, transparent);
}

[data-theme="dark"] .empty-column {
  background: color-mix(in srgb, var(--surface) 54%, transparent);
  border-color: color-mix(in srgb, var(--border-strong) 76%, transparent);
}

[data-theme="dark"] .search-field,
[data-theme="dark"] select,
[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] .icon-button,
[data-theme="dark"] .ghost-button,
[data-theme="dark"] .mini-button,
[data-theme="dark"] .stage-action,
[data-theme="dark"] .user-chip,
[data-theme="dark"] .app-nav {
  background: color-mix(in srgb, var(--surface-2) 88%, transparent);
  border-color: color-mix(in srgb, var(--border-strong) 70%, transparent);
}

[data-theme="dark"] .detail-item,
[data-theme="dark"] .protected-env-item,
[data-theme="dark"] .settings-status {
  background: color-mix(in srgb, var(--surface-2) 86%, transparent);
  border-color: color-mix(in srgb, var(--border-strong) 70%, transparent);
}

[data-theme="dark"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a8acc2' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 16px 16px;
}

/* ============================================================
   Inbox / Conversas — módulo de central de atendimento
   Reusa exclusivamente os tokens definidos em :root acima.
   ============================================================ */

.app-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border-radius: calc(var(--radius-md) - 3px);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}

.nav-link:hover {
  color: var(--text);
}

.nav-link.is-active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-xs);
}

.inbox-shell {
  grid-template-rows: auto 1fr;
}

.inbox-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 340px;
  gap: 14px;
  min-height: 0;
  height: calc(100vh - 110px);
}

.inbox-list-pane,
.inbox-thread-pane,
.inbox-lead-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.inbox-list-header {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

.inbox-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-chip {
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.filter-chip:hover {
  border-color: var(--border-strong);
}

.filter-chip.is-active {
  background: var(--gradient);
  border-color: transparent;
  color: #fff;
}

.conversation-list {
  display: grid;
  align-content: start;
  overflow-y: auto;
  padding: 8px;
}

.conversation-list-empty {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 40px 16px;
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.conversation-item {
  position: relative;
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: start;
  gap: 10px;
  width: 100%;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text);
  text-align: left;
  transition: background var(--transition), border-color var(--transition);
}

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

.conversation-item.is-active {
  background: var(--primary-soft);
  border-color: color-mix(in srgb, var(--primary) 30%, transparent);
}

.conversation-item.is-unread .conversation-summary strong {
  color: var(--text);
}

.conversation-summary {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.conversation-summary-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.conversation-summary-top strong {
  overflow: hidden;
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-summary-top time {
  flex-shrink: 0;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 700;
}

.conversation-phone {
  margin: 0;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 700;
}

.conversation-preview {
  margin: 0;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 2px;
}

.new-contact-badge {
  background: color-mix(in srgb, var(--gold) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--gold) 28%, transparent);
  color: var(--gold);
}

.status-novo {
  background: color-mix(in srgb, var(--gold) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--gold) 24%, transparent);
  color: var(--gold);
}

.status-em_atendimento {
  background: color-mix(in srgb, var(--blue) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--blue) 24%, transparent);
  color: var(--blue);
}

.status-qualificado {
  background: color-mix(in srgb, var(--green) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--green) 24%, transparent);
  color: var(--green);
}

.status-perdido {
  background: color-mix(in srgb, var(--red) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--red) 24%, transparent);
  color: var(--red);
}

.unread-badge {
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--gradient);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
}

.thread-empty-state,
.lead-panel-empty {
  display: grid;
  place-items: center;
  gap: 10px;
  flex: 1;
  padding: 32px;
  color: var(--text-faint);
  text-align: center;
}

.thread-empty-state svg,
.lead-panel-empty svg {
  width: 32px;
  height: 32px;
  stroke-width: 1.5;
  opacity: 0.6;
}

.thread-empty-state h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--text-muted);
}

.thread-empty-state p,
.lead-panel-empty p {
  margin: 0;
  max-width: 280px;
  font-size: 13px;
  line-height: 1.5;
}

.thread-content {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.thread-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

.thread-header-info {
  display: grid;
  flex: 1;
  gap: 2px;
  min-width: 0;
}

.thread-header-info strong {
  font-size: 14px;
  font-weight: 900;
}

.thread-header-info span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.thread-status-select {
  display: grid;
  gap: 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
}

.thread-status-select select {
  min-height: 36px;
  font-size: 12px;
}

.thread-messages {
  display: grid;
  align-content: start;
  flex: 1;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  background:
    radial-gradient(600px 240px at 100% 0%, color-mix(in srgb, var(--grad-to) 5%, transparent), transparent 70%),
    var(--bg);
}

.thread-loading,
.thread-error-state {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 32px;
  color: var(--text-faint);
  text-align: center;
}

.message-date-divider {
  display: flex;
  justify-content: center;
  margin: 6px 0;
}

.message-date-divider span {
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
}

.message-bubble {
  display: grid;
  gap: 4px;
  max-width: 70%;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.5;
}

.message-bubble p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-bubble time {
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 700;
}

.message-in {
  justify-self: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.message-out {
  justify-self: end;
  background: var(--primary-soft);
  border: 1px solid color-mix(in srgb, var(--primary) 18%, transparent);
  border-bottom-right-radius: 4px;
}

.message-out time {
  text-align: right;
}

.thread-composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.thread-composer #composerInput {
  flex: 1;
  min-height: 40px;
}

#leadPanelContent {
  overflow-y: auto;
  padding: 16px;
}

.lead-panel-header {
  margin-bottom: 4px;
}

.lead-panel-header h3 {
  margin: 0 0 2px;
  font-family: var(--font-display);
  font-size: 19px;
}

.lead-panel-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.lead-pane-section {
  display: grid;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.lead-pane-section h4 {
  margin: 0;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.qualification-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.qualification-row > span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.segmented-control {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.segmented-control button {
  height: 28px;
  padding: 0 11px;
  border-radius: calc(var(--radius-md) - 3px);
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  transition: background var(--transition), color var(--transition);
}

.segmented-control button.is-active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-xs);
}

.segmented-control button.is-active.temp-frio {
  color: var(--blue);
}

.segmented-control button.is-active.temp-morno {
  color: var(--orange);
}

.segmented-control button.is-active.temp-quente {
  color: var(--red);
}

.chip-select {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.service-chip {
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.service-chip:hover {
  border-color: var(--border-strong);
}

.service-chip.is-selected {
  background: var(--gradient);
  border-color: transparent;
  color: #fff;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 6px 0 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
}

.tag-chip button {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: var(--text-faint);
}

.tag-chip button:hover {
  background: var(--surface-3);
  color: var(--red);
}

.tag-chip svg {
  width: 12px;
  height: 12px;
}

.tag-add-form {
  display: flex;
  gap: 8px;
}

.tag-add-form input {
  flex: 1;
  min-height: 36px;
  font-size: 12px;
}

@media (max-width: 980px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
  }

  .app-nav {
    width: 100%;
  }

  .nav-link {
    flex: 1;
    justify-content: center;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kanban-board {
    height: calc(100vh - 340px);
  }

  .inbox-layout {
    grid-template-columns: 260px minmax(0, 1fr) 300px;
    height: calc(100vh - 170px);
  }
}

@media (max-width: 700px) {
  .app-shell {
    padding: 10px;
  }

  .topbar-actions,
  .toolbar,
  .filter-group,
  .auth-form {
    align-items: stretch;
    flex-direction: column;
  }

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

  .search-field {
    max-width: none;
    min-width: 0;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .toolbar .ghost-button,
  .primary-button {
    width: 100%;
  }

  .kanban-board {
    grid-auto-columns: minmax(268px, 86vw);
    height: auto;
    min-height: 540px;
    padding-bottom: 12px;
  }

  .form-grid,
  .detail-grid,
  .drawer-actions,
  .stage-select-row {
    grid-template-columns: 1fr;
  }

  .inbox-layout {
    grid-template-columns: 1fr;
    grid-auto-rows: 60vh;
    height: auto;
    overflow-x: auto;
    grid-auto-flow: column;
  }

  .inbox-list-pane,
  .inbox-thread-pane,
  .inbox-lead-pane {
    min-width: 86vw;
    scroll-snap-align: start;
  }

  .inbox-layout {
    scroll-snap-type: x mandatory;
  }

  .message-bubble {
    max-width: 86%;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}

/* Auth */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.auth-layout {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 18px;
  align-items: stretch;
}

.auth-layout-compact {
  grid-template-columns: minmax(320px, 520px);
  justify-content: center;
}

.auth-brand-panel,
.auth-card,
.admin-section {
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

.auth-brand-panel {
  /* Painel da marca: sempre escuro, como a arte original da Novo Normal,
     independente do tema claro/escuro do app. */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 48px;
  min-height: 520px;
  padding: clamp(26px, 4vw, 44px);
  background:
    radial-gradient(560px 420px at 92% -12%, rgba(192, 38, 211, 0.2), transparent 68%),
    radial-gradient(560px 420px at -12% 112%, rgba(43, 58, 235, 0.24), transparent 68%),
    #0b0a13;
  border-color: #2c2a40;
}

.auth-brand-logo-full {
  width: min(400px, 100%);
  height: auto;
  margin-left: -6px;
  filter: drop-shadow(0 12px 40px rgba(124, 58, 237, 0.28));
}

.auth-brand-panel h1,
.auth-card h1,
.auth-card h2 {
  margin: 0;
}

.auth-brand-copy h1 {
  max-width: 520px;
  color: #f4f2fb;
  font-family: var(--font-display);
  font-size: clamp(34px, 5vw, 52px);
  line-height: 0.98;
  letter-spacing: 0;
}

.auth-brand-copy p {
  max-width: 460px;
  margin: 14px 0 0;
  color: #b3aec9;
  line-height: 1.6;
}

.auth-card > p {
  max-width: 540px;
  margin: 16px 0 0;
  color: var(--text-muted);
}

.auth-card {
  display: grid;
  align-content: center;
  gap: 20px;
  padding: clamp(22px, 4vw, 34px);
}

.login-form {
  display: grid;
  gap: 14px;
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  width: 100%;
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  background: var(--surface-2);
  color: var(--text);
}

.password-toggle:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.password-toggle svg {
  width: 18px;
  height: 18px;
}

.auth-submit {
  min-height: 46px;
  justify-content: center;
}

.auth-feedback {
  min-height: 22px;
  color: var(--text-muted);
  font-size: 13px;
}

.auth-feedback[data-type="error"] {
  color: var(--red);
}

.auth-feedback[data-type="warning"] {
  color: var(--orange);
}

.auth-settings-button {
  width: fit-content;
}

.state-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  color: var(--primary);
  background: var(--primary-soft);
}

/* Admin */
.admin-shell {
  grid-template-rows: auto auto 1fr;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  max-width: 220px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-chip::before {
  content: "";
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gradient);
}

.admin-layout {
  display: grid;
  gap: 16px;
}

.admin-section {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-heading h2 {
  margin: 0;
  font-size: 20px;
}

.admin-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.admin-toolbar .search-field {
  flex: 1 1 280px;
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.admin-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.admin-table th {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface-2);
}

.admin-table tr:last-child td {
  border-bottom: 0;
}

.table-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.table-user strong,
.table-user span {
  display: block;
}

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

.role-master {
  background: color-mix(in srgb, var(--primary) 15%, transparent);
  color: var(--primary-strong);
}

.role-atendente {
  background: color-mix(in srgb, var(--blue) 14%, transparent);
  color: var(--blue);
}

.status-active {
  background: color-mix(in srgb, var(--green) 14%, transparent);
  color: var(--green);
}

.status-inactive {
  background: color-mix(in srgb, var(--red) 12%, transparent);
  color: var(--red);
}

.status-list {
  display: grid;
  gap: 10px;
}

.status-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.status-item.is-muted {
  opacity: 0.62;
}

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

.status-main strong,
.status-main span {
  display: block;
}

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

.status-swatch {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #000 16%, transparent);
}

.status-badges {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-weight: 800;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

/* Settings page */
.settings-page {
  min-height: 100vh;
  padding: 22px;
}

.settings-layout {
  width: min(1120px, 100%);
  min-height: calc(100vh - 44px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(300px, 0.82fr) minmax(360px, 1.18fr);
  gap: 18px;
  align-items: stretch;
}

.settings-hero,
.settings-panel {
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

.settings-hero {
  position: relative;
  display: grid;
  align-content: end;
  min-height: 560px;
  padding: clamp(24px, 4vw, 42px);
  overflow: hidden;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--grad-from) 18%, transparent), transparent 42%),
    linear-gradient(315deg, color-mix(in srgb, var(--grad-to) 18%, transparent), transparent 46%),
    var(--surface);
}

.settings-back {
  position: absolute;
  top: 18px;
  left: 18px;
}

.settings-brand-logo {
  width: min(320px, 80%);
  height: auto;
  margin-bottom: 24px;
  border-radius: 12px;
  filter: drop-shadow(0 10px 30px rgba(124, 58, 237, 0.24));
}

.settings-hero h1 {
  max-width: 520px;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(38px, 4.8vw, 58px);
  line-height: 0.98;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.settings-hero p:last-child {
  max-width: 520px;
  margin: 16px 0 0;
  color: var(--text-muted);
}

.settings-panel {
  display: grid;
  align-content: start;
  gap: 22px;
  padding: clamp(20px, 4vw, 34px);
}

.settings-form {
  display: grid;
  gap: 14px;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.settings-status {
  min-height: 44px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.settings-status[data-type="success"] {
  border-color: color-mix(in srgb, var(--green) 28%, var(--border));
  color: var(--green);
}

.settings-status[data-type="error"] {
  border-color: color-mix(in srgb, var(--red) 28%, var(--border));
  color: var(--red);
}

.settings-server-box {
  display: grid;
  gap: 14px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.settings-admin-box {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface-2) 62%, transparent);
}

.settings-admin-box h3 {
  margin: 0;
  font-size: 17px;
}

.settings-quick-user-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
}

.settings-quick-user-form button {
  width: 100%;
}

.settings-quick-user-form select {
  background-repeat: no-repeat;
  background-size: 16px 16px;
}

.settings-user-list {
  display: grid;
  gap: 8px;
}

.settings-user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.settings-user-item strong,
.settings-user-item span {
  display: block;
}

.settings-user-item > div {
  min-width: 0;
}

.settings-user-item > div span {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-empty {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.settings-shortcuts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.settings-shortcut-card {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 2px 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: border-color var(--transition), transform var(--transition), background var(--transition);
}

.settings-shortcut-card:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.settings-shortcut-card i,
.settings-shortcut-card svg {
  grid-row: 1 / 3;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  color: var(--primary);
}

.settings-shortcut-card span {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.settings-shortcut-card strong {
  font-size: 13px;
  line-height: 1.25;
}

.settings-server-box h3 {
  margin: 0;
  font-size: 16px;
}

.settings-server-box p {
  margin: 6px 0 0;
  color: var(--text-muted);
}

.protected-env-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.protected-env-item {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.protected-env-item strong,
.protected-env-item span {
  display: block;
}

.protected-env-item strong {
  overflow-wrap: anywhere;
  font-size: 12px;
}

.protected-env-item span {
  margin-top: 5px;
  color: var(--text-muted);
  font-size: 12px;
}

@media (max-width: 820px) {
  .auth-layout {
    grid-template-columns: 1fr;
  }

  .auth-brand-panel {
    min-height: 280px;
  }

  .section-heading {
    display: grid;
  }

  .status-item {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .status-badges {
    justify-content: flex-start;
  }

  .settings-layout {
    grid-template-columns: 1fr;
  }

  .settings-hero {
    min-height: 320px;
  }

  .settings-actions,
  .settings-actions button {
    width: 100%;
  }

  .settings-quick-user-form,
  .settings-shortcuts-grid {
    grid-template-columns: 1fr;
  }

  .protected-env-grid {
    grid-template-columns: 1fr;
  }
}
