:root {
  --bg-body: #0f172a;
  --bg-surface: #1e293b;
  --bg-surface-elevated: #263449;
  --bg-input: #0b1324;
  --border-color: #334155;
  --border-subtle: #1e293b;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --brand: #f59e0b;
  --brand-hover: #d97706;
  --brand-soft: rgba(245, 158, 11, 0.14);

  --blue: #38bdf8;
  --blue-soft: rgba(56, 189, 248, 0.14);
  --green: #10b981;
  --green-soft: rgba(16, 185, 129, 0.15);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.15);
  --purple: #a855f7;
  --purple-soft: rgba(168, 85, 247, 0.15);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-lg: 0 12px 32px -4px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Inter, Helvetica, Arial, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: var(--bg-body);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

/* Login Screen */
.login-overlay {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at top right, rgba(245, 158, 11, 0.15), transparent 45%),
              radial-gradient(circle at bottom left, rgba(56, 189, 248, 0.12), transparent 45%),
              var(--bg-body);
}

.login-card {
  width: 100%;
  max-width: 880px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  overflow: hidden;
}

@media (max-width: 768px) {
  .login-card {
    grid-template-columns: 1fr;
  }
}

.login-quick-panel {
  padding: 32px;
  background: rgba(15, 23, 42, 0.55);
  border-right: 1px solid var(--border-color);
}

.login-form-panel {
  padding: 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  flex-shrink: 0;
}

.role-card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.role-login-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
}

.role-login-btn:hover {
  border-color: var(--brand);
  transform: translateY(-1px);
  background: rgba(245, 158, 11, 0.1);
}

/* Layout Shell */
.app-shell {
  display: grid;
  grid-template-columns: 255px 1fr;
  min-height: 100vh;
}

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

/* Sidebar */
.sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
}

@media (max-width: 960px) {
  .sidebar {
    position: fixed;
    left: -270px;
    width: 260px;
    transition: left 0.2s ease;
  }
  .sidebar.open {
    left: 0;
  }
}

