/* ==========================================================================
   M3 Canvas Studio & Workbench Layout (Pixel-Perfect Auto-Fit & Clean Sidebar)
   ========================================================================== */

/* Custom Sleek Scrollbar */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--md-sys-color-outline-variant);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--md-sys-color-outline);
}

.m3-studio-layout {
  display: grid;
  grid-template-columns: 290px 1fr 330px;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--md-sys-color-surface-container-lowest);
}

/* Sidebars */
.m3-sidebar {
  background-color: var(--md-sys-color-surface-container-low);
  border-right: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
}

.m3-sidebar-right {
  border-right: none;
  border-left: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: relative;
  user-select: none;
}

.m3-sidebar-section {
  padding: 1.15rem;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

/* --- RIGHT SIDEBAR CANVA/FIGMA SEGMENTED TABS (ULTRA-PREMIUM) --- */
.m3-sidebar-tabs-wrapper {
  padding: 8px 10px 6px 10px;
  background: var(--md-sys-color-surface-container);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.m3-sidebar-tabs-bar {
  display: flex;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.35);
}

.m3-sidebar-tab-btn {
  flex: 1 1 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--md-sys-color-on-surface-variant, #94a3b8);
  font-family: var(--md-sys-typescale-label-large-font);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.2, 0, 0, 1);
  white-space: nowrap;
  user-select: none;
  position: relative;
}

.m3-sidebar-tab-btn .tab-icon {
  font-size: 18px;
  transition: transform 0.2s ease, color 0.2s ease;
}

.m3-sidebar-tab-btn .tab-icon-layers {
  color: #818cf8;
}

.m3-sidebar-tab-btn .tab-icon-props {
  color: #fbbf24;
}

.m3-sidebar-tab-btn .tab-label {
  letter-spacing: -0.01em;
  font-weight: 700;
}

.m3-sidebar-tab-btn .tab-badge {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--md-sys-color-outline, #94a3b8);
  border: 1px solid rgba(255, 255, 255, 0.06);
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.m3-sidebar-tab-btn .tab-badge-accent {
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
  border-color: rgba(99, 102, 241, 0.35);
}

.m3-sidebar-tab-btn:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: #f8fafc;
}

.m3-sidebar-tab-btn.active {
  background: rgba(30, 41, 59, 0.95);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.m3-sidebar-tab-btn.active .tab-icon {
  transform: scale(1.08);
}

.m3-sidebar-tab-btn.active .tab-badge {
  background: rgba(99, 102, 241, 0.25);
  color: #c7d2fe;
  border-color: rgba(99, 102, 241, 0.4);
}

.m3-sidebar-tab-pane {
  display: none;
  flex-direction: column;
  flex: 1;
  height: 100%;
  overflow: hidden;
}

.m3-sidebar-tab-pane.active {
  display: flex;
}

.m3-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: var(--md-sys-color-surface-container-low);
  flex-shrink: 0;
  height: 38px;
  box-sizing: border-box;
}

.m3-pane-header-title {
  font-size: 0.68rem;
  font-weight: 800;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.m3-layer-list {
  padding: 0.75rem 1rem;
  overflow-y: auto;
  flex: 1;
  height: calc(100% - 44px);
  box-sizing: border-box;
}

.m3-properties-scrollable {
  padding: 0.75rem 1rem;
  overflow-y: auto;
  flex: 1;
  height: calc(100% - 44px);
  box-sizing: border-box;
}

.m3-section-title {
  font-family: var(--md-sys-typescale-title-medium-font);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--md-sys-color-primary);
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Tool Grid (Elements) */
.m3-element-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}

.m3-element-card {
  background-color: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  color: var(--md-sys-color-on-surface);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-emphasized);
}

.m3-element-card:hover {
  background-color: var(--md-sys-color-surface-container-highest);
  border-color: var(--md-sys-color-primary);
  transform: translateY(-2px);
  box-shadow: var(--md-sys-elevation-1);
}

.m3-element-card:active {
  transform: scale(0.96);
}

/* Presets Grid */
.m3-preset-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
}

