/* Mesh gradient + industrial theme */
.app-logo {
  display: block;
  object-fit: contain;
  object-position: center;
}

/* Mobile sidebar drawer */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}
body.sidebar-open .sidebar-backdrop {
  display: block;
}
body.sidebar-open {
  overflow: hidden;
}
.app-sidebar {
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  will-change: transform;
}
body.sidebar-open .app-sidebar {
  transform: translateX(0);
}
@media (min-width: 1024px) {
  .app-sidebar {
    transform: translateX(0);
  }
  body.sidebar-open {
    overflow: auto;
  }
}

.mobile-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(61, 70, 84, 0.7);
  background: rgba(45, 52, 64, 0.5);
  color: #e2e8f0;
  transition: background 150ms, color 150ms;
}
.mobile-menu-btn:hover {
  background: rgba(14, 165, 233, 0.15);
  color: #0ea5e9;
}

.mesh-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
}
.mesh-blob-1 {
  top: -25%; left: -25%; width: 80%; height: 80%;
  background: radial-gradient(ellipse at center, rgba(14,165,233,0.12) 0%, transparent 70%);
}
.mesh-blob-2 {
  top: 33%; right: -25%; width: 60%; height: 60%;
  background: radial-gradient(ellipse at center, rgba(100,116,139,0.15) 0%, transparent 70%);
}
.mesh-blob-3 {
  bottom: -25%; left: 33%; width: 50%; height: 50%;
  background: radial-gradient(ellipse at center, rgba(139,92,246,0.08) 0%, transparent 70%);
}
.mesh-grid {
  position: absolute; inset: 0; opacity: 0.03;
  background-image:
    linear-gradient(rgba(255,255,255,.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.1) 1px, transparent 1px);
  background-size: 48px 48px;
}

.glass-card {
  border-radius: 0.75rem;
  border: 1px solid rgba(61, 70, 84, 0.6);
  background: rgba(26, 31, 39, 0.7);
  backdrop-filter: blur(12px);
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.2);
}

