/* PowerTech ERP — custom styles (works with Tailwind CDN) */

:root {
  --brand: #860031;
  --brand-dark: #6b0027;
  --brand-muted: rgba(134, 0, 49, 0.08);
  --surface: #f6f6f7;
}

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--surface);
}

.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  border-radius: 0.375rem;
  transition: color 0.15s, background 0.15s;
}
.nav-link:hover,
.nav-link.active {
  color: var(--brand);
  background: var(--brand-muted);
}

/* Nav dropdown — must sit above page content (no overflow clip on parents) */
.nav-item {
  position: relative;
}
.nav-item:hover,
.nav-item:focus-within {
  z-index: 200;
}
.mega-menu {
  position: absolute;
  left: 0;
  top: 100%;
  z-index: 201;
  min-width: 14rem;
  margin-top: 0;
  padding-top: 0.25rem;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}
/* Invisible bridge so hover does not break between link and menu */
.mega-menu::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -0.5rem;
  height: 0.5rem;
}
.nav-item:hover .mega-menu,
.nav-item:focus-within .mega-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

/* Utility top bar */
.top-utility-bar {
  background: #fff;
}

.topbar-datetime {
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.topbar-datetime-line {
  font-size: 0.75rem;
  font-weight: 500;
  color: #374151;
  white-space: nowrap;
  text-align: center;
  line-height: 1.25;
}
@media (min-width: 640px) {
  .topbar-datetime-line {
    font-size: 0.875rem;
  }
}
.topbar-datetime-line .dt-day {
  color: var(--brand);
  font-weight: 600;
}
.topbar-datetime-line .dt-sep {
  color: #d1d5db;
  margin: 0 0.5rem;
}
.topbar-datetime-line .dt-time {
  color: #6b7280;
  font-variant-numeric: tabular-nums;
}

.topbar-actions {
  flex-wrap: nowrap;
}

.topbar-action-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 600;
  color: #374151;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  text-decoration: none;
}
@media (min-width: 640px) {
  .topbar-action-btn {
    padding: 0.4375rem 0.75rem;
    font-size: 0.8125rem;
  }
}
@media (min-width: 1024px) {
  .topbar-action-btn {
    padding: 0.4375rem 0.875rem;
  }
}
.topbar-action-btn:hover {
  background: var(--brand-muted);
  border-color: rgba(134, 0, 49, 0.25);
  color: var(--brand);
}
.topbar-action-btn--active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.topbar-action-btn--active:hover {
  background: var(--brand-dark);
  color: #fff;
}

.profile-dropdown.hidden {
  display: none !important;
}

/* Main nav bar — wrap, allow dropdowns to overflow */
.nav-bar {
  overflow: visible;
  position: relative;
  z-index: 30;
}

header.no-print {
  isolation: isolate;
}

#desktop-nav {
  overflow: visible;
  flex-wrap: wrap;
  position: relative;
  z-index: 31;
}

#desktop-nav .nav-link {
  font-size: 0.8125rem;
  padding: 0.375rem 0.625rem;
  white-space: nowrap;
}

/* Mobile drawer */
#mobile-drawer.hidden {
  display: none !important;
}
.mobile-accordion-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}
.mobile-accordion-panel:not(.hidden) {
  max-height: 480px;
}
.mobile-chevron.rotate-180 {
  transform: rotate(180deg);
}

