/* MAXEK PRIMARY BRAND COLOR PALETTE */
:root {
  --maxek-red: #E30613;
  --maxek-charcoal: #232323;
  --bg-dark-ops: #141822;
  --bg-card-dark: #1E2533;
  /* Data-entry forms — navy tint (distinct from dashboard slate) */
  --bg-form-card: #172033;
  --bg-form-card-top: #1a2744;
  --bg-form-input: #0f1829;
  --border-form: #2a4060;
  --form-accent: #3d6ea8;
  /* Data display panels — slate/charcoal (view/list, no blue accent) */
  --bg-display-panel: #1E2533;
  --bg-display-panel-top: #242d3d;
  --border-display: #2E374A;
  --text-main: #F3F4F6;
  --text-muted: #9CA3AF;
  --border-subtle: #2E374A;

  /* Layout tokens — header, subbar, content (desktop-first) */
  --layout-toolbar-height: 56px;
  --layout-toolbar-padding-x: 24px;
  --layout-content-padding: 24px;
  --layout-content-padding-compact: 16px;
  --layout-control-height: 36px;
  --layout-control-radius: 8px;
  --layout-font-toolbar: 13px;
  --layout-font-subnav: 12px;
  --layout-gap: 12px;
  --layout-section-gap: 16px;
}

.maxek-layout,
.maxek-layout * {
  box-sizing: border-box;
}

.maxek-layout [data-project-section][hidden] {
  display: none !important;
}

.maxek-layout {
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg-dark-ops);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Top-nav layout: hide legacy left rail */
.maxek-topnav-layout .tool-rail {
  display: none !important;
}

.maxek-topnav-layout {
  flex-direction: column;
}

.maxek-topnav-layout .main-window {
  width: 100%;
  max-width: 100%;
}

/* VERTICAL TOOL RAIL */
.maxek-layout .tool-rail {
  width: 238px;
  background-color: var(--maxek-charcoal);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: 16px;
  flex-shrink: 0;
}

.maxek-layout .logo-container {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.maxek-logo {
  display: block;
  object-fit: contain;
  max-width: 100%;
  height: auto;
}

.maxek-logo--sidebar {
  width: 52px;
  margin-bottom: 10px;
}

.maxek-logo--header {
  width: 28px;
  flex-shrink: 0;
}

.maxek-layout .logo-link {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-decoration: none;
  color: inherit;
}

.maxek-layout .logo-text-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.maxek-layout .logo-text-main {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: 2px;
  text-decoration: none;
}

.maxek-layout .logo-text-main span {
  color: var(--maxek-red);
}

.maxek-layout .logo-subtext {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-top: 2px;
}

.maxek-layout .action-heading {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  margin-bottom: 10px;
}

.maxek-layout .rail-btn {
  background-color: transparent;
  border: 1px solid var(--maxek-charcoal);
  color: var(--text-main);
  padding: 9px 12px;
  border-radius: 6px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  margin-bottom: 7px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
  text-decoration: none;
}

.maxek-layout .department-btn {
  min-height: 42px;
  font-weight: 650;
  position: relative;
  border-color: transparent;
}

.maxek-layout .department-btn span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.maxek-layout .department-btn.active::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 99px;
  background: #fff;
}

.maxek-layout .rail-btn i {
  color: var(--maxek-red);
  font-size: 16px;
  transition: color 0.3s ease;
}

.maxek-layout .rail-btn:hover,
.maxek-layout .rail-btn.active {
  background-color: var(--maxek-red);
  border-color: var(--maxek-red);
  color: #fff;
}

.maxek-layout .rail-btn:hover i,
.maxek-layout .rail-btn.active i {
  color: #fff;
}

.maxek-layout .rail-group {
  margin-bottom: 5px;
}

.maxek-layout .rail-group-summary {
  border: 1px solid transparent;
  color: var(--text-main);
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  width: 100%;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  list-style: none;
}

.maxek-layout .rail-group-summary::-webkit-details-marker {
  display: none;
}

.maxek-layout .rail-group-summary span {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.maxek-layout .rail-group-summary i:first-child {
  color: var(--maxek-red);
  width: 18px;
  text-align: center;
}

.maxek-layout .rail-group-chevron {
  color: var(--text-muted);
  font-size: 11px;
  transition: transform 0.2s ease, color 0.2s ease;
}

.maxek-layout .rail-group[open] .rail-group-chevron {
  transform: rotate(180deg);
}

.maxek-layout .rail-group-summary:hover,
.maxek-layout .rail-group-summary.active {
  background: rgba(227, 6, 19, 0.14);
  border-color: rgba(227, 6, 19, 0.45);
  color: #fff;
}

.maxek-layout .rail-group-summary:hover .rail-group-chevron,
.maxek-layout .rail-group-summary.active .rail-group-chevron {
  color: #fff;
}

.maxek-layout .rail-subnav {
  display: grid;
  gap: 2px;
  padding: 4px 0 7px 27px;
}

.maxek-layout .rail-subbtn {
  color: #cbd5e1;
  text-decoration: none;
  font-size: 12px;
  line-height: 1.25;
  padding: 6px 8px;
  border-left: 2px solid rgba(156, 163, 175, 0.22);
  border-radius: 0 5px 5px 0;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.maxek-layout .rail-subbtn:hover,
.maxek-layout .rail-subbtn.active {
  background: rgba(227, 6, 19, 0.12);
  border-left-color: var(--maxek-red);
  color: #fff;
}

/* MAIN DASHBOARD CONTENT WINDOW */
.maxek-layout .main-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  min-width: 0;
}

.maxek-layout .maxek-toolbar-stack {
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg-dark-ops);
  overflow: visible;
}

.maxek-layout .top-utility-strip {
  min-height: var(--layout-toolbar-height);
  height: var(--layout-toolbar-height);
  background-color: var(--bg-card-dark);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 var(--layout-toolbar-padding-x);
  gap: var(--layout-gap);
  flex-shrink: 0;
}

.maxek-layout .search-wrapper {
  position: relative;
  width: min(320px, 100%);
}

.maxek-layout .search-wrapper input {
  width: 100%;
  height: var(--layout-control-height);
  background-color: var(--bg-dark-ops);
  border: 1px solid var(--border-subtle);
  padding: 0 14px 0 36px;
  border-radius: 999px;
  color: #fff;
  font-size: var(--layout-font-toolbar);
}

.maxek-layout .search-wrapper i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
}

.maxek-layout .header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.maxek-layout .user-status-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.maxek-layout .timestamp,
.maxek-layout .header-datetime {
  font-size: var(--layout-font-toolbar);
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  height: var(--layout-control-height);
  padding: 0 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--layout-control-radius);
  background: rgba(20, 24, 34, 0.55);
  display: inline-flex;
  align-items: center;
}

.maxek-layout .rail-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 16px;
}

.maxek-layout .rail-top-row .logo-container {
  padding-bottom: 0;
  border-bottom: none;
  margin-bottom: 0;
  min-width: 0;
}

.maxek-layout .rail-close {
  display: none;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: transparent;
  color: var(--text-main);
  cursor: pointer;
}

.maxek-layout .rail-close:hover {
  border-color: var(--maxek-red);
  color: var(--maxek-red);
}

.maxek-layout .department-subbar.is-collapsed {
  display: none;
}

.maxek-layout .department-subbar-reopen {
  display: none;
  align-items: center;
  gap: 8px;
  margin: 0 var(--layout-toolbar-padding-x);
  min-height: calc(var(--layout-toolbar-height) - 12px);
  padding: 0 14px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--layout-control-radius);
  background: rgba(20, 24, 34, 0.96);
  color: var(--text-main);
  font-size: var(--layout-font-subnav);
  font-weight: 650;
  cursor: pointer;
  flex: 0 0 auto;
}

.maxek-layout .department-subbar-reopen.is-visible {
  display: inline-flex;
}

.maxek-layout .department-subbar-reopen:hover {
  border-color: var(--maxek-red);
  color: #fff;
}

.maxek-layout .department-subbar-reopen i {
  color: var(--maxek-red);
}

.maxek-layout .department-subbar-close {
  flex-shrink: 0;
  width: var(--layout-control-height);
  height: var(--layout-control-height);
  margin-left: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--layout-control-radius);
  background: transparent;
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.maxek-layout .department-subbar-close:hover {
  border-color: var(--maxek-red);
  color: var(--maxek-red);
}

.maxek-layout .alert-badge {
  position: relative;
  cursor: pointer;
  font-size: 18px;
}

.maxek-layout .alert-count {
  position: absolute;
  top: -5px;
  right: -8px;
  background-color: var(--maxek-red);
  color: #fff;
  font-size: 10px;
  font-weight: bold;
  padding: 2px 5px;
  border-radius: 50%;
}

.maxek-layout .admin-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
}

.maxek-layout .admin-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: var(--maxek-red);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  flex-shrink: 0;
}

.maxek-layout .dashboard-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--layout-content-padding);
}

