:root {
  --sc-ink: #17212b;
  --sc-muted: #657184;
  --sc-line: #dfe5eb;
  --sc-bg: #f5f7fa;
  --sc-panel: #ffffff;
  --sc-primary: #1d6fd6;
  --sc-teal: #0f9f8f;
  --sc-green: #279653;
  --sc-orange: #d97706;
  --sc-red: #d23f31;
  --sc-purple: #7c3aed;
}

[v-cloak] {
  display: none;
}

body {
  background: var(--sc-bg);
  color: var(--sc-ink);
  font-family: Inter, Roboto, Arial, sans-serif;
}

.body--dark {
  --sc-ink: #eef3f8;
  --sc-muted: #a6b2c1;
  --sc-line: #2b3644;
  --sc-bg: #111820;
  --sc-panel: #17212b;
}

.app-header {
  background: #182633;
}

.login-page {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(29, 111, 214, 0.12), transparent 340px),
    var(--sc-bg);
}

.login-card {
  width: min(440px, 100%);
  border-radius: 8px;
}

.login-card .q-card__section:first-child {
  text-align: center;
}

.login-logo {
  display: block;
  width: min(340px, 100%);
  margin: 0 auto 18px;
  border-radius: 8px;
}

.login-card h1 {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.2;
}

.login-card p {
  margin: 8px 0 0;
  color: var(--sc-muted);
}

.user-chip {
  max-width: 260px;
  overflow: hidden;
  margin-right: 8px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 10px;
  border-radius: 50%;
  background: var(--sc-teal);
  box-shadow: 0 0 0 4px rgba(15, 159, 143, 0.18);
}

.brand-title-wrap {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.brand-title-wrap span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-logo {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 6px;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.app-page {
  min-height: calc(100vh - 50px);
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(29, 111, 214, 0.08), transparent 260px),
    var(--sc-bg);
}

.page-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  padding: 24px 0 8px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--sc-teal);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  color: var(--sc-ink);
  letter-spacing: 0;
}

h1 {
  max-width: 860px;
  font-size: clamp(1.75rem, 3vw, 3rem);
  line-height: 1.08;
  font-weight: 800;
}

h2 {
  font-size: 1.05rem;
  font-weight: 800;
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card,
.panel {
  background: var(--sc-panel);
  border: 1px solid var(--sc-line);
  border-radius: 8px;
}

.metric-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 96px;
  padding: 16px;
}

.metric-card strong {
  display: block;
  color: var(--sc-ink);
  font-size: 1.65rem;
  line-height: 1;
}

.metric-card span:last-child {
  display: block;
  margin-top: 6px;
  color: var(--sc-muted);
  font-size: 0.84rem;
  line-height: 1.25;
}

.metric-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 8px;
  color: #ffffff;
  font-size: 22px;
}

.metric-icon.blue {
  background: var(--sc-primary);
}

.metric-icon.green {
  background: var(--sc-green);
}

.metric-icon.teal {
  background: var(--sc-teal);
}

.metric-icon.red {
  background: var(--sc-red);
}

.metric-icon.purple {
  background: var(--sc-purple);
}

.metric-icon.orange {
  background: var(--sc-orange);
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 18px;
}

.finance-layout {
  display: grid;
  gap: 18px;
}

.finance-metrics {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  margin-bottom: 0;
}

.panel {
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 60px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--sc-line);
}

.panel-header.compact {
  min-height: 48px;
  padding: 12px 14px;
}

.dialog-card {
  width: min(560px, calc(100vw - 32px));
  border-radius: 8px;
}

.wide-dialog-card {
  width: min(980px, calc(100vw - 32px));
  border-radius: 8px;
}

.subpage-dialog {
  width: 100% !important;
  max-width: none !important;
  min-height: 100vh;
  max-height: none;
  border-radius: 0 !important;
  overflow-x: hidden;
}

.subpage-dialog > .q-card__section,
.subpage-dialog > .q-card__actions {
  width: min(1180px, 100%);
  margin-right: auto;
  margin-left: auto;
}

.subpage-dialog > .q-card__section.q-gutter-md {
  width: min(760px, 100%);
}

.subpage-dialog > .q-card__section:first-child {
  border-bottom: 1px solid var(--sc-line);
}

.subpage-dialog > .q-card__actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  border-top: 1px solid var(--sc-line);
  background: var(--sc-panel);
}

.contract-dialog {
  min-height: 100vh;
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--sc-line);
}

.dialog-heading p {
  margin: 4px 0 0;
  color: var(--sc-muted);
}

