:root {
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --bg: #ffffff;
  --primary: #2563eb;
  --ok: #16a34a;
  --surface: #f9fafb;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #f3f4f6;
  color: var(--text);
  line-height: 1.5;
}

.page {
  max-width: 1400px;
  min-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

@media (max-width: 1240px) {
  .page {
    min-width: auto;
    width: 100%;
    padding: 16px;
  }
}

.topbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  position: relative;
}

.topbar-main {
  display: flex;
  gap: 12px;
  align-items: center;
  flex: 1;
  flex-wrap: wrap;
}

.topbar-menu {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.hamburger-btn {
  display: none;
  background: var(--primary);
  color: white;
  border: 0;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 20px;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.hamburger-btn:hover {
  background: #1d4ed8;
}

.hamburger-btn i {
  font-size: 20px;
}

@media (max-width: 768px) {
  .topbar {
    flex-wrap: nowrap;
  }
  
  .topbar-main {
    flex: 1;
    min-width: 0;
  }
  
  .topbar-main input {
    flex: 1;
    min-width: 0;
  }
  
  .topbar-main button {
    flex-shrink: 0;
  }
  
  .hamburger-btn {
    display: flex;
    flex-shrink: 0;
  }
  
  .topbar-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    padding: 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-top: 8px;
    z-index: 100;
    display: none;
  }
  
  .topbar-menu.active {
    display: flex;
  }
  
  .topbar-menu .btn-secondary {
    width: 100%;
    justify-content: flex-start;
    text-align: left;
    padding: 12px 16px;
  }
  
  .topbar-menu .btn-secondary i {
    margin-right: 8px;
    width: 20px;
  }
}

/* Page size selector */
.page-size-label { color: var(--muted); font-size: 14px; }
.topbar select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}

/* Pager controls (right-aligned) */
.page-controls { margin-left: auto; }
.page-controls select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}

input {
  width: 260px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

@media (max-width: 768px) {
  input {
    width: 100%;
  }
}

button {
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.2s, transform 0.1s;
}

button:hover:not(:disabled) {
  background: #1d4ed8;
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button:disabled { 
  opacity: 0.6; 
  cursor: not-allowed; 
}

.msg { color: var(--muted); font-size: 14px; }

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  min-width: 1200px;
  position: relative;
}


@media (max-width: 1240px) {
  .card {
    min-width: auto;
    width: 100%;
  }
}

.table-responsive {
  position: relative;
  z-index: 2;
  min-height: 400px;
}

.table-responsive::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: url(images/Watermark.png);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 60% auto;
  opacity: .5;
  pointer-events: none;
  z-index: 0;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1200px;
  position: relative;
  z-index: 1;
}

thead th {
  text-align: center;
  font-weight: 600;
  font-size: 13px;
  padding: 16px 12px;
  border-bottom: 2px solid var(--border);
  background: rgba(249, 250, 251, 0.85);
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}

tbody td {
  padding: 16px 12px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
  font-size: 14px;
  text-align: center;
  background: rgba(255, 255, 255, 0.5);
  transition: background-color 0.15s;
}

tbody tr:hover td {
  background: rgba(249, 250, 251, 0.7);
}

tbody tr:last-child td {
  border-bottom: none;
}

.col-actions { width: 120px; }

.badge-ok {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ok);
  font-weight: 600;
  font-size: 16px;
}

.badge-ok i {
  font-size: 18px;
}

.badge-na {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #6b7280;
  font-weight: 600;
  font-size: 14px;
  padding: 4px 8px;
  background: #f3f4f6;
  border-radius: 4px;
}

.badge-na i {
  font-size: 14px;
}

.icon-btn-na {
  color: #6b7280;
  border-color: #d1d5db;
}

.icon-btn-na:hover {
  background: #f3f4f6;
  border-color: #6b7280;
  color: #4b5563;
}