.maxek-layout .section-header {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 25px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.maxek-layout .section-header span {
  color: var(--maxek-red);
}

.maxek-layout .analytics-grid {
  display: grid;
  grid-template-columns: 1.5fr 2fr 1.2fr;
  gap: 25px;
  margin-bottom: 30px;
}

.maxek-layout .panel-card {
  background-color: var(--bg-card-dark);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 20px;
}

.maxek-layout .panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.maxek-layout .chart-box {
  height: 180px;
  border: 2px dashed var(--border-subtle);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.maxek-layout .kpi-tile-row {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.maxek-layout .compact-tile {
  background-color: var(--bg-dark-ops);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--maxek-red);
  padding: 12px 15px;
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.maxek-layout .tile-meta p {
  font-size: 12px;
  color: var(--text-muted);
}

.maxek-layout .tile-meta h3 {
  font-size: 20px;
  font-weight: 700;
  margin-top: 2px;
}

.maxek-layout .data-grid-container {
  background-color: var(--bg-card-dark);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 25px;
}

.maxek-layout .grid-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.maxek-layout .erp-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.maxek-layout .erp-table th {
  padding: 14px;
  border-bottom: 2px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 13px;
  text-transform: uppercase;
}

.maxek-layout .erp-table td {
  padding: 14px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 14px;
}

.maxek-layout .erp-table a {
  color: var(--text-main);
  text-decoration: none;
}

.maxek-layout .erp-table a:hover {
  color: var(--maxek-red);
}

.maxek-layout .status-pill {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  display: inline-block;
}

.maxek-layout .status-pill.active {
  background-color: rgba(16, 185, 129, 0.2);
  color: #10B981;
}

.maxek-layout .status-pill.pending {
  background-color: rgba(245, 158, 11, 0.2);
  color: #F59E0B;
}

.maxek-layout .status-pill.empty {
  background-color: rgba(156, 163, 175, 0.2);
  color: var(--text-muted);
}

.maxek-layout .logout-link {
  color: var(--text-muted);
  font-size: 13px;
  text-decoration: none;
}

.maxek-layout .logout-link:hover {
  color: var(--maxek-red);
}

/* ── ENTERPRISE MODULE SYSTEM (Phase 2) ── */

.maxek-layout .sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 90;
}

.maxek-layout .sidebar-overlay.visible {
  display: block;
}

.maxek-layout .header-left {
  display: flex;
  align-items: center;
  gap: var(--layout-gap);
  min-width: 0;
  flex: 1;
}

.maxek-layout .sidebar-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  width: var(--layout-control-height);
  height: var(--layout-control-height);
  border-radius: var(--layout-control-radius);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.maxek-layout .header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.maxek-layout .header-logo {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--text-main);
  text-decoration: none;
  white-space: nowrap;
}

.maxek-layout .header-brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .maxek-layout .header-brand-sub {
    display: none;
  }
}

.maxek-layout .header-logo span {
  color: var(--maxek-red);
}

.maxek-layout .branch-select {
  background: var(--bg-dark-ops);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  height: var(--layout-control-height);
  padding: 0 12px;
  border-radius: var(--layout-control-radius);
  font-size: var(--layout-font-toolbar);
  min-width: 150px;
}

.maxek-layout .header-icon-btn {
  position: relative;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  width: var(--layout-control-height);
  height: var(--layout-control-height);
  border-radius: var(--layout-control-radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 15px;
}

.maxek-layout .header-icon-btn:hover {
  border-color: var(--maxek-red);
  color: var(--maxek-red);
}

.maxek-layout .header-logout-btn {
  min-height: var(--layout-control-height);
  height: var(--layout-control-height);
  padding: 0 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--layout-control-radius);
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-size: var(--layout-font-toolbar);
  font-weight: 700;
  white-space: nowrap;
}

.maxek-layout .header-logout-btn:hover {
  border-color: var(--maxek-red);
  color: #fff;
}

.maxek-layout .header-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--maxek-red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.maxek-layout .profile-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--layout-control-height);
  padding: 0 10px 0 4px;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  cursor: pointer;
  font-size: var(--layout-font-toolbar);
  font-weight: 600;
}

.maxek-layout .erp-field-with-action {
  align-items: stretch;
  gap: 10px;
}

.maxek-layout .erp-inline-action {
  border: 1px solid var(--border-subtle);
  background: var(--bg-dark-ops);
  color: var(--text-main);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  white-space: nowrap;
}

.maxek-layout .erp-inline-action:hover {
  border-color: var(--maxek-red);
  color: #fff;
}

.maxek-layout .erp-modal[hidden] {
  display: none;
}

.maxek-layout .erp-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.maxek-layout .erp-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.58);
}

.maxek-layout .erp-modal-card {
  position: relative;
  width: min(760px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: var(--bg-card-dark);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.36);
}

.maxek-layout .erp-modal-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.maxek-layout .erp-modal-header h3 {
  margin: 0 0 5px;
  font-size: 20px;
}

.maxek-layout .erp-modal-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.maxek-layout .erp-modal-close {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: transparent;
  color: var(--text-main);
  cursor: pointer;
  flex: 0 0 auto;
}

.maxek-layout .employee-detail-modal {
  width: min(940px, 100%);
}

.maxek-layout .employee-detail-layout {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 18px;
  align-items: start;
}

.maxek-layout .employee-detail-photo {
  width: 132px;
  height: 132px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border-subtle);
  background: var(--bg-dark-ops);
}

.maxek-layout .employee-detail-photo-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 42px;
}

.maxek-layout .attendance-worker-verify-panel {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--bg-dark-ops);
}

.maxek-layout .attendance-worker-verify-panel .employee-detail-photo {
  width: 96px;
  height: 96px;
}

.maxek-layout .attendance-worker-verify-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.maxek-layout .attendance-worker-verify-meta strong {
  font-size: 15px;
  color: var(--text-primary);
}

.maxek-layout .attendance-worker-verify-meta span {
  font-size: 13px;
  color: var(--text-muted);
}

.maxek-layout .attendance-worker-verify-hint {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.maxek-layout .employee-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.maxek-layout .employee-detail-grid div {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
}

.maxek-layout .employee-detail-grid span {
  display: block;
  margin-bottom: 4px;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
}

.maxek-layout .employee-detail-grid strong {
  color: var(--text-main);
  font-size: 14px;
  word-break: break-word;
}

.maxek-layout .employee-document-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  color: var(--text-muted);
  font-size: 13px;
}

.maxek-layout .employee-document-links a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 11px;
  color: var(--text-main);
  text-decoration: none;
}

.maxek-layout .employee-document-links a:hover {
  border-color: var(--maxek-red);
  color: var(--maxek-red);
}

.maxek-layout .employee-detail-actions {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.maxek-layout .erp-link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent-primary, #4da3ff);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.maxek-layout .erp-link-btn:hover {
  color: var(--text-main);
}

.maxek-layout .project-hub-card {
  width: min(1080px, 100%);
}

.maxek-layout .project-hub-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.maxek-layout .project-hub-stat {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px 14px;
}

.maxek-layout .project-hub-stat span {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.maxek-layout .project-hub-stat strong {
  font-size: 18px;
  color: var(--text-main);
}

.maxek-layout .project-hub-section {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
  background: rgba(0, 0, 0, 0.12);
}

.maxek-layout .project-hub-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.maxek-layout .project-hub-section-head h4 {
  margin: 0;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.maxek-layout .project-hub-section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.maxek-layout .project-hub-table-scroll {
  max-height: 220px;
}

.maxek-layout .erp-table-compact th,
.maxek-layout .erp-table-compact td {
  padding: 8px 10px;
  font-size: 13px;
}

.maxek-layout .project-hub-empty {
  color: var(--text-muted);
  font-style: italic;
}

.maxek-layout .project-hub-muted {
  color: var(--text-muted);
  font-size: 13px;
}

.maxek-layout .project-hub-footer {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.maxek-layout .staff-component-row,
.maxek-layout .staff-travel-row {
  grid-template-columns: minmax(140px, 1.4fr) minmax(120px, 1.2fr) minmax(100px, 1fr) auto;
  align-items: end;
}

.maxek-layout .staff-component-row .staff-component-custom-field[hidden] {
  display: none;
}

.maxek-layout .staff-increment-card {
  margin-top: 1rem;
}

.maxek-layout .staff-increment-history {
  margin-bottom: 1rem;
}

.maxek-layout .staff-increment-form {
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle, #e2e8f0);
}

.maxek-layout .erp-form-hint {
  color: var(--text-muted, #64748b);
  font-size: 13px;
  margin: 0 0 0.75rem;
}

.maxek-layout .rail-nav-scroll {
  flex: 1;
  overflow-y: auto;
  margin-right: -8px;
  padding-right: 8px;
}

.maxek-layout .department-subbar {
  display: flex;
  align-items: center;
  gap: var(--layout-gap);
  min-height: var(--layout-toolbar-height);
  height: var(--layout-toolbar-height);
  padding: 0 var(--layout-toolbar-padding-x);
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(20, 24, 34, 0.96);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
  flex: 0 0 auto;
  position: relative;
  z-index: 30;
}

.maxek-layout .department-subbar-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-size: var(--layout-font-toolbar);
  font-weight: 800;
  min-width: 0;
  max-width: 200px;
  padding-right: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
}

.maxek-layout .department-subbar-title i {
  color: var(--maxek-red);
}

.maxek-layout .department-subbar-scroll {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
  min-width: 0;
  flex: 1;
  height: 100%;
}

.maxek-layout .department-subbar-link {
  display: inline-flex;
  align-items: center;
  height: calc(var(--layout-control-height) - 4px);
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #cbd5e1;
  font-size: var(--layout-font-subnav);
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.maxek-layout .department-subbar-link:hover,
.maxek-layout .department-subbar-link.active {
  color: #fff;
  background: rgba(227, 6, 19, 0.15);
  border-color: rgba(227, 6, 19, 0.45);
}

.maxek-layout .erp-sub-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: calc(var(--layout-toolbar-height) - 8px);
  padding: 0 var(--layout-toolbar-padding-x);
  margin: 0;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(30, 37, 51, 0.98);
}

.maxek-layout .erp-sub-toolbar--secondary {
  min-height: calc(var(--layout-toolbar-height) - 10px);
  padding-top: 4px;
  padding-bottom: 4px;
  background: rgba(24, 28, 38, 0.98);
  border-bottom: 1px solid rgba(46, 55, 74, 0.9);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.maxek-layout .erp-sub-toolbar--secondary::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 18px;
  margin-right: 2px;
  border-radius: 99px;
  background: var(--maxek-red);
  flex-shrink: 0;
}

.maxek-layout .erp-sub-toolbar-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: calc(var(--layout-control-height) - 6px);
  padding: 0 10px;
  border-radius: 6px;
  font-size: var(--layout-font-subnav);
  font-weight: 650;
  color: #cbd5e1;
  text-decoration: none;
  border: 1px solid transparent;
  white-space: nowrap;
}

.maxek-layout .erp-sub-toolbar-link i {
  font-size: 0.78rem;
  color: var(--maxek-red);
  opacity: 0.95;
}

.maxek-layout .erp-sub-toolbar-link:hover,
.maxek-layout .erp-sub-toolbar-link.active {
  color: #fff;
  background: rgba(227, 6, 19, 0.15);
  border-color: rgba(227, 6, 19, 0.45);
}

.maxek-layout .erp-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--layout-gap);
}

