@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

  * {
    box-sizing: border-box;
  }

  :root {
    --page-gutter: 20px;
    --space-1: var(--theme-space-1);
    --space-2: var(--theme-space-2);
    --space-3: var(--theme-space-3);
    --space-4: var(--theme-space-4);
    --space-5: var(--theme-space-5);
    --radius-1: var(--theme-radius-xs);
    --radius-2: var(--theme-radius-sm);
    --radius-3: var(--theme-radius-md);
    --touch-target: var(--theme-control-height);
    --control-height: var(--theme-control-height);
    --line-soft: var(--legacy-border);
  }

  body {
    margin: 0;
    padding: 0;
    background: var(--legacy-bg);
    color: var(--legacy-text);
    font-family: var(--theme-font);
    font-size: 11.5px;
    line-height: 1.4;
    overflow-x: hidden;
  }

  .container {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: var(--page-gutter);
  }

  /* Control bar */
  .control-bar {
    background: var(--legacy-paper);
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-md);
    padding: 12px 16px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    box-shadow: var(--theme-shadow-sm);
  }

  .nav-group {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
  }

  .nav-btn {
    display: inline-flex;
    min-height: var(--touch-target);
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    background: var(--legacy-primary);
    color: var(--legacy-primary-text);
    text-decoration: none;
    font-weight: 700;
    border-radius: var(--legacy-radius-sm);
    transition: background var(--theme-transition);
    text-transform: uppercase;
    font-size: 9.5px;
    letter-spacing: 0.3px;
    border: none;
    cursor: pointer;
    line-height: 1.2;
    text-align: center;
  }

  .nav-btn:hover {
    background: var(--legacy-primary-hover);
  }

  .nav-btn.secondary {
    background: var(--legacy-paper-soft);
    color: var(--legacy-text);
    border: 1px solid var(--legacy-border);
  }

  .nav-btn.secondary:hover {
    background: var(--theme-paper-subtle);
  }

  .nav-btn.danger {
    background: var(--theme-danger);
    border: 1px solid color-mix(in srgb, var(--theme-danger) 78%, var(--theme-text));
    color: var(--theme-primary-text);
  }

  .nav-btn.danger:hover {
    background: color-mix(in srgb, var(--theme-danger) 78%, var(--theme-text));
  }

  .timestamp {
    font-size: 10px;
    color: var(--legacy-muted);
    font-weight: 500;
    margin-left: auto;
  }

  /* Views and Cards */
  .view-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--theme-paper-subtle);
    padding-bottom: 10px;
  }

  .tab-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: transparent;
    border: none;
    min-height: var(--touch-target);
    padding: 6px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--legacy-muted);
    cursor: pointer;
    border-radius: var(--legacy-radius-sm);
    transition: all var(--theme-transition);
  }

  .tab-btn-label {
    white-space: nowrap;
  }

  .followup-tab-alerts {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    line-height: 1;
  }

  .followup-tab-alert {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 22px;
    min-height: 18px;
    padding: 2px 5px;
    border: 1px solid var(--legacy-border);
    border-radius: var(--theme-radius-pill);
    background: var(--legacy-paper-soft);
    color: var(--legacy-muted);
    font-size: 8px;
    font-weight: 850;
  }

  .followup-tab-alert span {
    font-size: 7px;
    opacity: 0.78;
  }

  .followup-tab-alert strong {
    font-size: 9px;
    line-height: 1;
  }

  .followup-tab-alert.priority-urgente {
    border-color: color-mix(in srgb, var(--theme-danger) 34%, var(--legacy-border));
    background: var(--theme-danger-soft);
    color: var(--theme-danger-text);
  }

  .followup-tab-alert.priority-alta {
    border-color: color-mix(in srgb, var(--theme-warning) 34%, var(--legacy-border));
    background: var(--theme-warning-soft);
    color: var(--theme-warning-text);
  }

  .followup-tab-alert.priority-normal {
    border-color: color-mix(in srgb, var(--theme-info) 34%, var(--legacy-border));
    background: var(--theme-info-soft);
    color: var(--theme-info-text);
  }

  .followup-tab-alert.priority-baixa {
    border-color: var(--legacy-border);
    background: var(--legacy-paper-soft);
    color: var(--legacy-muted);
  }

  .followup-tab-alert.is-zero {
    opacity: 0.46;
  }

  .tab-btn.active .followup-tab-alert {
    border-color: color-mix(in srgb, var(--theme-primary-text) 30%, transparent);
    background: color-mix(in srgb, var(--theme-primary-text) 14%, transparent);
    color: var(--theme-primary-text);
  }

  .tab-btn.active {
    background: var(--legacy-primary);
    color: var(--legacy-primary-text);
  }

  .tab-btn:hover:not(.active) {
    background: var(--theme-paper-subtle);
    color: var(--legacy-text);
  }

  .view-panel {
    display: none;
  }

  .view-panel.active {
    display: block;
  }

  #panel-table {
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: visible;
  }

  .filter-bar {
    background: var(--legacy-paper);
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-md);
    padding: 12px;
    margin-bottom: 15px;
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 130px 140px 145px auto auto;
    gap: 8px;
    align-items: center;
    box-shadow: var(--theme-shadow-sm);
  }

  .payment-dashboard {
    display: grid;
    grid-template-columns: repeat(6, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
  }

  .payment-summary-card {
    background: var(--legacy-paper);
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-md);
    color: var(--legacy-muted);
    cursor: pointer;
    display: grid;
    gap: 4px;
    min-height: 58px;
    padding: 10px 12px;
    text-align: left;
  }

  .payment-summary-card span {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .payment-summary-card strong {
    font-size: 20px;
    line-height: 1;
  }

  .payment-summary-card.active {
    border-color: var(--theme-info-text);
    box-shadow: var(--theme-focus-ring);
  }

  .payment-summary-card.paid { border-left: 4px solid var(--theme-success); }
  .payment-summary-card.pending { border-left: 4px solid var(--theme-danger); }
  .payment-summary-card.scheduled { border-left: 4px solid var(--theme-info); }
  .payment-summary-card.today { border-left: 4px solid var(--theme-warning); }
  .payment-summary-card.overdue { border-left: 4px solid var(--theme-danger); }

  .filter-control {
    width: 100%;
    min-height: var(--control-height);
    padding: 6px 8px;
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-sm);
    font-family: inherit;
    font-size: 11px;
    color: var(--legacy-text);
    background: var(--legacy-paper);
    outline: none;
  }

  .filter-control:focus {
    border-color: var(--legacy-text);
  }

  .filter-meta {
    color: var(--legacy-muted);
    font-weight: 700;
    white-space: nowrap;
  }

  /* Tables */
  .section-title {
    border: 1.2px solid var(--legacy-primary);
    border-radius: var(--legacy-radius-sm) var(--legacy-radius-sm) 0 0;
    border-bottom: 0;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--legacy-primary);
    color: var(--theme-primary-text);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  table {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    border-collapse: collapse;
    background: var(--legacy-paper);
    box-shadow: var(--theme-shadow-sm);
    table-layout: fixed;
  }

  th, td {
    border: 1px solid var(--legacy-border);
    padding: 8px clamp(6px, 0.7vw, 10px);
    text-align: left;
    overflow-wrap: anywhere;
    word-break: normal;
  }

  td.first-column-cell {
    font-weight: 700;
  }

  th {
    position: relative;
    background: var(--legacy-paper-soft);
    font-weight: 700;
    font-size: 10px;
    text-transform: uppercase;
    color: var(--legacy-muted);
    user-select: none;
    cursor: grab;
    overflow-wrap: normal;
    white-space: normal;
  }

  th:active {
    cursor: grabbing;
  }

  .column-resize-handle {
    position: absolute;
    top: 0;
    right: -6px;
    bottom: 0;
    z-index: 2;
    width: 12px;
    border: 0;
    background: transparent;
    cursor: col-resize;
    padding: 0;
    touch-action: none;
  }

  .column-resize-handle::after {
    content: "";
    position: absolute;
    top: 8px;
    right: 4px;
    bottom: 8px;
    width: 2px;
    border-radius: var(--theme-radius-pill);
    background: var(--theme-border-strong);
    opacity: 0;
    transition: opacity 0.16s, background 0.16s;
  }

  th:hover .column-resize-handle::after,
  .column-resize-handle:focus-visible::after,
  body.is-resizing-columns .column-resize-handle::after {
    opacity: 0.72;
  }

  .column-resize-handle:focus-visible {
    outline: none;
  }

  body.is-resizing-columns {
    cursor: col-resize;
    user-select: none;
  }

  body.is-reordering-columns {
    cursor: grabbing;
    user-select: none;
  }

  th.is-column-dragging {
    opacity: 0.5;
  }

  th.is-column-drop-before::before,
  th.is-column-drop-after::after {
    content: "";
    position: absolute;
    top: -2px;
    bottom: -2px;
    z-index: 5;
    width: 3px;
    border-radius: var(--theme-radius-pill);
    background: var(--theme-info);
    box-shadow: var(--theme-focus-ring);
    pointer-events: none;
  }

  th.is-column-drop-before::before {
    left: -2px;
  }

  th.is-column-drop-after::after {
    right: -2px;
  }

  /* Status Colors */
  .status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    padding: 3px 6px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 9px;
    text-transform: uppercase;
    text-align: center;
    line-height: 1.15;
    overflow-wrap: anywhere;
    white-space: normal;
    word-break: normal;
  }

  .status-green {
    background: var(--theme-success-soft);
    color: var(--theme-success-text);
    border: 1px solid color-mix(in srgb, var(--theme-success) 34%, var(--legacy-border));
  }

  .status-yellow {
    background: var(--theme-warning-soft);
    color: var(--theme-warning-text);
    border: 1px solid color-mix(in srgb, var(--theme-warning) 34%, var(--legacy-border));
  }

  .status-red {
    background: var(--theme-danger-soft);
    color: var(--theme-danger-text);
    border: 1px solid color-mix(in srgb, var(--theme-danger) 34%, var(--legacy-border));
  }

  .status-blue {
    background: var(--theme-info-soft);
    color: var(--theme-info-text);
    border: 1px solid color-mix(in srgb, var(--theme-info) 34%, var(--legacy-border));
  }

  .status-ready {
    background: color-mix(in srgb, var(--theme-warning-soft) 78%, var(--legacy-paper));
    color: var(--theme-warning-text);
    border: 1px solid color-mix(in srgb, var(--theme-warning) 30%, var(--legacy-border));
  }

  .status-neutral {
    background: var(--legacy-paper-soft);
    color: var(--legacy-text);
    border: 1px solid var(--legacy-border);
  }

  .payment-due-text,
  .calendar-payment-due {
    color: var(--legacy-muted);
    font-size: 9px;
    font-weight: 700;
    margin-top: 4px;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .installations-table td[data-label="Ações"] .action-link {
    display: inline-flex;
    margin: 0 4px 4px 0;
    padding-inline: 6px;
    white-space: normal;
  }

  @media (pointer: coarse) and (min-width: 641px) {
    .column-resize-handle {
      right: -11px;
      width: 22px;
    }
  }

  .installation-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
  }

  .installation-badges:empty {
    display: none;
  }

  .installation-badge {
    border: 1px solid var(--legacy-border);
    border-radius: var(--theme-radius-pill);
    background: var(--legacy-paper-soft);
    color: var(--legacy-muted);
    display: inline-flex;
    align-items: center;
    font-size: 8px;
    font-weight: 850;
    line-height: 1.1;
    padding: 3px 6px;
    text-transform: uppercase;
  }

  .installation-badge.danger {
    background: var(--theme-danger-soft);
    border-color: color-mix(in srgb, var(--theme-danger) 34%, var(--legacy-border));
    color: var(--theme-danger-text);
  }

  .installation-badge.warning {
    background: var(--theme-warning-soft);
    border-color: color-mix(in srgb, var(--theme-warning) 34%, var(--legacy-border));
    color: var(--theme-warning-text);
  }

  .installation-badge.info {
    background: var(--theme-info-soft);
    border-color: color-mix(in srgb, var(--theme-info) 34%, var(--legacy-border));
    color: var(--theme-info-text);
  }

  .installation-os-label {
    display: inline;
    margin-bottom: 0;
    color: var(--legacy-muted);
    font-size: inherit;
    font-weight: 800;
    line-height: inherit;
    text-transform: uppercase;
  }

  .installation-client-name {
    color: var(--legacy-text);
    font-weight: 800;
    line-height: 1.2;
  }

  .os-cell {
    color: var(--legacy-text);
    font-size: inherit;
    font-weight: 800;
    white-space: normal;
  }

  .followup-toolbar {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: space-between;
    margin-bottom: 8px;
    padding: 8px 10px;
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-md);
    background: var(--legacy-paper);
  }

  .followup-title-row {
    align-items: center;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--legacy-text);
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin: 0;
    min-height: 0;
    padding: 0;
  }

  .followup-filters {
    display: grid;
    flex: 1 1 460px;
    grid-template-columns: repeat(3, minmax(118px, 1fr));
    gap: 6px;
    max-width: 720px;
  }

  .followup-filters .filter-control {
    min-height: 34px;
    padding: 6px 8px;
    font-size: 10px;
  }

  .followup-modal {
    max-width: 620px;
  }

  .followup-modal-form {
    display: grid;
    gap: 12px;
  }

  .followup-modal-actions {
    background: var(--theme-paper);
    border-top: 1px solid var(--theme-border);
    bottom: -16px;
    box-shadow: var(--theme-footer-shadow);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin: 4px -16px -16px;
    padding: 12px 16px;
    position: sticky;
    z-index: 5;
  }

  .followup-center {
    display: grid;
    gap: 14px;
  }

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

  .followup-metric {
    display: grid;
    gap: 3px;
    min-height: 54px;
    padding: 9px 10px;
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-md);
    background: var(--legacy-paper);
    color: var(--legacy-text);
    text-align: left;
  }

  .followup-metric span {
    color: var(--legacy-muted);
    font-size: 9px;
    font-weight: 900;
    text-transform: uppercase;
  }

  .followup-metric strong {
    color: var(--legacy-text);
    font-size: 20px;
    line-height: 1;
  }

  .followup-section {
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-md);
    background: var(--legacy-paper);
    overflow: hidden;
  }

  .followup-section-title {
    background: var(--legacy-paper-soft);
    border-bottom: 1px solid var(--legacy-border);
    color: var(--legacy-text);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    text-transform: uppercase;
  }

  .followup-section-title span {
    font-size: 11px;
    font-weight: 850;
  }

  .followup-section-title strong {
    border-radius: var(--theme-radius-pill);
    background: var(--theme-paper-subtle);
    color: var(--legacy-muted);
    min-width: 24px;
    padding: 3px 8px;
    text-align: center;
  }

  .followup-section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 10px;
    padding: 10px;
  }

  .followup-queue-grid {
    grid-template-columns: 1fr;
  }

  .followup-card {
    border: 1px solid var(--legacy-border);
    border-left: 5px solid var(--legacy-muted);
    border-radius: var(--legacy-radius-md);
    background: var(--legacy-paper);
    display: grid;
    gap: 8px;
    padding: 11px;
    min-width: 0;
  }

  .followup-row {
    align-items: center;
    grid-template-columns: minmax(0, 1.4fr) minmax(230px, 0.9fr) auto;
  }

  .followup-row-main {
    display: grid;
    gap: 3px;
    min-width: 0;
  }

  .followup-row .followup-card-head {
    justify-content: flex-start;
  }

  .followup-row-vehicle {
    white-space: nowrap;
  }

  .followup-row-actions {
    justify-content: flex-end;
  }

  .followup-card.priority-baixa { border-left-color: var(--legacy-muted); }
  .followup-card.priority-normal { border-left-color: var(--theme-info); }
  .followup-card.priority-alta { border-left-color: var(--theme-warning); }
  .followup-card.priority-urgente { border-left-color: var(--theme-danger); }

  .followup-card.status-concluida {
    border-left-color: var(--theme-success);
    background: var(--theme-success-soft);
    opacity: 0.82;
  }

  .followup-card.status-desativada {
    border-left-color: var(--theme-border-strong);
    background: var(--legacy-paper-soft);
    opacity: 0.78;
  }

  .followup-archive {
    background: var(--legacy-paper-soft);
  }

  .followup-archive-summary {
    align-items: center;
    cursor: pointer;
    justify-content: flex-start;
    list-style: none;
    margin-bottom: 0;
  }

  .followup-archive-summary strong {
    margin-left: auto;
  }

  .followup-archive-summary::-webkit-details-marker {
    display: none;
  }

  .followup-archive-summary::before {
    content: '+';
    display: inline-grid;
    place-items: center;
    width: 18px;
    height: 18px;
    margin-right: 8px;
    border-radius: var(--theme-radius-pill);
    background: var(--theme-paper-subtle);
    color: var(--legacy-muted);
    font-size: 12px;
    font-weight: 900;
  }

  .followup-archive[open] .followup-archive-summary {
    margin-bottom: 14px;
  }

  .followup-archive[open] .followup-archive-summary::before {
    content: '-';
  }

  .followup-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
  }

  .followup-card-head > div {
    display: grid;
    gap: 2px;
    min-width: 0;
  }

  .followup-card-head strong,
  .followup-card-task {
    color: var(--legacy-text);
    font-weight: 850;
    overflow-wrap: anywhere;
  }

  .followup-card-head span,
  .followup-card-service {
    color: var(--legacy-muted);
    font-size: 10px;
    font-weight: 650;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
  }

  .followup-priority {
    border-radius: var(--theme-radius-pill);
    background: var(--legacy-paper-soft);
    color: var(--legacy-muted);
    flex: 0 0 auto;
    font-size: 8px;
    font-weight: 900;
    padding: 4px 7px;
    text-transform: uppercase;
  }

  .followup-card-meta,
  .followup-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .followup-card-meta,
  .task-detail-list {
    display: grid;
    gap: 4px;
    min-width: 0;
  }

  .task-alert-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .task-alert-list:empty {
    display: none;
  }

  .task-detail-line {
    color: var(--legacy-muted);
    font-size: 11px;
    font-weight: 650;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }

  .task-detail-line strong {
    color: var(--legacy-text);
    font-weight: 850;
  }

  .followup-chip {
    border: 1px solid var(--legacy-border);
    border-radius: var(--theme-radius-pill);
    background: var(--legacy-paper-soft);
    color: var(--legacy-muted);
    font-size: 8.5px;
    font-weight: 850;
    line-height: 1.1;
    padding: 4px 7px;
    text-transform: uppercase;
  }

  .followup-chip.type-cobranca {
    background: var(--theme-danger-soft);
    border-color: color-mix(in srgb, var(--theme-danger) 34%, var(--legacy-border));
    color: var(--theme-danger-text);
  }

  .followup-chip.type-entrega {
    background: var(--theme-warning-soft);
    border-color: color-mix(in srgb, var(--theme-warning) 34%, var(--legacy-border));
    color: var(--theme-warning-text);
  }

  .followup-chip.type-pos-entrega,
  .followup-chip.type-followup {
    background: var(--theme-info-soft);
    border-color: color-mix(in srgb, var(--theme-info) 34%, var(--legacy-border));
    color: var(--theme-info-text);
  }

  .followup-chip.status-completed {
    background: var(--theme-success-soft);
    border-color: color-mix(in srgb, var(--theme-success) 34%, var(--legacy-border));
    color: var(--theme-success-text);
  }

  .followup-chip.status-disabled {
    background: var(--theme-paper-subtle);
    border-color: var(--legacy-border);
    color: var(--legacy-muted);
  }

  .followup-chip.due-vencida,
  .followup-chip.priority-urgente {
    background: var(--theme-danger-soft);
    border-color: color-mix(in srgb, var(--theme-danger) 34%, var(--legacy-border));
    color: var(--theme-danger-text);
  }

  .followup-chip.due-hoje,
  .followup-chip.due-próxima,
  .followup-chip.due-proxima,
  .followup-chip.priority-alta {
    background: var(--theme-warning-soft);
    border-color: color-mix(in srgb, var(--theme-warning) 34%, var(--legacy-border));
    color: var(--theme-warning-text);
  }

  .activity-mini-btn.primary {
    background: var(--theme-info);
    color: var(--theme-primary-text);
  }

  .followup-empty {
    border: 1px dashed var(--legacy-border);
    border-radius: var(--legacy-radius-md);
    color: var(--legacy-muted);
    font-weight: 750;
    padding: 14px;
    text-align: center;
  }

  .followup-empty-wide {
    background: var(--legacy-paper);
    padding: 24px;
  }

  .automation-settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    gap: 10px;
    margin-top: 10px;
  }

  .automation-settings-grid label {
    display: grid;
    gap: 5px;
    color: var(--legacy-muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .automation-setting-toggle {
    align-items: center;
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-md);
    display: flex !important;
    gap: 8px !important;
    min-height: 44px;
    padding: 8px 10px;
    text-transform: none !important;
  }

  .automation-setting-toggle input {
    width: 18px;
    height: 18px;
  }

  .automation-workspace {
    display: grid;
    gap: 12px;
  }

  .automation-dashboard {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
  }

  .automation-stat,
  .automation-list,
  .automation-editor,
  .automation-panel {
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-md);
    background: var(--legacy-paper);
  }

  .automation-stat {
    padding: 9px;
  }

  .automation-stat span,
  .automation-rule-btn span,
  .automation-rule-btn em,
  .automation-editor-head span,
  .automation-log span,
  .automation-log em,
  .automation-template span {
    color: var(--legacy-muted);
    font-size: 10px;
  }

  .automation-stat strong {
    display: block;
    margin-top: 3px;
    color: var(--legacy-text);
    font-size: 19px;
  }

  .automation-layout,
  .automation-bottom {
    display: grid;
    grid-template-columns: minmax(220px, 0.75fr) minmax(0, 1.5fr);
    gap: 10px;
  }

  .automation-bottom {
    grid-template-columns: 1fr 1fr;
  }

  .automation-list,
  .automation-editor,
  .automation-panel {
    padding: 10px;
  }

  .automation-list {
    display: grid;
    align-content: start;
    gap: 8px;
    max-height: 520px;
    overflow: auto;
  }

  .automation-list-title,
  .automation-editor-head,
  .automation-panel-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--legacy-text);
    font-weight: 900;
  }

  .automation-list-actions,
  .automation-summary-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
  }

  .automation-list-actions {
    max-width: 150px;
  }

  .automation-rule-btn,
  .automation-template {
    display: grid;
    gap: 4px;
    width: 100%;
    padding: 9px;
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-md);
    background: var(--legacy-paper-soft);
    color: var(--legacy-text);
    text-align: left;
  }

  .automation-rule-item {
    align-items: stretch;
    display: grid;
    gap: 6px;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .automation-rule-item .automation-rule-btn {
    height: 100%;
  }

  .automation-rule-delete {
    align-self: stretch;
    min-width: 64px;
  }

  .automation-rule-btn.active {
    border-color: var(--theme-focus);
    box-shadow: var(--theme-focus-ring);
  }

  .automation-rule-btn strong,
  .automation-template strong,
  .automation-log strong {
    color: var(--legacy-text);
  }

  .automation-editor-head {
    margin-bottom: 10px;
  }

  .automation-editor-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
  }

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

  .automation-form label {
    display: grid;
    gap: 4px;
    color: var(--legacy-muted);
    font-size: 9px;
    font-weight: 900;
    text-transform: uppercase;
  }

  .automation-form .span-2,
  .automation-form-actions {
    grid-column: 1 / -1;
  }

  .automation-toggle {
    align-content: center;
    grid-template-columns: auto 1fr;
    min-height: 38px;
  }

  .automation-textarea {
    min-height: 70px;
    font-family: Consolas, monospace;
    font-size: 11px;
  }

  .automation-textarea.small {
    min-height: 48px;
  }

  .automation-form-actions {
    display: flex;
    justify-content: flex-end;
  }

  .automation-template-grid,
  .automation-log-list {
    display: grid;
    gap: 8px;
  }

  .automation-log {
    display: grid;
    gap: 3px;
    padding: 8px;
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-md);
    background: var(--legacy-paper-soft);
  }

  .automation-summary-panel {
    align-items: center;
    background: var(--legacy-paper-soft);
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-md);
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 12px;
  }

  .automation-summary-panel > div {
    display: grid;
    gap: 4px;
  }

  .automation-summary-actions {
    flex: 0 0 auto;
  }

  .automation-summary-panel strong {
    color: var(--legacy-text);
  }

  .automation-summary-panel span,
  .automation-empty-inline,
  .automation-value-empty,
  .automation-simulation-result span {
    color: var(--legacy-muted);
    font-size: 11px;
  }

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

  .modal.automation-modal {
    height: min(840px, calc(100dvh - 32px));
    max-width: min(1180px, calc(100vw - 32px));
    max-height: calc(100dvh - 32px);
    width: min(1180px, calc(100vw - 32px));
  }

  .modal-body.automation-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    padding: 0;
  }

  .automation-modal-workspace {
    height: 100%;
    min-height: 0;
  }

  .automation-modal-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    height: 100%;
    max-height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .automation-modal-sidebar {
    border-right: 1px solid var(--legacy-border);
    background: var(--legacy-paper-soft);
    display: grid;
    align-content: start;
    gap: 12px;
    min-height: 0;
    overscroll-behavior: contain;
    padding: 14px;
    overflow: auto;
  }

  .automation-modal-rule-list {
    display: grid;
    gap: 8px;
  }

  .automation-wizard {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
  }

  .automation-stepper {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
    padding: 12px;
    border-bottom: 1px solid var(--legacy-border);
    background: var(--legacy-paper);
  }

  .automation-stepper button {
    align-items: center;
    background: var(--legacy-paper-soft);
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-md);
    color: var(--legacy-muted);
    cursor: pointer;
    display: flex;
    font-family: inherit;
    font-size: 10px;
    font-weight: 850;
    gap: 6px;
    min-height: 38px;
    padding: 6px 8px;
  }

  .automation-stepper button span {
    align-items: center;
    background: var(--theme-paper-subtle);
    border-radius: var(--theme-radius-pill);
    color: var(--legacy-muted);
    display: inline-flex;
    height: 20px;
    justify-content: center;
    width: 20px;
  }

  .automation-stepper button.active {
    background: var(--theme-info-soft);
    border-color: var(--theme-focus);
    color: var(--theme-info-text);
  }

  .automation-stepper button.active span {
    background: var(--theme-info);
    color: var(--theme-primary-text);
  }

  .automation-wizard-body {
    min-height: 0;
    overscroll-behavior: contain;
    overflow: auto;
    padding: 16px;
  }

  .automation-step-panel {
    display: grid;
    gap: 14px;
  }

  .automation-step-head {
    display: grid;
    gap: 4px;
  }

  .automation-step-head strong {
    color: var(--legacy-text);
    font-size: 18px;
  }

  .automation-step-head span {
    color: var(--legacy-muted);
    font-size: 12px;
  }

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

  .automation-trigger-card {
    background: var(--legacy-paper);
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-md);
    color: var(--legacy-text);
    cursor: pointer;
    display: grid;
    gap: 5px;
    min-height: 88px;
    padding: 12px;
    text-align: left;
  }

  .automation-trigger-card.active {
    background: var(--theme-info-soft);
    border-color: var(--theme-info);
    box-shadow: var(--theme-focus-ring);
  }

  .automation-trigger-card span {
    color: var(--legacy-muted);
    font-size: 11px;
  }

  .automation-mode-row,
  .automation-group-head {
    align-items: center;
    display: grid;
    grid-template-columns: auto minmax(180px, 260px) auto;
    gap: 8px;
  }

  .automation-condition-list,
  .automation-action-list,
  .automation-group-list {
    display: grid;
    gap: 10px;
  }

  .automation-condition-row,
  .automation-action-row {
    align-items: end;
    background: var(--legacy-paper-soft);
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-md);
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(145px, 1fr) minmax(145px, 1fr) minmax(160px, 1fr) auto;
    padding: 10px;
  }

  .automation-action-row {
    grid-template-columns: repeat(4, minmax(130px, 1fr)) auto;
  }

  .automation-condition-row label,
  .automation-action-row label {
    display: grid;
    gap: 4px;
    min-width: 0;
  }

  .automation-action-row .span-2 {
    grid-column: 1 / span 4;
  }

  .automation-condition-row label span,
  .automation-action-row label span,
  .automation-mode-row span {
    color: var(--legacy-muted);
    font-size: 10px;
    font-weight: 850;
    text-transform: uppercase;
  }

  .automation-between {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .automation-group {
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-md);
    display: grid;
    gap: 10px;
    padding: 10px;
  }

  .automation-validation {
    background: var(--theme-danger-soft);
    border: 1px solid color-mix(in srgb, var(--theme-danger) 34%, var(--legacy-border));
    border-radius: var(--legacy-radius-md);
    color: var(--theme-danger-text);
    display: grid;
    gap: 4px;
    font-size: 12px;
    padding: 10px;
  }

  .automation-validation.ok {
    background: var(--theme-success-soft);
    border-color: color-mix(in srgb, var(--theme-success) 34%, var(--legacy-border));
    color: var(--theme-success-text);
  }

  .automation-review {
    display: grid;
    gap: 8px;
  }

  .automation-review div,
  .automation-simulation-result {
    background: var(--legacy-paper-soft);
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-md);
    display: grid;
    gap: 4px;
    padding: 10px;
  }

  .automation-review span {
    color: var(--legacy-muted);
    font-size: 10px;
    font-weight: 850;
    text-transform: uppercase;
  }

  .automation-review strong,
  .automation-simulation-result strong {
    color: var(--legacy-text);
    font-size: 12px;
    line-height: 1.4;
  }

  .automation-wizard-footer {
    align-items: center;
    background: var(--theme-paper);
    border-top: 1px solid var(--theme-border);
    bottom: 0;
    box-shadow: var(--theme-footer-shadow-strong);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    padding: 12px;
    position: sticky;
    z-index: 6;
  }

  .automation-delete-footer {
    margin-right: auto;
  }

  .installation-task-item.priority-urgente {
    box-shadow: var(--theme-inline-danger-marker);
  }

  .installation-task-item.priority-alta {
    box-shadow: var(--theme-inline-warning-marker);
  }

  .empty-table-result {
    text-align: center;
    color: var(--legacy-muted);
  }

  .delivered-installations-section {
    margin-top: 18px;
  }

  .delivered-section-title {
    align-items: center;
    background: var(--legacy-paper-soft);
    color: var(--legacy-muted);
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 11px;
  }

  .delivered-section-title strong {
    color: var(--legacy-muted);
    font-size: 10px;
    font-weight: 850;
    text-transform: none;
  }

  .delivered-installations-table {
    background: var(--legacy-paper-soft);
  }

  .delivered-installations-table th {
    background: var(--theme-paper-subtle);
    color: var(--legacy-muted);
  }

  .delivered-installations-table td {
    background: var(--legacy-paper-soft);
    color: var(--legacy-muted);
  }

  /* Form Modal */
  .modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--theme-overlay);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--space-4);
  }

  .modal {
    background: var(--legacy-paper);
    border-radius: var(--legacy-radius-md);
    width: 100%;
    max-width: 500px;
    max-height: calc(100dvh - 32px);
    box-shadow: var(--theme-shadow-md);
    border: 1px solid var(--legacy-border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .history-modal {
    max-width: 720px;
  }

  .modal-header {
    background: var(--legacy-primary);
    color: var(--legacy-primary-text);
    padding: 12px 16px;
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .close-btn {
    background: transparent;
    border: none;
    color: var(--legacy-primary-text);
    font-size: 16px;
    cursor: pointer;
    font-weight: 700;
    min-height: var(--touch-target);
    min-width: var(--touch-target);
  }

  .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 16px;
    overflow-y: auto;
  }

  .installation-modal-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 14px;
    width: 100%;
  }

  .installation-modal-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--legacy-border);
    border-radius: 6px;
    background: var(--legacy-paper);
    color: var(--legacy-muted);
    cursor: pointer;
    font-family: inherit;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    min-height: 38px;
    min-width: 0;
    padding: 0 12px;
    text-align: center;
    white-space: nowrap;
  }

  .installation-modal-tab.active {
    background: var(--legacy-primary);
    border-color: var(--legacy-text);
    color: var(--theme-primary-text);
  }

  .installation-tab-panel {
    display: none;
  }

  .installation-tab-panel.active {
    display: block;
  }

  .installation-modal-footer {
    background: var(--theme-paper);
    border-top: 1px solid var(--theme-border);
    bottom: -16px;
    box-shadow: var(--theme-footer-shadow);
    display: flex;
    justify-content: flex-end;
    margin: 12px -16px -16px;
    padding: 12px 16px;
    position: sticky;
    z-index: 5;
  }

  .task-compose {
    display: grid;
    gap: 8px;
    margin-bottom: 12px;
  }

  .notes-textarea {
    min-height: 82px;
    resize: vertical;
  }

  .installation-task-list {
    display: grid;
    gap: 8px;
  }

  .installation-task-item,
  .installation-empty-state {
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-md);
    background: var(--legacy-paper-soft);
    padding: 10px;
  }

  .installation-task-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
  }

  .installation-task-item.done {
    opacity: 0.72;
  }

  .installation-task-item.disabled {
    opacity: 0.72;
    background: var(--legacy-paper-soft);
  }

  .installation-task-item.overdue {
    border-color: color-mix(in srgb, var(--theme-danger) 34%, var(--legacy-border));
    background: var(--theme-danger-soft);
  }

  .installation-task-main {
    display: grid;
    gap: 3px;
    min-width: 0;
  }

  .installation-task-main strong {
    overflow-wrap: anywhere;
  }

  .installation-task-main span,
  .installation-empty-state {
    color: var(--legacy-muted);
    font-size: 10px;
    font-weight: 700;
  }

  .installation-task-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .automation-resolution-modal {
    width: min(100%, 560px);
  }

  .automation-resolution-body {
    display: grid;
    gap: 12px;
  }

  .automation-resolution-lead,
  .automation-resolution-note {
    margin: 0;
    color: var(--legacy-muted);
    font-size: 12px;
    line-height: 1.5;
  }

  .automation-resolution-task {
    padding: 10px 12px;
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-md);
    background: var(--legacy-paper-soft);
    color: var(--legacy-text);
    font-size: 12px;
    font-weight: 800;
  }

  .automation-resolution-select-all,
  .automation-resolution-option {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: start;
    gap: 10px;
    cursor: pointer;
  }

  .automation-resolution-select-all {
    padding: 10px 12px;
    border: 1px solid color-mix(in srgb, var(--theme-info) 34%, var(--legacy-border));
    border-radius: var(--legacy-radius-md);
    background: var(--theme-info-soft);
    color: var(--theme-info-text);
    font-size: 12px;
    font-weight: 900;
  }

  .automation-resolution-options {
    display: grid;
    gap: 8px;
  }

  .automation-resolution-option {
    padding: 12px;
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-md);
    background: var(--legacy-paper);
  }

  .automation-resolution-option span {
    display: grid;
    gap: 4px;
  }

  .automation-resolution-option strong {
    color: var(--legacy-text);
    font-size: 12px;
  }

  .automation-resolution-option em,
  .automation-resolution-option small {
    color: var(--legacy-muted);
    font-size: 11px;
    font-style: normal;
    line-height: 1.35;
  }

  .automation-resolution-actions {
    background: var(--theme-paper);
    border-top: 1px solid var(--theme-border);
    bottom: -16px;
    box-shadow: var(--theme-footer-shadow);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    margin: 4px -16px -16px;
    padding: 12px 16px;
    position: sticky;
    z-index: 5;
  }

  .activity-mini-btn {
    border: 1px solid var(--legacy-border);
    border-radius: 6px;
    background: var(--legacy-paper);
    color: var(--legacy-text);
    cursor: pointer;
    font-family: inherit;
    font-size: 9px;
    font-weight: 800;
    min-height: 30px;
    padding: 5px 8px;
  }

  .activity-mini-btn.danger {
    color: var(--theme-danger-text);
  }

  .settings-modal {
    max-width: 720px;
  }

  .settings-section {
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-md);
    padding: 12px;
    margin-bottom: 12px;
    background: var(--legacy-paper);
  }

  .settings-section:last-child {
    margin-bottom: 0;
  }

  .settings-section-title {
    color: var(--legacy-text);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .settings-section-title-spaced {
    margin-bottom: 12px;
  }

  .settings-actions,
  .settings-header-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
  }

  .settings-actions {
    margin-top: 10px;
  }

  .settings-header-row {
    justify-content: space-between;
    margin-bottom: 12px;
  }

  .settings-note {
    color: var(--legacy-muted);
    font-size: 10px;
    font-weight: 700;
    margin-top: 8px;
  }

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

  .history-item {
    border: 1px solid var(--legacy-border);
    border-radius: 6px;
    background: var(--legacy-paper-soft);
    padding: 10px 12px;
  }

  .history-item-title {
    color: var(--legacy-text);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .history-item-meta {
    color: var(--legacy-muted);
    font-size: 10px;
    font-weight: 700;
    margin-top: 2px;
  }

  .history-item-detail {
    color: var(--legacy-muted);
    font-size: 11px;
    margin-top: 6px;
  }

  .history-empty {
    border: 1px dashed var(--legacy-border);
    border-radius: var(--legacy-radius-md);
    color: var(--legacy-muted);
    font-weight: 700;
    padding: 18px;
    text-align: center;
  }

  .status-toggle {
    cursor: pointer;
    font: inherit;
    min-height: 28px;
    transition: filter 0.16s, transform 0.16s, box-shadow 0.16s;
  }

  .status-toggle:hover,
  .status-toggle:focus-visible {
    filter: brightness(0.96);
    outline: none;
    transform: translateY(-1px);
    box-shadow: var(--theme-shadow-sm);
  }

  .delivery-confirmation-meta {
    color: var(--theme-muted-soft);
    font-size: 10px;
    font-weight: 750;
    line-height: 1.25;
    margin-top: 5px;
  }

  .delivery-confirmation-modal {
    max-width: 420px;
  }

  .delivery-confirmation-body {
    display: grid;
    gap: 12px;
  }

  .delivery-confirmation-lead {
    color: var(--theme-muted);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.4;
    margin: 0;
  }

  .delivery-confirmation-summary {
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius-sm);
    background: var(--theme-paper-soft);
    color: var(--theme-text);
    font-size: 12px;
    font-weight: 750;
    line-height: 1.35;
    padding: 9px 10px;
  }

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

  .delivery-confirmation-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
  }

  .form-group {
    margin-bottom: 12px;
  }

  .form-group label {
    display: block;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--legacy-muted);
  }

  .form-control {
    width: 100%;
    min-height: var(--control-height);
    padding: 6px 8px;
    font-family: inherit;
    font-size: 11.5px;
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-sm);
    outline: none;
  }

  .form-control:focus {
    border-color: var(--legacy-text);
  }

  .service-textarea {
    resize: vertical;
    height: 60px;
  }

  .service-suggest-wrap {
    position: relative;
  }

  .service-suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
    z-index: 1200;
    max-height: 196px;
    overflow-y: auto;
    background: var(--legacy-paper);
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-md);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
    padding: 5px;
  }

  .service-suggestions[hidden] {
    display: none;
  }

  .service-suggestion-item {
    width: 100%;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--legacy-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2px;
    min-height: 44px;
    padding: 7px 8px;
    text-align: left;
  }

  .service-suggestion-item:hover,
  .service-suggestion-item:focus-visible,
  .service-suggestion-item.active {
    background: var(--theme-info-soft);
    outline: 0;
  }

  .service-suggestion-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
  }

  .service-suggestion-main {
    font-size: 12px;
    font-weight: 800;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .service-suggestion-meta,
  .service-suggestion-empty {
    color: var(--legacy-muted);
    font-size: 10px;
    font-weight: 700;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .service-suggestion-action {
    flex: 0 0 auto;
    margin-left: 8px;
    border: 1px solid var(--legacy-border);
    border-radius: 999px;
    color: var(--legacy-muted);
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
    padding: 5px 7px;
  }

  .service-suggestion-item:hover .service-suggestion-action,
  .service-suggestion-item:focus-visible .service-suggestion-action,
  .service-suggestion-item.active .service-suggestion-action {
    border-color: var(--legacy-text);
    color: var(--legacy-text);
  }

  .service-suggestion-empty {
    padding: 10px;
  }

  .field-hint {
    color: var(--legacy-muted);
    font-size: 10px;
    font-weight: 600;
    margin-top: 4px;
  }

  .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .btn-submit {
    width: 100%;
    min-height: var(--touch-target);
    padding: 8px;
    background: var(--legacy-primary);
    color: var(--legacy-primary-text);
    border: none;
    border-radius: var(--legacy-radius-sm);
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    transition: background 0.2s;
  }

  .btn-submit:hover {
    background: var(--legacy-primary-hover);
  }

  /* Calendar View */
  .calendar-toolbar {
    display: grid;
    grid-template-columns: auto minmax(180px, 1fr) auto;
    align-items: center;
    gap: 12px;
    background: var(--legacy-paper);
    border: 1px solid var(--legacy-border);
    border-radius: 8px 8px 0 0;
    padding: 10px 12px;
  }

  .calendar-toolbar-nav {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }

  .calendar-arrow-btn {
    width: 38px;
    height: 38px;
    border: 1px solid var(--legacy-border);
    border-radius: 6px;
    background: var(--legacy-paper-soft);
    color: var(--legacy-text);
    cursor: pointer;
    font-size: 22px;
    font-weight: 800;
    line-height: 1;
  }

  .calendar-arrow-btn:hover {
    background: var(--theme-paper-subtle);
  }

  .calendar-mode-switch {
    display: inline-flex;
    justify-self: end;
    overflow: hidden;
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-md);
    background: var(--legacy-paper-soft);
  }

  .calendar-mode-btn {
    min-height: 38px;
    border: 0;
    border-right: 1px solid var(--legacy-border);
    background: transparent;
    color: var(--legacy-muted);
    cursor: pointer;
    font: inherit;
    font-size: 10px;
    font-weight: 800;
    padding: 0 12px;
    text-transform: uppercase;
  }

  .calendar-mode-btn:last-child {
    border-right: 0;
  }

  .calendar-mode-btn.active {
    background: var(--legacy-primary);
    color: var(--theme-primary-text);
  }

  .calendar-title {
    font-weight: 800;
    font-size: 13px;
    text-transform: uppercase;
    text-align: center;
  }

  .calendar-grid {
    display: grid;
    background: var(--legacy-border);
    gap: 1px;
    border: 1px solid var(--legacy-border);
  }

  .calendar-month {
    grid-template-columns: repeat(7, 1fr);
  }

  .calendar-weekday {
    background: var(--legacy-paper-soft);
    padding: 8px;
    text-align: center;
    font-weight: 700;
    color: var(--legacy-muted);
  }

  .calendar-day {
    background: var(--legacy-paper);
    min-height: 132px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: background 0.15s, box-shadow 0.15s;
  }

  .calendar-day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
  }

  .day-count {
    min-width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--theme-radius-pill);
    background: var(--theme-paper-subtle);
    color: var(--legacy-muted);
    font-size: 9px;
    font-weight: 800;
  }

  .calendar-day.drag-over {
    background: var(--theme-info-soft);
    box-shadow: inset 0 0 0 2px var(--theme-info);
  }

  .calendar-day.other-month {
    background: var(--legacy-paper-soft);
    color: var(--theme-border-strong);
  }

  .day-number {
    font-weight: 700;
    font-size: 10px;
    margin-bottom: 4px;
  }

  .calendar-item {
    padding: 9px;
    border-radius: var(--legacy-radius-md);
    font-size: 9.5px;
    font-weight: 600;
    cursor: pointer;
    overflow: hidden;
    white-space: normal;
    border: 1px solid transparent;
    border-left-width: 4px;
    display: grid;
    gap: 7px;
    line-height: 1.25;
    user-select: none;
    box-shadow: var(--theme-shadow-sm);
  }

  .calendar-item.compact {
    padding: 6px 7px;
    gap: 4px;
    font-size: 8.8px;
  }

  .calendar-item.compact .calendar-card-sub {
    display: none;
  }

  .calendar-item.compact .calendar-card-main {
    gap: 1px;
  }

  .calendar-item.compact .calendar-card-compact-line {
    color: inherit;
    font-size: 8px;
    font-weight: 700;
    opacity: 0.78;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .calendar-item.compact .calendar-payment {
    display: none;
  }

  .calendar-more-btn {
    border: 1px dashed var(--theme-border-strong);
    border-radius: 6px;
    background: var(--legacy-paper-soft);
    color: var(--legacy-muted);
    cursor: pointer;
    font: inherit;
    font-size: 9px;
    font-weight: 800;
    padding: 4px;
  }

  .calendar-item.is-dragging {
    opacity: 0.58;
  }

  .calendar-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
  }

  .calendar-item-top > div {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-width: 0;
  }

  .calendar-item-time {
    border-radius: var(--theme-radius-pill);
    background: color-mix(in srgb, var(--legacy-paper) 62%, transparent);
    color: currentColor;
    font-size: 9px;
    font-weight: 900;
    padding: 2px 6px;
  }

  .calendar-item-status {
    background: transparent;
    border: 1px solid currentColor;
    border-radius: var(--theme-radius-pill);
    color: inherit;
    cursor: pointer;
    font-family: inherit;
    font-size: 7.5px;
    font-weight: 800;
    padding: 1px 4px;
    text-transform: uppercase;
  }

  .calendar-chip-action {
    transition: background 0.16s, transform 0.16s, box-shadow 0.16s;
  }

  .calendar-chip-action:hover,
  .calendar-chip-action:focus-visible {
    outline: none;
    transform: translateY(-1px);
    box-shadow: var(--theme-shadow-sm);
  }

  .calendar-item-client {
    color: var(--legacy-text);
    font-size: 10.5px;
    font-weight: 800;
    overflow-wrap: anywhere;
  }

  .calendar-card-main {
    display: grid;
    gap: 2px;
    min-width: 0;
  }

  .calendar-card-sub {
    color: inherit;
    font-size: 8.5px;
    font-weight: 800;
    opacity: 0.78;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
  }

  .calendar-payment {
    border: 0;
    border-radius: var(--theme-radius-pill);
    background: color-mix(in srgb, var(--legacy-paper) 55%, transparent);
    color: currentColor;
    cursor: pointer;
    font-family: inherit;
    font-size: 8px;
    font-weight: 800;
    padding: 2px 6px;
    white-space: nowrap;
  }

  .calendar-payment.paid {
    background: color-mix(in srgb, var(--theme-success) 18%, transparent);
  }

  .calendar-payment.pending {
    background: color-mix(in srgb, var(--theme-danger) 18%, transparent);
  }

  .calendar-payment.scheduled {
    background: color-mix(in srgb, var(--theme-info) 18%, transparent);
  }

  .calendar-payment.today {
    background: color-mix(in srgb, var(--theme-warning) 20%, transparent);
  }

  .calendar-payment.overdue {
    background: color-mix(in srgb, var(--theme-danger) 22%, transparent);
  }

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

  .calendar-card-field,
  .calendar-card-section {
    border-radius: 6px;
    background: color-mix(in srgb, var(--legacy-paper) 34%, transparent);
    display: grid;
    gap: 2px;
    min-width: 0;
    padding: 5px 6px;
    color: inherit;
    overflow-wrap: anywhere;
  }

  .calendar-card-field strong {
    color: inherit;
    font-size: 8.8px;
    font-weight: 850;
    min-width: 0;
    white-space: pre-wrap;
  }

  .calendar-info-label {
    color: inherit;
    font-size: 7.5px;
    font-weight: 900;
    letter-spacing: 0.2px;
    opacity: 0.68;
    text-transform: uppercase;
  }

  .calendar-card-service {
    color: inherit;
    display: -webkit-box;
    font-size: 9px;
    font-weight: 750;
    line-height: 1.28;
    overflow: hidden;
    white-space: pre-wrap;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
  }

  .chassi-section {
    background: color-mix(in srgb, var(--legacy-paper) 42%, transparent);
  }

  .calendar-item-chassi {
    color: inherit;
    overflow-wrap: anywhere;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 8.5px;
    letter-spacing: 0.2px;
    white-space: pre-wrap;
  }

  .calendar-item.green { background: var(--theme-success-soft); color: var(--theme-success-text); border-color: color-mix(in srgb, var(--theme-success) 34%, var(--legacy-border)); border-left-color: var(--theme-success); }
  .calendar-item.yellow { background: var(--theme-warning-soft); color: var(--theme-warning-text); border-color: color-mix(in srgb, var(--theme-warning) 34%, var(--legacy-border)); border-left-color: var(--theme-warning); }
  .calendar-item.red { background: var(--theme-danger-soft); color: var(--theme-danger-text); border-color: color-mix(in srgb, var(--theme-danger) 34%, var(--legacy-border)); border-left-color: var(--theme-danger); }
  .calendar-item.blue { background: var(--theme-info-soft); color: var(--theme-info-text); border-color: color-mix(in srgb, var(--theme-info) 34%, var(--legacy-border)); border-left-color: var(--theme-info); }
  .calendar-item.ready { background: color-mix(in srgb, var(--theme-warning-soft) 74%, var(--legacy-paper)); color: var(--theme-warning-text); border-color: color-mix(in srgb, var(--theme-warning) 28%, var(--legacy-border)); border-left-color: color-mix(in srgb, var(--theme-warning) 70%, var(--legacy-border)); }

  .calendar-week {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    align-items: stretch;
  }

  .week-day,
  .day-drop-zone {
    background: var(--legacy-paper);
    min-height: 420px;
    padding: 8px;
    transition: background 0.15s, box-shadow 0.15s;
  }

  .week-day.drag-over,
  .day-drop-zone.drag-over {
    background: var(--theme-info-soft);
    box-shadow: inset 0 0 0 2px var(--theme-info);
  }

  .week-day-header {
    display: grid;
    gap: 2px;
    border-bottom: 1px solid var(--theme-paper-subtle);
    margin-bottom: 8px;
    padding-bottom: 8px;
    text-align: center;
    text-transform: uppercase;
  }

  .week-day-header span:first-child {
    color: var(--legacy-muted);
    font-size: 9px;
    font-weight: 800;
  }

  .week-day-header strong {
    color: var(--legacy-text);
    font-size: 13px;
  }

  .week-day-header span:last-child {
    color: var(--legacy-muted);
    font-size: 9px;
    font-weight: 700;
    text-transform: none;
  }

  .week-day-list {
    display: grid;
    gap: 7px;
  }

  .calendar-empty-mini {
    border: 1px dashed var(--legacy-border);
    border-radius: var(--legacy-radius-md);
    color: var(--theme-border-strong);
    font-size: 10px;
    font-weight: 800;
    padding: 16px 8px;
    text-align: center;
  }

  .calendar-day-view {
    display: block;
    background: transparent;
    border: 1px solid var(--legacy-border);
  }

  .day-drop-zone {
    display: grid;
    gap: 10px;
    min-height: 360px;
    background: var(--legacy-paper);
  }

  .day-timeline-row {
    display: grid;
    grid-template-columns: 68px minmax(0, 1fr);
    align-items: start;
    gap: 10px;
  }

  .day-timeline-time {
    position: sticky;
    top: 8px;
    border-radius: var(--theme-radius-pill);
    background: var(--legacy-paper-soft);
    color: var(--legacy-text);
    font-size: 10px;
    font-weight: 900;
    padding: 7px 8px;
    text-align: center;
  }

  .day-empty {
    align-self: center;
    justify-self: center;
    display: grid;
    gap: 6px;
    border: 1px dashed var(--legacy-border);
    border-radius: 10px;
    color: var(--legacy-muted);
    padding: 26px;
    text-align: center;
  }

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

  .calendar-day-view .calendar-card-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .calendar-day-view .calendar-card-service {
    -webkit-line-clamp: 5;
  }

  .calendar-week .calendar-card-grid {
    grid-template-columns: 1fr;
  }

  .calendar-week .calendar-card-service {
    -webkit-line-clamp: 4;
  }

  .calendar-agenda {
    display: grid;
    gap: 10px;
    background: transparent;
    border: 0;
  }

  .agenda-day {
    background: var(--legacy-paper);
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-md);
    overflow: hidden;
  }

  .agenda-day-header {
    background: var(--legacy-paper-soft);
    color: var(--legacy-text);
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .agenda-item {
    border-top: 1px solid var(--theme-paper-subtle);
    cursor: pointer;
    padding: 10px 12px;
  }

  .agenda-item.green { border-left: 4px solid var(--theme-success); }
  .agenda-item.yellow { border-left: 4px solid var(--theme-warning); }
  .agenda-item.red { border-left: 4px solid var(--theme-danger); }
  .agenda-item.blue { border-left: 4px solid var(--theme-info); }

  .agenda-item-title {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    font-weight: 800;
  }

  .agenda-item-meta {
    color: var(--legacy-muted);
    font-size: 10px;
    margin-top: 4px;
  }

  .agenda-empty {
    background: var(--legacy-paper);
    border: 1px dashed var(--legacy-border);
    border-radius: var(--legacy-radius-md);
    color: var(--legacy-muted);
    font-weight: 700;
    padding: 18px;
    text-align: center;
  }

  /* Action buttons */
  .action-link {
    background: transparent;
    border: 0;
    color: var(--theme-info);
    font: inherit;
    text-decoration: none;
    font-weight: 700;
    margin-right: 8px;
    padding: 0;
    cursor: pointer;
  }

  .action-link.delete {
    color: var(--theme-danger);
  }

  .chassi-text {
    font-family: inherit;
    font-size: inherit;
    color: var(--legacy-text);
    font-weight: 800;
    text-transform: uppercase;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .service-cell {
    line-height: 1.35;
    white-space: pre-wrap;
    overflow-wrap: break-word;
  }

  .vehicle-cell {
    line-height: 1.35;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  .muted {
    color: var(--theme-border-strong);
  }

  .vin-feedback {
    margin-top: 5px;
    min-height: 14px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }

  .vin-feedback.valid {
    color: var(--theme-success-text);
  }

  .vin-feedback.invalid {
    color: var(--theme-danger-text);
  }

  .vin-feedback.warning {
    color: var(--theme-warning-text);
  }

  .form-control.invalid-field {
    border-color: var(--theme-danger);
    background: var(--theme-danger-soft);
  }

  .form-control.invalid-field:focus {
    border-color: var(--theme-danger-text);
    box-shadow: var(--theme-danger-ring);
  }

  @media (max-width: 900px) {
    :root {
      --page-gutter: 16px;
    }

    .control-bar {
      align-items: flex-start;
    }

    .nav-group {
      flex: 1 1 100%;
    }

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

    .filter-bar {
      grid-template-columns: 1fr 1fr;
    }

    .payment-dashboard {
      grid-template-columns: repeat(3, minmax(120px, 1fr));
    }

    .followup-filters,
    .automation-settings-grid {
      grid-template-columns: 1fr;
    }

    .followup-metrics,
    .automation-dashboard {
      grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .followup-row,
    .automation-layout,
    .automation-bottom,
    .automation-modal-shell,
    .automation-condition-row,
    .automation-action-row {
      grid-template-columns: 1fr;
    }

    .automation-modal-shell {
      grid-template-rows: auto minmax(0, 1fr);
    }

    .automation-action-row .span-2 {
      grid-column: auto;
    }

    .automation-modal-sidebar {
      border-right: 0;
      border-bottom: 1px solid var(--legacy-border);
      max-height: 300px;
    }

    .automation-stepper,
    .automation-trigger-grid,
    .automation-summary-list {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .followup-row-actions {
      justify-content: flex-start;
    }
  }

  @media (max-width: 640px) {
    :root {
      --page-gutter: 12px;
    }

    body {
      font-size: 13px;
      line-height: 1.45;
    }

    .control-bar,
    .filter-bar,
    .section-title,
    .calendar-toolbar {
      border-radius: var(--radius-3);
    }

    .control-bar {
      padding: var(--space-3);
    }

    .nav-group {
      gap: var(--space-2);
      width: 100%;
    }

    .nav-btn,
    .tab-btn {
      flex: 1 1 160px;
      white-space: normal;
    }

    .tab-btn.has-followup-alerts {
      gap: 5px;
    }

    .tab-btn.has-followup-alerts .followup-tab-alerts {
      justify-content: center;
      flex-wrap: wrap;
    }

    .view-selector {
      display: grid;
      grid-template-columns: 1fr;
      border-bottom: 0;
      gap: var(--space-2);
      padding-bottom: var(--space-2);
    }

    .tab-btn {
      background: var(--legacy-paper);
      border: 1px solid var(--legacy-border);
    }

    .followup-title-row {
      align-items: stretch;
      flex-direction: column;
    }

    .followup-title-row .nav-btn,
    .followup-modal-actions .nav-btn {
      width: 100%;
    }

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

    .filter-bar {
      grid-template-columns: 1fr;
      gap: var(--space-2);
      padding: var(--space-3);
    }

    .payment-dashboard {
      grid-template-columns: 1fr 1fr;
      gap: var(--space-2);
    }

    .followup-section-grid {
      grid-template-columns: 1fr;
      padding: var(--space-2);
    }

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

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

    .modal.automation-modal {
      max-width: calc(100vw - 20px);
      width: calc(100vw - 20px);
    }

    .automation-modal-shell {
      height: 100%;
      max-height: 100%;
      min-height: 0;
    }

    .automation-stepper,
    .automation-trigger-grid,
    .automation-summary-list,
    .automation-mode-row,
    .automation-group-head {
      grid-template-columns: 1fr;
    }

    .automation-wizard-footer {
      display: grid;
      grid-template-columns: 1fr;
    }

    .automation-wizard-footer .nav-btn,
    .automation-summary-panel .nav-btn {
      width: 100%;
    }

    .automation-summary-panel {
      align-items: stretch;
      flex-direction: column;
    }

    .followup-card {
      padding: var(--space-3);
    }

    .followup-card-head {
      flex-direction: column;
    }

    .followup-card-actions .activity-mini-btn {
      flex: 1 1 120px;
    }

    .payment-summary-card {
      min-height: 52px;
      padding: 9px 10px;
    }

    .filter-meta {
      order: 10;
      white-space: normal;
    }

    .section-title {
      margin-bottom: var(--space-2);
      padding: var(--space-3);
      line-height: 1.2;
    }

    table,
    thead,
    tbody,
    tr,
    td {
      display: block;
      width: 100%;
    }

    thead {
      display: none;
    }

    th {
      cursor: default;
    }

    table {
      background: transparent;
      border-collapse: separate;
      box-shadow: none;
      min-width: 0 !important;
      table-layout: auto;
      width: 100%;
    }

    colgroup,
    .column-resize-handle {
      display: none !important;
    }

    tbody {
      display: grid;
      gap: var(--space-2);
    }

    tr {
      background: var(--legacy-paper);
      border: 1px solid var(--legacy-border);
      border-radius: var(--radius-3);
      box-shadow: var(--theme-shadow-sm);
      display: flex;
      flex-direction: column;
      padding: var(--space-3);
    }

    td {
      border: 0;
      border-bottom: 1px solid var(--theme-paper-subtle);
      display: grid;
      grid-template-columns: minmax(102px, 0.38fr) minmax(0, 1fr);
      gap: var(--space-2);
      padding: var(--space-2) 0;
      text-align: left;
    }

    td:last-child {
      border-bottom: 0;
      padding-bottom: 0;
    }

    td::before {
      content: attr(data-label);
      color: var(--legacy-muted);
      font-size: 10px;
      font-weight: 800;
      letter-spacing: 0.3px;
      line-height: 1.2;
      text-transform: uppercase;
    }

    .action-link {
      display: inline-flex;
      min-height: var(--touch-target);
      align-items: center;
      justify-content: center;
      margin-right: var(--space-3);
    }

    .installations-table td[data-label="Ações"] {
      display: flex;
      flex-wrap: wrap;
      gap: var(--space-2);
      order: -1;
    }

    .installations-table td[data-label="Ações"]::before {
      flex: 1 0 100%;
    }

    .installations-table td[data-label="Ações"] .action-link {
      flex: 1 1 120px;
      margin-right: 0;
    }

    .chassi-text {
      overflow-wrap: anywhere;
      white-space: normal;
    }

    .service-cell {
      max-width: none;
      white-space: pre-wrap;
    }

    .calendar-toolbar {
      grid-template-columns: 1fr;
      gap: var(--space-2);
      padding: var(--space-3);
    }

    .calendar-toolbar-nav,
    .calendar-mode-switch {
      justify-self: stretch;
      width: 100%;
    }

    .calendar-toolbar-nav {
      display: grid;
      grid-template-columns: 1fr 44px 44px;
    }

    .calendar-mode-btn {
      flex: 1;
    }

    .calendar-title {
      order: -1;
      text-align: center;
    }

    .calendar-agenda {
      display: grid;
    }

    .calendar-item {
      gap: 8px;
      padding: 10px;
    }

    .calendar-item-top {
      align-items: flex-start;
      flex-direction: column;
    }

    .calendar-payment {
      white-space: normal;
    }

    .calendar-card-grid,
    .calendar-day-view .calendar-card-grid,
    .calendar-week .calendar-card-grid {
      grid-template-columns: 1fr;
    }

    .calendar-card-service {
      -webkit-line-clamp: 6;
    }

    .calendar-item-chassi {
      word-break: break-all;
    }

    .day-timeline-row {
      grid-template-columns: 1fr;
      gap: 6px;
    }

    .day-timeline-time {
      position: static;
      justify-self: start;
    }

    .modal-backdrop {
      align-items: stretch;
      justify-content: stretch;
      padding: 0;
    }

    .modal {
      border: 0;
      border-radius: 0;
      height: 100dvh;
      max-height: 100dvh;
      max-width: none;
    }

    .modal-body {
      flex: 1;
      padding: var(--space-4);
    }

    #installation-form {
      min-height: 100%;
    }

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

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

    .installation-task-item {
      grid-template-columns: 1fr;
      align-items: stretch;
    }

    .installation-task-actions {
      justify-content: flex-start;
    }

    .btn-submit {
      bottom: 0;
      position: sticky;
    }
  }

  @media (max-width: 420px) {
    .nav-btn,
    .tab-btn {
      flex-basis: 100%;
    }

    td {
      grid-template-columns: 1fr;
      gap: var(--space-1);
    }
  }

  @media print {
    .no-print,
    .modal-backdrop,
    .column-resize-handle {
      display: none !important;
    }

    th {
      cursor: default;
    }
  }

  [data-context][hidden],
  #sales-workspace[hidden] {
    display: none !important;
  }

  .module-selector {
    margin-bottom: 10px;
  }

  .module-selector + .view-selector {
    margin-top: 0;
  }

  .sales-filter-bar {
    grid-template-columns: minmax(220px, 1fr) 190px auto auto;
  }

  .kanban-board {
    display: grid;
    grid-template-columns: repeat(3, minmax(230px, 1fr));
    gap: 12px;
    align-items: start;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .sales-kanban-board {
    grid-template-columns: repeat(5, minmax(230px, 1fr));
  }

  .sales-kanban-board .kanban-column[data-sale-stage="won"] {
    background: color-mix(in srgb, var(--theme-success-soft) 78%, var(--legacy-paper));
    border-color: color-mix(in srgb, var(--theme-success) 42%, var(--legacy-border));
  }

  .sales-kanban-board .kanban-column[data-sale-stage="lost"] {
    background: color-mix(in srgb, var(--theme-danger-soft) 78%, var(--legacy-paper));
    border-color: color-mix(in srgb, var(--theme-danger) 42%, var(--legacy-border));
  }

  .sales-kanban-board .kanban-column[data-sale-stage="won"] > header,
  .sales-kanban-board .kanban-column[data-sale-stage="lost"] > header {
    border-bottom-color: currentColor;
  }

  .sales-kanban-board .kanban-column[data-sale-stage="won"] > header {
    background: color-mix(in srgb, var(--theme-success) 12%, var(--legacy-paper));
    color: var(--theme-success-text);
  }

  .sales-kanban-board .kanban-column[data-sale-stage="lost"] > header {
    background: color-mix(in srgb, var(--theme-danger) 12%, var(--legacy-paper));
    color: var(--theme-danger-text);
  }

  .sales-kanban-board .kanban-column[data-sale-stage="won"] > header span::before,
  .sales-kanban-board .kanban-column[data-sale-stage="lost"] > header span::before {
    background: currentColor;
    border-radius: 50%;
    content: '';
    display: inline-block;
    height: 7px;
    margin-right: 6px;
    vertical-align: 1px;
    width: 7px;
  }

  .sales-kanban-board .kanban-column[data-sale-stage="won"] > header strong {
    background: var(--theme-success);
    border-color: var(--theme-success);
    color: var(--theme-on-dark, #fff);
  }

  .sales-kanban-board .kanban-column[data-sale-stage="lost"] > header strong {
    background: var(--theme-danger);
    border-color: var(--theme-danger);
    color: var(--theme-on-dark, #fff);
  }

  .sales-kanban-board .kanban-column[data-sale-stage="won"] .kanban-card {
    border-color: color-mix(in srgb, var(--theme-success) 35%, var(--legacy-border));
    border-left: 4px solid var(--theme-success);
  }

  .sales-kanban-board .kanban-column[data-sale-stage="lost"] .kanban-card {
    border-color: color-mix(in srgb, var(--theme-danger) 35%, var(--legacy-border));
    border-left: 4px solid var(--theme-danger);
  }

  .sales-kanban-board .kanban-column[data-sale-stage="won"] .kanban-card:hover,
  .sales-kanban-board .kanban-column[data-sale-stage="lost"] .kanban-card:hover {
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.14);
    transform: translateY(-2px);
  }

  .kanban-column {
    min-height: 180px;
    background: var(--legacy-paper-soft);
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-md);
    box-shadow: var(--theme-shadow-sm);
    transition: border-color var(--theme-transition), background var(--theme-transition);
  }

  .kanban-column.is-drop-target {
    background: color-mix(in srgb, var(--legacy-primary) 8%, var(--legacy-paper-soft));
    border-color: var(--legacy-primary);
  }

  .kanban-column > header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--legacy-border);
    color: var(--legacy-text);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .kanban-column > header strong {
    align-items: center;
    background: var(--legacy-paper);
    border: 1px solid var(--legacy-border);
    border-radius: var(--theme-radius-pill);
    display: inline-flex;
    font-size: 10px;
    justify-content: center;
    min-height: 22px;
    min-width: 22px;
    padding: 0 6px;
  }

  .kanban-column-content {
    display: grid;
    gap: 8px;
    min-height: 128px;
    padding: 10px;
  }

  .kanban-card {
    background: var(--legacy-paper);
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-sm);
    box-shadow: var(--theme-shadow-sm);
    cursor: grab;
    display: grid;
    gap: 6px;
    padding: 10px;
  }

  .installations-kanban-board .kanban-card {
    cursor: default;
  }

  .kanban-card.is-dragging {
    cursor: grabbing;
    opacity: 0.54;
  }

  .kanban-card-title {
    background: transparent;
    border: 0;
    color: var(--legacy-text);
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    padding: 0;
    text-align: left;
  }

  .kanban-card p,
  .kanban-empty {
    color: var(--legacy-muted);
    font-size: 11px;
    line-height: 1.4;
    margin: 0;
  }

  .kanban-empty {
    padding: 4px;
  }

  .kanban-card-action {
    align-items: center;
    background: var(--legacy-paper-soft);
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-sm);
    color: var(--legacy-text);
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-size: 10px;
    font-weight: 800;
    justify-content: center;
    min-height: 30px;
    padding: 4px 8px;
  }

  .kanban-card-action:hover {
    background: var(--legacy-primary);
    color: var(--legacy-primary-text);
  }

  .sales-actions,
  .sales-card-actions {
    align-items: center;
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .sales-actions {
    white-space: nowrap;
  }

  .sales-kanban-card-head {
    align-items: flex-start;
    display: flex;
    gap: 8px;
    justify-content: space-between;
  }

  .sales-kanban-card-head .kanban-card-title {
    flex: 1;
    min-width: 0;
  }

  .sales-card-actions {
    flex-wrap: nowrap;
  }

  .sales-action-icon {
    align-items: center;
    background: var(--legacy-paper-soft);
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-sm);
    color: var(--legacy-muted);
    cursor: pointer;
    display: inline-flex;
    flex: 0 0 30px;
    height: 30px;
    justify-content: center;
    padding: 0;
    transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
    width: 30px;
  }

  .sales-action-icon svg {
    fill: none;
    height: 15px;
    pointer-events: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
    width: 15px;
  }

  .sales-action-icon:hover {
    transform: translateY(-1px);
  }

  .sales-action-icon:focus-visible {
    outline: 2px solid var(--legacy-primary);
    outline-offset: 2px;
  }

  .sales-action-icon--edit,
  .sales-action-icon--open {
    color: var(--theme-info);
  }

  .sales-action-icon--edit:hover,
  .sales-action-icon--open:hover {
    background: var(--theme-info-soft);
    border-color: var(--theme-info);
  }

  .sales-action-icon--schedule {
    color: var(--theme-success);
  }

  .sales-action-icon--schedule:hover {
    background: var(--theme-success-soft);
    border-color: var(--theme-success);
  }

  .sales-action-icon--delete {
    color: var(--theme-danger);
  }

  .sales-action-icon--delete:hover {
    background: var(--theme-danger-soft);
    border-color: var(--theme-danger);
  }

  #modal-backdrop[data-entity-mode="installation"] [data-sales-only],
  #modal-backdrop[data-entity-mode="sale"] [data-installation-only] {
    display: none !important;
  }

  #modal-backdrop[data-entity-mode="sale"] .installation-section-attendance {
    grid-column: 1 / -1;
  }

  .sales-message-panel {
    gap: 14px;
  }

  .sales-message-panel.active {
    display: grid;
  }

  #modal-backdrop .sales-message-section {
    align-content: start;
    display: grid;
    gap: 10px;
    grid-column: span 7;
    min-width: 0;
  }

  #modal-backdrop .sales-message-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(12, minmax(0, 1fr));
  }

  #modal-backdrop .sales-message-preview-field {
    grid-column: 1 / -1;
  }

  .sales-message-header {
    display: grid;
    gap: 4px;
  }

  .sales-message-header p,
  .sales-message-hint,
  .sales-message-status {
    color: var(--legacy-muted);
    font-size: 11px;
    line-height: 1.45;
    margin: 0;
  }

  .sales-message-hint {
    margin-top: 6px;
  }

  .sales-whatsapp-message {
    line-height: 1.5;
    min-height: 148px;
    max-height: 320px;
    overflow-y: auto;
    resize: vertical;
    white-space: pre-wrap;
  }

  #modal-backdrop .sales-whatsapp-message {
    min-height: 148px;
    max-height: 320px;
    line-height: 1.55;
  }

  .sales-message-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
  }

  .sales-message-actions .btn-submit,
  .sales-message-actions .nav-btn {
    min-height: 38px;
  }

  .sales-message-status[data-state="error"] {
    color: var(--legacy-danger, #b42318);
    font-weight: 700;
  }

  .sales-message-status[data-state="success"] {
    color: var(--legacy-success, #18794e);
    font-weight: 700;
  }

  .sales-reference-prompt {
    align-items: flex-start;
    background: color-mix(in srgb, var(--legacy-primary) 8%, transparent);
    border-left: 3px solid var(--legacy-primary);
    border-radius: 6px;
    color: var(--legacy-muted);
    display: grid;
    font-size: 11px;
    gap: 7px;
    line-height: 1.4;
    margin-top: 7px;
    padding: 8px 9px;
  }

  .sales-reference-prompt[hidden] {
    display: none;
  }

  .sales-reference-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }

  .sales-reference-actions .action-link.muted {
    color: var(--legacy-muted);
  }

  #modal-backdrop {
    padding: 16px;
  }

  #modal-backdrop .installation-modal {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    width: min(1120px, calc(100vw - 32px)) !important;
    max-width: min(1120px, calc(100vw - 32px)) !important;
    max-height: calc(100dvh - 32px);
  }

  #modal-backdrop .installation-modal .modal-body {
    max-height: none;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 18px;
  }

  #modal-backdrop .installation-modal form,
  #modal-backdrop .installation-tab-panel,
  #modal-backdrop .installation-form-grid,
  #modal-backdrop .installation-form-section,
  #modal-backdrop .installation-section-grid,
  #modal-backdrop .installation-modal .form-group {
    min-width: 0;
  }

  #modal-backdrop .installation-form-grid {
    gap: 12px;
  }

  #modal-backdrop .installation-form-section {
    gap: 10px;
    padding: 14px;
    overflow: visible;
  }

  #modal-backdrop .installation-section-title {
    font-size: 12px;
  }

  #modal-backdrop .installation-section-grid {
    align-items: start;
    gap: 12px;
  }

  #modal-backdrop .purchase-entry-grid {
    grid-template-columns: minmax(220px, 420px);
  }

  #modal-backdrop .common-attendance-grid,
  #modal-backdrop .installation-section-vehicle .installation-section-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
  }

  #modal-backdrop .attendance-vendor,
  #modal-backdrop .attendance-store,
  #modal-backdrop .attendance-client,
  #modal-backdrop .sales-sale-stage,
  #modal-backdrop .installation-os-group {
    grid-column: span 3;
  }

  #modal-backdrop .attendance-phones {
    grid-column: 1 / -1;
  }

  #modal-backdrop[data-entity-mode="sale"] .attendance-phones {
    grid-column: span 5;
  }

  #modal-backdrop[data-entity-mode] .installation-section-vehicle .sales-chassis-group,
  #modal-backdrop[data-entity-mode] .installation-section-vehicle .sales-vehicle-model,
  #modal-backdrop[data-entity-mode] .installation-section-vehicle .sales-vehicle-version,
  #modal-backdrop[data-entity-mode] .installation-section-vehicle .vehicle-year-group {
    grid-column: span 3;
  }

  #modal-backdrop .installation-modal .vin-form-group {
    min-width: 0;
  }

  #modal-backdrop .installation-modal .vin-field-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  #modal-backdrop .installation-modal-footer {
    position: sticky;
    z-index: 15;
    bottom: -18px;
    margin: 2px -18px -18px;
    padding: 12px 18px;
    border-top: 1px solid var(--legacy-border);
    background: color-mix(in srgb, var(--legacy-paper) 96%, transparent);
    box-shadow: 0 -8px 18px rgba(15, 23, 42, 0.06);
  }

  #modal-backdrop .installation-modal-footer .btn-submit {
    width: auto;
    min-width: 190px;
  }

  .sales-reference-combobox {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 38px;
    position: relative;
  }

  .sales-reference-combobox .form-control {
    border-bottom-right-radius: 0;
    border-right: 0;
    border-top-right-radius: 0;
    min-width: 0;
  }

  .sales-reference-toggle {
    align-items: center;
    background: var(--legacy-paper-soft);
    border: 1px solid var(--legacy-border);
    border-bottom-right-radius: var(--legacy-radius-sm);
    border-top-right-radius: var(--legacy-radius-sm);
    color: var(--legacy-text);
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    justify-content: center;
    line-height: 1;
    padding: 0;
  }

  .sales-reference-toggle svg {
    fill: none;
    height: 18px;
    pointer-events: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2.25;
    width: 18px;
  }

  .sales-reference-combobox:focus-within {
    z-index: 20;
  }

  .sales-reference-combobox:focus-within .form-control,
  .sales-reference-combobox:focus-within .sales-reference-toggle {
    border-color: var(--legacy-text);
  }

  .sales-reference-toggle:hover,
  .sales-reference-toggle:focus-visible {
    background: var(--theme-info-soft);
    outline: 0;
  }

  .sales-reference-options {
    background: var(--legacy-paper);
    border: 1px solid var(--legacy-border);
    border-radius: var(--legacy-radius-sm);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.16);
    display: grid;
    gap: 2px;
    left: 0;
    max-height: 220px;
    overflow-y: auto;
    padding: 5px;
    position: absolute;
    right: 0;
    top: calc(100% + 5px);
    z-index: 50;
  }

  .sales-reference-options[data-placement="top"] {
    top: auto;
    bottom: calc(100% + 5px);
  }

  .sales-reference-options[hidden] {
    display: none;
  }

  .sales-reference-option {
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: var(--legacy-text);
    cursor: pointer;
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    min-height: 36px;
    padding: 7px 8px;
    text-align: left;
    width: 100%;
  }

  .sales-reference-option:hover,
  .sales-reference-option:focus-visible {
    background: var(--theme-info-soft);
    outline: 0;
  }

  .sales-reference-options-empty {
    color: var(--legacy-muted);
    font-size: 11px;
    margin: 0;
    padding: 8px;
  }

  .sales-phone-group {
    align-content: start;
  }

  .sales-phone-control {
    align-items: start;
    display: grid;
    gap: 8px;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .sales-phone-list {
    display: grid;
    gap: 7px;
  }

  .sales-phone-row {
    align-items: center;
    display: grid;
    gap: 8px;
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .sales-phone-row input[type="radio"] {
    accent-color: var(--legacy-primary);
    height: 16px;
    margin: 0;
    width: 16px;
  }

  .sales-phone-empty,
  .sales-phone-feedback {
    color: var(--legacy-muted);
    font-size: 11px;
    line-height: 1.4;
    margin: 0;
  }

  .sales-phone-feedback {
    margin-top: 4px;
  }

  .sales-phone-list.is-invalid .sales-phone-row .form-control,
  .sales-phone-list.is-invalid {
    border-color: var(--legacy-danger, #b42318);
  }

  .sales-phone-add {
    margin-top: 0;
    min-height: 34px;
    width: fit-content;
  }

  #modal-backdrop[data-entity-mode="sale"] .form-control.is-invalid {
    border-color: var(--legacy-danger, #b42318);
  }

  @media (max-width: 900px) {
    #modal-backdrop .common-attendance-grid,
    #modal-backdrop .installation-section-vehicle .installation-section-grid {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #modal-backdrop .installation-section-attendance .form-group,
    #modal-backdrop .installation-section-vehicle .form-group {
      grid-column: auto;
    }

    #modal-backdrop .attendance-phones,
    #modal-backdrop .sales-message-section,
    #modal-backdrop .sales-vehicle-version {
      grid-column: 1 / -1;
    }

    #modal-backdrop .sales-message-preview-field {
      grid-column: 1 / -1;
    }

  }

  @media (max-width: 760px) {
    .kanban-board,
    .sales-kanban-board {
      grid-template-columns: repeat(3, minmax(220px, 1fr));
    }

    .sales-message-actions {
      align-items: stretch;
      flex-direction: column;
    }

    .sales-message-actions .btn-submit,
    .sales-message-actions .nav-btn {
      width: 100%;
    }

    #modal-backdrop .sales-whatsapp-message {
      max-height: 260px;
    }

    .sales-phone-row {
      align-items: stretch;
      grid-template-columns: auto minmax(0, 1fr);
    }

    .sales-phone-row .action-link {
      grid-column: 2;
      justify-self: start;
    }

    .sales-phone-add {
      width: 100%;
    }

    .sales-phone-control {
      grid-template-columns: 1fr;
    }

    #modal-backdrop .common-attendance-grid,
    #modal-backdrop .installation-section-vehicle .installation-section-grid {
      grid-template-columns: 1fr;
    }

    #modal-backdrop .installation-section-attendance .form-group,
    #modal-backdrop .installation-section-vehicle .form-group {
      grid-column: 1;
    }

    #modal-backdrop {
      padding: 8px;
    }

    #modal-backdrop .installation-modal {
      width: calc(100vw - 16px) !important;
      max-width: calc(100vw - 16px) !important;
      max-height: calc(100dvh - 16px);
      border-radius: 12px;
    }

    #modal-backdrop .installation-modal .modal-body {
      padding: 12px;
    }

    #modal-backdrop .installation-modal-footer {
      bottom: -12px;
      margin: 2px -12px -12px;
      padding: 10px 12px;
    }

    #modal-backdrop .installation-modal-footer .btn-submit {
      width: 100%;
    }

  }