.m3-preset-card {
  aspect-ratio: 1.414;
  border-radius: var(--md-sys-shape-corner-medium);
  border: 2px solid transparent;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  transition: all var(--md-sys-motion-duration-short) ease;
  box-shadow: var(--md-sys-elevation-1);
}

.m3-preset-card:hover, .m3-preset-card.active {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 3px rgba(186, 195, 255, 0.35);
}

.m3-preset-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(18, 19, 24, 0.88);
  backdrop-filter: blur(8px);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.3rem 0.4rem;
  text-align: center;
  color: var(--md-sys-color-on-surface);
}

/* Canvas Viewport & Pan Stage */
.m3-canvas-viewport {
  background-color: var(--md-sys-color-surface-container-lowest);
  position: relative;
  overflow: hidden;
  background-image: radial-gradient(rgba(255, 255, 255, 0.08) 1.5px, transparent 1.5px);
  background-size: 24px 24px;
  height: 100%;
  width: 100%;
  box-sizing: border-box;
  user-select: none;
}

.m3-canvas-viewport.pan-mode {
  cursor: grab !important;
}

.m3-canvas-viewport.panning {
  cursor: grabbing !important;
}

.m3-canvas-toolbar {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background-color: rgba(30, 41, 59, 0.94);
  border: 1px solid var(--md-sys-color-outline-variant);
  padding: 4px 10px;
  border-radius: var(--md-sys-shape-corner-full);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), var(--md-sys-elevation-2);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.m3-icon-btn.m3-icon-btn-danger:hover {
  background-color: rgba(239, 68, 68, 0.2);
  color: #f87171 !important;
}

.m3-icon-btn:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.m3-toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--md-sys-color-outline-variant);
  margin: 0 0.25rem;
}

.m3-canvas-stage-wrapper {
  position: absolute;
  top: 50%;
  left: 50%;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(255, 255, 255, 0.15);
  border-radius: var(--md-sys-shape-corner-small);
  overflow: visible;
  background-color: #ffffff;
  transform-origin: center center;
  transition: box-shadow 0.2s ease;
  user-select: none;
}

#certificate-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ==========================================================================
   Daftar Layer (Dynamic Flexible M3 Tree)
   ========================================================================== */
.m3-layer-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

.m3-layer-item {
  background-color: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  padding: 7px 9px;
  border-radius: var(--md-sys-shape-corner-small);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: grab;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
  user-select: none;
  position: relative;
}

.m3-layer-item:active {
  cursor: grabbing;
}

.m3-layer-item:hover {
  background-color: var(--md-sys-color-surface-container-highest);
  border-color: var(--md-sys-color-outline);
}

.m3-layer-item.active {
  background-color: var(--md-sys-color-primary-container);
  border-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary-container);
}

.m3-layer-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--md-sys-color-outline);
  cursor: grab;
  opacity: 0.55;
  transition: opacity 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
}

.m3-layer-item:hover .m3-layer-drag-handle {
  opacity: 1;
  color: var(--md-sys-color-primary);
}

.m3-layer-item.dragging {
  opacity: 0.4;
  background-color: var(--md-sys-color-surface-container-high) !important;
  border: 2px dashed var(--md-sys-color-primary) !important;
  transform: scale(0.97);
}

.m3-layer-item.drag-over-top {
  border-top: 3px solid var(--md-sys-color-primary) !important;
  box-shadow: 0 -4px 10px rgba(99, 102, 241, 0.4);
}

.m3-layer-item.drag-over-bottom {
  border-bottom: 3px solid var(--md-sys-color-primary) !important;
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.4);
}

.m3-layer-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  flex: 1;
}

.m3-icon-btn {
  background: transparent;
  border: none;
  color: var(--md-sys-color-on-surface-variant, #cac4d0);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: var(--md-sys-shape-corner-full);
  transition: all var(--md-sys-motion-duration-short) ease;
  flex-shrink: 0;
}

.m3-icon-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--md-sys-color-on-surface);
}

.m3-icon-btn.active {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.m3-icon-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--md-sys-color-on-surface);
}