.nav-link {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.5rem 0.75rem; border-radius: 0.5rem;
  font-size: 0.875rem; color: #d4dce6;
  transition: colors 150ms;
}
button.nav-link {
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  text-align: left;
}
.nav-link:hover { background: rgba(45,52,64,0.5); color: #f1f5f9; }
.nav-link-active {
  background: rgba(14,165,233,0.1); color: #0ea5e9;
  border: 1px solid rgba(14,165,233,0.2);
}

.status-badge {
  display: inline-flex; align-items: center; gap: 0.375rem;
  padding: 0.125rem 0.625rem; border-radius: 0.375rem;
  font-size: 0.75rem; font-weight: 500; border-width: 1px;
}
.status-dot { width: 6px; height: 6px; border-radius: 50%; }
.status-pr { background: rgba(245,158,11,0.15); color: #fbbf24; border-color: rgba(245,158,11,0.3); }
.status-pr .status-dot { background: #fbbf24; }
.status-po { background: rgba(59,130,246,0.15); color: #60a5fa; border-color: rgba(59,130,246,0.3); }
.status-po .status-dot { background: #60a5fa; }
.status-gr { background: rgba(139,92,246,0.15); color: #a78bfa; border-color: rgba(139,92,246,0.3); }
.status-gr .status-dot { background: #a78bfa; }
.status-pi { background: rgba(16,185,129,0.15); color: #34d399; border-color: rgba(16,185,129,0.3); }
.status-pi .status-dot { background: #34d399; }

.htmx-indicator { opacity: 0; transition: opacity 200ms; }
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-request.htmx-indicator { opacity: 1; }

.btn-primary {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 1rem; border-radius: 0.5rem;
  font-size: 0.875rem; font-weight: 500;
  background: #0ea5e9; color: white;
  transition: background 150ms;
}
.btn-primary:hover { background: #0284c7; }
.btn-primary.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}
.btn-ghost {
  display: inline-flex; align-items: center;
  padding: 0.375rem 0.75rem; border-radius: 0.5rem;
  font-size: 0.8125rem; color: #d4dce6;
  border: 1px solid rgba(61,70,84,0.6);
  background: transparent;
  transition: background 150ms, color 150ms;
}
.btn-ghost:hover { background: rgba(45,52,64,0.5); color: #f1f5f9; }
.btn-ghost.btn-sm { padding: 0.3125rem 0.625rem; font-size: 0.75rem; }

.toolbar-row { min-width: 0; }
.toolbar-control {
  border-radius: 0.5rem;
  background: rgba(45, 52, 64, 0.6);
  border: 1px solid rgba(61, 70, 84, 0.8);
  font-size: 0.8125rem;
  color: #f1f5f9;
  padding: 0.375rem 0.625rem;
  outline: none;
}
.toolbar-control:focus {
  border-color: rgba(14, 165, 233, 0.5);
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.25);
}
.toolbar-select { min-width: 9rem; }
.toolbar-date { width: 8.5rem; }
.toolbar-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: 0.5rem;
  font-size: 1.125rem; line-height: 1; color: #0ea5e9;
  border: 1px solid rgba(14, 165, 233, 0.25);
  background: rgba(14, 165, 233, 0.1);
}
.toolbar-icon-btn:hover { background: rgba(14, 165, 233, 0.2); }

.file-drop-zone {
  display: block;
  padding: 1.25rem;
  border-radius: 0.5rem;
  border: 1px dashed rgba(61, 70, 84, 0.8);
  background: rgba(45, 52, 64, 0.3);
  text-align: center;
}
.file-drop-zone:hover { border-color: rgba(14, 165, 233, 0.4); background: rgba(14, 165, 233, 0.05); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

body.modal-open { overflow: hidden; }
.modal {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  opacity: 0; pointer-events: none;
  transition: opacity 200ms ease;
}
.modal.open { opacity: 1; pointer-events: auto; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}
.modal-panel {
  position: relative; z-index: 1;
  width: 100%; max-width: 24rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(61, 70, 84, 0.7);
  background: rgba(26, 31, 39, 0.98);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  transform: translateY(8px) scale(0.98);
  transition: transform 200ms ease;
}
.modal.open .modal-panel { transform: translateY(0) scale(1); }
.modal-panel-wide { max-width: 28rem; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(61, 70, 84, 0.5);
}
.modal-close {
  font-size: 1.5rem; line-height: 1; color: #c2ccd8;
  padding: 0 0.25rem;
}
.modal-close:hover { color: #f1f5f9; }
.modal-body { padding: 1.25rem; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(61, 70, 84, 0.5);
}

#aggregates-bar { margin-bottom: 0.75rem; }

.aggregate-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(61, 70, 84, 0.6);
  background: rgba(26, 31, 39, 0.7);
  backdrop-filter: blur(12px);
  font-size: 0.8125rem;
  color: #e2e8f0;
  cursor: pointer;
  transition: border-color 150ms, background 150ms, box-shadow 150ms, transform 150ms;
}
.aggregate-filter-btn:hover {
  border-color: rgba(14, 165, 233, 0.35);
  background: rgba(45, 52, 64, 0.6);
}
.aggregate-filter-btn:active {
  transform: scale(0.98);
}
.aggregate-filter-btn.active {
  box-shadow: 0 0 0 1px rgba(14, 165, 233, 0.25);
}
.aggregate-filter-all {
  font-weight: 600;
  padding: 0.375rem 1rem;
}
.aggregate-filter-all.active {
  border-color: rgba(14, 165, 233, 0.5);
  background: rgba(14, 165, 233, 0.12);
  color: #38bdf8;
}
.aggregate-filter-pr.active {
  border-color: rgba(251, 191, 36, 0.5);
  background: rgba(251, 191, 36, 0.1);
}
.aggregate-filter-po.active {
  border-color: rgba(96, 165, 250, 0.5);
  background: rgba(96, 165, 250, 0.1);
}
.aggregate-filter-gr.active {
  border-color: rgba(167, 139, 250, 0.5);
  background: rgba(167, 139, 250, 0.1);
}
.aggregate-filter-pi.active {
  border-color: rgba(52, 211, 153, 0.5);
  background: rgba(52, 211, 153, 0.1);
}
.aggregate-filter-total {
  cursor: default;
  margin-left: 0.25rem;
}

.row-warning { border-left: 2px solid #ef4444; background: rgba(239,68,68,0.05); }
.row-stuck { border-left: 2px solid #f59e0b; background: rgba(245,158,11,0.06); }

.detail-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity 200ms;
}
.detail-backdrop.open { opacity: 1; pointer-events: auto; }

.detail-panel {
  position: fixed; top: 0; right: 0; height: 100%; width: 100%; max-width: 420px;
  background: rgba(26,31,39,0.95); backdrop-filter: blur(16px);
  border-left: 1px solid rgba(61,70,84,0.6);
  padding: 1.5rem; z-index: 51; overflow-y: auto;
  transform: translateX(100%); transition: transform 250ms ease;
  box-shadow: -8px 0 30px rgba(0,0,0,0.3);
}
.detail-panel.open { transform: translateX(0); }

/* Page layout: toolbar fixed width, only data table scrolls horizontally */
.page-content {
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}
.page-toolbar {
  min-width: 0;
  max-width: 100%;
}
.data-table-scroll {
  width: 100%;
  max-width: 100%;
  overflow: auto;
  max-height: calc(100vh - 13rem);
  border-radius: 0.75rem;
  border: 1px solid rgba(61, 70, 84, 0.6);
  background: rgba(26, 31, 39, 0.7);
  backdrop-filter: blur(12px);
}
.data-table-scroll .data-table-inner {
  width: max-content;
  min-width: 100%;
}
.data-table-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(45, 52, 64, 0.98);
}
.data-table-scroll thead th.sticky-action {
  right: 0;
  z-index: 11;
}
.data-table-scroll tbody td.sticky-action {
  position: sticky;
  right: 0;
  background: rgba(26, 31, 39, 0.98);
}

/* Virtual table */
.virtual-table-root {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  position: relative;
}
.virtual-table-root.vt-busy .vt-viewport {
  opacity: 0.85;
}
.vt-loader {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  height: 2px;
  overflow: hidden;
}
.vt-loader-bar {
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, transparent, #0ea5e9, transparent);
  animation: vt-load 1s ease-in-out infinite;
}
@keyframes vt-load {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}
.vt-viewport {
  contain: layout style;
}
.vt-table {
  width: max-content;
  min-width: 100%;
}
.vt-table tbody tr:not(.vt-spacer) {
  height: 32px;
  contain: layout style paint;
}
.vt-spacer td {
  padding: 0 !important;
  border: 0 !important;
  line-height: 0;
}
.vt-sticky-action {
  position: sticky;
  right: 0;
  background: rgba(26, 31, 39, 0.98);
  z-index: 5;
}
.vt-head th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(45, 52, 64, 0.98);
}

/* Brighter text on dark backgrounds */
select option,
input::placeholder,
textarea::placeholder {
  color: #adb9c7;
}
input, select, textarea {
  color: #f1f5f9;
}
label {
  color: #c2ccd8;
}

/* Mobile responsive */
@media (max-width: 1023px) {
  .data-table-scroll {
    max-height: calc(100dvh - 14rem);
  }
  .modal-panel {
    width: calc(100% - 1.5rem);
    max-width: calc(100% - 1.5rem);
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
  }
  .modal-panel-wide {
    max-width: calc(100% - 1.5rem);
  }
  .toolbar-control {
    min-height: 2.75rem;
    font-size: 1rem;
  }
  .toolbar-date {
    width: 100%;
    max-width: 100%;
  }
  .toolbar-row {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar-row .toolbar-search {
    max-width: 100%;
    width: 100%;
  }
  .btn-primary,
  .btn-ghost {
    min-height: 2.75rem;
  }
  .nav-link {
    min-height: 2.75rem;
    padding-top: 0.625rem;
    padding-bottom: 0.625rem;
  }
}

@media (max-width: 639px) {
  .data-table-scroll {
    max-height: calc(100dvh - 15rem);
  }
}
