/**
 * Operations Center MAIN PAGE modernization — Phase 5A.1
 * Scoped under .operations-center-page.operations-center-main-modern only.
 * Drawers/modals are siblings outside this root — do not style them here.
 * No !important.
 */

.operations-center-page.operations-center-main-modern {
  --ops-gap: 12px;
  --ops-radius: 8px;
  --ops-control: 36px;
  --ops-touch: 44px;
  --ops-ink: var(--ds-color-ink, var(--ink, #24262d));
  --ops-muted: var(--ds-color-muted, var(--muted, #6b7280));
  --ops-line: var(--ds-color-line, var(--line, #e5e7eb));
  --ops-surface: #fff;
  --ops-surface-quiet: #f8f9fa;
  --ops-accent: var(--accent, #0f766e);
  --ops-warn: var(--amber, #b45309);
  --ops-danger: var(--red, #b42318);
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.operations-center-page.operations-center-main-modern *,
.operations-center-page.operations-center-main-modern *::before,
.operations-center-page.operations-center-main-modern *::after {
  box-sizing: border-box;
}

/* —— Header —— */
.operations-center-page.operations-center-main-modern .operations-center-header {
  margin: 0;
}

.operations-center-page.operations-center-main-modern .operations-center-header__eyebrow {
  margin: 0 0 4px;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ops-muted);
}

.operations-center-page.operations-center-main-modern .operations-center-header__title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--ops-ink);
  line-height: 1.25;
}

.operations-center-page.operations-center-main-modern .operations-center-lead {
  margin: 4px 0 0;
  max-width: 42rem;
  font-size: 0.875rem;
  line-height: 1.4;
}

.operations-center-page.operations-center-main-modern .operations-center-api-note {
  margin: 8px 0 0;
  font-size: 0.8125rem;
}

/* —— KPI strip —— */
.operations-center-page.operations-center-main-modern .operations-center-kpis {
  min-width: 0;
}

.operations-center-page.operations-center-main-modern .operations-center-kpi-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.operations-center-page.operations-center-main-modern .operations-center-kpi {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--ops-line);
  border-radius: 6px;
  background: var(--ops-surface);
  box-shadow: none;
  min-width: 0;
}

.operations-center-page.operations-center-main-modern .operations-center-kpi strong {
  display: block;
  font-size: 1.15rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--ops-ink);
  line-height: 1.2;
}

.operations-center-page.operations-center-main-modern .operations-center-kpi span {
  display: block;
  margin-top: 4px;
  font-size: 0.6875rem;
  line-height: 1.3;
  color: var(--ops-muted);
  overflow-wrap: break-word;
  word-break: normal;
}

.operations-center-page.operations-center-main-modern .operations-center-kpi--risk {
  border-color: color-mix(in srgb, var(--ops-warn) 35%, var(--ops-line));
  background: color-mix(in srgb, var(--ops-warn) 6%, var(--ops-surface));
}

.operations-center-page.operations-center-main-modern .operations-center-kpi--risk strong {
  color: var(--ops-warn);
}

/* —— Panels —— */
.operations-center-page.operations-center-main-modern .operations-center-layout {
  gap: var(--ops-gap);
  min-width: 0;
}

.operations-center-page.operations-center-main-modern .operations-center-recent-panel,
.operations-center-page.operations-center-main-modern .operations-center-workorders-panel {
  margin: 0 0 var(--ops-gap);
  border: 1px solid var(--ops-line);
  border-radius: var(--ops-radius);
  background: var(--ops-surface);
  box-shadow: none;
  min-width: 0;
}

.operations-center-page.operations-center-main-modern .operations-center-recent-panel .panel-heading,
.operations-center-page.operations-center-main-modern .operations-center-workorders-panel .panel-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--ops-line);
}

.operations-center-page.operations-center-main-modern .operations-center-recent-panel .panel-heading h2,
.operations-center-page.operations-center-main-modern .operations-center-workorders-panel .panel-heading h2 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

.operations-center-page.operations-center-main-modern .operations-center-list-count {
  font-size: 0.8125rem;
  font-weight: 500;
}

.operations-center-page.operations-center-main-modern .operations-workorders-section-head__actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.operations-center-page.operations-center-main-modern .operations-workorders-section-head__actions .btn {
  min-height: var(--ops-control);
}

/* —— Filters —— */
.operations-center-page.operations-center-main-modern #operationsCenterFilters {
  padding: 10px 12px;
  border-bottom: 1px solid var(--ops-line);
}

.operations-center-page.operations-center-main-modern .operations-center-filters {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(9rem, 0.7fr));
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.operations-center-page.operations-center-main-modern .operations-center-filter-input,
.operations-center-page.operations-center-main-modern .operations-center-filter-select {
  width: 100%;
  min-width: 0;
  min-height: var(--ops-control);
  border: 1px solid var(--ops-line);
  border-radius: 6px;
  background: var(--ops-surface);
  color: var(--ops-ink);
  font-size: 0.875rem;
  padding: 0 10px;
  box-shadow: none;
}

.operations-center-page.operations-center-main-modern .operations-center-filter-input:focus,
.operations-center-page.operations-center-main-modern .operations-center-filter-select:focus {
  outline: 2px solid color-mix(in srgb, var(--ops-accent) 35%, transparent);
  outline-offset: 1px;
}

/* —— Operation cards —— */
.operations-center-page.operations-center-main-modern #operationsCenterTable {
  padding: 10px 12px 12px;
  min-width: 0;
}

.operations-center-page.operations-center-main-modern .operations-center-cards {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.operations-center-page.operations-center-main-modern .operations-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 14px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--ops-line);
  border-radius: 6px;
  background: var(--ops-surface);
  box-shadow: none;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.operations-center-page.operations-center-main-modern .operations-card:hover {
  border-color: color-mix(in srgb, var(--ops-ink) 18%, var(--ops-line));
  background: var(--ops-surface);
}

.operations-center-page.operations-center-main-modern .operations-card.is-selected {
  border-color: color-mix(in srgb, var(--ops-accent) 45%, var(--ops-line));
  background: color-mix(in srgb, var(--ops-accent) 5%, var(--ops-surface));
  box-shadow: none;
}

.operations-center-page.operations-center-main-modern .operations-card__main {
  min-width: 0;
  gap: 6px;
}

.operations-center-page.operations-center-main-modern .operations-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
}