/* ==========================================================================
   Properti Layer (Structured M3 Inspector)
   ========================================================================== */
.m3-prop-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}

.m3-color-picker-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-small);
  padding: 4px 8px;
}

.m3-color-swatch-input {
  -webkit-appearance: none;
  appearance: none;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: var(--md-sys-shape-corner-small);
  cursor: pointer;
  background: transparent;
  padding: 0;
}

.m3-color-swatch-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.m3-color-swatch-input::-webkit-color-swatch {
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 4px;
}

/* Batch Importer View */
.m3-batch-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
  width: 100%;
  overflow-y: auto;
  height: 100%;
}

.m3-dropzone {
  border: 2px dashed var(--md-sys-color-primary);
  background-color: rgba(186, 195, 255, 0.04);
  border-radius: var(--md-sys-shape-corner-extra-large);
  padding: 3.5rem 2rem;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  transition: all var(--md-sys-motion-duration-medium) ease;
}

.m3-dropzone:hover, .m3-dropzone.dragover {
  background-color: rgba(186, 195, 255, 0.08);
  border-color: var(--md-sys-color-on-primary-container);
  transform: scale(1.01);
}

.m3-table-container {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--md-sys-shape-corner-medium);
  border: 1px solid var(--md-sys-color-outline-variant);
  background-color: var(--md-sys-color-surface-container-low);
}

.m3-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.m3-table th {
  background-color: var(--md-sys-color-surface-container-high);
  padding: 10px 14px;
  color: var(--md-sys-color-primary);
  font-weight: 700;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.m3-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface);
}

.m3-table tr:hover td {
  background-color: var(--md-sys-color-surface-container);
}

.m3-mapping-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.m3-mapping-card {
  background-color: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* ==========================================================================
   Element Library Catalog Modal (Rich Store)
   ========================================================================== */
.m3-catalog-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(10px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.m3-catalog-modal.active {
  display: flex;
}

.m3-catalog-card {
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-large);
  width: 96%;
  max-width: 1260px;
  height: 88vh;
  max-height: 800px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 48px rgba(0,0,0,0.6);
  overflow: hidden;
}

.m3-catalog-header {
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container);
  flex-shrink: 0;
}

.m3-catalog-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Left Sidebar Navigation (VS Code Settings Style) */
.m3-catalog-sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--md-sys-color-surface-container);
  border-right: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  flex-direction: column;
  padding: 0.85rem;
  gap: 0.35rem;
  overflow-y: auto;
}

.canva-catalog-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-small);
  padding: 0.45rem 0.65rem;
  margin-bottom: 0.6rem;
  transition: all 0.2s;
}

.canva-catalog-search:focus-within {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

.canva-catalog-search input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--md-sys-color-on-surface);
  font-size: 0.8rem;
  outline: none;
}

.m3-catalog-nav-item,
.m3-tpl-nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  border-radius: var(--md-sys-shape-corner-small);
  border: 1px solid transparent;
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  width: 100%;
}

.m3-catalog-nav-item:hover,
.m3-tpl-nav-item:hover {
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
}

.m3-catalog-nav-item.active,
.m3-tpl-nav-item.active {
  background: rgba(99, 102, 241, 0.14);
  color: var(--md-sys-color-primary);
  border-color: rgba(99, 102, 241, 0.3);
  font-weight: 700;
}

.m3-catalog-nav-item .nav-count-badge,
.m3-tpl-nav-item .nav-count-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 9999px;
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-outline);
}

.m3-catalog-nav-item.active .nav-count-badge,
.m3-tpl-nav-item.active .nav-count-badge {
  background: var(--md-sys-color-primary);
  color: #ffffff;
}

/* Center Gallery Content Area */
.m3-catalog-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--md-sys-color-surface-container-low);
  overflow: hidden;
  min-width: 0;
}

.m3-catalog-main-header {
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-low);
  flex-shrink: 0;
}

.m3-catalog-body {
  padding: 1.15rem;
  overflow-y: auto;
  flex: 1;
}