.sidebar-header {
  padding: 20px 18px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-nav {
  padding: 14px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-item:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.nav-item.active {
  color: #0f172a;
  background: var(--brand);
  font-weight: 600;
}

.nav-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  font-weight: 600;
}

.nav-item.active .nav-badge {
  background: rgba(15, 23, 42, 0.25);
  color: #0f172a;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border-color);
  background: rgba(15, 23, 42, 0.4);
}

/* Main Content Area */
.main-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 64px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 600;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.page-container {
  padding: 24px;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

/* Cards & Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  font-weight: 600;
}

.kpi-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
  overflow: hidden;
}

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-title {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-body {
  padding: 20px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
}

.grid-equal-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

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

/* Workshop Bays Visual Grid */
.bays-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.bay-box {
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bay-box.occupied {
  border-color: rgba(245, 158, 11, 0.5);
  background: rgba(245, 158, 11, 0.06);
}

.bay-box.available {
  border-color: rgba(16, 185, 129, 0.35);
}

/* Kanban Board */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(255px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 12px;
}

.kanban-col {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  min-height: 460px;
}

.kanban-col-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 13px;
}

.kanban-col-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.job-card-tile {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.job-card-tile:hover {
  border-color: var(--brand);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.plate-badge {
  display: inline-block;
  padding: 2px 8px;
  background: #0f172a;
  border: 1px solid #475569;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.05em;
  color: #f8fafc;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-amber { background: var(--brand-soft); color: var(--brand); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }
.badge-gray { background: rgba(148, 163, 184, 0.15); color: var(--text-secondary); }

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

th {
  text-align: left;
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-color);
}

td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--brand);
  color: #0f172a;
}
.btn-primary:hover {
  background: var(--brand-hover);
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-color);
}
.btn-secondary:hover {
  border-color: var(--text-secondary);
}

.btn-success {
  background: var(--green);
  color: #052e16;
}

.btn-danger {
  background: var(--red-soft);
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
  background: var(--red);
  color: #fff;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 13.5px;
  width: 100%;
}

.form-control:focus {
  outline: none;
  border-color: var(--brand);
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.78);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 720px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.modal-box.modal-xl {
  max-width: 1060px;
}

.modal-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-body {
  padding: 22px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* Checklist grid inside Job Card */
.checklist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}

.checklist-item {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.check-pills {
  display: flex;
  gap: 4px;
}

.check-pill {
  padding: 3px 7px;
  font-size: 11px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 600;
}

.check-pill.active-Pass {
  background: var(--green);
  color: #052e16;
  border-color: var(--green);
}
.check-pill.active-Attention {
  background: var(--brand);
  color: #0f172a;
  border-color: var(--brand);
}
.check-pill.active-Fail {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #0f172a;
  border: 1px solid var(--brand);
  color: var(--text-primary);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 600;
}

/* Printable Area */
.printable-doc {
  background: #ffffff;
  color: #0f172a;
  padding: 32px;
  border-radius: var(--radius-sm);
}

.printable-doc table th {
  background: #f1f5f9;
  color: #334155;
  border-bottom: 2px solid #cbd5e1;
}

.printable-doc table td {
  border-bottom: 1px solid #e2e8f0;
  color: #0f172a;
}

@media print {
  @page {
    margin: 10mm;
    size: auto;
  }
  html, body {
    background: #fff !important;
    color: #000 !important;
    margin: 0 !important;
    padding: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }
  #app, .sidebar, .topbar, .page-container, .modal-header, .modal-footer, .no-print {
    display: none !important;
  }
  #modal-root {
    display: block !important;
    position: static !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  .modal-backdrop {
    display: block !important;
    position: static !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
  }
  .modal-box {
    display: block !important;
    max-width: 100% !important;
    width: 100% !important;
    max-height: none !important;
    height: auto !important;
    min-height: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    margin: 0 !important;
    padding: 0 !important;
    page-break-after: avoid !important;
    break-after: avoid !important;
  }
  .modal-body {
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
  }
  .printable-doc {
    padding: 0 !important;
    margin: 0 !important;
    background: #fff !important;
    color: #000 !important;
    page-break-after: avoid !important;
    break-after: avoid !important;
  }
}

/* ============================================================================
   PHOTO GALLERY (BEFORE / AFTER / REMARK SPECIAL CONDITION) & EXCEL IMPORT
   ============================================================================ */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
  gap: 14px;
}

.photo-card {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.photo-card:hover {
  border-color: var(--brand);
  transform: translateY(-2px);
}

.photo-thumb-wrap {
  position: relative;
  width: 100%;
  height: 155px;
  background: #020617;
  overflow: hidden;
  cursor: pointer;
}

.photo-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-cat-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.photo-cat-Before {
  background: #dc2626;
  color: #ffffff;
}

.photo-cat-After {
  background: #059669;
  color: #ffffff;
}

.photo-cat-Remark {
  background: #d97706;
  color: #0f172a;
}

.photo-area-pill {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-color);
  color: #f8fafc;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.photo-card-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.upload-dropzone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  background: rgba(15, 23, 42, 0.45);
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}

.upload-dropzone:hover {
  border-color: var(--brand);
  background: rgba(245, 158, 11, 0.05);
}

.compare-pair-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 14px;
}

@media (max-width: 700px) {
  .compare-pair-box {
    grid-template-columns: 1fr;
  }
}

/* ============================================================================
   MOBILE PHONE & TABLET RESPONSIVENESS
   ============================================================================ */
.mobile-menu-btn {
  display: none;
}

.mobile-bottom-nav {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

@media (max-width: 960px) {
  .mobile-menu-btn {
    display: inline-flex;
  }

  .sidebar-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.72);
    z-index: 25;
  }

  .topbar {
    height: auto;
    min-height: 58px;
    padding: 10px 14px;
    flex-wrap: wrap;
  }

  .page-container {
    padding: 14px;
    padding-bottom: 80px;
  }

  .mobile-bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 62px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    z-index: 24;
  }

  .mobile-nav-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 10.5px;
    font-weight: 600;
    cursor: pointer;
  }

  .mobile-nav-btn.active {
    color: var(--brand);
  }
}