.maxek-layout .erp-summary-grid--stats {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.maxek-layout .erp-stat-card {
  background: var(--bg-card-dark);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--maxek-red);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 64px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.maxek-layout .erp-stat-card span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
}

.maxek-layout .erp-stat-card strong {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.maxek-layout .erp-stat-card strong small {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.maxek-layout .erp-notice-bar {
  margin-bottom: 1rem;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(59, 130, 246, 0.35);
  background: rgba(30, 58, 138, 0.18);
  color: #dbeafe;
  font-size: 13px;
  line-height: 1.5;
}

.maxek-layout .erp-notice-bar a {
  color: #93c5fd;
  font-weight: 600;
}

.maxek-layout .erp-notice-bar a:hover {
  color: #fff;
}

.maxek-layout .erp-module-section {
  margin-top: 0.25rem;
}

.maxek-layout .erp-module-section-title {
  margin: 0 0 0.65rem;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.maxek-layout .erp-module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
}

.maxek-layout .erp-module-tile {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card-dark);
  color: var(--text-main);
  text-decoration: none;
  transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.15s ease;
}

.maxek-layout .erp-module-tile:hover {
  border-color: rgba(227, 6, 19, 0.55);
  background: rgba(30, 37, 51, 0.95);
  transform: translateY(-1px);
}

.maxek-layout .erp-module-tile-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(227, 6, 19, 0.12);
  color: var(--maxek-red);
  font-size: 15px;
  flex-shrink: 0;
}

.maxek-layout .erp-module-tile-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.maxek-layout .erp-module-tile-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
}

.maxek-layout .erp-module-tile-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.maxek-layout .erp-module-tile-chevron {
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0.7;
}

.maxek-layout .erp-summary-grid--compact {
  gap: 0.65rem;
}

.maxek-layout .erp-table-toolbar--compact {
  padding: 0.35rem 0;
  gap: 0.45rem;
}

.maxek-layout .help-topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}

.maxek-layout .help-topic-card .erp-form-title {
  margin-bottom: 0.35rem;
  font-size: 0.95rem;
}

.maxek-layout .help-topic-category {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  margin-bottom: 0.25rem;
}

.maxek-layout .help-topic-desc {
  margin: 0 0 0.65rem;
  font-size: 0.85rem;
  color: #475569;
  line-height: 1.45;
}

.maxek-layout .help-topic-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.maxek-layout .help-contact-list {
  margin: 0.75rem 0 0;
  display: grid;
  gap: 0.55rem;
}

.maxek-layout .help-contact-list div {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.maxek-layout .help-contact-list dt {
  margin: 0;
  font-weight: 700;
  color: #64748b;
}

.maxek-layout .help-contact-list dd {
  margin: 0;
  color: #1f2937;
}

.maxek-layout .department-hub {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - (var(--layout-toolbar-height) * 2) - (var(--layout-content-padding) * 2));
  padding: var(--layout-content-padding);
}

.maxek-layout .department-hub-card {
  max-width: 420px;
  width: 100%;
  padding: 36px 32px;
  border-radius: 18px;
  border: 1px solid var(--border-subtle);
  background: rgba(20, 24, 34, 0.88);
  text-align: center;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
}

.maxek-layout .department-hub-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin-bottom: 18px;
  border-radius: 16px;
  background: rgba(227, 6, 19, 0.12);
  color: var(--maxek-red);
  font-size: 26px;
}

.maxek-layout .department-hub-card h2 {
  margin: 0 0 10px;
  color: #fff;
  font-size: 24px;
  font-weight: 800;
}

.maxek-layout .department-hub-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

.maxek-layout .page-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--layout-gap);
  margin-bottom: var(--layout-section-gap);
  flex-wrap: wrap;
}

.maxek-layout .page-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
  line-height: 1.25;
}

.maxek-layout .breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
}

.maxek-layout .breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
}

.maxek-layout .breadcrumb a:hover {
  color: var(--maxek-red);
}

.maxek-layout .page-header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.maxek-layout .erp-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

.maxek-layout .erp-btn-primary {
  background: var(--maxek-red);
  color: #fff;
  border-color: var(--maxek-red);
}

.maxek-layout .erp-btn-primary:hover {
  filter: brightness(1.08);
  color: #fff;
}

.maxek-layout .erp-btn-ghost {
  background: transparent;
  color: var(--text-main);
  border-color: var(--border-subtle);
}

.maxek-layout .erp-btn-ghost:hover {
  border-color: var(--maxek-red);
  color: var(--maxek-red);
}

.maxek-layout .erp-btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

/* Standard vertical data-entry screen: toolbar → form → table */
.maxek-layout .erp-module-layout {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.maxek-layout .erp-module-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(180deg, var(--bg-display-panel-top) 0%, var(--bg-display-panel) 100%);
  border: 1px solid var(--border-display);
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

.maxek-layout .erp-module-toolbar-search {
  position: relative;
  flex: 1 1 220px;
  max-width: 420px;
  min-width: 180px;
}

.maxek-layout .erp-module-toolbar-search > i,
.maxek-layout .erp-module-toolbar-search-form > i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
  pointer-events: none;
  z-index: 1;
}

.maxek-layout .erp-module-toolbar-search input,
.maxek-layout .erp-module-toolbar-search-form input {
  width: 100%;
  background: var(--bg-dark-ops);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  border-radius: 8px;
  padding: 8px 12px 8px 34px;
  font-size: 13px;
}

.maxek-layout .erp-module-toolbar-search-form {
  position: relative;
  margin: 0;
}

.maxek-layout .erp-module-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.maxek-layout .erp-module-form-panel {
  margin: 0;
}

.maxek-layout .erp-module-table-panel {
  margin: 0;
}

.maxek-layout .erp-module-table-panel--hidden {
  display: none;
}

@media print {
  .maxek-layout .erp-module-toolbar,
  .maxek-layout .erp-module-form-panel,
  .maxek-layout .page-actions,
  .maxek-layout .tool-rail,
  .maxek-layout .maxek-top-nav,
  .maxek-layout #department-subbar {
    display: none !important;
  }

  .maxek-layout .erp-module-table-panel {
    border: none;
    box-shadow: none;
  }

  body.erp-print-table-only .maxek-layout > *:not(.main-window),
  body.erp-print-table-only .main-window > *:not(.dashboard-body),
  body.erp-print-table-only .dashboard-body > *:not(:has(.erp-print-focus)) {
    display: none !important;
  }

  body.erp-print-table-only .erp-print-focus {
    display: block !important;
    border: none;
    box-shadow: none;
  }
}

.maxek-layout .module-layout {
  display: grid;
  grid-template-columns: minmax(320px, 380px) 1fr;
  gap: 24px;
  align-items: start;
}

.maxek-layout .erp-module-layout.module-layout--stacked {
  display: flex;
  flex-direction: column;
}

.maxek-layout .module-layout.module-layout--list-only {
  grid-template-columns: 1fr;
}

.maxek-layout .worker-module-layout {
  grid-template-columns: minmax(300px, 400px) minmax(0, 1fr);
  gap: 20px;
}

.maxek-layout .worker-module-layout .worker-form-card {
  align-self: start;
}

.maxek-layout .worker-form-card {
  padding: 16px 18px;
}

.maxek-layout .worker-form-card .erp-form-title {
  font-size: 16px;
  margin-bottom: 12px;
}

.maxek-layout .worker-form-grid--compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}

.maxek-layout .worker-form-grid--compact .erp-form-actions {
  margin-top: 2px;
}

.maxek-layout .worker-form-grid--compact .erp-field input,
.maxek-layout .worker-form-grid--compact .erp-field select {
  min-height: 40px;
  padding: 8px 10px;
  font-size: 13px;
}

.maxek-layout .worker-form-grid--compact .erp-field input[type="file"] {
  min-height: 40px;
  padding: 6px 10px;
  font-size: 12px;
}

.maxek-layout .worker-form-grid--compact .erp-field label {
  font-size: 11px;
}

.maxek-layout .worker-rate-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(20, 24, 34, 0.55);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.35;
}

.maxek-layout .worker-rate-summary[hidden] {
  display: none;
}

.maxek-layout .worker-rate-summary-label {
  flex: 0 0 100%;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.maxek-layout .worker-rate-pill strong {
  font-weight: 600;
  color: var(--text-main);
  margin-right: 4px;
}

.maxek-layout .settings-module-layout {
  grid-template-columns: minmax(280px, 360px) minmax(420px, 1fr);
}

.maxek-layout .settings-module-layout #department-master {
  max-width: 360px;
}

.maxek-layout .settings-module-layout #department-master .erp-form-grid {
  grid-template-columns: 1fr;
}

.maxek-layout .settings-module-layout #department-master .span-2,
.maxek-layout .settings-module-layout #department-master .erp-form-actions {
  grid-column: span 1;
}

/* Module / data-entry pages — navy form surfaces (dashboard keeps --bg-card-dark) */
.maxek-layout:not(.dashboard-mode) .main-window {
  background: #111722;
}

.maxek-layout:not(.dashboard-mode) .dashboard-body {
  background: transparent;
}