/* Compact Canva Item Cards */
.m3-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.65rem;
}

.m3-catalog-item {
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  padding: 0.65rem 0.45rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.35rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  user-select: none;
}

.m3-catalog-item:hover,
.m3-catalog-item.selected {
  background: var(--md-sys-color-surface-container-highest);
  border-color: var(--md-sys-color-primary);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.m3-catalog-item.selected {
  border-width: 2px;
  border-color: var(--md-sys-color-primary);
  background: rgba(99, 102, 241, 0.12);
}

.m3-catalog-preview {
  width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(30, 41, 59, 0.6) 0%, rgba(15, 23, 42, 0.9) 100%);
  border-radius: var(--md-sys-shape-corner-small);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
  position: relative;
}

.m3-catalog-preview canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.m3-catalog-item strong {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--md-sys-color-on-surface);
  line-height: 1.25;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.m3-catalog-item .item-sublabel {
  font-size: 0.62rem;
  color: var(--md-sys-color-outline);
  line-height: 1.2;
}

.canva-item-badge {
  font-size: 0.68rem;
  font-weight: 700;
  background: rgba(99, 102, 241, 0.15);
  color: var(--md-sys-color-primary);
  padding: 2px 8px;
  border-radius: 9999px;
  border: 1px solid rgba(99, 102, 241, 0.25);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 1px;
}

/* Right Inspector Preview Window */
.m3-catalog-inspector {
  width: 320px;
  flex-shrink: 0;
  background: var(--md-sys-color-surface-container);
  border-left: 1px solid var(--md-sys-color-outline-variant);
  display: flex;
  flex-direction: column;
  padding: 1.15rem;
  overflow-y: auto;
  gap: 0.95rem;
}

.catalog-inspector-preview-box {
  width: 100%;
  height: 190px;
  background: radial-gradient(circle at center, rgba(30, 41, 59, 0.8) 0%, rgba(15, 23, 42, 0.98) 100%);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
}

.catalog-inspector-preview-box canvas {
  max-width: 180px;
  max-height: 180px;
  object-fit: contain;
  display: block;
}

.inspector-tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.inspector-tag {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 9999px;
  background: rgba(99, 102, 241, 0.15);
  color: var(--md-sys-color-primary);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.inspector-spec-box {
  background: var(--md-sys-color-surface-container-low);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-small);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.75rem;
}

.inspector-spec-row {
  display: flex;
  justify-content: space-between;
  color: var(--md-sys-color-outline);
}

.inspector-spec-row strong {
  color: var(--md-sys-color-on-surface);
}

