:root {
  --primary-navy: #0f172a;
  --primary-blue: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary-blue: #38bdf8;
  --accent-cyan: #06b6d4;
  --bg-main: #f6f8fb;
  --card-bg: #ffffff;
  --border-color: #e8ecf2;
  --border-focus: #3b82f6;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active-bg: rgba(37, 99, 235, 0.15);
  --sidebar-active-text: #60a5fa;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 4px 16px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 10px 25px -3px rgba(15, 23, 42, 0.08), 0 4px 10px -2px rgba(15, 23, 42, 0.04);
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Sarabun', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* App Layout */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
  width: 260px;
  background-color: var(--sidebar-bg);
  color: #fff;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-brand {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #2563eb, #38bdf8);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.brand-text h1 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  color: #f8fafc;
  letter-spacing: -0.3px;
}

.brand-text p {
  font-size: 11px;
  color: #94a3b8;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-menu {
  padding: 16px 12px;
  flex: 1;
  overflow-y: auto;
}

.menu-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #64748b;
  padding: 12px 12px 6px 12px;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  color: var(--sidebar-text);
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 13.5px;
  text-decoration: none;
  transition: all 0.2s ease;
  margin-bottom: 3px;
  gap: 12px;
}

.nav-link i {
  font-size: 16px;
  width: 20px;
  text-align: center;
  color: #64748b;
  transition: color 0.2s;
}

.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: #f8fafc;
}

.nav-link:hover i {
  color: #38bdf8;
}

.nav-link.active {
  background-color: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 600;
}

.nav-link.active i {
  color: #60a5fa;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #475569, #334155);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #fff;
}

.user-info {
  flex: 1;
  overflow: hidden;
}

.user-info .user-name {
  font-size: 13px;
  font-weight: 600;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-info .user-role {
  font-size: 11px;
  color: #94a3b8;
}

/* Main Container */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
}

/* Navbar */
.app-header {
  height: 68px;
  background-color: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 99;
}

.header-search {
  position: relative;
  width: 380px;
}

.header-search input {
  width: 100%;
  padding: 9px 14px 9px 40px;
  background-color: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 13.5px;
  transition: all 0.2s;
}

.header-search input:focus {
  background-color: #fff;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  outline: none;
}

.header-search i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background-color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-icon:hover {
  background-color: #f8fafc;
  color: var(--primary-blue);
  border-color: #cbd5e1;
}

.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

/* Content Area */
.app-content {
  padding: 28px;
  flex: 1;
}

/* Page Header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary-navy);
  margin: 0;
  letter-spacing: -0.4px;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Enterprise Cards */
.card-modern {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 24px;
  transition: box-shadow 0.2s;
}

.card-modern:hover {
  box-shadow: var(--shadow-md);
}

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

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-navy);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Metrics Dashboard Cards */
.metric-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.metric-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.metric-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary-navy);
  margin: 6px 0 2px 0;
  letter-spacing: -0.5px;
}