.card {
  background: #fff;
  border-radius: 0.75rem;
  border: 1px solid rgba(229, 231, 235, 0.8);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.card-hover {
  transition: box-shadow 0.2s;
}
.card-hover:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #fff;
  background: var(--brand);
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover {
  background: var(--brand-dark);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  cursor: pointer;
}
.btn-secondary:hover {
  background: #f9fafb;
}

.badge-success { display: inline-flex; padding: 0.125rem 0.5rem; font-size: 0.75rem; font-weight: 500; border-radius: 9999px; background: #ecfdf5; color: #047857; }
.badge-warning { display: inline-flex; padding: 0.125rem 0.5rem; font-size: 0.75rem; font-weight: 500; border-radius: 9999px; background: #fffbeb; color: #b45309; }
.badge-danger { display: inline-flex; padding: 0.125rem 0.5rem; font-size: 0.75rem; font-weight: 500; border-radius: 9999px; background: #fef2f2; color: #b91c1c; }
.badge-info { display: inline-flex; padding: 0.125rem 0.5rem; font-size: 0.75rem; font-weight: 500; border-radius: 9999px; background: #eff6ff; color: #1d4ed8; }
.badge-brand { display: inline-flex; padding: 0.125rem 0.5rem; font-size: 0.75rem; font-weight: 500; border-radius: 9999px; background: var(--brand); color: #fff; }

.form-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
}
.form-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(134, 0, 49, 0.15);
}
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 0.25rem;
}

.sub-tab {
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #4b5563;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  cursor: pointer;
}
.sub-tab:hover { color: var(--brand); }
.sub-tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

table.dataTable thead th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  background: rgba(249, 250, 251, 0.8);
  padding: 0.75rem 1rem;
}
table.dataTable tbody td {
  font-size: 0.875rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f3f4f6;
}
table.dataTable tbody tr:hover {
  background: #fafafa;
}

.dataTables_wrapper .dataTables_filter input {
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
}

@media print {
  .no-print { display: none !important; }
}

/* ── Right canvas (short forms) ── */
.pt-canvas-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}
.pt-canvas-root.is-open {
  pointer-events: auto;
}
.pt-canvas-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.pt-canvas-root.is-open .pt-canvas-overlay {
  opacity: 1;
}
.pt-canvas-panel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(100%, 28rem);
  background: #fff;
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.pt-canvas-root.is-open .pt-canvas-panel {
  transform: translateX(0);
}
.pt-canvas-header {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid #f3f4f6;
  flex-shrink: 0;
}
.pt-canvas-header-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.625rem;
  background: rgba(134, 0, 49, 0.08);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.pt-canvas-title {
  font-size: 1.0625rem;
  font-weight: 600;
  color: #111827;
  line-height: 1.3;
}
.pt-canvas-subtitle {
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: 0.125rem;
}
.pt-canvas-close {
  width: 2rem;
  height: 2rem;
  border: none;
  background: #f3f4f6;
  border-radius: 0.5rem;
  color: #6b7280;
  cursor: pointer;
  flex-shrink: 0;
  margin-left: auto;
}
.pt-canvas-close:hover {
  background: #e5e7eb;
  color: #374151;
}
.pt-canvas-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
}
.pt-canvas-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}
.pt-canvas-field {
  width: 100%;
}
.pt-canvas-field--half {
  width: calc(50% - 0.5rem);
}
@media (max-width: 480px) {
  .pt-canvas-field--half {
    width: 100%;
  }
}
.pt-canvas-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid #f3f4f6;
  background: #fafafa;
  flex-shrink: 0;
}
body.pt-canvas-open {
  overflow: hidden;
}

.pt-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.125rem;
  background: #111827;
  color: #fff;
  border-radius: 0.625rem;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s, transform 0.25s;
}
.pt-toast.show {
  opacity: 1;
  transform: translateY(0);
}
.pt-toast i {
  color: #34d399;
}

/* ── Full form pages (product, invoice, etc.) ── */
.form-page {
  max-width: 1200px;
  margin: 0 auto;
}
.form-page-header {
  /* position: sticky; */
  top: 5.5rem;
  z-index: 20;
  background: rgba(246, 246, 247, 0.92);
  backdrop-filter: blur(8px);
  margin: -0.5rem -0.25rem 1.5rem;
  padding: 0.75rem 0.25rem;
  border-bottom: 1px solid #e5e7eb;
}
.form-page-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.5rem;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #374151;
  flex-shrink: 0;
  margin-top: 0.125rem;
}
.form-page-back:hover {
  border-color: var(--brand);
  color: var(--brand);
}
.form-section {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  margin-bottom: 1rem;
  overflow: hidden;
}
.form-section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
  background: #fafafa;
  border-bottom: 1px solid #f3f4f6;
}
.form-section-title i {
  color: var(--brand);
  opacity: 0.85;
}
.form-section-body {
  padding: 1.25rem;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem 1.25rem;
}
.form-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 768px) {
  .form-grid, .form-grid-3 {
    grid-template-columns: 1fr;
  }
}
.form-field span.required {
  color: #dc2626;
}

/* Single-card multi-section form (e.g. product form) */
.form-one-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  overflow: hidden;
}
.form-one-card .form-section {
  border: none;
  border-radius: 0;
  margin-bottom: 0;
  box-shadow: none;
}
.form-one-card .form-section + .form-section {
  border-top: 1px solid #e5e7eb;
}
.form-one-card .form-section-title {
  background: #fafafa;
  padding: 1rem 1.5rem;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-one-card .form-section-body {
  padding: 1.25rem 1.5rem 1.5rem;
}
.form-one-card-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  background: #fafafa;
  border-top: 1px solid #e5e7eb;
}
.form-field-full {
  grid-column: 1 / -1;
}
.form-hint {
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: 0.25rem;
}
.product-image-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  border: 2px dashed #d1d5db;
  border-radius: 0.75rem;
  background: #fafafa;
  color: #6b7280;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.product-image-upload:hover {
  border-color: var(--brand);
  background: rgba(134, 0, 49, 0.04);
  color: var(--brand);
}
.product-image-upload i {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
  opacity: 0.6;
}