.operations-center-page.operations-center-main-modern .operations-card__no {
  font-size: 0.8125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ops-muted);
}

.operations-center-page.operations-center-main-modern .operations-card__date {
  font-size: 0.75rem;
}

.operations-center-page.operations-center-main-modern .operations-card__customer {
  margin: 0;
  font-size: 0.975rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--ops-ink);
  overflow-wrap: break-word;
  word-break: normal;
}

.operations-center-page.operations-center-main-modern .operations-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.operations-center-page.operations-center-main-modern .operations-card__owner {
  margin: 0;
  font-size: 0.8125rem;
  overflow-wrap: break-word;
  word-break: normal;
}

.operations-center-page.operations-center-main-modern .operations-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 550;
  line-height: 1.2;
  white-space: normal;
  overflow-wrap: anywhere;
}

.operations-center-page.operations-center-main-modern .operations-badge--stage {
  background: color-mix(in srgb, var(--ops-accent) 12%, transparent);
  color: color-mix(in srgb, var(--ops-accent) 85%, var(--ops-ink));
}

.operations-center-page.operations-center-main-modern .operations-badge--muted {
  background: var(--ops-surface-quiet);
  color: var(--ops-muted);
  border: 1px solid var(--ops-line);
}

.operations-center-page.operations-center-main-modern .operations-badge--warn {
  background: color-mix(in srgb, var(--ops-warn) 12%, transparent);
  color: var(--ops-warn);
}

.operations-center-page.operations-center-main-modern .operations-badge--danger {
  background: color-mix(in srgb, var(--ops-danger) 12%, transparent);
  color: var(--ops-danger);
}

