/* UT-VP | Utility Check Sheet & Maintenance Portal Styles */
:root {
  --ut-bg: #f1f5f9;
  --ut-surface: #ffffff;
  --ut-border: #e2e8f0;
  --ut-text: #0f172a;
  --ut-text-muted: #64748b;
  --ut-primary: #0284c7;
  --ut-primary-dark: #0369a1;
  --ut-primary-light: #e0f2fe;
  --ut-success: #10b981;
  --ut-success-bg: #d1fae5;
  --ut-warning: #f59e0b;
  --ut-warning-bg: #fef3c7;
  --ut-danger: #ef4444;
  --ut-danger-bg: #fee2e2;
  --ut-purple: #7c3aed;
  --ut-radius: 12px;
  --ut-shadow: 0 4px 15px -3px rgba(15, 23, 42, 0.07), 0 2px 6px -2px rgba(15, 23, 42, 0.04);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Sarabun', 'Prompt', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--ut-bg);
  color: var(--ut-text);
  line-height: 1.5;
}

/* Top Navbar */
.ut-navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  padding: 0.7rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.ut-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.ut-brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #00f0ff, #0284c7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4);
}

.ut-brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.ut-brand-badge {
  background: rgba(56, 189, 248, 0.2);
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: #38bdf8;
  font-size: 0.72rem;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-weight: 700;
}

.ut-brand-sub {
  font-size: 0.78rem;
  color: #94a3b8;
}

.ut-nav-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ut-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.18s ease;
  text-decoration: none;
  font-family: inherit;
}

.ut-btn:active {
  transform: translateY(1px);
}

.ut-btn-cmms {
  background: linear-gradient(135deg, #4f46e5, #3b82f6);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}

.ut-btn-cmms:hover {
  background: linear-gradient(135deg, #4338ca, #2563eb);
}

.ut-btn-sync {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.ut-btn-sync:hover {
  background: rgba(16, 185, 129, 0.25);
}

.ut-btn-primary {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
}

.ut-btn-primary:hover {
  background: linear-gradient(135deg, #0369a1, #075985);
}

.ut-btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.ut-btn-success:hover {
  background: linear-gradient(135deg, #059669, #047857);
}

.ut-btn-outline {
  background: #ffffff;
  color: #334155;
  border: 1px solid #cbd5e1;
}

.ut-btn-outline:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

/* Main Container */
.ut-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1rem 1.25rem 3rem;
}

/* 5 Category Cards Grid */
.ut-category-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.2rem;
}

@media (max-width: 1024px) {
  .ut-category-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 640px) {
  .ut-category-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.ut-cat-card {
  background: var(--ut-surface);
  border: 2px solid var(--ut-border);
  border-radius: var(--ut-radius);
  padding: 0.85rem 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  box-shadow: var(--ut-shadow);
  position: relative;
  overflow: hidden;
}

.ut-cat-card:hover {
  transform: translateY(-2px);
  border-color: #7dd3fc;
}

.ut-cat-card.active {
  border-color: var(--ut-primary);
  background: linear-gradient(135deg, #ffffff 0%, #f0f9ff 100%);
  box-shadow: 0 6px 18px rgba(2, 132, 199, 0.16);
}

.ut-cat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.ut-cat-info {
  flex: 1;
  min-width: 0;
}

.ut-cat-name {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--ut-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ut-cat-meta {
  font-size: 0.76rem;
  color: var(--ut-text-muted);
  margin-top: 2px;
}

/* Sub-Tabs Bar */
.ut-tabs-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  background: var(--ut-surface);
  padding: 0.6rem 0.85rem;
  border-radius: var(--ut-radius);
  border: 1px solid var(--ut-border);
  box-shadow: var(--ut-shadow);
  margin-bottom: 1rem;
}

.ut-tabs-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.ut-tab-btn {
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--ut-text-muted);
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: all 0.15s;
  font-family: inherit;
}

.ut-tab-btn:hover {
  background: #f1f5f9;
  color: var(--ut-text);
}

.ut-tab-btn.active {
  background: var(--ut-primary);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.3);
}

/* Filter & Month Controls */
.ut-controls-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.ut-input, .ut-select {
  padding: 0.45rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.88rem;
  font-family: inherit;
  background: #ffffff;
  color: var(--ut-text);
}

.ut-input:focus, .ut-select:focus {
  outline: none;
  border-color: var(--ut-primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

/* 28 Set Pills Selector */
.ut-set-pills-card {
  background: var(--ut-surface);
  border: 1px solid var(--ut-border);
  border-radius: var(--ut-radius);
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--ut-shadow);
}

.ut-set-pills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 0.45rem;
  margin-top: 0.6rem;
}

.ut-set-pill {
  padding: 0.42rem 0.6rem;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.15s;
}

.ut-set-pill:hover {
  border-color: var(--ut-primary);
  background: #f0f9ff;
}

.ut-set-pill.active {
  border: 2px solid var(--ut-primary);
  background: #e0f2fe;
  color: #0369a1;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.2);
}

.ut-set-pill.done {
  background: #ecfdf5;
  border-color: #6ee7b7;
  color: #065f46;
}

.ut-set-pill.partial {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #92400e;
}

/* Set Job Header Banner */
.ut-job-banner {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
  color: #ffffff;
  border-radius: var(--ut-radius);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.18);
}

.ut-progress-bar-wrap {
  width: 100%;
  background: rgba(255, 255, 255, 0.18);
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.ut-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #34d399, #10b981);
  transition: width 0.3s ease;
}

/* Machine Check Cards inside a Set */
.ut-machines-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 1rem;
}

@media (max-width: 640px) {
  .ut-machines-grid {
    grid-template-columns: 1fr;
  }
}

.ut-machine-card {
  background: var(--ut-surface);
  border: 2px solid var(--ut-border);
  border-radius: var(--ut-radius);
  box-shadow: var(--ut-shadow);
  overflow: hidden;
  transition: all 0.2s;
}

.ut-machine-card.is-saved {
  border-color: #34d399;
}

.ut-machine-card.is-abnormal {
  border-color: #f87171;
}

.ut-machine-header {
  padding: 0.85rem 1rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--ut-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.ut-machine-card.is-saved .ut-machine-header {
  background: #ecfdf5;
}

.ut-machine-title {
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--ut-text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ut-seq-badge {
  background: #0f172a;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
}

.ut-machine-body {
  padding: 1rem;
}

/* 5 Checkboxes Grid */
.ut-checklist-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}

@media (max-width: 480px) {
  .ut-checklist-grid {
    grid-template-columns: 1fr;
  }
}

.ut-check-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  cursor: pointer;
  user-select: none;
  font-size: 0.86rem;
  font-weight: 600;
  transition: all 0.15s;
}

.ut-check-item.checked {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #1d4ed8;
}

.ut-check-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #0284c7;
  cursor: pointer;
}

/* Numeric & Text Inputs Grid */
.ut-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin-bottom: 0.85rem;
}