@media (max-width: 992px) {
  .m3-catalog-inspector {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .m3-catalog-card,
  .m3-template-hub-card {
    width: 100% !important;
    max-width: 100% !important;
    height: 94vh !important;
    max-height: 94vh !important;
    border-radius: 16px 16px 0 0 !important;
    margin: 0 !important;
  }

  .m3-template-hub-modal,
  .m3-elements-catalog-modal {
    padding: 0 !important;
    align-items: flex-end !important;
  }

  .m3-catalog-header {
    padding: 0.65rem 0.85rem !important;
  }
  .m3-catalog-header h3 {
    font-size: 0.92rem !important;
  }
  .m3-catalog-header p {
    display: none !important;
  }

  .m3-catalog-layout {
    flex-direction: column !important;
    overflow: hidden !important;
  }

  .m3-catalog-sidebar {
    width: 100% !important;
    min-width: 100% !important;
    max-height: 48px !important;
    flex-direction: row !important;
    align-items: center !important;
    padding: 0.35rem 0.65rem !important;
    gap: 6px !important;
    border-right: none !important;
    border-bottom: 1px solid var(--md-sys-color-outline-variant) !important;
    overflow-x: auto !important;
    scrollbar-width: none !important;
    -webkit-overflow-scrolling: touch !important;
    flex-shrink: 0 !important;
  }
  .m3-catalog-sidebar::-webkit-scrollbar {
    display: none !important;
  }

  .m3-catalog-sidebar > div[style*="text-transform:uppercase"] {
    display: none !important;
  }

  .canva-catalog-search {
    min-width: 120px !important;
    max-width: 150px !important;
    margin-bottom: 0 !important;
    padding: 0.3rem 0.5rem !important;
    flex-shrink: 0 !important;
  }

  .m3-catalog-nav-item,
  .m3-tpl-nav-item {
    width: auto !important;
    flex-shrink: 0 !important;
    white-space: nowrap !important;
    padding: 5px 10px !important;
    border-radius: 9999px !important;
    font-size: 0.72rem !important;
    gap: 4px !important;
  }

  .m3-catalog-main {
    flex: 1 !important;
    width: 100% !important;
    padding: 0.5rem !important;
    overflow-y: auto !important;
  }

  .m3-template-card-grid {
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)) !important;
    gap: 0.5rem !important;
  }

  .m3-template-thumb {
    height: 105px !important;
  }

  .m3-template-info {
    padding: 0.55rem !important;
    gap: 0.25rem !important;
  }

  .m3-template-title {
    font-size: 0.76rem !important;
    line-height: 1.2 !important;
  }

  .m3-template-desc {
    display: none !important;
  }

  .m3-template-tag {
    font-size: 0.56rem !important;
    padding: 1px 4px !important;
  }

  .m3-template-apply-btn {
    margin-top: 0.35rem !important;
    padding: 5px 8px !important;
    font-size: 0.68rem !important;
  }

  .m3-catalog-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)) !important;
    gap: 0.45rem !important;
  }

  .m3-catalog-item {
    padding: 0.5rem 0.35rem !important;
  }

  .catalog-item-thumb {
    width: 44px !important;
    height: 44px !important;
  }
}

/* ==========================================================================
   Template Hub Master Suite Modal (Horizontal Split Left-to-Right)
   ========================================================================== */
.m3-template-hub-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(10px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.m3-template-hub-modal.active {
  display: flex;
}

.m3-template-hub-card {
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-large);
  width: 100%;
  max-width: 1080px;
  height: 88vh;
  max-height: 800px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.m3-template-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.9rem;
}

.m3-hub-template-item {
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.m3-hub-template-item:hover {
  border-color: var(--md-sys-color-gold);
  transform: translateY(-4px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.m3-hub-template-item.active {
  border: 2px solid var(--md-sys-color-gold);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.3);
}

.m3-template-thumb {
  height: 135px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: #0f172a;
}

.m3-template-thumb-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  z-index: 1;
  transition: transform 0.3s ease;
}

.m3-hub-template-item:hover .m3-template-thumb-canvas {
  transform: scale(1.04);
}

.m3-template-thumb-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 0.6rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  z-index: 3;
}

.m3-template-thumb-active-pill {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 0.62rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 4px;
  background: #059669;
  color: #fff;
  display: none;
  align-items: center;
  gap: 3px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  z-index: 3;
}

.m3-hub-template-item.active .m3-template-thumb-active-pill {
  display: flex;
}

.m3-template-info {
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.m3-template-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--md-sys-color-on-surface);
  line-height: 1.25;
}

.m3-template-desc {
  font-size: 0.7rem;
  color: var(--md-sys-color-outline);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.m3-template-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.m3-template-tag {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface-variant);
}

.m3-template-apply-btn {
  margin-top: 0.5rem;
  width: 100%;
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 6px;
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: all 0.2s;
}

.m3-hub-template-item:hover .m3-template-apply-btn {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border-color: var(--md-sys-color-primary);
}

.m3-hub-template-item.active .m3-template-apply-btn {
  background: var(--md-sys-color-gold);
  color: #000;
  border-color: var(--md-sys-color-gold);
}

.m3-hub-template-item.is-custom-item {
  border-color: rgba(245, 158, 11, 0.4);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.04) 0%, var(--md-sys-color-surface-container) 100%);
}

.m3-hub-template-item.is-custom-item:hover {
  border-color: #f59e0b;
  box-shadow: 0 10px 24px rgba(245, 158, 11, 0.2);
}