.operations-center-page.operations-center-main-modern .operations-card__actions {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
  min-width: 0;
  max-width: 100%;
}

.operations-center-page.operations-center-main-modern .operations-card__actions .btn,
.operations-center-page.operations-center-main-modern .operations-card__action--primary,
.operations-center-page.operations-center-main-modern .operations-card__action--secondary {
  max-width: 100%;
}

.operations-center-page.operations-center-main-modern .operations-card__action--primary {
  min-height: var(--ops-control);
}

.operations-center-page.operations-center-main-modern .operations-card__action--secondary {
  min-height: var(--ops-control);
  color: var(--ops-muted);
  border-color: var(--ops-line);
  background: transparent;
  font-weight: 500;
}

.operations-center-page.operations-center-main-modern .operations-card__action--secondary:hover {
  color: var(--ops-ink);
  border-color: color-mix(in srgb, var(--ops-ink) 20%, var(--ops-line));
}

.operations-center-page.operations-center-main-modern .operations-center-empty {
  margin: 4px;
  padding: 18px 14px;
  border: 1px dashed var(--ops-line);
  border-radius: 6px;
  text-align: center;
  font-size: 0.875rem;
  color: var(--ops-muted);
}

/* —— Work orders main —— */
.operations-center-page.operations-center-main-modern #operationsCenterAllWorkOrders {
  padding: 10px 12px 12px;
  min-width: 0;
}

.operations-center-page.operations-center-main-modern .operations-wo-main {
  min-width: 0;
}

.operations-center-page.operations-center-main-modern .operations-wo-main__cards {
  display: none;
}

.operations-center-page.operations-center-main-modern .operations-center-table-wrap {
  overflow-x: auto;
  max-width: 100%;
  border: 1px solid var(--ops-line);
  border-radius: 6px;
}

.operations-center-page.operations-center-main-modern .operations-wo-main__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.operations-center-page.operations-center-main-modern .operations-wo-main__table th {
  text-align: left;
  font-weight: 600;
  color: var(--ops-muted);
  background: var(--ops-surface-quiet);
  padding: 8px 10px;
  border-bottom: 1px solid var(--ops-line);
  white-space: nowrap;
}

.operations-center-page.operations-center-main-modern .operations-wo-main__table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--ops-line);
  vertical-align: middle;
  overflow-wrap: break-word;
  word-break: normal;
}

.operations-center-page.operations-center-main-modern .operations-wo-main__table tr:last-child td {
  border-bottom: 0;
}

.operations-center-page.operations-center-main-modern .operations-wo-main__no,
.operations-center-page.operations-center-main-modern .operations-wo-main__customer {
  overflow-wrap: break-word;
  word-break: normal;
}

.operations-center-page.operations-center-main-modern .operations-center-table__actions,
.operations-center-page.operations-center-main-modern .operations-wo-main__actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.operations-center-page.operations-center-main-modern .operations-wo-main__actions .btn {
  min-height: 32px;
}