.ut-field-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: #475569;
  margin-bottom: 0.25rem;
}

/* Camera Photo Box */
.ut-photo-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.ut-photo-slot {
  border: 1.5px dashed #94a3b8;
  border-radius: 10px;
  padding: 0.55rem;
  text-align: center;
  background: #f8fafc;
  position: relative;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.ut-photo-slot.has-img {
  border-style: solid;
  border-color: #10b981;
  background: #f0fdf4;
}

.ut-photo-preview {
  width: 100%;
  height: 95px;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
}

/* Tables for Master Plan & 141 Checklist */
.ut-card-section {
  background: var(--ut-surface);
  border: 1px solid var(--ut-border);
  border-radius: var(--ut-radius);
  padding: 1.1rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--ut-shadow);
}

.ut-section-title {
  font-size: 1.05rem;
  font-weight: 800;
  margin: 0 0 0.85rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ut-table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
}

.ut-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
  background: #ffffff;
}

.ut-table th {
  background: #dbeafe;
  color: #1e3a8a;
  font-weight: 800;
  padding: 0.6rem 0.55rem;
  border: 1px solid #93c5fd;
  text-align: center;
  white-space: nowrap;
}

.ut-table td {
  padding: 0.48rem 0.55rem;
  border: 1px solid #e2e8f0;
  vertical-align: middle;
}

.ut-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

.ut-table tbody tr:hover {
  background: #f0f9ff;
}

.ut-table tbody tr.row-done {
  background: #f0fdf4;
}

.ut-table tbody tr.row-abnormal {
  background: #fef2f2;
}

/* Modal Lightbox */
.ut-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.ut-modal-card {
  background: #ffffff;
  border-radius: 14px;
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

/* Print Styles for Audit / ISO Check Sheet */
@media print {
  .ut-navbar,
  .ut-category-grid,
  .ut-tabs-bar,
  .ut-no-print {
    display: none !important;
  }
  body {
    background: #ffffff;
  }
  .ut-container {
    max-width: 100%;
    padding: 0;
  }
  .ut-card-section {
    box-shadow: none;
    border: none;
    padding: 0;
    margin-bottom: 1rem;
  }
  .ut-table th, .ut-table td {
    border: 1px solid #000000 !important;
    font-size: 10pt;
    padding: 4px;
  }
}