.maxek-layout .erp-form-card {
  background: linear-gradient(180deg, var(--bg-form-card-top) 0%, var(--bg-form-card) 100%);
  color: var(--text-main);
  border: 1px solid var(--border-form);
  border-left: 3px solid var(--form-accent);
  border-radius: 10px;
  padding: 16px 18px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.maxek-layout .erp-form-card--compact {
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.maxek-layout .erp-form-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--text-main);
}

.maxek-layout .erp-form-subtitle {
  margin: 0.5rem 0 0.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
}

.maxek-layout .erp-hint {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.maxek-layout .maker-row {
  padding: 0.75rem;
  border: 1px solid var(--border-form);
  border-radius: 8px;
  background: rgba(15, 24, 41, 0.65);
  color: var(--text-main);
}

.maxek-layout .boq-module-layout {
  grid-template-columns: 1fr;
}

.maxek-layout .dpr-module-layout {
  grid-template-columns: 1fr;
}

.maxek-layout .dpr-attach-scroll {
  overflow-x: auto;
}

.maxek-layout .dpr-attach-table {
  min-width: 880px;
}

.maxek-layout .dpr-attach-actions {
  white-space: nowrap;
  min-width: 11rem;
}

.maxek-layout .boq-lines-table {
  table-layout: auto;
  min-width: 760px;
}

.maxek-layout .boq-lines-table .boq-col-no {
  width: 3rem;
}

.maxek-layout .boq-lines-table .boq-col-desc {
  min-width: 240px;
  width: 38%;
}

.maxek-layout .boq-lines-table .boq-col-qty,
.maxek-layout .boq-lines-table .boq-col-rate {
  min-width: 7.5rem;
  width: 7.5rem;
}

.maxek-layout .boq-lines-table .boq-col-unit {
  min-width: 7rem;
  width: 7rem;
}

.maxek-layout .boq-lines-table .boq-col-amount {
  min-width: 8rem;
  width: 8rem;
}

.maxek-layout .boq-lines-table .boq-col-actions {
  width: 3.5rem;
}

.maxek-layout .boq-lines-table .boq-input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.45rem 0.5rem;
  font-size: 0.875rem;
  background: #fff;
  color: #111827;
}

.maxek-layout .boq-lines-table .boq-desc {
  min-height: 3.25rem;
  resize: vertical;
  line-height: 1.35;
}

.maxek-layout .boq-lines-table .boq-qty,
.maxek-layout .boq-lines-table .boq-rate {
  min-width: 5.5rem;
  text-align: right;
}

.maxek-layout .boq-lines-table .boq-amount {
  background: #f8fafc;
  font-weight: 600;
  text-align: right;
}

.maxek-layout .boq-lines-table td {
  vertical-align: middle;
}

.maxek-layout .erp-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.maxek-layout .erp-form-grid--compact {
  gap: 10px 12px;
}

.maxek-layout .erp-form-grid .span-2 {
  grid-column: span 2;
}

.maxek-layout .erp-form-actions {
  grid-column: span 2;
  margin-top: 4px;
}

.maxek-layout .erp-field {
  display: flex;
  flex-direction: column-reverse;
  gap: 6px;
}

.maxek-layout .erp-field input:not([type="checkbox"]):not([type="radio"]),
.maxek-layout .erp-field select,
.maxek-layout .erp-field textarea {
  width: 100%;
  border: 1px solid var(--border-form);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  background: var(--bg-form-input);
  color: var(--text-main);
  min-height: 42px;
}

.maxek-layout .erp-field input::placeholder,
.maxek-layout .erp-field textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.75;
}

.maxek-layout .erp-field input[type="date"],
.maxek-layout .erp-field input[type="month"],
.maxek-layout .erp-field input[type="datetime-local"] {
  color-scheme: dark;
}

.maxek-layout .erp-field select option {
  background: var(--bg-form-card);
  color: var(--text-main);
}

.maxek-layout .coa-entry-panel .coa-options-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.25rem;
  align-items: center;
  padding-top: 4px;
}

.maxek-layout .coa-entry-panel .coa-check {
  position: static;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  pointer-events: auto;
}

.maxek-layout .coa-entry-panel .coa-check input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  min-height: 0;
  margin: 0;
  padding: 0;
  accent-color: var(--maxek-red);
}

.maxek-layout .erp-field input[type="file"] {
  min-height: 42px;
  padding: 8px 12px;
}

.maxek-layout .erp-field textarea {
  min-height: 88px;
  resize: vertical;
}

.maxek-layout .erp-field label {
  position: static;
  display: block;
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-muted);
  pointer-events: none;
  transition: color 0.2s ease;
}

.maxek-layout .erp-field input:focus,
.maxek-layout .erp-field select:focus,
.maxek-layout .erp-field textarea:focus,
.maxek-layout .erp-field input.has-value,
.maxek-layout .erp-field select.has-value,
.maxek-layout .erp-field textarea.has-value,
.maxek-layout .erp-field input:not(:placeholder-shown),
.maxek-layout .erp-field textarea:not(:placeholder-shown) {
  border-color: var(--maxek-red);
  outline: none;
  box-shadow: 0 0 0 1px rgba(227, 6, 19, 0.25);
}

.maxek-layout .erp-field:focus-within label {
  color: var(--maxek-red);
}

.maxek-layout .erp-field.erp-field-with-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  gap: 6px 10px;
  align-items: stretch;
}

.maxek-layout .erp-field.erp-field-with-action label {
  grid-column: 1 / -1;
  grid-row: 1;
}

.maxek-layout .erp-field.erp-field-with-action select,
.maxek-layout .erp-field.erp-field-with-action input:not([type="checkbox"]):not([type="radio"]) {
  grid-column: 1;
  grid-row: 2;
}

.maxek-layout .erp-field.erp-field-with-action .erp-inline-action {
  grid-column: 2;
  grid-row: 2;
  align-self: stretch;
}

.maxek-layout .erp-field-auto-number {
  display: flex;
  flex-direction: column-reverse;
  gap: 6px;
  border: 1px solid var(--border-form);
  border-radius: 8px;
  background: var(--bg-form-input);
  min-height: auto;
  padding: 0;
}

.maxek-layout .erp-field-auto-number:focus-within {
  border-color: var(--maxek-red);
  box-shadow: 0 0 0 1px rgba(227, 6, 19, 0.25);
}

.maxek-layout .erp-field-auto-number label {
  position: static;
  display: block;
  margin: 0;
  padding: 0 12px;
  padding-top: 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-muted);
}

.maxek-layout .erp-field-auto-number:focus-within label {
  color: var(--maxek-red);
}

.maxek-layout .erp-auto-number {
  display: block;
  width: 100%;
  padding: 10px 12px 12px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-main);
  letter-spacing: 0.02em;
}

.maxek-layout .erp-validation {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--maxek-red);
  background: rgba(227, 6, 19, 0.12);
  color: #fecaca;
  font-size: 14px;
}

.maxek-layout .erp-table-panel {
  background: linear-gradient(180deg, var(--bg-display-panel-top) 0%, var(--bg-display-panel) 100%);
  border: 1px solid var(--border-display);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.16);
}

/* Module pages: table/list panels stay slate — forms use navy + blue accent */
.maxek-layout:not(.dashboard-mode) .erp-table-panel {
  background: linear-gradient(180deg, var(--bg-display-panel-top) 0%, var(--bg-display-panel) 100%);
  border: 1px solid var(--border-display);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.16);
}

.maxek-layout:not(.dashboard-mode) .data-grid-container {
  background: linear-gradient(180deg, var(--bg-display-panel-top) 0%, var(--bg-display-panel) 100%);
  border: 1px solid var(--border-display);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.16);
}

.maxek-layout .erp-table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--layout-gap);
  min-height: var(--layout-toolbar-height);
  padding: 0 var(--layout-content-padding);
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.maxek-layout .erp-table-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.maxek-layout .erp-table-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.maxek-layout .erp-table-search {
  position: relative;
}

.maxek-layout .erp-table-search i {
  position: absolute;
  left: 12px;
  top: 11px;
  color: var(--text-muted);
  font-size: 13px;
}

.maxek-layout .erp-table-search input {
  background: var(--bg-dark-ops);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  border-radius: 8px;
  padding: 8px 12px 8px 34px;
  min-width: 220px;
  font-size: 13px;
}

.maxek-layout .erp-table-scroll {
  overflow-x: auto;
}

.maxek-layout .erp-table-module {
  border-radius: 0;
}

.maxek-layout .erp-table-module thead th {
  position: sticky;
  top: 0;
  background: var(--bg-display-panel-top);
  z-index: 2;
}

.maxek-layout .erp-table-panel .erp-table-toolbar {
  border-bottom-color: var(--border-display);
}

.maxek-layout .erp-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  font-size: 13px;
  color: var(--text-muted);
}

.maxek-layout .erp-page-buttons {
  display: flex;
  gap: 8px;
}

.maxek-layout .approval-badge,
.maxek-layout .status-pill {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  display: inline-block;
  white-space: nowrap;
}