.metric-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.icon-blue { background-color: #eff6ff; color: #2563eb; }
.icon-amber { background-color: #fffbeb; color: #d97706; }
.icon-purple { background-color: #faf5ff; color: #9333ea; }
.icon-emerald { background-color: #ecfdf5; color: #059669; }
.icon-rose { background-color: #fff1f2; color: #e11d48; }
.icon-cyan { background-color: #ecfeff; color: #0891b2; }

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-draft { background-color: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.badge-info { background-color: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.badge-warning { background-color: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.badge-primary { background-color: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; }
.badge-purple { background-color: #f3e8ff; color: #7e22ce; border: 1px solid #e9d5ff; }
.badge-success { background-color: #d1fae5; color: #047857; border: 1px solid #a7f3d0; }
.badge-danger { background-color: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.badge-secondary { background-color: #f1f5f9; color: #64748b; }

/* Action Badges */
.action-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.badge-action-add { background-color: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.badge-action-change { background-color: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.badge-action-delete { background-color: #fff1f2; color: #be123c; border: 1px solid #fecdd3; }

/* Action Segmented Selector */
.segmented-control {
  display: flex;
  background-color: #f1f5f9;
  padding: 4px;
  border-radius: 10px;
  gap: 4px;
}

.segmented-option {
  flex: 1;
  text-align: center;
}

.segmented-option input[type="radio"] {
  display: none;
}

.segmented-option label {
  display: block;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-muted);
  user-select: none;
}

.segmented-option input[type="radio"]:checked + label {
  background-color: #ffffff;
  color: var(--primary-blue);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.segmented-option.action-add input[type="radio"]:checked + label {
  background-color: #059669;
  color: #ffffff;
}

.segmented-option.action-change input[type="radio"]:checked + label {
  background-color: #2563eb;
  color: #ffffff;
}

.segmented-option.action-delete input[type="radio"]:checked + label {
  background-color: #dc2626;
  color: #ffffff;
}

/* FROM / TO Comparison Box */
.comparison-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: #ffffff;
  overflow: hidden;
  margin-bottom: 16px;
  transition: all 0.2s;
}

.comparison-card.is-diff {
  border-color: #93c5fd;
  box-shadow: 0 0 0 1px #bfdbfe;
}

.comparison-header {
  background-color: #f8fafc;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--primary-navy);
}

.comparison-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  divide-x: 1px solid var(--border-color);
}

.comparison-col {
  padding: 14px 16px;
}

.comparison-col.col-from {
  background-color: #fafbfc;
  border-right: 1px solid var(--border-color);
}

.comparison-col.col-to {
  background-color: #ffffff;
}

.col-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.diff-indicator {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  background-color: #eff6ff;
  color: #1d4ed8;
  font-weight: 600;
}

.diff-same {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  background-color: #f1f5f9;
  color: #64748b;
  font-weight: 500;
}

/* Workflow Timeline */
.workflow-stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  padding: 20px 0;
  margin-bottom: 24px;
}

.workflow-stepper::before {
  content: '';
  position: absolute;
  top: 40px;
  left: 40px;
  right: 40px;
  height: 3px;
  background-color: #e2e8f0;
  z-index: 1;
}

.workflow-step {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.step-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: #ffffff;
  border: 3px solid #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 8px;
  transition: all 0.3s ease;
}

.workflow-step.completed .step-circle {
  background-color: #10b981;
  border-color: #10b981;
  color: #ffffff;
}

.workflow-step.active .step-circle {
  background-color: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
  box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.2);
}

.step-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  max-width: 110px;
}

.step-subtext {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Form inputs */
.form-control, .form-select {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  font-size: 13.5px;
  color: var(--text-main);
  background-color: #ffffff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus, .form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  outline: none;
}

.form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

/* Buttons */
.btn-primary {
  background-color: var(--primary-blue);
  border-color: var(--primary-blue);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-weight: 600;
  font-size: 13.5px;
  transition: all 0.2s;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-outline-primary {
  color: var(--primary-blue);
  border-color: #bfdbfe;
  background-color: #eff6ff;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-weight: 600;
  font-size: 13.5px;
}

.btn-outline-primary:hover {
  background-color: var(--primary-blue);
  color: #fff;
  border-color: var(--primary-blue);
}

/* Autosave indicator */
.autosave-badge {
  font-size: 11.5px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.autosave-badge.saving {
  color: #d97706;
}

.autosave-badge.saved {
  color: #059669;
}

/* Print CSS */
@media print {
  body {
    background-color: #fff !important;
    font-size: 11pt !important;
    color: #000 !important;
  }
  .app-sidebar, .app-header, .btn, .no-print {
    display: none !important;
  }
  .app-main, .app-content {
    padding: 0 !important;
    margin: 0 !important;
  }
  .card-modern, .comparison-card {
    border: 1px solid #000 !important;
    box-shadow: none !important;
    page-break-inside: avoid;
  }
  @page {
    size: A4 portrait;
    margin: 10mm;
  }
}

/* Responsive */
@media (max-width: 992px) {
  .app-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: -260px;
  }
  .app-sidebar.show {
    left: 0;
  }
  .comparison-body {
    grid-template-columns: 1fr;
  }
  .comparison-col.col-from {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  .workflow-stepper {
    overflow-x: auto;
    padding-bottom: 10px;
  }
}

/* ==========================================================================
   Microsoft Access MDB Authentic Form Sheet & Record Navigation Styles
   ========================================================================== */
.ecn-sheet-container {
  max-width: 1200px;
  margin: 0 auto;
}

.ecn-sheet-card {
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #d0d7de;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
  overflow: hidden;
  margin-bottom: 80px;
}

.ecn-sheet-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid #2563eb;
}

.ecn-sheet-section-title {
  background: #f1f5f9;
  padding: 10px 18px;
  font-weight: 700;
  font-size: 13.5px;
  color: #1e293b;
  border-top: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ecn-sheet-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0;
}

.ecn-sheet-table th {
  background-color: #f8fafc;
  color: #475569;
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  vertical-align: middle;
}

.ecn-sheet-table td {
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  vertical-align: middle;
  background-color: #ffffff;
  transition: background-color 0.2s;
}

.ecn-sheet-table tr.is-diff-row td {
  background-color: #f0f9ff;
}

.ecn-sheet-table tr.is-diff-row td.field-label-cell {
  background-color: #e0f2fe;
  color: #0369a1;
  font-weight: 700;
}

.ecn-sheet-table .field-label-cell {
  background-color: #f8fafc;
  font-weight: 600;
  font-size: 13px;
  color: #334155;
  width: 240px;
}

.ecn-sheet-table .input-cell {
  position: relative;
}

.ecn-sheet-table .form-control,
.ecn-sheet-table .form-select {
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  font-size: 13.5px;
  padding: 7px 10px;
  transition: all 0.2s ease-in-out;
}

.ecn-sheet-table .form-control:focus,
.ecn-sheet-table .form-select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  background-color: #ffffff;
}

.ecn-action-radio-group {
  display: flex;
  gap: 16px;
  padding: 12px 18px;
  background: #ffffff;
  align-items: center;
}

.ecn-action-radio-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1.5px solid #e2e8f0;
  transition: all 0.2s;
}

.ecn-action-radio-item:hover {
  background-color: #f8fafc;
  border-color: #cbd5e1;
}

.ecn-action-radio-item input[type="radio"]:checked + span {
  color: #2563eb;
}

.ecn-action-radio-item.active-add {
  background-color: #ecfdf5;
  border-color: #10b981;
  color: #065f46;
}

.ecn-action-radio-item.active-change {
  background-color: #eff6ff;
  border-color: #3b82f6;
  color: #1e40af;
}

.ecn-action-radio-item.active-delete {
  background-color: #fef2f2;
  border-color: #ef4444;
  color: #991b1b;
}

.signature-sheet-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1.5px solid #cbd5e1;
  background-color: #ffffff;
}

.signature-sheet-box {
  padding: 14px;
  border-right: 1px solid #e2e8f0;
  background: #ffffff;
}

.signature-sheet-box:last-child {
  border-right: none;
}

.signature-sheet-box .sig-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: #475569;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Access-style Bottom Record Navigator */
.access-nav-bar {
  position: fixed;
  bottom: 0;
  left: 260px;
  right: 0;
  background: #ffffff;
  border-top: 1.5px solid #cbd5e1;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 1000;
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 992px) {
  .access-nav-bar {
    left: 0;
  }
}

.access-record-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.access-record-controls .btn-nav {
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
}

.access-record-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  background: #f1f5f9;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
}

.access-record-indicator input {
  width: 55px;
  text-align: center;
  font-weight: bold;
  border-radius: 4px;
  border: 1px solid #94a3b8;
  padding: 2px 4px;
}

/* ==========================================================================
   SweetAlert2 Modern Styling
   ========================================================================== */
.swal2-toast {
  border-radius: 12px !important;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1) !important;
  font-family: 'Sarabun', 'Inter', sans-serif !important;
  border: 1px solid rgba(0, 0, 0, 0.06) !important;
  padding: 12px 18px !important;
}

.swal2-toast .swal2-title {
  font-size: 14px !important;
  font-weight: 600 !important;
  color: #1e293b !important;
  margin: 0 8px !important;
}

.swal2-popup {
  border-radius: 16px !important;
  font-family: 'Sarabun', 'Inter', sans-serif !important;
}

.swal2-popup .swal2-title {
  font-size: 18px !important;
  font-weight: 700 !important;
  color: #0f172a !important;
}

.swal2-popup .swal2-html-container {
  font-size: 14px !important;
  color: #475569 !important;
}