.btn-delete-custom-tpl {
  opacity: 0.75;
  transition: opacity 0.2s, transform 0.2s;
  border-radius: 6px;
}

.btn-delete-custom-tpl:hover {
  opacity: 1;
  transform: scale(1.15);
  background: rgba(239, 68, 68, 0.15);
}

.m3-override-pill {
  animation: fadeInPill 0.3s ease;
}

@keyframes fadeInPill {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Canva-Style Ultra-Flexible Properties Inspector
   ========================================================================== */
.canva-prop-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.canva-tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.canva-tag-pill {
  background: rgba(99, 102, 241, 0.12);
  color: var(--md-sys-color-primary);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--md-sys-shape-corner-full);
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.canva-tag-pill:hover {
  background: var(--md-sys-color-primary);
  color: #ffffff;
  transform: translateY(-1px);
}

.canva-stepper-box {
  display: flex;
  align-items: center;
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  overflow: hidden;
}

.canva-stepper-btn {
  background: transparent;
  border: none;
  color: var(--md-sys-color-on-surface);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 700;
  font-size: 1.1rem;
  transition: background 0.15s;
}

.canva-stepper-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.canva-stepper-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--md-sys-color-on-surface);
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  outline: none;
}

.canva-range-slider {
  width: 100%;
  accent-color: var(--md-sys-color-primary);
  margin-top: 4px;
  cursor: pointer;
}

.canva-btn-ribbon {
  display: flex;
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  padding: 3px;
  gap: 2px;
}

.canva-ribbon-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--md-sys-color-on-surface-variant);
  padding: 6px 0;
  border-radius: var(--md-sys-shape-corner-small);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85rem;
  transition: all 0.15s ease;
}

.canva-ribbon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--md-sys-color-on-surface);
}

.canva-ribbon-btn.active {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  box-shadow: var(--md-sys-elevation-1);
}

.canva-swatch-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.canva-swatch-circle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.canva-swatch-circle:hover {
  transform: scale(1.2);
}

.canva-swatch-circle.active {
  border-color: #ffffff;
  transform: scale(1.15);
}

.canva-align-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.canva-action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 6px;
}

/* ==========================================================================
   M3 Canvas Studio Mobile Responsive & Off-Canvas Drawers (Canva/Figma UI)
   ========================================================================== */
.m3-mobile-drawer-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-high);
  flex-shrink: 0;
}

.m3-mobile-drawer-backdrop {
  display: none;
}

.m3-mobile-studio-dock {
  display: none;
}

@media (max-width: 900px) {
  .m3-studio-layout {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: calc(100vh - 64px);
    position: relative;
    overflow: hidden;
  }

  .m3-canvas-viewport {
    flex: 1;
    width: 100% !important;
    height: 100% !important;
    position: relative;
    padding-bottom: 56px; /* Spacing for mobile bottom dock */
    box-sizing: border-box;
  }

  .m3-canvas-toolbar {
    top: 0.5rem;
    padding: 3px 8px;
    gap: 3px;
    max-width: 95%;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .m3-canvas-toolbar::-webkit-scrollbar {
    display: none;
  }

  .m3-canvas-toolbar #btn-zoom-fit span {
    display: none;
  }

  .m3-canvas-toolbar #preview-data-text {
    display: none;
  }

  /* Off-Canvas Mobile Bottom Drawers */
  .m3-mobile-drawer-header {
    display: flex;
  }

  .m3-mobile-drawer-backdrop {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 190;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s cubic-bezier(0.2, 0, 0, 1);
  }

  .m3-mobile-drawer-backdrop.active {
    opacity: 1;
    pointer-events: auto;
  }

  .m3-sidebar-left,
  .m3-sidebar-right {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 82vh !important;
    max-height: 82vh !important;
    z-index: 200 !important;
    background-color: var(--md-sys-color-surface-container) !important;
    border-radius: 20px 20px 0 0 !important;
    border-top: 1px solid var(--md-sys-color-outline-variant) !important;
    border-left: none !important;
    border-right: none !important;
    box-shadow: 0 -12px 36px rgba(0, 0, 0, 0.65) !important;
    transform: translateY(105%) !important;
    transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }

  .m3-sidebar-left.mobile-open,
  .m3-sidebar-right.mobile-open {
    transform: translateY(0) !important;
  }

  /* Hide local dock since universal .m3-global-bottom-bar handles navigation */
  .m3-mobile-studio-dock {
    display: none !important;
  }
}