.contract-items {
  padding-top: 0;
}

.contract-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--sc-panel);
}

.contract-table th,
.contract-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--sc-line);
  color: var(--sc-ink);
  font-size: 0.9rem;
  line-height: 1.35;
  text-align: left;
  vertical-align: middle;
}

.contract-table th {
  color: var(--sc-muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.contract-table th:first-child,
.contract-table td:first-child {
  width: 40%;
}

.contract-table th:last-child,
.contract-table td:last-child {
  width: 56px;
  text-align: right;
}

.finance-invoice-items h2 {
  margin: 6px 0 12px;
}

.panel-header.compact {
  min-height: auto;
  padding: 0 0 12px;
  border-bottom: 0;
}

.quote-items-section {
  display: grid;
  gap: 14px;
}

.quote-items-table th:first-child,
.quote-items-table td:first-child {
  min-width: 280px;
}

.quote-items-table th:nth-child(5),
.quote-items-table td:nth-child(5) {
  min-width: 220px;
}

.quote-total-panel {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(180px, 260px) minmax(160px, 1fr);
  align-items: center;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--sc-line);
  border-radius: 8px;
  background: rgba(29, 111, 214, 0.05);
}

.quote-total-panel div {
  display: grid;
  gap: 4px;
}

.quote-total-panel span {
  color: var(--sc-muted);
  font-size: 0.84rem;
}

.quote-total-panel strong {
  font-size: 1.35rem;
}

.sc-select-popup {
  z-index: 10000;
}

.sc-select-popup .q-item {
  min-height: 42px;
}

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

.quote-item-row {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) 76px 96px 78px minmax(120px, 1fr) 36px;
  align-items: stretch;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--sc-line);
  border-radius: 8px;
}

.quote-item-row .q-field,
.quote-item-row .q-field__control {
  min-height: 56px;
}

.quote-item-total {
  display: grid;
  gap: 2px;
  align-content: center;
  min-height: 56px;
}

.quote-item-total span {
  color: var(--sc-muted);
  font-size: 0.75rem;
}

.quote-item-total strong {
  white-space: nowrap;
}

.invoice-banner-clickable {
  cursor: pointer;
  transition: box-shadow 0.16s ease, transform 0.16s ease;
}

.invoice-banner-clickable:hover {
  box-shadow: 0 6px 18px rgba(29, 111, 214, 0.16);
  transform: translateY(-1px);
}

.empty-table-cell {
  padding: 18px;
  color: var(--sc-muted);
  text-align: center;
}

.sla-green,
.sla-yellow,
.sla-orange,
.sla-red,
.sla-black {
  min-width: 72px;
  justify-content: center;
  color: #ffffff;
}

.sla-green {
  background: var(--sc-green);
}

.sla-yellow {
  background: #c89d16;
}

.sla-orange {
  background: var(--sc-orange);
}

.sla-red {
  background: var(--sc-red);
}

.sla-black {
  background: #111111;
}

.q-table__container {
  background: transparent;
}

.technician-avatar {
  font-weight: 700;
}

.technician-photo-field {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.technician-photo-preview {
  width: 72px;
  height: 72px;
  font-size: 24px;
  font-weight: 700;
}

.technician-photo-preview img,
.technician-avatar img {
  object-fit: cover;
}

.technician-photo-actions {
  display: grid;
  gap: 8px;
}

.client-address-grid {
  display: grid;
  grid-template-columns: 180px 1fr 140px;
  gap: 12px;
}

.client-address-grid .q-field:nth-child(2),
.client-address-grid .q-field:nth-child(4) {
  grid-column: span 2;
}

.settings-panel {
  padding-bottom: 18px;
}

.settings-tabs {
  color: var(--sc-ink);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 16px;
  padding: 18px;
}

.settings-full,
.settings-grid .q-toggle {
  grid-column: 1 / -1;
}

.evolution-connection-controls {
  display: grid;
  grid-template-columns: minmax(260px, 420px) auto;
  align-items: start;
  gap: 12px;
}

.evolution-connection-status {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sc-muted);
}

.evolution-qr {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px;
  border: 1px solid var(--sc-line);
  background: var(--sc-surface);
}

.evolution-qr img {
  width: 240px;
  height: 240px;
  object-fit: contain;
}

.evolution-qr p {
  margin: 8px 0 0;
  color: var(--sc-muted);
}

.permission-matrix-wrap {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--sc-border);
  border-radius: 8px;
  background: var(--sc-surface);
}

