/* Maintenances module — aligned with Taoyen shell + resource index pages (vehicles/shops) */

/* Stat variant used on index (overdue) — matches repair_requests pattern */
.stat-card-danger .stat-icon {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.12) 0%, rgba(220, 38, 38, 0.08) 100%);
  color: #dc2626;
}

/* Optional: total cost emphasis */
.stat-card-cost .stat-icon {
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.12) 0%, rgba(15, 118, 110, 0.08) 100%);
  color: #0d9488;
}

/* Index — maintenance cards (grid) */
.maintenance-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr));
  gap: 1.25rem;
}

.maintenance-record-card {
  background: var(--ty-white, #fff);
  border-radius: var(--ty-radius-lg, 14px);
  border: 1px solid var(--ty-slate-200, #e2e8f0);
  overflow: hidden;
  box-shadow: var(--ty-shadow, 0 1px 3px rgba(0, 0, 0, 0.08));
  transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.maintenance-record-card:hover {
  box-shadow: 0 8px 24px rgba(12, 31, 63, 0.1);
  border-color: rgba(13, 148, 136, 0.35);
}

.maintenance-record-card__header {
  background: linear-gradient(135deg, #0c1f3f 0%, #1a3460 55%, #0d9488 100%);
  padding: 1.25rem 1.5rem;
  position: relative;
}

/*
  Dark gradient header: beat body.ty-app h3 / dashboard p !important
  navy/slate defaults that make titles/subtitles invisible on this background.
  Do not target badge spans — they keep their own chip colors.
*/
body.ty-app .maintenance-record-card__header .maintenance-record-card__title,
body.ty-app .maintenance-record-card__header h3,
body.ty-app .maintenance-record-card__icon {
  color: #ffffff !important;
}

body.ty-app .maintenance-record-card__header .maintenance-record-card__subtitle,
body.ty-app .maintenance-record-card__header p.maintenance-record-card__subtitle {
  color: rgba(255, 255, 255, 0.9) !important;
}

.maintenance-record-card__icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  margin-bottom: 0.75rem;
}

.maintenance-record-card__title {
  font-size: 1.0625rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 0.25rem 0;
  font-family: var(--ty-font-th, "Sarabun", sans-serif);
}

.maintenance-record-card__subtitle {
  font-size: 0.8125rem;
  color: rgba(255, 255, 255, 0.85);
  margin: 0;
}

.maintenance-record-card__status {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
}

.maintenance-record-card__body {
  padding: 1.25rem 1.5rem;
}

.maintenance-record-card__row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--ty-slate-100, #f1f5f9);
}

.maintenance-record-card__row:last-child {
  border-bottom: none;
}

.maintenance-record-card__row-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--ty-teal-bg, #e6f7f6);
  color: var(--ty-teal, #0d9488);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.maintenance-record-card__label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ty-slate-500, #64748b);
  font-weight: 600;
  margin-bottom: 0.125rem;
}

.maintenance-record-card__value {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ty-slate-800, #1e293b);
}

.maintenance-record-card__footer {
  padding: 1rem 1.5rem;
  background: var(--ty-slate-50, #f8fafc);
  border-top: 1px solid var(--ty-slate-200, #e2e8f0);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.maintenance-record-card__footer form.button_to {
  display: inline;
  margin: 0;
}

.maintenance-record-card__footer form.button_to .btn {
  width: auto;
}

/* Empty state */
.maintenances-empty {
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--ty-white, #fff);
  border-radius: var(--ty-radius-lg, 14px);
  border: 2px dashed var(--ty-slate-200, #e2e8f0);
}

.maintenances-empty__icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.maintenances-empty__title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--ty-slate-800, #1e293b);
  margin: 0 0 0.5rem 0;
}

.maintenances-empty__hint {
  font-size: 0.875rem;
  color: var(--ty-slate-500, #64748b);
  margin: 0 0 1.25rem 0;
}

/* New / edit — breadcrumb */
.maintenance-form-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
}

.maintenance-form-breadcrumb a {
  color: var(--ty-teal, #0d9488);
  text-decoration: none;
  font-weight: 500;
}

.maintenance-form-breadcrumb a:hover {
  color: var(--ty-navy-mid, #1a3460);
  text-decoration: underline;
}

.maintenance-form-breadcrumb .sep {
  color: var(--ty-slate-400, #94a3b8);
}

.maintenance-form-breadcrumb .current {
  color: var(--ty-slate-600, #475569);
  font-weight: 500;
}

/* Form layout — sections as cards inside ty-app */
.maintenance-form-page {
  max-width: 1100px;
  margin: 0 auto;
}

.maintenance-form .form-section-card {
  background: var(--ty-white, #fff);
  border-radius: var(--ty-radius-lg, 14px);
  border: 1px solid var(--ty-slate-200, #e2e8f0);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.maintenance-form__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 1024px) {
  .maintenance-form__grid {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

.maintenance-form__col {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.maintenance-form-errors {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.28);
  border-radius: var(--ty-radius-sm, 8px);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  color: #b91c1c;
}

.maintenance-form-errors ul {
  margin: 0.5rem 0 0 1.25rem;
  padding: 0;
}

.maintenance-form .form-section-card h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ty-navy-mid, #1a3460);
  margin: 0 0 1rem 0;
  font-family: var(--ty-font-th, "Sarabun", sans-serif);
}

.maintenance-form .form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ty-slate-700, #334155);
  margin-bottom: 0.375rem;
}

.maintenance-form .form-input,
.maintenance-form .input-field,
.maintenance-form select.form-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--ty-slate-200, #e2e8f0);
  border-radius: var(--ty-radius-sm, 6px);
  font-size: 0.875rem;
  background: var(--ty-white, #fff);
  color: var(--ty-slate-800, #1e293b);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.maintenance-form .form-input:focus,
.maintenance-form .input-field:focus,
.maintenance-form select.form-input:focus,
.maintenance-form .form-select:focus {
  outline: none;
  border-color: var(--ty-teal, #0d9488);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.maintenance-form .form-select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--ty-slate-200, #e2e8f0);
  border-radius: var(--ty-radius-sm, 6px);
  font-size: 0.875rem;
  background: var(--ty-white, #fff);
  color: var(--ty-slate-800, #1e293b);
}

/* Show page */
.maintenance-show-layout {
  max-width: 1200px;
  margin: 0 auto;
}

/* Detail pages: back + status row (matches form cancel/submit alignment — end-aligned, compact gap) */
.maintenance-show-toolbar,
.resource-show-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.maintenance-show-grid {
  display: grid;
  grid-template-columns: 1fr minmax(260px, 340px);
  gap: 1.5rem;
}

@media (max-width: 960px) {
  .maintenance-show-grid {
    grid-template-columns: 1fr;
  }
}

.maintenance-detail-card {
  background: var(--ty-white, #fff);
  border-radius: var(--ty-radius-lg, 14px);
  border: 1px solid var(--ty-slate-200, #e2e8f0);
  padding: 1.5rem;
}

.maintenance-detail-card h2 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--ty-navy-mid, #1a3460);
  margin: 0 0 1rem 0;
}

.maintenance-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--ty-slate-100, #f1f5f9);
}

.maintenance-detail-row:last-child {
  border-bottom: none;
}

.maintenance-detail-label {
  font-size: 0.8125rem;
  color: var(--ty-slate-500, #64748b);
  font-weight: 500;
}

.maintenance-detail-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ty-slate-800, #1e293b);
  text-align: right;
}

.maintenance-detail-card a.maintenance-link {
  color: var(--ty-teal, #0d9488);
  font-weight: 600;
  text-decoration: none;
}

.maintenance-detail-card a.maintenance-link:hover {
  text-decoration: underline;
  color: var(--ty-navy-mid, #1a3460);
}

.maintenance-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.maintenance-sidebar-card {
  background: var(--ty-white, #fff);
  border-radius: var(--ty-radius-lg, 14px);
  border: 1px solid var(--ty-slate-200, #e2e8f0);
  padding: 1.5rem;
}

.maintenance-sidebar-card h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ty-navy-mid, #1a3460);
  margin: 0 0 1rem 0;
}

.maintenance-cost-highlight {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--ty-teal, #0d9488);
}

.maintenance-timeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.maintenance-timeline-dot--scheduled {
  background: #0d9488;
}

.maintenance-timeline-dot--performed {
  background: #f59e0b;
}

.maintenance-timeline-dot--completed {
  background: #16a34a;
}

.maintenance-timeline {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.maintenance-timeline-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.maintenance-timeline-row .maintenance-timeline-meta {
  font-size: 0.75rem;
  color: var(--ty-slate-500, #64748b);
}

.maintenance-timeline-row .maintenance-timeline-date {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ty-slate-800, #1e293b);
}

.maintenance-detail-description {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--ty-slate-100, #f1f5f9);
}

.maintenance-detail-description h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--ty-navy-mid, #1a3460);
  margin: 0 0 0.5rem 0;
}

.maintenance-detail-description p {
  font-size: 0.875rem;
  color: var(--ty-slate-600, #475569);
  line-height: 1.6;
  margin: 0;
}

.maintenance-history-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.65rem;
  background: var(--ty-slate-50, #f8fafc);
  border-radius: var(--ty-radius-sm, 6px);
  border: 1px solid var(--ty-slate-100, #f1f5f9);
}

.maintenance-history-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #0c1f3f 0%, #0d9488 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════════════════
   PM Templates (admin)
═══════════════════════════════════════════════════════════════════════════ */
.pm-templates-page {
  max-width: 56rem;
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

.pm-templates-index {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

.pm-templates-index .pm-templates-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1.5rem;
}

.pm-templates-index .templates-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .pm-templates-index .templates-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .pm-templates-index .templates-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.pm-templates-index .pm-templates-empty svg {
  width: 4rem;
  height: 4rem;
  margin: 0 auto 1rem;
  color: #94a3b8;
}

.pm-templates-index .pm-templates-empty h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #0f172a;
  margin: 0 0 0.5rem;
}

.pm-templates-index .pm-templates-empty p {
  color: #475569;
  margin: 0 0 1.5rem;
}

.pm-template-card .pm-template-interval {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 600;
  background: #e0f2fe;
  color: #075985;
}

.pm-template-card .pm-template-interval svg {
  width: 1rem;
  height: 1rem;
}

.pm-template-card .pm-template-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.pm-template-card .pm-template-name {
  font-size: 1.25rem;
  font-weight: 600;
  color: #0f172a;
  margin: 0 0 1rem;
}

.pm-template-card .pm-template-stats {
  margin-bottom: 1.5rem;
}

.pm-template-card .pm-template-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.pm-template-card .pm-template-stat-row span:first-child {
  color: #475569;
}

.pm-template-card .pm-template-stat-row span:last-child {
  font-weight: 500;
  color: #0f172a;
}

.pm-template-card .pm-template-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid #e2e8f0;
}

.pm-template-card .pm-template-actions .btn-outline,
.pm-template-card .pm-template-actions .btn-danger {
  flex: 1;
  text-align: center;
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
}

.pm-templates-form .pm-form-section {
  margin-bottom: 1.5rem;
}

.pm-templates-form .pm-form-section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.125rem;
  font-weight: 600;
  color: #0f172a;
  margin: 0 0 1rem;
}

.pm-templates-form .pm-form-section-title svg {
  width: 1.25rem;
  height: 1.25rem;
  color: #0ea5e9;
  flex-shrink: 0;
}

.pm-templates-form .pm-form-section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.pm-templates-form .pm-form-section-title-row .pm-form-section-title {
  margin: 0;
}

.pm-templates-form .pm-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 768px) {
  .pm-templates-form .pm-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pm-templates-form .pm-form-grid .pm-form-span-2 {
    grid-column: span 2;
  }
}

.pm-templates-form .pm-form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.pm-templates-form .pm-form-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: #334155;
}

.pm-templates-form .pm-input-with-suffix {
  position: relative;
}

.pm-templates-form .pm-input-with-suffix .input-field {
  padding-right: 3rem;
}

.pm-templates-form .pm-input-suffix {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.875rem;
  color: #64748b;
  pointer-events: none;
}

.pm-templates-form .pm-checkbox-row {
  display: flex;
  align-items: center;
  min-height: 2.625rem;
  gap: 0.5rem;
}

.pm-templates-form .pm-checkbox-row input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}

.pm-templates-form .pm-checkbox-row span {
  font-size: 0.875rem;
  color: #475569;
}

.pm-templates-form .pm-form-errors {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 1.5rem;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.pm-templates-form .pm-form-errors svg {
  width: 1.25rem;
  height: 1.25rem;
  color: #f87171;
  flex-shrink: 0;
  margin-top: 0.125rem;
}

.pm-templates-form .pm-form-errors h3 {
  font-size: 0.875rem;
  font-weight: 600;
  color: #991b1b;
  margin: 0 0 0.5rem;
}

.pm-templates-form .pm-form-errors ul {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.875rem;
  color: #b91c1c;
}

.pm-templates-form .checklist-items {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.pm-templates-form .checklist-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 1rem;
}

.pm-templates-form .checklist-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e2e8f0;
}

.pm-templates-form .checklist-item-header span {
  font-size: 0.875rem;
  font-weight: 500;
  color: #334155;
}

.pm-templates-form .checklist-item-remove {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.875rem;
  color: #ef4444;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.pm-templates-form .checklist-item-remove:hover {
  color: #b91c1c;
}

.pm-templates-form .checklist-item-remove svg {
  width: 1rem;
  height: 1rem;
}

.pm-templates-form .checklist-item-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 768px) {
  .pm-templates-form .checklist-item-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .pm-templates-form .checklist-item-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .pm-templates-form .checklist-item-grid .pm-item-span-2 {
    grid-column: span 2;
  }
}

.pm-templates-form .pm-form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.5rem;
}

.pm-templates-form .btn-add-item {
  font-size: 0.875rem;
  padding: 0.375rem 0.75rem;
}

.pm-templates-form .btn-add-item svg {
  width: 1rem;
  height: 1rem;
  display: inline-block;
  vertical-align: -0.125em;
  margin-right: 0.25rem;
}

/* CM repair checklist — shared 9-column costing grid (cb · desc · cat · qty · unit · gross · disc · net · action) */
.cm-costing-table {
  --cm-costing-input-h: 2.125rem;
  --cm-costing-inline-pad: 0.75rem;
  --cm-costing-grid: 1.25rem minmax(14rem, 1fr) minmax(7rem, 9rem) minmax(3.5rem, 4.25rem) 4.5rem 4.5rem 3.85rem 4.25rem max-content;
  --cm-costing-gap: 0.375rem 0.5rem;
  margin-top: 0.5rem;
  padding-inline: var(--cm-costing-inline-pad);
}

.cm-costing-table__header,
.cm-costing-table__row,
.pm-checklist--costing label.pm-item--costing {
  display: grid;
  grid-template-columns: var(--cm-costing-grid);
  gap: var(--cm-costing-gap);
  align-items: center;
}

.cm-costing-col-cb { grid-column: 1; }
.cm-costing-col-desc { grid-column: 2; min-width: 0; }
.cm-costing-col-cat { grid-column: 3; min-width: 0; }
.cm-costing-col-qty { grid-column: 4; min-width: 0; }
.cm-costing-col-unit { grid-column: 5; min-width: 0; }
.cm-costing-col-gross { grid-column: 6; min-width: 0; text-align: right; font-variant-numeric: tabular-nums; }
.cm-costing-col-disc { grid-column: 7; min-width: 0; }
.cm-costing-col-net { grid-column: 8; min-width: 0; }
.cm-costing-col-action { grid-column: 9; }

.cm-costing-table__header {
  padding: 0 0 0.5rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--slate-500, #64748b);
  border-bottom: 1px solid var(--slate-200, #e2e8f0);
}

.cm-costing-table__header .cm-costing-col-cb {
  visibility: hidden;
}

.cm-costing-table__header .cm-costing-col-qty,
.cm-costing-table__header .cm-costing-col-unit,
.cm-costing-table__header .cm-costing-col-gross,
.cm-costing-table__header .cm-costing-col-disc,
.cm-costing-table__header .cm-costing-col-net {
  text-align: right;
  padding-right: 0.35rem;
}

.cm-costing-table .form-input,
.cm-costing-table .form-select,
.cm-costing-table .combobox__control,
.cm-costing-table .pm-add-custom__btn {
  min-height: var(--cm-costing-input-h);
  height: var(--cm-costing-input-h);
  box-sizing: border-box;
  padding-block: 0.3rem;
}

.cm-costing-table .combobox__input {
  padding-inline: 0.35rem 2rem;
}

.cm-costing-table .pm-add-custom__fields .pm-add-custom__name,
.cm-costing-table .pm-add-custom__fields .pm-add-custom__qty,
.cm-costing-table .pm-add-custom__fields .pm-add-custom__category,
.cm-costing-table .pm-add-custom__fields .pm-add-custom__est .form-input {
  padding-block: 0.3rem;
  line-height: 1.25;
}

.cm-costing-table .combobox__control {
  display: flex;
  align-items: center;
}

.cm-costing-table .pm-add-custom__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-top: 0;
  padding-bottom: 0;
  line-height: 1;
}

.cm-costing-table .input-with-suffix {
  height: var(--cm-costing-input-h);
}

.cm-costing-table .input-with-suffix .form-input {
  height: 100%;
  min-height: 0;
}

.pm-checklist--costing {
  margin-top: 0;
}

.cm-costing-table .pm-checklist--costing {
  border: none;
  border-radius: 0;
  margin-bottom: 0;
  overflow: visible;
}

.pm-checklist--costing .pm-items {
  padding: 0;
  gap: 0;
}

.pm-checklist--costing label.pm-item--costing {
  padding: 0.625rem 0;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-top: none;
  gap: var(--cm-costing-gap);
}

.pm-checklist--costing label.pm-item--costing:first-of-type {
  border-top: 1px solid var(--slate-200, #e2e8f0);
}

.pm-checklist--costing label.pm-item--costing + label.pm-item--costing {
  border-top: 1px solid var(--slate-200, #e2e8f0);
}

.pm-checklist--costing label.pm-item--costing .pm-custom-remove {
  justify-self: end;
  align-self: center;
  margin: 0;
  width: var(--cm-costing-input-h);
  height: var(--cm-costing-input-h);
  flex-shrink: 0;
}

.pm-checklist--costing .pm-qty-input,
.pm-checklist--costing .pm-unit-price-input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 0.3rem 0.35rem;
  font-size: 0.8125rem;
  text-align: right;
}

.pm-checklist--costing .pm-item-name {
  font-size: 0.875rem;
}

.pm-checklist--costing .pm-item-category {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--slate-600, #475569);
  line-height: 1.25;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pm-checklist--costing .pm-line-net,
.pm-add-custom--costing .pm-add-custom__net {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: var(--cm-costing-input-h);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.8125rem;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  padding-right: 0.15rem;
}

.pm-checklist--costing .pm-line-net {
  color: #7c3aed;
}

.pm-checklist--costing .discount-combobox {
  width: 100%;
  min-width: 0;
}

.pm-checklist--costing .discount-combobox .combobox__input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 0.3rem 0.2rem;
  font-size: 0.75rem;
  text-align: right;
}

.cm-costing-table .pm-checklist-summary {
  padding: 0.625rem 0;
  margin: 0;
}

.cm-costing-table .checklist-empty {
  padding: 1.5rem 0;
}

.cm-costing-table .checklist-empty.hidden,
.cm-costing-table .checklist-empty[hidden],
.cm-costing-table .checklist-empty.pm-is-hidden,
.cm-costing-table .checklist-items.hidden,
.cm-costing-table .checklist-items[hidden],
.cm-costing-table .checklist-items.pm-is-hidden {
  display: none !important;
}

/* CM add row — flush with costing table grid (override workflow .add-item-row chrome) */
.cm-costing-table .add-item-row.pm-add-custom--costing {
  padding: 0.75rem 0 0;
  margin: 0;
  border: none;
  border-top: 1px dashed var(--slate-200, #e2e8f0);
  border-radius: 0;
  background: transparent;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}

.cm-costing-table .pm-add-custom--costing .pm-add-custom__fields {
  padding: 0;
  width: 100%;
  grid-template-columns: var(--cm-costing-grid);
  gap: var(--cm-costing-gap);
  align-items: center;
}

.pm-add-custom--costing .pm-add-custom__desc {
  width: 100%;
  min-width: 0;
}

.pm-add-custom--costing .pm-add-custom__category {
  width: 100%;
  min-width: 0;
  padding: 0 1.75rem 0 0.4rem;
  font-size: 0.75rem;
  line-height: 1.2;
}

.pm-add-custom--costing .pm-add-custom__qty {
  width: 100%;
  min-width: 0;
  padding: 0.3rem 0.35rem;
  text-align: right;
}

.pm-add-custom--costing .pm-add-custom__est {
  width: 100%;
  min-width: 0;
}

.pm-add-custom--costing .pm-add-custom__est .form-input {
  width: 100%;
  padding: 0.3rem 1.5rem 0.3rem 0.35rem;
  text-align: right;
}

.pm-add-custom--costing .pm-add-custom__discount {
  width: 100%;
  min-width: 0;
  padding: 0.3rem 0.15rem;
  font-size: 0.75rem;
}

.pm-add-custom--costing .pm-add-custom__net {
  color: var(--teal-700, #0f766e);
}

.pm-add-custom--costing .pm-add-custom__btn {
  justify-self: end;
  white-space: nowrap;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

.pm-add-custom--costing .pm-add-custom__cb-spacer {
  display: block;
}

@media (max-width: 900px) {
  .cm-costing-table__header {
    display: none;
  }

  .pm-checklist--costing label.pm-item--costing,
  .pm-add-custom--costing .pm-add-custom__fields {
    grid-template-columns: 1.25rem 1fr;
    grid-template-areas:
      "cb desc"
      ". cat"
      ". qty"
      ". unit"
      ". gross"
      ". disc"
      ". net"
      ". action";
  }

  .pm-checklist--costing label.pm-item--costing .cm-costing-col-cb,
  .pm-add-custom--costing .cm-costing-col-cb { grid-area: cb; }
  .pm-checklist--costing label.pm-item--costing .cm-costing-col-desc,
  .pm-add-custom--costing .cm-costing-col-desc { grid-area: desc; }
  .pm-checklist--costing label.pm-item--costing .cm-costing-col-cat,
  .pm-add-custom--costing .cm-costing-col-cat { grid-area: cat; }
  .pm-checklist--costing label.pm-item--costing .cm-costing-col-qty,
  .pm-add-custom--costing .cm-costing-col-qty { grid-area: qty; }
  .pm-checklist--costing label.pm-item--costing .cm-costing-col-unit,
  .pm-add-custom--costing .cm-costing-col-unit { grid-area: unit; }
  .pm-checklist--costing label.pm-item--costing .cm-costing-col-gross,
  .pm-add-custom--costing .cm-costing-col-gross { grid-area: gross; }
  .pm-checklist--costing label.pm-item--costing .cm-costing-col-disc,
  .pm-add-custom--costing .cm-costing-col-disc { grid-area: disc; }
  .pm-checklist--costing label.pm-item--costing .cm-costing-col-net,
  .pm-add-custom--costing .cm-costing-col-net { grid-area: net; }
  .pm-checklist--costing label.pm-item--costing .cm-costing-col-action,
  .pm-add-custom--costing .cm-costing-col-action { grid-area: action; justify-self: end; }

  .pm-add-custom--costing .cm-costing-col-desc,
  .pm-add-custom--costing .cm-costing-col-cat,
  .pm-add-custom--costing .cm-costing-col-action {
    grid-column: 1 / -1;
  }

  .pm-add-custom--costing .pm-add-custom__btn {
    width: 100%;
  }
}

/* Checklist card — CM description combobox dropdown escapes .card { overflow: hidden } */
.pm-template-checklist-card.card:has(.combobox.is-open) {
  overflow: visible;
  position: relative;
  z-index: 45;
}

.pm-template-checklist-card.card:has(.combobox.is-open) .card-body,
.pm-template-checklist-card.card:has(.combobox.is-open) .pm-add-custom--costing {
  overflow: visible;
}

.pm-add-custom--costing .combobox.is-open {
  z-index: 50;
}

.pm-add-custom--costing .combobox.is-open .combobox__dropdown {
  z-index: 60;
}