.form-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 1rem;
  overflow-x: auto;
}
.form-tab {
  padding: 0.625rem 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #6b7280;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}
.form-tab:hover { color: var(--brand); }
.form-tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}
.form-tab-panel.hidden { display: none; }

.line-items-table {
  width: 100%;
  font-size: 0.8125rem;
}
.line-items-table th {
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
  padding: 0.625rem 0.5rem;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}
.line-items-table td {
  padding: 0.375rem 0.25rem;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: middle;
}
.line-items-table .form-input {
  padding: 0.375rem 0.5rem;
  font-size: 0.8125rem;
}
.line-items-table tfoot td {
  border-bottom: none;
  padding-top: 0.75rem;
}
.invoice-totals {
  background: #fafafa;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
}
.invoice-totals-row {
  display: flex;
  justify-content: space-between;
  padding: 0.375rem 0;
  font-size: 0.875rem;
  color: #4b5563;
}
.invoice-totals-row.grand {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--brand);
  border-top: 1px solid #e5e7eb;
  margin-top: 0.5rem;
  padding-top: 0.75rem;
}
.ledger-summary-card {
  background: linear-gradient(135deg, #860031 0%, #6b0027 100%);
  color: #fff;
  border-radius: 0.75rem;
  padding: 1.25rem;
}
.ref-screenshots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}
.ref-screenshot {
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  overflow: hidden;
  background: #fff;
}
.ref-screenshot img {
  width: 100%;
  aspect-ratio: 16/10;
  object-fit: cover;
  object-position: top;
  background: #f3f4f6;
}
.ref-screenshot figcaption {
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  color: #6b7280;
  border-top: 1px solid #f3f4f6;
}

/* ── List page toolbar (products, etc.) ── */
.page-header-block {
  margin-bottom: 1.25rem;
}
.page-header-block h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #111827;
}
.page-header-meta {
  font-size: 0.875rem;
  color: #6b7280;
  margin-top: 0.25rem;
}
.page-stats-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}
@media (min-width: 640px) {
  .page-stats-row {
    grid-template-columns: repeat(4, 1fr);
  }
}
.page-stat-pill {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.page-stat-pill i {
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  background: rgba(134, 0, 49, 0.08);
  color: var(--brand);
  font-size: 0.875rem;
  flex-shrink: 0;
}
.page-stat-pill.warning i {
  background: #fffbeb;
  color: #b45309;
}
.page-stat-pill span {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
}
.page-stat-pill strong {
  font-size: 1.125rem;
  font-weight: 600;
  color: #111827;
  line-height: 1.2;
}

.page-toolbar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
@media (min-width: 768px) {
  .page-toolbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}
.page-toolbar-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
}
.page-toolbar-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9ca3af;
  margin-right: 0.25rem;
}
.master-data-group {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  overflow: hidden;
  background: #fafafa;
}
.master-data-group .master-data-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #374151;
  background: transparent;
  border: none;
  border-right: 1px solid #e5e7eb;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.master-data-group .master-data-btn:last-child {
  border-right: none;
}
.master-data-group .master-data-btn:hover {
  background: #fff;
  color: var(--brand);
}
.master-data-group .master-data-btn i {
  font-size: 0.75rem;
  opacity: 0.7;
}
.page-toolbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.table-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #f3f4f6;
  background: #fafafa;
  border-radius: 0.75rem 0.75rem 0 0;
}
.table-card-header h2 {
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
}
.table-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.table-card .dataTables_wrapper {
  padding: 0 1rem 1rem;
}
.table-card .dataTables_wrapper .dt-buttons {
  padding-top: 0.75rem;
}
.products-table td:first-child + td + td {
  font-weight: 500;
}
.btn-table-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.375rem;
  color: #6b7280;
  border: 1px solid transparent;
  transition: all 0.15s;
}
.btn-table-action:hover {
  background: rgba(134, 0, 49, 0.08);
  color: var(--brand);
  border-color: rgba(134, 0, 49, 0.15);
}
