/* 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;
}

/* ═══════════════════════════════════════════════════════════════════
   MAINTENANCE DRAFTS HUB (/maintenance/drafts)
   ═══════════════════════════════════════════════════════════════════ */

.maintenance-drafts-hub {
  padding-bottom: 2.5rem;
}

.maintenance-drafts-hub .text-muted {
  color: #475569 !important; /* slate-600: 7.0:1 contrast on white (WCAG AAA) */
}

/* Filters Card */
.drafts-filters-card {
  margin-bottom: 1.5rem;
  border-radius: var(--ty-radius-lg, 12px);
  border: 1px solid var(--ty-slate-200, #e2e8f0);
  background: #ffffff;
  box-shadow: var(--ty-shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.05));
}

.drafts-filters-card .card-body {
  padding: 1.25rem 1.5rem;
}

.drafts-filters-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.875rem;
  align-items: flex-end;
}

@media (min-width: 640px) {
  .drafts-filters-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .drafts-filters-grid {
    grid-template-columns: minmax(13rem, 1.8fr) minmax(8.5rem, 1fr) minmax(8.5rem, 1fr) minmax(8.5rem, 1fr) auto auto;
    gap: 1rem;
  }
}

.drafts-filter-field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.drafts-filter-field .form-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #1e293b; /* slate-800: 14.2:1 contrast on white (WCAG AAA) */
  margin-bottom: 0;
}

.drafts-search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.drafts-search-wrapper .search-icon {
  position: absolute;
  left: 0.75rem;
  color: #64748b; /* slate-500: 4.56:1 contrast on white (WCAG AA) */
  pointer-events: none;
}

.drafts-search-wrapper .form-input {
  padding-left: 2.25rem;
  width: 100%;
}

.maintenance-drafts-hub .form-input::placeholder {
  color: #64748b; /* slate-500: 4.56:1 contrast (WCAG AA) */
  opacity: 1;
}

.drafts-filter-field--stale {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 40px;
}

.drafts-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #1e293b; /* slate-800: 14.2:1 contrast */
  cursor: pointer;
  user-select: none;
  margin-bottom: 0;
}

.drafts-checkbox-label input[type="checkbox"] {
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 4px;
  border: 1px solid #94a3b8;
  cursor: pointer;
  accent-color: #0f766e;
}

.drafts-filter-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 40px;
}

/* Hub Layout — table is full width; system assist is a floating right drawer */
.drafts-hub-layout {
  display: block;
  position: relative;
}

.drafts-assist-header-btn {
  flex-shrink: 0;
}

.drafts-assist-tab {
  position: fixed;
  top: calc(54px + 50%);
  right: 0;
  z-index: 185;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0.9rem 0.55rem;
  border: 1px solid #5eead4;
  border-right: 0;
  border-radius: 10px 0 0 10px;
  background: #0f766e;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  writing-mode: vertical-rl;
  transform: translateY(-50%) rotate(180deg);
  cursor: pointer;
  box-shadow: -4px 8px 20px rgba(15, 118, 110, 0.28);
}

.drafts-assist-tab:hover,
.drafts-assist-tab:focus-visible {
  background: #115e59;
  outline: 2px solid #99f6e4;
  outline-offset: 2px;
}

.drafts-assist-tab svg {
  flex-shrink: 0;
  transform: rotate(180deg);
}

.drafts-hub-layout.is-assist-open .drafts-assist-tab {
  visibility: hidden;
  pointer-events: none;
}