/* ==========================================================================
   Live Delivery Tracker — Advanced Table Components (v14.9)
   ========================================================================== */

/* Tracker Toolbar */
.m3-tracker-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

/* Filter Status Chips */
.m3-filter-chips {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.m3-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid var(--md-sys-color-outline-variant);
  background: transparent;
  color: var(--md-sys-color-outline);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.m3-filter-chip:hover {
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
}

.m3-filter-chip.active {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* Bulk Action Bar */
.m3-bulk-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.65rem;
  padding: 10px 16px;
  margin-bottom: 0.75rem;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 10px;
  animation: fadeInBulk 0.25s ease;
}

@keyframes fadeInBulk {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Sortable Column Headers */
.m3-th-sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s ease;
  white-space: nowrap;
}

.m3-th-sortable:hover {
  color: var(--md-sys-color-primary) !important;
}

.m3-sort-icon {
  font-size: 14px !important;
  vertical-align: middle;
  margin-left: 2px;
  opacity: 0.4;
  transition: opacity 0.15s ease;
}

.m3-th-sortable.sort-active .m3-sort-icon {
  opacity: 1;
  color: var(--md-sys-color-primary);
}

/* Tracker Table */
.m3-tracker-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  text-align: left;
}

.m3-tracker-table thead tr {
  background: var(--md-sys-color-surface-container-high);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.m3-tracker-table th {
  padding: 10px 12px;
  font-weight: 800;
  color: var(--md-sys-color-on-surface);
}

.m3-tracker-table td {
  padding: 10px 12px;
  color: var(--md-sys-color-on-surface);
}

.m3-tracker-table tbody tr {
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  transition: background 0.15s ease;
}

.m3-tracker-table tbody tr:hover {
  background: var(--md-sys-color-surface-container);
}

.m3-tracker-table tbody tr.row-selected {
  background: rgba(99, 102, 241, 0.06);
}

.m3-tracker-table tbody tr.row-editing {
  background: rgba(16, 185, 129, 0.06);
  outline: 1px solid rgba(16, 185, 129, 0.3);
}

/* Tracker Row Checkbox */
.m3-row-checkbox {
  width: 16px;
  height: 16px;
  accent-color: #6366f1;
  cursor: pointer;
}

/* Inline Edit Input */
.m3-inline-edit {
  background: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-primary);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.78rem;
  color: var(--md-sys-color-on-surface);
  width: 100%;
  max-width: 180px;
  outline: none;
}

.m3-inline-edit:focus {
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

/* Action Buttons in Table Row */
.m3-row-action-group {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.m3-row-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-row-wa {
  background: rgba(37, 211, 102, 0.12);
  color: #25d366;
}
.btn-row-wa:hover {
  background: rgba(37, 211, 102, 0.25);
}

.btn-row-edit {
  background: rgba(99, 102, 241, 0.1);
  color: #818cf8;
}
.btn-row-edit:hover {
  background: rgba(99, 102, 241, 0.22);
}

.btn-row-delete {
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
}
.btn-row-delete:hover {
  background: rgba(239, 68, 68, 0.2);
}

.btn-row-save {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
}
.btn-row-save:hover {
  background: rgba(16, 185, 129, 0.25);
}

.btn-row-cancel {
  background: rgba(148, 163, 184, 0.1);
  color: #94a3b8;
}
.btn-row-cancel:hover {
  background: rgba(148, 163, 184, 0.2);
}

/* Tracker Pagination */
.m3-tracker-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--md-sys-color-outline-variant);
  font-size: 0.82rem;
  color: var(--md-sys-color-outline);
}