.permission-matrix {
  width: 100%;
  min-width: 860px;
  border-collapse: separate;
  border-spacing: 0;
}

.permission-matrix th,
.permission-matrix td {
  min-width: 132px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--sc-border);
  border-right: 1px solid var(--sc-border);
  text-align: center;
  vertical-align: middle;
}

.permission-matrix th:first-child,
.permission-matrix td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 260px;
  max-width: 320px;
  text-align: left;
  background: var(--sc-surface);
}

.permission-matrix th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--sc-soft);
  font-weight: 700;
}

.permission-matrix th:first-child {
  z-index: 4;
  background: var(--sc-soft);
}

.permission-matrix tr:last-child td {
  border-bottom: 0;
}

.permission-matrix th:last-child,
.permission-matrix td:last-child {
  border-right: 0;
}

.permission-matrix span,
.permission-matrix strong,
.permission-matrix small {
  display: block;
  line-height: 1.25;
}

.permission-matrix small {
  margin-top: 3px;
  color: var(--sc-muted);
  font-size: 11px;
  font-weight: 500;
}

.template-helper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--sc-line);
  border-radius: 8px;
  background: rgba(29, 111, 214, 0.05);
}

.template-helper p {
  margin: 6px 0 0;
  color: var(--sc-muted);
}

.template-file-box,
.template-tags-box {
  display: grid;
  gap: 10px;
}

.template-file-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--sc-muted);
  font-size: 0.86rem;
}

.template-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.template-editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.85fr);
  gap: 16px;
}

.template-editor-grid h2 {
  margin-bottom: 10px;
}

.template-preview {
  min-height: 374px;
  padding: 16px;
  border: 1px solid var(--sc-line);
  border-radius: 8px;
  background: var(--sc-panel);
  overflow: auto;
}

.template-preview table {
  width: 100%;
  margin: 10px 0;
  border-collapse: collapse;
}

.template-preview th,
.template-preview td {
  padding: 8px;
  border: 1px solid var(--sc-line);
  text-align: left;
}

.prompt-box textarea {
  min-height: 150px;
}

.whatsapp-chat {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 18px;
  min-height: 650px;
}

.conversation-list,
.chat-panel {
  min-height: 650px;
}

.conversation-list .q-list {
  max-height: 590px;
  overflow: auto;
}

.chat-panel {
  display: flex;
  flex-direction: column;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 78px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--sc-line);
}

.chat-header span {
  display: block;
  margin-top: 4px;
  color: var(--sc-muted);
  font-size: 0.86rem;
}

.sender-input {
  width: min(260px, 40vw);
}

.table-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  flex-wrap: wrap;
}

.table-search-field {
  width: min(320px, 100%);
  min-width: 220px;
}

.attendance-inline {
  border-bottom: 1px solid var(--sc-line);
  background: var(--sc-panel);
}

.attendance-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  padding: 14px;
}

.attendance-grid .q-field,
.attendance-grid .q-field__control {
  height: 136px;
}

.attendance-grid textarea {
  min-height: 86px;
  resize: none;
}

.attendance-grid .attendance-remote-field .q-field__control,
.attendance-grid .attendance-remote-field.q-field__control {
  height: 56px;
  min-height: 56px;
}

.ticket-items-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 12px;
  padding: 0 14px 14px;
}

.settings-full.ticket-items-grid {
  padding: 0;
}

.ticket-items-panel {
  border: 1px solid var(--sc-line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--sc-panel);
}

.ticket-item-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 86px auto;
  gap: 8px;
  align-items: stretch;
  padding: 10px;
  border-top: 1px solid var(--sc-line);
}

.ticketActionDialog .ticket-item-row,
.ticket-action-dialog .ticket-item-row {
  grid-template-columns: minmax(220px, 1fr) 88px minmax(140px, 0.8fr) auto;
}

.ticket-item-row .q-field,
.ticket-item-row .q-field__control {
  min-height: 64px;
  height: 64px;
}

.ticket-item-row .q-field__control-container {
  justify-content: center;
}

.ticket-item-row .q-field__native,
.ticket-item-row .q-field__input {
  min-height: 0;
  line-height: 1.2;
}

.ticket-item-row .q-field__native > span {
  display: -webkit-box;
  overflow: hidden;
  line-height: 1.2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.ticket-item-row .q-btn {
  align-self: center;
}

.empty-inline {
  margin: 0;
  padding: 12px;
  color: var(--sc-muted);
  font-size: 0.86rem;
}

.usage-client-filter {
  min-width: 260px;
}

.usage-summary {
  display: grid;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--sc-line);
}