.drafts-assist-backdrop {
  position: fixed;
  top: 54px;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 180;
  background: rgba(15, 23, 42, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.drafts-hub-layout.is-assist-open .drafts-assist-backdrop {
  opacity: 1;
  pointer-events: auto;
}

.drafts-hub-aside {
  position: fixed;
  top: 54px;
  right: 0;
  z-index: 190;
  display: flex;
  flex-direction: column;
  width: min(26rem, calc(100vw - 0.75rem));
  height: calc(100dvh - 54px);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.drafts-hub-layout.is-assist-open .drafts-hub-aside {
  transform: translateX(0);
  pointer-events: auto;
}

@media (max-width: 1023px) {
  .drafts-assist-tab {
    top: auto;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 185;
    writing-mode: horizontal-tb;
    transform: none;
    padding: 0.7rem 1rem;
    border-right: 1px solid #5eead4;
    border-radius: 999px;
    box-shadow: 0 10px 24px rgba(15, 118, 110, 0.32);
  }

  .drafts-assist-tab svg {
    transform: none;
  }

  .drafts-hub-layout.is-assist-open .drafts-assist-backdrop {
    background: rgba(15, 23, 42, 0.45);
  }
}

/* Table Card */
.drafts-table-card {
  border-radius: var(--ty-radius-lg, 12px);
  border: 1px solid var(--ty-slate-200, #e2e8f0);
  background: #ffffff;
  box-shadow: var(--ty-shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.05));
  overflow: hidden;
}

.drafts-table-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.drafts-table-card__title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: #0f172a; /* slate-900: 15.5:1 contrast */
  margin: 0;
}

.drafts-table {
  width: 100%;
  margin-bottom: 0;
  border-collapse: collapse;
}

.drafts-table th {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #334155; /* slate-700: 10.5:1 contrast on #f8fafc (WCAG AAA) */
  background: #f8fafc;
  padding: 0.75rem 1rem;
  white-space: nowrap;
  border-bottom: 1px solid #e2e8f0;
}

.drafts-table td {
  padding: 0.75rem 1rem;
  vertical-align: middle;
  font-size: 0.875rem;
  color: #1e293b; /* slate-800: 14.2:1 contrast on white */
  border-bottom: 1px solid #f1f5f9;
}

.drafts-table tbody tr {
  cursor: pointer;
}

.drafts-table tbody tr:focus-visible {
  outline: 2px solid #5eead4;
  outline-offset: -2px;
}

.drafts-table tr:hover td {
  background-color: #f8fafc;
}

/* Focused Row Highlighting */
.drafts-table tr.is-focused td {
  background-color: rgba(13, 148, 136, 0.09) !important;
  border-top-color: rgba(13, 148, 136, 0.25);
  border-bottom-color: rgba(13, 148, 136, 0.25);
}

.drafts-table tr.is-focused td:first-child {
  border-left: 3px solid #0f766e;
}

/* Row Actions */
.draft-row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.375rem;
  white-space: nowrap;
}

.draft-row-actions form.button_to {
  display: inline-flex;
  margin: 0;
  padding: 0;
}

.draft-row-actions .btn {
  white-space: nowrap;
}

.maintenance-drafts-hub .draft-row-actions a.btn.btn-outline.btn-active,
.maintenance-drafts-hub .draft-row-actions .btn.btn-active {
  /* dashboard.css .btn-outline { background: transparent !important } otherwise
     wins and the focused Assist link is white text on a white cell. */
  background: #0f766e !important;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  border-color: #0f766e !important;
}

/* Accessible High-Contrast Badges */
.badge-cm {
  background: #e0f2fe;
  color: #075985 !important; /* sky-800: 6.22:1 contrast on sky-100 (WCAG AA) */
  border: 1px solid #7dd3fc;
  font-weight: 600;
}

.badge-pm {
  background: #ede9fe;
  color: #6d28d9 !important; /* violet-700: 7.06:1 contrast on violet-100 (WCAG AAA) */
  border: 1px solid #ddd6fe;
  font-weight: 600;
}

.badge-archived {
  background: #f1f5f9;
  color: #334155 !important; /* slate-700: 9.41:1 contrast on slate-100 (WCAG AAA) */
  border: 1px solid #cbd5e1;
  font-weight: 600;
}

.maintenance-drafts-hub .badge-warning {
  background: #fef3c7;
  color: #78350f !important; /* amber-900: 9.69:1 contrast on amber-100 (WCAG AAA) */
  border: 1px solid #fde68a;
  font-weight: 600;
}

.maintenance-drafts-hub .badge-info {
  background: #dbeafe;
  color: #1e40af !important; /* blue-800: 7.56:1 contrast on blue-100 (WCAG AAA) */
  border: 1px solid #bfdbfe;
  font-weight: 600;
}

/* Assist Panel */
.drafts-assist-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  border-radius: 12px 0 0 12px;
  border: 1px solid #e2e8f0;
  border-right: 0;
  background: #ffffff;
  box-shadow: -16px 0 40px rgba(15, 23, 42, 0.16);
  overflow: hidden;
}