.date {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.icon-btn {
  background: transparent;
  color: #111827;
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 8px;
  margin-right: 6px;
  font-size: 16px;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}

.icon-btn i {
  font-size: 14px;
}

.icon-btn:hover { 
  background: var(--surface);
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.message-icon-btn {
  padding: 8px 12px;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}

.message-icon-btn i {
  font-size: 14px;
}

.watermark {
  margin-top: 40px;
  text-align: center;
  color: #d1d5db;
  font-size: 72px;
  font-weight: 800;
  line-height: 0.9;
  user-select: none;
}
.btn-secondary {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}
.btn-secondary:hover {
  background: var(--surface);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}


.pager { 
  display: flex; 
  gap: 12px; 
  align-items: center; 
  margin: 24px 0; 
  flex-wrap: wrap;
  padding: 16px;
  background: var(--surface);
  border-radius: 8px;
}

.page-numbers {
  display: flex;
  gap: 8px;
  align-items: center;
}

.page-numbers button {
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.page-numbers button:hover:not(:disabled):not(.active) {
  background: var(--surface);
  border-color: var(--primary);
  color: var(--primary);
}

.page-numbers button.active {
  background: var(--primary);
  color: white;
  font-weight: 600;
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.page-numbers button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

@media (max-width: 768px) {
  .pager {
    flex-direction: column;
    align-items: stretch;
  }
  
  .page-controls {
    margin-left: 0;
    width: 100%;
    justify-content: center;
  }
}

/* Remember-me checkbox styling */
.remember-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}
.remember-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  accent-color: var(--primary);
}
.remember-label {
  font-size: 14px;
  color: var(--muted);
}

/* Login Page Styles */
.login-body {
  background: linear-gradient(135deg, #ffffff 0%, #b1b1b1 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-container {
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
}

.login-card {
  background: var(--bg);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 100%;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-header i {
  font-size: 48px;
  color: var(--primary);
  margin-bottom: 16px;
  display: block;
}

.login-header h2 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}

.login-header p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input-group i {
  position: absolute;
  left: 14px;
  color: var(--muted);
  font-size: 16px;
  z-index: 1;
}

.input-group input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-size: 14px;
  transition: all 0.2s;
}

.input-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.login-btn {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: white;
  border: 0;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  margin-top: 8px;
}

.login-btn:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.login-btn:active {
  transform: translateY(0);
}

.login-msg {
  text-align: center;
  color: #dc2626;
  font-size: 14px;
  margin-top: 8px;
  min-height: 20px;
}

@media (max-width: 480px) {
  .login-container {
    max-width: 100%;
  }
  
  .login-card {
    padding: 24px;
  }
  
  .login-header i {
    font-size: 40px;
  }
  
  .login-header h2 {
    font-size: 20px;
  }
}

/* Confirmation modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal {
  background: var(--bg);
  padding: 20px;
  border-radius: 8px;
  width: 90%;
  max-width: 420px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}
.modal h3 {
  margin: 0 0 8px;
}
.modal p {
  color: var(--muted);
  margin-bottom: 16px;
}
.modal .modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.modal .btn-primary {
  background: var(--primary);
  color: #fff;
  border: 0;
  padding: 8px 12px;
  border-radius: 6px;
}
.modal .btn-secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 6px;
}

/* Full-screen blurred error modal */
.error-modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.35);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  z-index: 2000;
}
.error-modal {
  background: rgba(255,255,255,0.98);
  border-radius: 12px;
  padding: 24px;
  max-width: 560px;
  width: calc(100% - 48px);
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  text-align: center;
}
.error-modal p {
  color: #b91c1c;
  font-size: 16px;
  margin-top: 8px;
}
.modal-close {
  position: absolute;
  right: 16px;
  top: 16px;
  background: transparent;
  border: 0;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted);
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--text);
}

/* View Remarks Modal with blurred background */
.view-remarks-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  z-index: 2000;
}

.view-remarks-content {
  background: var(--bg);
  border-radius: 16px;
  padding: 0;
  width: 90%;
  max-width: 600px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  position: relative;
}

.view-remarks-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.view-remarks-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.view-remarks-header h3 i {
  color: var(--primary);
}

.view-remarks-work-order {
  padding: 16px 24px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.view-remarks-text {
  padding: 24px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
  min-height: 120px;
  max-height: 400px;
  overflow-y: auto;
}

/* Responsive table wrapper */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
}

/* Tablet and below: enable horizontal scroll */
@media (max-width: 1240px) {
  .table-responsive {
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
  }
  
  table {
    min-width: 1000px;
  }
}

/* Desktop: hide accordion-specific elements */
.desktop-only {
  display: table-cell;
}

.accordion-header-content {
  display: none;
}

.work-order-text {
  display: inline;
}

@media (max-width: 768px) {
  .work-order-text {
    display: none;
  }
}

/* Small screens: accordion layout */
@media (max-width: 768px) {
  .page {
    padding: 12px;
  }
  
  .card {
    border-radius: 8px;
  }
  
  thead { 
    display: none; 
  }
  
  table { 
    border: 0;
    min-width: auto;
    background: transparent;
  }
  
  tbody tr.accordion-row {
    display: block;
    border: 1px solid var(--border);
    margin-bottom: 12px;
    border-radius: 8px;
    background: white;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: all 0.3s ease;
  }
  
  /* Accordion header (always visible) */
  tbody tr.accordion-row td.accordion-header {
    display: block;
    padding: 0;
    border-bottom: none;
    cursor: pointer;
    background: var(--surface);
  }
  
  .accordion-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    width: 100%;
  }
  
  .work-order-no {
    font-weight: 600;
    font-size: 16px;
    color: var(--text);
    flex: 1;
  }
  
  .work-order-status {
    font-size: 12px;
    color: var(--muted);
    padding: 4px 8px;
    background: var(--bg);
    border-radius: 4px;
    margin: 0 12px;
  }
  
  .accordion-icon {
    font-size: 14px;
    color: var(--muted);
    transition: transform 0.3s ease;
  }
  
  tbody tr.accordion-row.expanded .accordion-icon {
    transform: rotate(180deg);
  }
  
  /* Accordion details (hidden by default) */
  tbody tr.accordion-row td.accordion-detail {
    display: none;
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    justify-content: space-between;
    align-items: center;
  }
  
  tbody tr.accordion-row.expanded td.accordion-detail {
    display: flex;
  }
  
  tbody tr.accordion-row td.accordion-detail:last-of-type {
    border-bottom: none;
  }
  
  tbody tr.accordion-row td.accordion-detail::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 16px;
    flex-shrink: 0;
  }
  
  /* Hide desktop-only status column on mobile */
  tbody tr.accordion-row td.desktop-only {
    display: none !important;
  }
  
  .col-actions { 
    width: auto; 
  }
  
  .icon-btn {
    margin: 4px;
  }
}