.maxek-layout .approval-draft { background: rgba(156, 163, 175, 0.2); color: #9ca3af; }
.maxek-layout .approval-pending-checker { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.maxek-layout .approval-pending,
.maxek-layout .approval-pending-approval { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.maxek-layout .approval-approved,
.maxek-layout .approval-active,
.maxek-layout .approval-present,
.maxek-layout .approval-paid { background: rgba(16, 185, 129, 0.2); color: #10b981; }
.maxek-layout .approval-rejected,
.maxek-layout .approval-inactive,
.maxek-layout .approval-absent { background: rgba(239, 68, 68, 0.2); color: #ef4444; }

.maxek-layout .workflow-role-badge {
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.maxek-layout .role-maker { background: rgba(99, 102, 241, 0.2); color: #818cf8; }
.maxek-layout .role-checker { background: rgba(14, 165, 233, 0.2); color: #38bdf8; }
.maxek-layout .role-approver { background: rgba(227, 6, 19, 0.2); color: #f87171; }

.maxek-layout .approval-widgets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 30px;
}

.maxek-layout .approval-widget {
  background: var(--bg-card-dark);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--maxek-red);
  border-radius: 8px;
  padding: 18px 20px;
}

.maxek-layout .approval-widget h4 {
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 8px;
}

.maxek-layout .approval-widget .count {
  font-size: 28px;
  font-weight: 700;
}

.maxek-layout a.approval-widget:hover {
  border-color: var(--maxek-red);
}

.maxek-layout .workflow-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.maxek-layout .workflow-inline-form {
  display: inline;
  margin: 0;
}

.maxek-layout .workflow-hint {
  font-size: 12px;
  color: var(--maxek-muted, #888);
  font-style: italic;
}

.maxek-layout .dashboard-counter-section {
  margin-bottom: 24px;
}

.maxek-layout .counter-section-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.maxek-layout .counter-grid {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

.maxek-layout .approval-history-panel {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 16px;
  margin-top: 8px;
}

.maxek-layout .approval-history-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}

.maxek-layout .approval-history-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 16px;
  font-size: 13px;
}

.maxek-layout .approval-history-grid .label {
  display: block;
  font-size: 11px;
  opacity: 0.7;
  text-transform: uppercase;
}

.maxek-layout .approval-history-grid .span-2 {
  grid-column: span 2;
}

.maxek-layout .rejection-notice {
  border-left: 3px solid var(--maxek-red);
  margin: 12px 0;
}

.maxek-layout .reject-modal[hidden] {
  display: none;
}

.maxek-layout .reject-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.maxek-layout .reject-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}

.maxek-layout .reject-modal-card {
  position: relative;
  background: var(--maxek-panel, #1a1a1a);
  border-radius: 12px;
  padding: 24px;
  min-width: 360px;
  max-width: 90vw;
  z-index: 1;
}

.maxek-layout .notification-unread {
  font-weight: 600;
}

.maxek-layout .transaction-tab-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: rgba(24, 28, 38, 0.98);
  border-bottom: 1px solid var(--border-subtle);
}

.maxek-layout .transaction-tab {
  background: rgba(30, 37, 51, 0.85);
  border: 1px solid transparent;
  color: #cbd5e1;
  padding: 8px 16px;
  cursor: pointer;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.maxek-layout .transaction-tab:hover {
  color: #fff;
  background: rgba(227, 6, 19, 0.1);
  border-color: rgba(227, 6, 19, 0.35);
}

.maxek-layout .transaction-tab.active {
  color: #fff;
  background: rgba(227, 6, 19, 0.18);
  border-color: rgba(227, 6, 19, 0.45);
  border-bottom-color: var(--maxek-red);
}

/* Data-entry / module tab bar — navy theme (distinct from dashboard slate) */
.maxek-layout .erp-form-card--tabs {
  background: linear-gradient(180deg, var(--bg-form-card-top) 0%, var(--bg-form-card) 100%);
  color: var(--text-main);
  border: 1px solid var(--border-form);
  border-left: 3px solid var(--form-accent);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.maxek-layout .erp-tab-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.maxek-layout .erp-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 650;
  color: #cbd5e1;
  background: rgba(23, 32, 51, 0.92);
  border: 1px solid var(--border-form);
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.maxek-layout .erp-tab:hover {
  color: #fff;
  background: rgba(227, 6, 19, 0.12);
  border-color: rgba(227, 6, 19, 0.4);
}

.maxek-layout .erp-tab.active {
  color: #fff;
  background: rgba(227, 6, 19, 0.2);
  border-color: var(--maxek-red);
  box-shadow: inset 0 -2px 0 var(--maxek-red);
}

.maxek-layout .erp-tab .erp-badge {
  background: var(--maxek-red);
  color: #fff;
  border-radius: 999px;
  padding: 0 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  margin-left: 0.15rem;
}

.maxek-layout .erp-btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.maxek-layout .erp-form-card--tabs .erp-btn-ghost {
  background: rgba(23, 32, 51, 0.92);
  color: #cbd5e1;
  border-color: var(--border-form);
}

.maxek-layout .erp-form-card--tabs .erp-btn-ghost:hover {
  color: #fff;
  background: rgba(227, 6, 19, 0.12);
  border-color: rgba(227, 6, 19, 0.4);
}

.maxek-layout .erp-form-card--tabs .erp-btn-primary {
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.15);
}

.maxek-layout .transaction-tab-panel {
  display: none;
}

.maxek-layout .transaction-tab-panel.active {
  display: block;
}

.maxek-layout .approval-timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.maxek-layout .approval-timeline-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.maxek-layout .approval-timeline-marker {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 6px;
  background: var(--maxek-red, #c0392b);
  flex-shrink: 0;
}

.maxek-layout .approval-timeline-body {
  flex: 1;
  font-size: 13px;
}

.maxek-layout .approval-timeline-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  opacity: 0.85;
  font-size: 12px;
  margin-top: 4px;
}

.maxek-layout .approval-timeline-remarks {
  margin: 6px 0 0;
  font-size: 12px;
  opacity: 0.9;
}

.maxek-layout .approval-active {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
}

.maxek-layout .module-stack {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.maxek-layout .flash-messages {
  margin-bottom: 20px;
}

/* ── DASHBOARD HOME (dark ERP theme) ── */

.maxek-layout.dashboard-mode .main-window {
  background: var(--bg-dark-ops);
  overflow: hidden;
}

.maxek-layout.dashboard-mode .dashboard-body {
  padding: var(--layout-content-padding-compact) var(--layout-content-padding);
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.maxek-layout.dashboard-mode .dash-context-bar {
  display: flex;
  align-items: center;
  gap: var(--layout-section-gap);
  flex-wrap: wrap;
  background: var(--bg-card-dark);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 0;
}

.maxek-layout.dashboard-mode .dash-project-select {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 160px;
}

.maxek-layout.dashboard-mode .dash-project-select label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.maxek-layout.dashboard-mode .dash-select {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  background: var(--bg-dark-ops);
  color: var(--text-main);
}

.maxek-layout.dashboard-mode .dash-select-sm {
  padding: 7px 10px;
  font-size: 12px;
}

.maxek-layout.dashboard-mode .dash-progress-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
}

.maxek-layout.dashboard-mode .dash-progress-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
}

.maxek-layout.dashboard-mode .dash-progress-track {
  flex: 1;
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.maxek-layout.dashboard-mode .dash-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--maxek-red), #f97316);
  border-radius: 999px;
}

.maxek-layout.dashboard-mode .dash-progress-pct {
  font-size: 13px;
  font-weight: 700;
  color: var(--maxek-red);
}

.maxek-layout.dashboard-mode .dash-quick-links {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.maxek-layout.dashboard-mode .dash-quick-links a {
  font-size: 13px;
  color: #93c5fd;
  text-decoration: none;
  font-weight: 500;
}

.maxek-layout.dashboard-mode .dash-quick-links a:hover {
  color: #fff;
  text-decoration: underline;
}

.maxek-layout.dashboard-mode .dash-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--layout-gap);
  margin-bottom: 0;
}

.maxek-layout.dashboard-mode .dash-kpi-card {
  background: var(--bg-card-dark);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.maxek-layout.dashboard-mode .dash-kpi-card-accent {
  border-color: rgba(227, 6, 19, 0.45);
}

.maxek-layout.dashboard-mode .dash-kpi-card .tile-meta p {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

.maxek-layout.dashboard-mode .dash-kpi-card .tile-meta h3 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-main);
  margin: 4px 0 2px;
  line-height: 1;
}

.maxek-layout.dashboard-mode .dash-kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.maxek-layout.dashboard-mode .dash-kpi-icon {
  font-size: 22px;
  color: rgba(227, 6, 19, 0.55);
  margin-top: 4px;
}

.maxek-layout.dashboard-mode .dash-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--layout-gap);
  margin-bottom: 0;
}

.maxek-layout.dashboard-mode .dash-chart-card {
  background: var(--bg-card-dark);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.maxek-layout.dashboard-mode .dash-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  gap: 12px;
}

.maxek-layout.dashboard-mode .dash-chart-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.maxek-layout.dashboard-mode .dash-chart-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.maxek-layout.dashboard-mode .dash-badge {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  font-weight: 600;
}

.maxek-layout.dashboard-mode .dash-badge-green {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
}

.maxek-layout.dashboard-mode .dash-health-layout {
  display: flex;
  align-items: center;
  gap: 28px;
}

.maxek-layout.dashboard-mode .dash-donut {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: conic-gradient(
    #10b981 0deg 130deg,
    #f59e0b 130deg 200deg,
    #3b82f6 200deg 300deg,
    rgba(255, 255, 255, 0.12) 300deg 360deg
  );
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.maxek-layout.dashboard-mode .dash-donut-inner {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: var(--bg-card-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 800;
  color: var(--text-main);
  box-shadow: inset 0 0 0 1px var(--border-subtle);
}

.maxek-layout.dashboard-mode .dash-health-bars {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.maxek-layout.dashboard-mode .dash-health-item-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-main);
  margin-bottom: 6px;
}

.maxek-layout.dashboard-mode .dash-health-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.maxek-layout.dashboard-mode .dash-health-fill {
  height: 100%;
  border-radius: 999px;
}

.maxek-layout.dashboard-mode .dash-bar-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  height: 180px;
  padding-top: 10px;
}

.maxek-layout.dashboard-mode .dash-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  gap: 8px;
}

.maxek-layout.dashboard-mode .dash-bar {
  width: 100%;
  max-width: 36px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, #14b8a6, #0ea5e9);
  min-height: 8px;
}

.maxek-layout.dashboard-mode .dash-bar-col:nth-child(2) .dash-bar { background: linear-gradient(180deg, #f59e0b, #ef4444); }
.maxek-layout.dashboard-mode .dash-bar-col:nth-child(3) .dash-bar { background: linear-gradient(180deg, #10b981, #059669); }
.maxek-layout.dashboard-mode .dash-bar-col:nth-child(4) .dash-bar { background: linear-gradient(180deg, #6366f1, #8b5cf6); }
.maxek-layout.dashboard-mode .dash-bar-col:nth-child(5) .dash-bar { background: linear-gradient(180deg, #ec4899, #f43f5e); }
.maxek-layout.dashboard-mode .dash-bar-col:nth-child(6) .dash-bar { background: linear-gradient(180deg, #3b82f6, #2563eb); }
.maxek-layout.dashboard-mode .dash-bar-col:nth-child(7) .dash-bar { background: linear-gradient(180deg, #8b5cf6, #6366f1); }

.maxek-layout.dashboard-mode .dash-bar-col span {
  font-size: 11px;
  color: var(--text-muted);
}

.maxek-layout.dashboard-mode .dash-table-panel {
  background: var(--bg-card-dark);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.maxek-layout.dashboard-mode .dash-table-panel .erp-table-toolbar {
  background: transparent;
  border-bottom: 1px solid var(--border-subtle);
}

.maxek-layout.dashboard-mode .dash-table-panel .erp-table-title {
  color: var(--text-main);
}

.maxek-layout.dashboard-mode .dash-workflow-table th {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}

.maxek-layout.dashboard-mode .dash-workflow-table td {
  color: var(--text-main);
  border-bottom: 1px solid var(--border-subtle);
}

.maxek-layout.dashboard-mode .dash-workflow-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.maxek-layout.dashboard-mode .dash-action-link {
  color: #93c5fd;
  font-weight: 600;
  text-decoration: none;
}

.maxek-layout.dashboard-mode .dash-action-link:hover {
  color: #fff;
  text-decoration: underline;
}

@media (max-width: 1200px) {
  .maxek-layout.dashboard-mode .dash-charts-row {
    grid-template-columns: 1fr;
  }

  .maxek-layout.dashboard-mode .dash-kpi-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {
  .maxek-layout.dashboard-mode .dash-kpi-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .maxek-layout.dashboard-mode .dash-charts-row {
    grid-template-columns: 1fr;
  }

  .maxek-layout.dashboard-mode .dash-health-layout {
    flex-direction: column;
  }
}

@media (max-width: 600px) {
  .maxek-layout.dashboard-mode .dash-kpi-row {
    grid-template-columns: 1fr;
  }
}

/* Login standalone */
.maxek-login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-dark-ops);
  padding: 24px;
}

.maxek-login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card-dark);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 32px;
}

.maxek-login-card h1 {
  text-align: center;
  margin: 0 0 8px;
  font-size: 28px;
}

.maxek-login-card h1 span {
  color: var(--maxek-red);
}

.maxek-login-card .subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 28px;
  font-size: 13px;
}

.maxek-login-card .erp-field {
  position: relative;
  margin-bottom: 16px;
}

.maxek-login-card .erp-field input {
  width: 100%;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 16px 12px 8px;
  font-size: 14px;
  background: var(--bg-dark-ops);
  color: var(--text-main);
}

.maxek-login-card .erp-field label {
  position: absolute;
  left: 12px;
  top: 14px;
  font-size: 13px;
  color: var(--text-muted);
  pointer-events: none;
  transition: all 0.2s ease;
}

.maxek-login-card .erp-field input:focus,
.maxek-login-card .erp-field input:not(:placeholder-shown) {
  border-color: var(--maxek-red);
  outline: none;
}

.maxek-login-card .erp-field input:focus + label,
.maxek-login-card .erp-field input:not(:placeholder-shown) + label {
  top: 4px;
  font-size: 11px;
  color: var(--maxek-red);
}

@media (max-width: 1100px) {
  .maxek-layout.dashboard-mode .dash-two-col {
    grid-template-columns: 1fr;
  }
}

/* Dashboard v2 sections */
.maxek-layout.dashboard-mode .dash-hero {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
}

.maxek-layout.dashboard-mode .dash-hero-text h2 {
  margin: 0 0 6px;
  font-size: 1.75rem;
  color: var(--text-main);
}

.maxek-layout.dashboard-mode .dash-hero-text p {
  margin: 0;
  color: var(--text-muted);
}

.maxek-layout.dashboard-mode .dash-hero-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.maxek-layout.dashboard-mode .dash-badge-count {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  margin-left: 6px;
}

.maxek-layout.dashboard-mode .section-header {
  color: var(--text-main);
}

.maxek-layout.dashboard-mode .counter-section-title {
  color: var(--text-main);
}

.maxek-layout.dashboard-mode a.approval-widget {
  color: var(--text-main);
  text-decoration: none;
}

.maxek-layout.dashboard-mode a.approval-widget:hover {
  color: #fff;
}

.maxek-layout.dashboard-mode .dash-section {
  margin-bottom: 28px;
}

.maxek-layout.dashboard-mode .dash-summary-grid {
  grid-template-columns: repeat(5, 1fr);
}

.maxek-layout.dashboard-mode .dash-summary-card {
  text-align: center;
  padding: 20px 12px;
}

.maxek-layout.dashboard-mode .dash-summary-card i {
  font-size: 1.25rem;
  opacity: 0.7;
  margin-bottom: 8px;
  display: block;
}

.maxek-layout.dashboard-mode .dash-two-col {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 20px;
  margin-bottom: 28px;
}

.maxek-layout.dashboard-mode .dash-panel {
  background: var(--bg-card-dark, #1e293b);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 16px 20px;
}

.maxek-layout.dashboard-mode .dash-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.maxek-layout.dashboard-mode .dash-panel-head h3 {
  margin: 0;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.maxek-layout.dashboard-mode .dash-panel-head a {
  font-size: 13px;
  color: var(--maxek-red, #ef4444);
  text-decoration: none;
}

.maxek-layout.dashboard-mode .dash-activity-feed,
.maxek-layout.dashboard-mode .dash-notif-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.maxek-layout.dashboard-mode .dash-activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 14px;
}

.maxek-layout.dashboard-mode .dash-activity-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.maxek-layout.dashboard-mode .dash-activity-meta {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.maxek-layout.dashboard-mode .dash-activity-remarks {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 2px;
}

.maxek-layout.dashboard-mode .dash-activity-empty,
.maxek-layout.dashboard-mode .dash-notif-empty {
  color: var(--text-muted);
  font-size: 14px;
  padding: 12px 0;
}

.maxek-layout.dashboard-mode .dash-side-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.maxek-layout.dashboard-mode .dash-notif-item {
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 13px;
}

.maxek-layout.dashboard-mode .dash-notif-item.unread {
  border-left: 3px solid var(--maxek-red, #ef4444);
  padding-left: 10px;
}

.maxek-layout.dashboard-mode .dash-notif-item span {
  display: block;
  color: var(--text-muted);
  margin-top: 2px;
}

.maxek-layout.dashboard-mode .dash-notif-item small {
  color: var(--text-muted);
  font-size: 11px;
}

.maxek-layout.dashboard-mode .dash-approval-links {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.maxek-layout.dashboard-mode .dash-approval-links a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}

.maxek-layout.dashboard-mode .dash-approval-links a:hover {
  background: rgba(255,255,255,0.08);
}

.maxek-layout.dashboard-mode .dash-approval-links strong {
  font-size: 1.25rem;
  color: var(--maxek-red, #ef4444);
}

.maxek-layout.dashboard-mode .dash-counter-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.maxek-layout.dashboard-mode .dash-counter-grid {
  grid-template-columns: repeat(2, 1fr);
}

.maxek-layout.dashboard-mode .dash-kpi-compact {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1100px) {
  .maxek-layout.dashboard-mode .dash-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .maxek-layout.dashboard-mode .dash-counter-tabs {
    grid-template-columns: 1fr;
  }

  .maxek-layout.dashboard-mode .dash-kpi-compact {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1100px) {
  .maxek-layout .analytics-grid {
    grid-template-columns: 1fr;
  }

  .maxek-layout .module-layout {
    grid-template-columns: 1fr;
  }

  .maxek-layout .approval-widgets {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .maxek-layout .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .maxek-layout .tool-rail {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .maxek-layout .tool-rail.open {
    transform: translateX(0);
  }

  .maxek-layout .search-wrapper {
    width: 100%;
    max-width: 280px;
  }

  .maxek-layout .header-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .maxek-layout .profile-chip span {
    display: none;
  }

  .maxek-layout .header-logout-btn span {
    display: none;
  }

  .maxek-layout .header-logout-btn {
    width: var(--layout-control-height);
    justify-content: center;
    padding: 0;
  }

  .maxek-layout .top-utility-strip {
    height: auto;
    min-height: var(--layout-toolbar-height);
    flex-wrap: wrap;
    gap: var(--layout-gap);
    padding: 10px var(--layout-content-padding-compact);
  }

  .maxek-layout .department-subbar {
    height: auto;
    min-height: var(--layout-toolbar-height);
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 10px var(--layout-content-padding-compact);
  }

  .maxek-layout .department-subbar-scroll {
    width: 100%;
  }

  .maxek-layout .tool-rail.open .rail-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .maxek-layout .header-datetime {
    font-size: 11px;
    padding: 5px 8px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .maxek-layout .dashboard-body {
    padding: var(--layout-content-padding-compact);
  }

  .maxek-layout.dashboard-mode .dashboard-body {
    padding: var(--layout-content-padding-compact);
  }

  .maxek-layout .erp-form-grid {
    grid-template-columns: 1fr;
  }

  .maxek-layout .erp-form-grid .span-2,
  .maxek-layout .erp-form-actions {
    grid-column: span 1;
  }

  .maxek-layout .worker-module-layout {
    grid-template-columns: 1fr;
  }

  .maxek-layout .worker-form-grid--compact .span-2,
  .maxek-layout .worker-form-grid .span-2 {
    grid-column: span 1;
  }

  .maxek-layout .erp-field.erp-field-with-action {
    grid-template-columns: 1fr;
  }

  .maxek-layout .erp-field.erp-field-with-action .erp-inline-action {
    grid-column: 1;
    grid-row: 3;
  }

  .maxek-layout .erp-inline-action {
    min-height: var(--layout-control-height);
    justify-content: center;
  }

  .maxek-layout .employee-detail-layout {
    grid-template-columns: 1fr;
  }

  .maxek-layout .employee-detail-photo {
    width: 96px;
    height: 96px;
  }

  .maxek-layout .project-hub-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* DPR measurement entry */
.maxek-layout .dpr-dimension-group {
  margin-bottom: 0.75rem;
}

.maxek-layout .dpr-dimension-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.maxek-layout .dpr-reading-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.maxek-layout .dpr-reading-row input {
  flex: 1;
  min-width: 0;
}

.maxek-layout .dpr-steel-line {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px dashed var(--erp-border, #e2e8f0);
}

/* ── Dashboard single-screen tabs (Overview / Operations) ── */

.maxek-layout.dashboard-mode .header-datetime {
  color: var(--text-muted);
  background: rgba(20, 24, 34, 0.55);
  border-color: var(--border-subtle);
}

.maxek-layout.dashboard-mode .dash-header-zone {
  display: flex;
  flex-direction: column;
  gap: var(--layout-gap);
  flex-shrink: 0;
}

.maxek-layout.dashboard-mode .dash-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--layout-gap);
  overflow: hidden;
}

.maxek-layout.dashboard-mode .dash-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--layout-gap);
  flex-wrap: wrap;
  flex-shrink: 0;
  min-height: var(--layout-control-height);
}

.maxek-layout.dashboard-mode .dash-hero-text {
  min-width: 0;
  flex: 1;
}

.maxek-layout.dashboard-mode .dash-top-row h2 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.maxek-layout.dashboard-mode .dash-top-row p {
  margin: 2px 0 0;
  font-size: var(--layout-font-subnav);
  color: var(--text-muted);
  line-height: 1.35;
}

.maxek-layout.dashboard-mode .dash-top-row-minimal {
  align-items: center;
}

.maxek-layout.dashboard-mode .dash-tab-bar-inline {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.maxek-layout.dashboard-mode .dash-settings-btn {
  flex-shrink: 0;
}

.maxek-layout.dashboard-mode .dash-context-compact {
  margin-bottom: 0;
  padding: 10px 14px;
  flex-shrink: 0;
}

.maxek-layout.dashboard-mode .dash-tab-bar {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-subtle);
  min-height: calc(var(--layout-control-height) + 2px);
  align-items: flex-end;
}

.maxek-layout.dashboard-mode .dash-tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--layout-font-toolbar);
  font-weight: 700;
  padding: 8px 14px 6px;
  border-radius: 8px 8px 0 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  min-height: var(--layout-control-height);
}

.maxek-layout.dashboard-mode .dash-tab:hover {
  color: var(--text-main);
  background: rgba(227, 6, 19, 0.08);
}

.maxek-layout.dashboard-mode .dash-tab.active {
  color: var(--text-main);
  border-bottom-color: var(--maxek-red);
  background: rgba(227, 6, 19, 0.1);
}

.maxek-layout.dashboard-mode .dash-tab-panels {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.maxek-layout.dashboard-mode .dash-tab-panel {
  display: none;
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  flex-direction: column;
  gap: var(--layout-gap);
  padding-right: 2px;
  scrollbar-width: thin;
}

.maxek-layout.dashboard-mode .dash-tab-panel.active {
  display: flex;
}

.maxek-layout.dashboard-mode .dash-kpi-compact {
  grid-template-columns: repeat(4, 1fr);
  gap: var(--layout-gap);
  margin-bottom: 0;
}

.maxek-layout.dashboard-mode .dash-kpi-compact .dash-kpi-card {
  padding: 10px 12px;
  border-radius: 10px;
}

.maxek-layout.dashboard-mode .dash-kpi-compact .tile-meta h3 {
  font-size: 20px;
}

.maxek-layout.dashboard-mode .dash-charts-compact {
  gap: var(--layout-gap);
  margin-bottom: 0;
}

.maxek-layout.dashboard-mode .dash-charts-compact .dash-chart-card {
  padding: 12px 14px;
  border-radius: 10px;
}

.maxek-layout.dashboard-mode .dash-bar-chart-compact {
  height: 96px;
}

.maxek-layout.dashboard-mode .dash-donut-compact {
  width: 88px;
  height: 88px;
}

.maxek-layout.dashboard-mode .dash-donut-compact .dash-donut-inner {
  width: 54px;
  height: 54px;
  font-size: 18px;
}

.maxek-layout.dashboard-mode .dash-health-compact {
  gap: 14px;
}

.maxek-layout.dashboard-mode .dash-summary-compact {
  grid-template-columns: repeat(5, 1fr);
  gap: var(--layout-gap);
  margin-bottom: 0;
}

.maxek-layout.dashboard-mode .dash-summary-compact .approval-widget,
.maxek-layout.dashboard-mode .dash-summary-compact .dash-summary-card {
  background: var(--bg-card-dark);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  text-decoration: none;
}

.maxek-layout.dashboard-mode .dash-summary-compact .approval-widget h4 {
  color: var(--text-muted);
}

.maxek-layout.dashboard-mode .dash-summary-compact .approval-widget .count {
  color: var(--text-main);
}

.maxek-layout.dashboard-mode .dash-summary-compact .dash-summary-card {
  padding: 10px 8px;
}

.maxek-layout.dashboard-mode .dash-summary-compact .count {
  font-size: 22px;
}

.maxek-layout.dashboard-mode .dash-ops-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  grid-template-rows: minmax(120px, 1fr) auto;
  gap: var(--layout-gap);
  min-height: min-content;
  flex: 1;
}

.maxek-layout.dashboard-mode .dash-ops-grid > .dash-panel {
  min-height: 0;
}

.maxek-layout.dashboard-mode .dash-ops-grid > .dash-table-compact {
  grid-column: 1 / -1;
}

.maxek-layout.dashboard-mode .dash-panel-light {
  background: var(--bg-card-dark);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 12px 14px;
  border-radius: 10px;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.maxek-layout.dashboard-mode .dash-panel-light .dash-panel-head h3 {
  color: var(--text-main);
  font-size: 0.92rem;
}

.maxek-layout.dashboard-mode .dash-panel-light .dash-panel-head a {
  color: #f87171;
}

.maxek-layout.dashboard-mode .dash-panel-light .dash-activity-item {
  border-bottom-color: var(--border-subtle);
  padding: 8px 0;
  font-size: 13px;
  color: var(--text-main);
}

.maxek-layout.dashboard-mode .dash-panel-light .dash-activity-meta,
.maxek-layout.dashboard-mode .dash-panel-light .dash-notif-item span,
.maxek-layout.dashboard-mode .dash-panel-light .dash-notif-item small,
.maxek-layout.dashboard-mode .dash-panel-light .dash-activity-empty,
.maxek-layout.dashboard-mode .dash-panel-light .dash-notif-empty {
  color: var(--text-muted);
}

.maxek-layout.dashboard-mode .dash-panel-light .dash-activity-icon {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.maxek-layout.dashboard-mode .dash-panel-light .dash-notif-item {
  border-bottom-color: var(--border-subtle);
  padding: 8px 0;
}

.maxek-layout.dashboard-mode .dash-panel-light .dash-notif-item.unread {
  border-left-color: var(--maxek-red);
}

.maxek-layout.dashboard-mode .dash-panel-light .dash-approval-links a {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.maxek-layout.dashboard-mode .dash-panel-light .dash-approval-links a:hover {
  background: rgba(255, 255, 255, 0.08);
}

.maxek-layout.dashboard-mode .dash-panel-light .dash-approval-links strong {
  color: var(--maxek-red);
}

.maxek-layout.dashboard-mode .dash-scroll-region {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.maxek-layout.dashboard-mode .dash-scroll-region-sm {
  max-height: 140px;
}

.maxek-layout.dashboard-mode .dash-table-compact {
  padding: 0;
}

.maxek-layout.dashboard-mode .dash-table-compact .erp-table-toolbar {
  min-height: auto;
  padding: 10px 14px;
}

.maxek-layout.dashboard-mode .dash-table-compact .erp-table th,
.maxek-layout.dashboard-mode .dash-table-compact .erp-table td {
  padding: 8px 10px;
  font-size: 12px;
}

.maxek-layout.dashboard-mode .dash-table-compact .erp-table-scroll {
  max-height: none;
  overflow: visible;
}

.maxek-layout.dashboard-mode .section-header {
  font-size: 15px;
  margin-bottom: 8px;
  color: var(--text-main);
}

.maxek-layout .dash-display-toggles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px 16px;
}

.maxek-layout .dash-display-toggles label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-main);
  line-height: 1.3;
}

.maxek-layout .dash-display-hint {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--text-muted);
}

.maxek-layout .dash-display-modal-card {
  max-width: 520px;
}

.maxek-layout .dash-display-form .erp-form-actions {
  margin-top: 16px;
}

@media (max-width: 1200px) {
  .maxek-layout.dashboard-mode .dash-summary-compact {
    grid-template-columns: repeat(3, 1fr);
  }

  .maxek-layout.dashboard-mode .dash-ops-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    overflow-y: auto;
  }

  .maxek-layout.dashboard-mode .dash-tab-panel.active {
    overflow-y: auto;
  }
}

@media (max-width: 900px) {
  .maxek-layout.dashboard-mode .dash-kpi-compact {
    grid-template-columns: repeat(2, 1fr);
  }

  .maxek-layout.dashboard-mode .dash-charts-compact {
    grid-template-columns: 1fr;
  }

  .maxek-layout.dashboard-mode .dash-summary-compact {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Approvals — compact list & detail */
.approval-tab-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.approvals-compact-table td,
.approvals-compact-table th {
  white-space: nowrap;
}

.approval-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.approval-detail-ref {
  margin: 0.25rem 0 0;
  color: var(--erp-muted, #64748b);
}

.approval-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem 1.25rem;
  margin-bottom: 1rem;
}

.approval-detail-grid .detail-label {
  display: block;
  font-size: 0.75rem;
  color: var(--erp-muted, #64748b);
  margin-bottom: 0.15rem;
}

.approval-detail-actions {
  flex-wrap: wrap;
  gap: 0.5rem;
}

.dash-workflow-summary {
  padding: 0.75rem 1rem;
  margin: 0;
  font-size: 0.9rem;
}

.maxek-layout .erp-guarantee-row {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--border-form);
  border-radius: 8px;
  background: rgba(15, 24, 41, 0.45);
}

.maxek-layout .erp-row-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-primary, #6ea8fe);
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(110, 168, 254, 0.12);
}

.maxek-layout .erp-treasury-section {
  margin-top: 4px;
  background: rgba(15, 24, 41, 0.55);
}

.maxek-layout .erp-bill-submission-panel {
  margin-bottom: 8px;
}

.maxek-layout .erp-bill-submission-row {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--border-form);
  border-radius: 8px;
  background: rgba(15, 24, 41, 0.35);
}

.maxek-layout .erp-pending-bill-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.maxek-layout .erp-pending-bill-summary span {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.maxek-layout .erp-pending-bill-summary strong {
  font-size: 16px;
  color: var(--text-main);
}

/* ── TOP HORIZONTAL NAV (MAXEK UI Standard) ── */

.maxek-topnav-layout .maxek-toolbar-stack {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.maxek-top-nav {
  background: var(--maxek-charcoal);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  overflow: visible;
}

.maxek-top-nav--horizontal {
  display: block;
  position: relative;
  z-index: 50;
  overflow: visible;
}

.maxek-top-nav--drawer {
  display: none;
  flex: 1;
  overflow: auto;
  background: transparent;
  border: 0;
}

.maxek-top-nav-list {
  list-style: none;
  margin: 0;
  padding: 0 8px;
  display: flex;
  align-items: stretch;
  gap: 2px;
  overflow-x: auto;
  overflow-y: visible;
  flex-wrap: nowrap;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.maxek-top-nav--drawer .maxek-top-nav-list {
  flex-direction: column;
  padding: 8px 12px 16px;
  overflow-x: hidden;
}

.maxek-top-nav-item {
  position: relative;
  flex-shrink: 0;
}

.maxek-top-nav--horizontal .maxek-top-nav-item.has-children:hover,
.maxek-top-nav--horizontal .maxek-top-nav-item.has-children:focus-within,
.maxek-top-nav--horizontal .maxek-top-nav-item.has-children.is-open {
  z-index: 80;
}

.maxek-top-nav--drawer .maxek-top-nav-item {
  width: 100%;
}

.maxek-top-nav-link,
.maxek-top-nav-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--text-main);
  font-size: var(--layout-font-toolbar);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.maxek-top-nav--drawer .maxek-top-nav-link,
.maxek-top-nav--drawer .maxek-top-nav-trigger {
  width: 100%;
  height: auto;
  min-height: 42px;
  border-radius: 6px;
  justify-content: flex-start;
}

.maxek-top-nav-link i,
.maxek-top-nav-trigger i:first-child {
  color: var(--maxek-red);
  font-size: 14px;
}

.maxek-top-nav-link:hover,
.maxek-top-nav-trigger:hover,
.maxek-top-nav-item.is-active > .maxek-top-nav-link,
.maxek-top-nav-item.is-active > .maxek-top-nav-trigger,
.maxek-top-nav-link.active,
.maxek-top-nav-trigger.active {
  background: rgba(227, 6, 19, 0.15);
  color: #fff;
}

.maxek-top-nav-chevron {
  font-size: 10px;
  margin-left: 2px;
  opacity: 0.7;
  transition: transform 0.2s ease;
}

.maxek-top-nav-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 220px;
  max-width: 320px;
  max-height: 70vh;
  overflow: auto;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0 8px 8px 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  z-index: 200;
  padding: 6px 0;
}

.maxek-top-nav--drawer .maxek-top-nav-dropdown {
  position: static;
  display: none;
  min-width: 0;
  max-width: none;
  max-height: none;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  box-shadow: none;
  margin: 4px 0 8px 12px;
  padding: 4px 0;
}

.maxek-top-nav--horizontal .maxek-top-nav-dropdown {
  position: fixed;
  top: var(--maxek-dropdown-top, auto);
  left: var(--maxek-dropdown-left, auto);
  right: auto;
  bottom: auto;
  margin-top: 0;
}

.maxek-top-nav-item.has-children:hover > .maxek-top-nav-dropdown,
.maxek-top-nav-item.has-children:focus-within > .maxek-top-nav-dropdown,
.maxek-top-nav-item.has-children.is-open > .maxek-top-nav-dropdown {
  display: block;
}

.maxek-top-nav-item.has-children:hover .maxek-top-nav-chevron,
.maxek-top-nav-item.has-children:focus-within .maxek-top-nav-chevron,
.maxek-top-nav-item.has-children.is-open .maxek-top-nav-chevron {
  transform: rotate(180deg);
}

.maxek-top-nav-dropdown-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  color: #1f2937;
  font-size: 13px;
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.maxek-top-nav--drawer .maxek-top-nav-dropdown-link {
  color: var(--text-main);
}

.maxek-top-nav-dropdown-link:hover,
.maxek-top-nav-dropdown-link.active {
  background: rgba(227, 6, 19, 0.08);
  color: var(--maxek-red);
}

.maxek-top-nav-dropdown-link i {
  width: 16px;
  text-align: center;
  color: var(--maxek-red);
  font-size: 12px;
}

.maxek-mobile-nav {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(320px, 88vw);
  z-index: 100;
  background: var(--maxek-charcoal);
  border-right: 1px solid var(--border-subtle);
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
}

.maxek-mobile-nav.open {
  display: flex;
  transform: translateX(0);
}

.maxek-mobile-nav.open .maxek-top-nav--drawer {
  display: block;
}

.maxek-mobile-nav-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.maxek-mobile-nav-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
}

.maxek-topnav-layout .sidebar-toggle {
  display: none;
}

/* Module toolbar macro */
.erp-module-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  background: var(--bg-card-dark);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
}

.erp-module-toolbar-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.erp-module-toolbar-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
}

.erp-module-toolbar-search {
  position: relative;
  min-width: 200px;
  flex: 1;
  max-width: 360px;
}

.erp-module-toolbar-search i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
}

.erp-module-toolbar-search input {
  width: 100%;
  height: var(--layout-control-height);
  padding: 0 12px 0 34px;
  border-radius: var(--layout-control-radius);
  border: 1px solid var(--border-subtle);
  background: var(--bg-dark-ops);
  color: var(--text-main);
  font-size: var(--layout-font-toolbar);
}

.erp-module-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Dashboard live tables & quick entry */
.maxek-layout.dashboard-mode .dash-page-simple {
  overflow: auto;
}

.maxek-layout.dashboard-mode .dash-welcome-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--layout-gap);
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.maxek-layout.dashboard-mode .dash-welcome-row h2 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-main);
}

.maxek-layout.dashboard-mode .dash-welcome-row p {
  margin: 2px 0 0;
  font-size: var(--layout-font-subnav);
  color: var(--text-muted);
}

.maxek-layout.dashboard-mode .dash-ref-kpi-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.maxek-layout.dashboard-mode .dash-ref-kpi-card {
  background: var(--bg-card-dark);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-height: 88px;
}

.maxek-layout.dashboard-mode .dash-ref-kpi-card p {
  margin: 0 0 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
}

.maxek-layout.dashboard-mode .dash-ref-kpi-card h3 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
}

.maxek-layout.dashboard-mode .dash-ref-kpi-card .dash-ref-kpi-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 11px;
  color: var(--maxek-red);
  text-decoration: none;
}

.maxek-layout.dashboard-mode .dash-ref-kpi-icon {
  font-size: 22px;
  opacity: 0.35;
  color: var(--maxek-red);
}

.maxek-layout.dashboard-mode .dash-quick-entry {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
  background: var(--bg-card-dark);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
}

.maxek-layout.dashboard-mode .dash-quick-entry-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-right: 4px;
}

.maxek-layout.dashboard-mode .dash-quick-entry .erp-btn {
  font-size: 12px;
}

.maxek-layout.dashboard-mode .dash-live-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.maxek-layout.dashboard-mode .dash-live-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.maxek-layout.dashboard-mode .dash-live-panel-full {
  min-height: 200px;
}

.maxek-layout.dashboard-mode .dash-live-panel {
  background: var(--bg-card-dark);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 220px;
}

.maxek-layout.dashboard-mode .dash-live-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.maxek-layout.dashboard-mode .dash-live-panel-head h3 {
  margin: 0;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.maxek-layout.dashboard-mode .dash-live-panel .erp-table-scroll {
  flex: 1;
  overflow: auto;
}

.maxek-layout.dashboard-mode .dash-live-panel .erp-table {
  font-size: 12px;
}

.maxek-layout.dashboard-mode .dash-live-panel .erp-table th,
.maxek-layout.dashboard-mode .dash-live-panel .erp-table td {
  padding: 8px 10px;
}

@media (max-width: 1400px) {
  .maxek-layout.dashboard-mode .dash-ref-kpi-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  .maxek-layout.dashboard-mode .dash-ref-kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .maxek-layout.dashboard-mode .dash-live-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .maxek-topnav-layout .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .maxek-top-nav--horizontal {
    display: none;
  }

  .maxek-layout .search-wrapper {
    width: 100%;
    max-width: 280px;
  }
}

@media (max-width: 640px) {
  .maxek-layout.dashboard-mode .dash-ref-kpi-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