.usage-banner {
  border: 1px solid var(--sc-line);
  background: var(--sc-panel);
}

.usage-banner.near_limit {
  border-color: rgba(217, 119, 6, 0.45);
}

.usage-banner.at_limit {
  border-color: rgba(200, 157, 22, 0.55);
}

.usage-banner.exceeded {
  border-color: rgba(210, 63, 49, 0.55);
}

.usage-banner.ok {
  border-color: rgba(39, 150, 83, 0.35);
}

.message-stack {
  flex: 1;
  min-height: 420px;
  max-height: 520px;
  padding: 18px;
  overflow: auto;
  background:
    linear-gradient(180deg, rgba(15, 159, 143, 0.04), transparent 220px),
    var(--sc-bg);
}

.message-row {
  display: flex;
  margin-bottom: 12px;
}

.message-row.outbound {
  justify-content: flex-end;
}

.message-bubble {
  width: fit-content;
  max-width: min(620px, 82%);
  padding: 12px 14px;
  border: 1px solid var(--sc-line);
  border-radius: 8px;
  background: var(--sc-panel);
}

.message-row.outbound .message-bubble {
  border-color: rgba(29, 111, 214, 0.25);
  background: rgba(29, 111, 214, 0.1);
}

.message-meta {
  margin-bottom: 6px;
  color: var(--sc-muted);
  font-size: 0.75rem;
}

.message-bubble strong {
  display: block;
  margin-bottom: 4px;
  color: var(--sc-ink);
}

.message-bubble p {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.45;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 14px;
  border-top: 1px solid var(--sc-line);
  background: var(--sc-panel);
}

.composer-input {
  flex: 1;
}

.empty-chat {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--sc-muted);
}

.ticket-action-dialog {
  width: min(1240px, calc(100vw - 32px));
  max-width: min(1240px, calc(100vw - 32px));
  max-height: calc(100vh - 44px);
  border-radius: 8px;
  overflow-x: hidden;
}

.ticket-workspace-dialog {
  width: 100%;
  max-width: none;
  min-height: 100vh;
  max-height: none;
  border-radius: 0;
}

.ticket-action-dialog p {
  margin: 6px 0 0;
  color: var(--sc-muted);
}

.ticket-action-dialog .settings-grid {
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  padding: 18px 24px;
}

.ticket-action-dialog .ticket-items-grid {
  grid-template-columns: repeat(2, minmax(360px, 1fr));
  padding: 0;
}

.ticket-action-dialog .ticket-items-panel {
  min-width: 0;
}

.ticket-workspace-dialog > .q-card__section,
.ticket-workspace-dialog > .q-card__actions {
  margin-right: auto;
  margin-left: auto;
  width: min(1320px, 100%);
}

.ticket-workspace-dialog > .q-card__actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  border-top: 1px solid var(--sc-line);
  background: var(--sc-panel);
}

@media (max-width: 1280px) {
  .content-grid {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
  }
}

@media (max-width: 920px) {
  .app-page {
    padding: 16px;
  }

  .page-band,
  .split-layout,
  .whatsapp-chat {
    display: block;
  }

  .page-band .q-btn {
    margin-top: 16px;
  }

  .content-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .panel + .panel {
    margin-top: 16px;
  }

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

  .evolution-connection-controls {
    grid-template-columns: 1fr;
  }

  .evolution-qr {
    align-items: flex-start;
    flex-direction: column;
  }

  .template-helper,
  .template-editor-grid {
    grid-template-columns: 1fr;
  }

  .template-helper {
    align-items: stretch;
    flex-direction: column;
  }

  .ticket-action-dialog .settings-grid,
  .ticket-action-dialog .ticket-items-grid {
    grid-template-columns: 1fr;
  }

  .conversation-list,
  .chat-panel {
    min-height: auto;
  }

  .chat-panel {
    margin-top: 16px;
  }

  .chat-header,
  .composer {
    align-items: stretch;
    flex-direction: column;
  }

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

  .ticket-items-grid,
  .settings-full.ticket-items-grid {
    grid-template-columns: 1fr;
    padding: 0 14px 14px;
  }

  .ticket-item-row,
  .ticket-action-dialog .ticket-item-row {
    grid-template-columns: 1fr;
  }

  .quote-item-row,
  .quote-total-panel {
    grid-template-columns: 1fr;
  }

  .sender-input {
    width: 100%;
  }

  .message-stack {
    max-height: 56vh;
  }
}

@media (max-width: 560px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .metric-card {
    min-height: 82px;
  }
}