.m3-tracker-pagination .m3-page-btn-group {
  display: flex;
  align-items: center;
  gap: 3px;
}

.m3-tracker-pagination .m3-page-btn {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  background: transparent;
  border: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  transition: all 0.15s ease;
}

.m3-tracker-pagination .m3-page-btn:hover:not(:disabled) {
  background: var(--md-sys-color-surface-container-high);
}

.m3-tracker-pagination .m3-page-btn.active {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border-color: var(--md-sys-color-primary);
}

.m3-tracker-pagination .m3-page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Empty State */
.m3-tracker-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--md-sys-color-outline);
}

.m3-tracker-empty .empty-icon {
  font-size: 56px;
  opacity: 0.3;
  margin-bottom: 0.75rem;
}

.m3-tracker-empty .empty-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: var(--md-sys-color-on-surface);
}

.m3-tracker-empty .empty-desc {
  font-size: 0.82rem;
  max-width: 400px;
  line-height: 1.5;
}

/* Loading Spinner */
.m3-tracker-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2.5rem;
  color: var(--md-sys-color-outline);
  font-size: 0.88rem;
}

.m3-tracker-loading .spinner-ring {
  width: 28px;
  height: 28px;
  border: 3px solid var(--md-sys-color-outline-variant);
  border-top-color: var(--md-sys-color-primary);
  border-radius: 50%;
  animation: spinTracker 0.8s linear infinite;
}

@keyframes spinTracker {
  to { transform: rotate(360deg); }
}

/* Row flash animation on save */
@keyframes rowSaveFlash {
  0% { background: rgba(16, 185, 129, 0.2); }
  100% { background: transparent; }
}
.row-just-saved {
  animation: rowSaveFlash 1.2s ease forwards;
}

/* Modal Sheet Item Card Hover */
.m3-sheet-item-card:hover {
  background: var(--md-sys-color-surface-container-high) !important;
  border-color: #10b981 !important;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
}

/* ==========================================================================
   MULTI-PAGE (DUPLEX) FLOATING SWITCHER & MATRICULATION TABLE SUITE (CANVA STYLE)
   ========================================================================== */
.m3-floating-page-switcher {
  position: absolute;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 9999px;
  padding: 5px 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 1px rgba(255, 255, 255, 0.25);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

.m3-floating-page-switcher:hover {
  border-color: rgba(255, 255, 255, 0.28);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
}

.page-switcher-pill-group {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 4px;
  border-radius: 9999px;
}

.page-switcher-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #94a3b8;
  background: transparent;
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  white-space: nowrap;
}

.page-switcher-btn:hover {
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.08);
}

.page-switcher-btn.active {
  color: #ffffff;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.45);
}

.page-switcher-btn#btn-page-2.active {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.45);
}

.page-switcher-divider {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.18);
  margin: 0 2px;
}

.page-duplex-toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #cbd5e1;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 9999px;
  transition: all 0.15s ease;
  user-select: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.page-duplex-toggle-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.page-duplex-toggle-chip input[type="checkbox"] {
  display: none;
}

.page-duplex-toggle-chip .toggle-track {
  width: 28px;
  height: 16px;
  background: #475569;
  border-radius: 9999px;
  position: relative;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.page-duplex-toggle-chip input[type="checkbox"]:checked + .toggle-track {
  background: #10b981;
}

.page-duplex-toggle-chip .toggle-thumb {
  width: 12px;
  height: 12px;
  background: #ffffff;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-duplex-toggle-chip input[type="checkbox"]:checked + .toggle-track .toggle-thumb {
  transform: translateX(12px);
}

.page-duplex-toggle-chip .toggle-label {
  white-space: nowrap;
  display: inline-block;
}

@media (max-width: 900px) {
  .m3-floating-page-switcher {
    bottom: 4.75rem;
    padding: 4px 8px;
    gap: 4px;
    max-width: 95%;
  }
  .page-switcher-btn {
    padding: 5px 10px;
    font-size: 0.72rem;
  }
  .page-duplex-toggle-chip {
    padding: 3px 6px;
    font-size: 0.7rem;
  }
}