/* —— Breakpoints —— */
@media (max-width: 1279px) {
  .operations-center-page.operations-center-main-modern .operations-center-kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* Tablet / narrow desktop content: stack filters + card actions inside viewport */
@media (max-width: 1023px) {
  .operations-center-page.operations-center-main-modern .operations-center-list,
  .operations-center-page.operations-center-main-modern .operations-center-layout,
  .operations-center-page.operations-center-main-modern #operationsCenterFilters,
  .operations-center-page.operations-center-main-modern #operationsCenterTable,
  .operations-center-page.operations-center-main-modern #operationsCenterAllWorkOrders {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .operations-center-page.operations-center-main-modern .operations-center-filters {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    overflow: visible;
  }

  .operations-center-page.operations-center-main-modern .operations-center-filter-input {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .operations-center-page.operations-center-main-modern .operations-center-filter-select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .operations-center-page.operations-center-main-modern .operations-card {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    max-width: 100%;
  }

  .operations-center-page.operations-center-main-modern .operations-card__actions {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex-shrink: 1;
  }

  .operations-center-page.operations-center-main-modern .operations-card__actions .btn {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
    max-width: 100%;
    white-space: normal;
  }

  /* Avoid desktop WO table forcing document width on tablet */
  .operations-center-page.operations-center-main-modern .operations-wo-main__table-wrap {
    display: none;
  }

  .operations-center-page.operations-center-main-modern .operations-wo-main__cards {
    display: grid;
    gap: 8px;
    min-width: 0;
    max-width: 100%;
  }

  .operations-center-page.operations-center-main-modern .operations-wo-card {
    padding: 12px;
    border: 1px solid var(--ops-line);
    border-radius: 6px;
    background: var(--ops-surface);
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .operations-center-page.operations-center-main-modern .operations-wo-card__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px 8px;
    min-width: 0;
  }

  .operations-center-page.operations-center-main-modern .operations-wo-card__no {
    font-size: 0.875rem;
    overflow-wrap: break-word;
    min-width: 0;
  }

  .operations-center-page.operations-center-main-modern .operations-wo-card__customer {
    margin: 6px 0 0;
    font-size: 0.9375rem;
    font-weight: 600;
    overflow-wrap: break-word;
    word-break: normal;
  }

  .operations-center-page.operations-center-main-modern .operations-wo-card__meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 6px;
    font-size: 0.8125rem;
    min-width: 0;
  }

  .operations-center-page.operations-center-main-modern .operations-wo-card .operations-wo-main__actions {
    display: flex;
    flex-wrap: wrap;
    margin-top: 10px;
    width: 100%;
    min-width: 0;
  }

  .operations-center-page.operations-center-main-modern .operations-wo-card .operations-wo-main__actions .btn {
    flex: 1 1 auto;
    min-width: 0;
    white-space: normal;
  }

  .operations-center-page.operations-center-main-modern .operations-center-table__actions {
    min-width: 0;
  }
}

@media (max-width: 900px) {
  .operations-center-page.operations-center-main-modern .operations-center-filters {
    grid-template-columns: minmax(0, 1fr);
  }

  .operations-center-page.operations-center-main-modern .operations-center-filter-input {
    grid-column: auto;
  }

  .operations-center-page.operations-center-main-modern .operations-card__actions {
    flex-direction: column;
  }

  .operations-center-page.operations-center-main-modern .operations-card__actions .btn {
    flex: 1 1 auto;
    width: 100%;
  }
}

@media (max-width: 767px) {
  .operations-center-page.operations-center-main-modern .operations-center-header__title {
    font-size: 1.2rem;
  }

  .operations-center-page.operations-center-main-modern .operations-center-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Phone: stacked filters — no horizontal scroll track */
  .operations-center-page.operations-center-main-modern .operations-center-filters {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    overflow: visible;
  }

  .operations-center-page.operations-center-main-modern .operations-center-filter-input,
  .operations-center-page.operations-center-main-modern .operations-center-filter-select {
    grid-column: auto;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    min-height: var(--ops-touch);
  }

  .operations-center-page.operations-center-main-modern .operations-card__actions {
    flex-direction: column;
  }

  .operations-center-page.operations-center-main-modern .operations-card__actions .btn {
    flex: 1 1 auto;
    width: 100%;
    min-height: var(--ops-touch);
    min-width: 0;
    white-space: normal;
  }

  .operations-center-page.operations-center-main-modern .operations-wo-card .operations-wo-main__actions .btn {
    min-height: var(--ops-touch);
    width: 100%;
  }

  .operations-center-page.operations-center-main-modern .operations-workorders-section-head__actions {
    width: 100%;
  }

  .operations-center-page.operations-center-main-modern .operations-workorders-section-head__actions .btn {
    min-height: var(--ops-touch);
  }
}

@media (max-width: 430px) {
  .operations-center-page.operations-center-main-modern .operations-center-filters {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 390px) {
  .operations-center-page.operations-center-main-modern .operations-center-kpi-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}