.drafts-assist-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.9375rem;
  font-weight: 700;
  color: #0f172a; /* slate-900: 15.5:1 contrast */
}

.drafts-assist-panel__heading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.drafts-assist-panel__close {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0.35rem 0.6rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  color: #334155;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.drafts-assist-panel__close:hover,
.drafts-assist-panel__close:focus-visible {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
  outline: 2px solid #99f6e4;
  outline-offset: 2px;
}

.drafts-assist-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
}

.drafts-assist-focus-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 1.25rem;
  color: #1e293b;
}

.drafts-assist-subtitle {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #475569; /* slate-600: 7.0:1 contrast (WCAG AAA) */
  margin: 1.25rem 0 0.5rem 0;
}

.drafts-assist-subtitle:first-of-type {
  margin-top: 0;
}

/* Readiness Checklist */
.draft-readiness-checklist {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-bottom: 1rem;
}

.draft-readiness-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
}

.draft-readiness-item svg {
  flex-shrink: 0;
}

.draft-readiness-item--missing {
  background: #fffbeb;
  color: #78350f; /* amber-900: 9.7:1 contrast on #fffbeb (WCAG AAA) */
  border: 1px solid #fde68a;
}

.draft-readiness-item--ready {
  background: #f0fdf4;
  color: #14532d; /* green-900: 10.1:1 contrast on #f0fdf4 (WCAG AAA) */
  border: 1px solid #bbf7d0;
}

/* Sibling Chips */
.draft-sibling-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  padding: 0;
  margin: 0 0 1rem 0;
  list-style: none;
}

.draft-sibling-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.3125rem 0.625rem;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #0f172a; /* slate-900: 15.5:1 contrast */
  text-decoration: none;
  transition: all 0.15s ease;
}

.draft-sibling-link:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

/* Guidance Notes Stream */
.draft-guidance-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  padding: 0;
  margin: 0 0 1rem 0;
  list-style: none;
}

.draft-guidance-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.75rem;
}

.draft-guidance-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  margin-bottom: 0.375rem;
}

.draft-guidance-card__author {
  font-weight: 700;
  color: #0f172a; /* slate-900: 15.5:1 contrast */
}

.draft-guidance-card__time {
  color: #475569; /* slate-600: 7.23:1 contrast on #f8fafc (WCAG AAA) */
  font-weight: 500;
}

.draft-guidance-card__body {
  font-size: 0.8125rem;
  color: #1e293b; /* slate-800: 14.2:1 contrast on #f8fafc (WCAG AAA) */
  line-height: 1.45;
}

.draft-guidance-card__body p {
  margin-bottom: 0;
}

/* Empty States */
.drafts-empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
}

.drafts-empty-state__icon {
  color: #94a3b8; /* slate-400: graphical non-text element meets 3:1 */
  margin: 0 auto 0.75rem auto;
}

.drafts-empty-state__text {
  font-size: 0.875rem;
  color: #475569; /* slate-600: 7.0:1 contrast (WCAG AAA) */
  margin-bottom: 0;
}

/* Pagination Bar */
.drafts-pagination-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  border-top: 1px solid #f1f5f9;
}



