/* ══════════════════════════════════════════════════════════════════
   CONTENTO'S DATABASE — Black & Red Marble UI
   ══════════════════════════════════════════════════════════════════ */

/* ── Reset & Base ────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #080809;
  --surface: rgba(18, 18, 22, 0.85);
  --surface-solid: #121216;
  --surface-raised: rgba(26, 26, 32, 0.9);
  --surface-overlay: rgba(32, 32, 40, 0.92);
  --border: rgba(255, 255, 255, 0.07);
  --border-subtle: rgba(255, 255, 255, 0.04);
  --border-red: rgba(180, 30, 30, 0.2);
  --text: #eaeaef;
  --text-secondary: #a8a8b8;
  --text-muted: #5e5e70;
  --primary: #c41a1a;
  --primary-hover: #e03030;
  --primary-glow: rgba(196, 26, 26, 0.2);
  --primary-subtle: rgba(196, 26, 26, 0.07);
  --danger: #ef4444;
  --danger-hover: #f87171;
  --success: #22c55e;
  --success-subtle: rgba(34, 197, 94, 0.1);
  --warning: #f59e0b;
  --warning-subtle: rgba(245, 158, 11, 0.1);
  --radius: 10px;
  --radius-lg: 14px;
  --radius-sm: 6px;
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5), 0 1px 4px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.65), 0 4px 12px rgba(0, 0, 0, 0.4);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
}

html, body {
  overflow-x: hidden;
  max-width: 100vw;
  overscroll-behavior-x: none;
  touch-action: pan-y;
}

/* Prevent iOS zoom on input focus — must be 16px+ globally */
input, select, textarea {
  font-size: 16px !important;
  touch-action: manipulation;
}

/* Lock down all elements from triggering horizontal scroll/zoom */
*, *::before, *::after {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  /* ── Marble background ── */
  background-color: #060607;
  background-image:
    /* Deep red vein glow — top left */
    radial-gradient(ellipse 80% 60% at 15% 20%, rgba(140, 15, 15, 0.18) 0%, transparent 60%),
    /* Red vein — center right */
    radial-gradient(ellipse 50% 80% at 85% 45%, rgba(120, 10, 10, 0.12) 0%, transparent 55%),
    /* Subtle warm pulse — bottom */
    radial-gradient(ellipse 90% 40% at 50% 95%, rgba(100, 10, 10, 0.1) 0%, transparent 50%),
    /* Dark stone veins */
    radial-gradient(ellipse 40% 30% at 30% 70%, rgba(20, 20, 28, 0.8) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 70% 25%, rgba(18, 18, 24, 0.6) 0%, transparent 65%),
    /* Fine grain texture */
    radial-gradient(circle at 20% 50%, rgba(30, 10, 10, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(25, 8, 8, 0.1) 0%, transparent 35%),
    radial-gradient(circle at 50% 10%, rgba(20, 20, 30, 0.3) 0%, transparent 50%);
  background-attachment: fixed;
}

/* ── Layout ──────────────────────────────────────────────────────── */
.app {
  display: flex;
  min-height: 100vh;
  max-width: 100vw;
  overflow: hidden;
}

/* ══════════════════════════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════════════════════════ */
.sidebar {
  width: 270px;
  background:
    linear-gradient(180deg,
      rgba(12, 12, 14, 0.97) 0%,
      rgba(8, 8, 10, 0.98) 50%,
      rgba(10, 10, 12, 0.99) 100%);
  backdrop-filter: blur(20px);
  color: #fff;
  padding: 0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  height: 100vh;
  position: sticky;
  top: 0;
  border-right: 1px solid var(--border);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
}

.sidebar h1 {
  font-size: 17px;
  font-weight: 800;
  padding: 24px 22px 22px;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.4px;
  background:
    linear-gradient(135deg, rgba(180, 20, 20, 0.08) 0%, transparent 50%),
    linear-gradient(225deg, rgba(100, 10, 10, 0.05) 0%, transparent 40%);
}

.sidebar h1 span {
  background: linear-gradient(135deg, #e53e3e 0%, #c41a1a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar h2 {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(255, 255, 255, 0.25);
  padding: 22px 22px 8px;
  font-weight: 700;
}

/* ── Collapsible Sidebar Sections ────────────────────────────────── */
.sidebar-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-toggle {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color var(--transition);
}

.sidebar-toggle:hover {
  color: rgba(255, 255, 255, 0.55);
}

.toggle-arrow {
  font-size: 9px;
  transition: transform var(--transition);
  display: inline-block;
  line-height: 1;
}

.toggle-arrow.collapsed {
  transform: rotate(-90deg);
}

.sidebar-collapsible {
  overflow-y: auto;
  transition: max-height 0.3s ease, opacity 0.2s ease;
  max-height: 2000px;
  opacity: 1;
}

.sidebar-collapsible.collapsed {
  max-height: 0 !important;
  opacity: 0;
  overflow: hidden;
}

.table-list {
  list-style: none;
  overflow-y: auto;
}

#tableList {
  flex: 1;
  min-height: 0;
}

#queryList {
  max-height: 200px;
}

.table-list li {
  padding: 9px 22px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.45);
  border-left: 2px solid transparent;
  position: relative;
}

.table-list li::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
  transition: all var(--transition);
}

.table-list li:hover {
  background: rgba(196, 26, 26, 0.04);
  color: rgba(255, 255, 255, 0.8);
  border-left-color: rgba(196, 26, 26, 0.25);
}

.table-list li:hover::before {
  background: rgba(196, 26, 26, 0.4);
}

.table-list li.active {
  background: linear-gradient(90deg, rgba(196, 26, 26, 0.1) 0%, rgba(196, 26, 26, 0.03) 100%);
  color: #fff;
  border-left-color: var(--primary);
  font-weight: 600;
}

.table-list li.active::before {
  background: var(--primary);
  box-shadow: 0 0 8px rgba(196, 26, 26, 0.5);
}

/* Sidebar Footer */
.sidebar-footer {
  margin-top: auto;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(0, 0, 0, 0.3);
}

.sidebar-footer-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  min-width: 0;
}

.sidebar-footer-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-info {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.15);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.settings-gear {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.2);
  cursor: pointer;
  padding: 7px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}

.settings-gear:hover {
  color: var(--primary-hover);
  background: rgba(196, 26, 26, 0.08);
}

/* ══════════════════════════════════════════════════════════════════
   MAIN CONTENT
   ══════════════════════════════════════════════════════════════════ */
.main {
  flex: 1;
  padding: 32px 36px;
  overflow-x: hidden;
  overflow-y: auto;
  min-width: 0;
  max-width: calc(100vw - 270px);
  height: 100vh;
}

/* ── Welcome State ───────────────────────────────────────────────── */
.welcome {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60vh;
  text-align: center;
}

.welcome h2 {
  font-size: 26px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: -0.3px;
}

.welcome p {
  color: var(--text-muted);
  margin-top: 8px;
  font-size: 15px;
}

/* ── Toolbar ─────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  max-width: 100%;
}

.toolbar h2 {
  font-size: 24px;
  font-weight: 800;
  margin-right: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  letter-spacing: -0.5px;
}

.search-box {
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  width: 260px;
  max-width: 100%;
  outline: none;
  transition: all var(--transition);
  background: var(--surface);
  backdrop-filter: blur(12px);
  color: var(--text);
  font-family: var(--font-sans);
}

.search-box::placeholder {
  color: var(--text-muted);
}

.search-box:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--surface-raised);
}

.sort-select {
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: var(--font-sans);
  outline: none;
  transition: all var(--transition);
  background: var(--surface);
  backdrop-filter: blur(12px);
  color: var(--text-secondary);
  cursor: pointer;
  min-width: 160px;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235e5e70' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.sort-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.sort-select option {
  background: var(--surface-solid);
  color: var(--text);
}

/* ══════════════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════════════ */
.btn {
  padding: 9px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-sans);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, #d42020 0%, #a01515 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(196, 26, 26, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #e53030 0%, #c41a1a 100%);
  box-shadow: 0 4px 16px rgba(196, 26, 26, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.18);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-success {
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.btn-success:hover {
  background: linear-gradient(135deg, #2dd468 0%, #1db954 100%);
  box-shadow: 0 4px 16px rgba(34, 197, 94, 0.35);
}

/* ══════════════════════════════════════════════════════════════════
   TABLE LAYOUT — Desktop: traditional rows, Mobile: cards
   ══════════════════════════════════════════════════════════════════ */

.table-wrapper-outer {
  position: relative;
  max-width: 100%;
}

.table-wrapper {
  background: var(--surface);
  backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow-x: auto;
  max-width: 100%;
}

/* ── Scroll arrow buttons ── */
.scroll-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d42020 0%, #a01515 100%);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 0 12px rgba(196, 26, 26, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all 0.2s ease;
  font-size: 18px;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
}

.scroll-arrow.visible {
  opacity: 1;
  pointer-events: auto;
}

.scroll-arrow:hover {
  background: linear-gradient(135deg, #e53030 0%, #c41a1a 100%);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5), 0 0 20px rgba(196, 26, 26, 0.4);
  transform: translateY(-50%) scale(1.1);
}

.scroll-arrow:active {
  transform: translateY(-50%) scale(0.95);
}

.scroll-arrow-left {
  left: -18px;
}

.scroll-arrow-right {
  right: -18px;
}

/* Edge fade hints */
.table-wrapper-outer::before,
.table-wrapper-outer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40px;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.table-wrapper-outer::before {
  left: 0;
  background: linear-gradient(90deg, rgba(18, 18, 22, 0.9) 0%, transparent 100%);
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}

.table-wrapper-outer::after {
  right: 0;
  background: linear-gradient(270deg, rgba(18, 18, 22, 0.9) 0%, transparent 100%);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

.table-wrapper-outer.can-scroll-left::before {
  opacity: 1;
}

.table-wrapper-outer.can-scroll-right::after {
  opacity: 1;
}

.data-table {
  min-width: 100%;
  width: max-content;
  border-collapse: collapse;
  font-size: 13px;
  border: none;
}

/* Desktop: show table header */
.data-table thead {
  display: table-header-group;
}

.data-table th {
  background: rgba(0, 0, 0, 0.3);
  padding: 10px 6px;
  text-align: left;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table tbody {
  display: table-row-group;
}

.data-table tr {
  display: table-row;
  transition: background 0.2s ease;
}

.data-table tr:hover td {
  background: rgba(196, 26, 26, 0.03);
}

.data-table td {
  display: table-cell;
  padding: 10px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  vertical-align: middle;
}

/* Hide data-label on desktop — only used in mobile card layout */
.data-table td::before {
  display: none;
}

/* Actions cell in table row */
.data-table td.actions {
  white-space: nowrap;
  text-align: right;
  padding: 8px 6px;
}

.data-table td.actions .btn {
  margin-left: 4px;
}

/* Empty state row */
.data-table .empty-cell {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  border: none;
  font-size: 15px;
  display: table-cell;
  justify-content: center;
}

/* ── Row Pop-in Animation ──────────────────────────────────────── */
.data-table tr.row-pop-in {
  animation: rowPopIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes rowPopIn {
  0% {
    opacity: 0;
    transform: scale(0.92) translateY(-8px);
    box-shadow: 0 0 0 2px rgba(196, 26, 26, 0.4);
  }
  50% {
    box-shadow: 0 0 20px rgba(196, 26, 26, 0.25);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
    box-shadow: none;
  }
}

/* Pop-in highlight flash for desktop table rows */
.data-table tr.row-pop-in td {
  animation: cellFlash 0.6s ease both;
}

@keyframes cellFlash {
  0% {
    background: rgba(196, 26, 26, 0.12);
  }
  100% {
    background: transparent;
  }
}

/* ── Pagination ──────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 4px;
  font-size: 13px;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.pagination-buttons {
  display: flex;
  gap: 8px;
}

.sort-arrow {
  margin-left: 4px;
  font-size: 10px;
}

/* ══════════════════════════════════════════════════════════════════
   MODALS — Frosted Overlay
   ══════════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.25s;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
}

.modal-overlay.show {
  opacity: 1;
}

.modal {
  background: var(--surface-solid);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow:
    var(--shadow-lg),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  overflow-x: hidden;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  touch-action: pan-y;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.modal-overlay.show .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(196, 26, 26, 0.04) 0%, transparent 60%);
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.modal-close:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

/* ══════════════════════════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════════════════════════ */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.form-group label .type-hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  max-width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px; /* 16px prevents iOS auto-zoom on focus */
  font-family: var(--font-sans);
  outline: none;
  transition: all var(--transition);
  background: rgba(8, 8, 10, 0.6);
  color: var(--text);
  touch-action: manipulation;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: rgba(8, 8, 10, 0.8);
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
}

.form-group .identity-badge {
  display: inline-block;
  background: rgba(8, 8, 10, 0.4);
  color: var(--text-muted);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  border: 1px dashed rgba(255, 255, 255, 0.08);
  width: 100%;
  font-style: italic;
}

/* ══════════════════════════════════════════════════════════════════
   TOASTS
   ══════════════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 250px;
  backdrop-filter: blur(16px);
  letter-spacing: 0.01em;
}

.toast.success {
  background: linear-gradient(135deg, rgba(22, 163, 74, 0.9), rgba(21, 128, 61, 0.9));
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.toast.error {
  background: linear-gradient(135deg, rgba(196, 26, 26, 0.9), rgba(160, 21, 21, 0.9));
  border: 1px solid rgba(239, 68, 68, 0.3);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ── Loading ─────────────────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--text-muted);
  gap: 12px;
  font-size: 14px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── Confirm Dialog ──────────────────────────────────────────────── */
.confirm-body {
  text-align: center;
  padding: 12px 0;
}

.confirm-body p {
  font-size: 15px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ══════════════════════════════════════════════════════════════════
   QUERY EDITOR
   ══════════════════════════════════════════════════════════════════ */
.query-editor-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 100%;
  overflow: hidden;
}

.query-top-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  max-width: 100%;
}

.query-top-bar h2 {
  font-size: 24px;
  font-weight: 800;
  margin-right: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  letter-spacing: -0.5px;
}

.query-name-input {
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  width: 260px;
  max-width: 100%;
  outline: none;
  transition: all var(--transition);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
}

.query-name-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.query-desc-input {
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  width: 100%;
  outline: none;
  transition: all var(--transition);
  color: var(--text-muted);
  background: var(--surface);
  font-family: var(--font-sans);
}

.query-desc-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  color: var(--text);
}

.query-textarea {
  width: 100%;
  min-height: 180px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.7;
  resize: vertical;
  outline: none;
  background: rgba(8, 8, 10, 0.7);
  color: var(--text);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: all var(--transition);
  tab-size: 2;
}

.query-textarea:focus {
  border-color: var(--primary);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.4), 0 0 0 3px var(--primary-glow);
}

.query-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Query results keep traditional table layout */
.query-results {
  background: var(--surface);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow-x: auto;
  max-width: 100%;
}

.query-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(0, 0, 0, 0.2);
}

/* Query results — keep table layout even on mobile */
.query-results .data-table td {
  max-width: 220px;
  font-size: 13px;
  padding: 10px 16px;
}

@media (max-width: 768px) {
  .query-results .data-table thead {
    display: table-header-group;
  }

  .query-results .data-table tbody {
    display: table-row-group;
  }

  .query-results .data-table tr {
    display: table-row;
    background: transparent;
    border: none;
    border-radius: 0;
    overflow: visible;
  }

  .query-results .data-table td {
    display: table-cell;
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: normal;
    padding: 10px 12px;
  }

  .query-results .data-table td::before {
    display: none;
  }

  .query-results .data-table td:first-child {
    padding-top: 10px;
  }

  .query-results .data-table td:last-child {
    padding-bottom: 10px;
  }
}

.query-results-info {
  padding: 12px 18px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.query-error {
  padding: 16px;
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.15);
  border-radius: var(--radius);
  color: #f87171;
  font-size: 14px;
  font-family: var(--font-mono);
  white-space: pre-wrap;
  word-break: break-word;
}

.query-empty {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.sidebar .table-list + .table-list {
  border-top: none;
}

.table-list li .query-icon {
  flex-shrink: 0;
}

.table-list li .query-delete {
  margin-left: auto;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.15);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  line-height: 1;
  border-radius: 4px;
  transition: all var(--transition);
}

.table-list li .query-delete:hover {
  color: #f87171;
  background: rgba(239, 68, 68, 0.1);
}

/* ══════════════════════════════════════════════════════════════════
   CONTAINER TRACKING
   ══════════════════════════════════════════════════════════════════ */
.ct-page {
  max-width: 100%;
}

.ct-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.ct-header h2 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.ct-header-actions {
  display: flex;
  gap: 8px;
}

/* Search bar */
.ct-search-bar {
  position: relative;
  margin-bottom: 16px;
}

.ct-search-input {
  width: 100%;
  padding: 11px 40px 11px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(8, 8, 10, 0.6);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
  transition: all var(--transition);
}

.ct-search-input::placeholder {
  color: var(--text-muted);
}

.ct-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: rgba(8, 8, 10, 0.8);
}

.ct-search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  border-radius: 4px;
  transition: all var(--transition);
}

.ct-search-clear:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

/* Pagination */
.ct-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 24px;
  padding: 16px 0;
}

.ct-page-info {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.ct-page-total {
  color: var(--text-muted);
  font-weight: 400;
}

/* Toggle button row (Return/No Return, Swap/No Swap) */
.ct-toggle-row {
  display: flex;
  gap: 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.ct-toggle-btn {
  flex: 1;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-sans);
  background: rgba(8, 8, 10, 0.5);
  color: var(--text-muted);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
}

.ct-toggle-btn:not(:last-child) {
  border-right: 1px solid var(--border);
}

.ct-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
}

.ct-toggle-btn.active {
  background: var(--primary-subtle);
  color: var(--primary-hover);
  font-weight: 700;
}

/* Filter pills */
.ct-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.ct-filter-pill {
  padding: 7px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ct-filter-pill:hover {
  border-color: var(--pill-color, var(--text-muted));
  color: var(--pill-color, var(--text));
}

.ct-filter-pill.active {
  background: var(--pill-color, var(--primary));
  color: #fff;
  border-color: var(--pill-color, var(--primary));
}

.ct-pill-count {
  background: rgba(255, 255, 255, 0.15);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
}

.ct-filter-pill.active .ct-pill-count {
  background: rgba(255, 255, 255, 0.25);
}

/* Container grid */
.ct-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* Container card */
.ct-card {
  background: var(--surface);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  border-top: 2px solid var(--card-border);
}

.ct-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--card-border);
}

.ct-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 0;
}

.ct-card-id {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
}

.ct-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid;
  letter-spacing: 0.3px;
}

.ct-status-badge-lg {
  padding: 6px 18px;
  font-size: 13px;
}

.ct-card-body {
  padding: 12px 18px;
}

.ct-card-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
}

.ct-card-label {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.ct-card-value {
  color: var(--text);
  font-weight: 500;
  text-align: right;
}

.ct-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.15);
}

/* Detail page */
.ct-detail {
  max-width: 100%;
}

.ct-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.ct-detail-header h2 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.ct-detail-sub {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 2px;
}

.ct-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.ct-detail-card {
  background: var(--surface);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.ct-detail-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(196, 26, 26, 0.2), transparent);
}

.ct-detail-card h3 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.ct-info-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ct-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}

.ct-info-row span {
  color: var(--text-muted);
}

.ct-info-row strong {
  color: var(--text);
  font-weight: 600;
}

/* Action form */
.ct-action-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ct-action-form select,
.ct-action-form input {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font-sans);
  background: rgba(8, 8, 10, 0.6);
  color: var(--text);
  outline: none;
  transition: all var(--transition);
}

.ct-action-form select:focus,
.ct-action-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Inline yard selector in the container detail info rows */
.ct-yard-select {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px !important;
  font-family: var(--font-sans);
  background: rgba(8, 8, 10, 0.6);
  color: var(--text);
  outline: none;
  cursor: pointer;
  transition: all var(--transition);
}
.ct-yard-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Lifecycle form elements */
.ct-form-hint {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 4px;
}

.ct-field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: -4px;
}

.ct-manual-override {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.ct-manual-override details summary {
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  transition: color var(--transition);
}

.ct-manual-override details summary:hover {
  color: var(--text-secondary);
}

.ct-manual-override details[open] summary {
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.btn-success {
  background: var(--success);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-success:hover {
  background: #16a34a;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.15);
}

/* Status timeline */
.ct-timeline {
  position: relative;
  padding-left: 24px;
}

.ct-timeline::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border);
}

.ct-timeline-item {
  position: relative;
  padding: 8px 0 16px 16px;
}

.ct-timeline-item:last-child {
  padding-bottom: 0;
}

.ct-timeline-dot {
  position: absolute;
  left: -20px;
  top: 12px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--surface-solid);
  z-index: 1;
}

.ct-timeline-latest .ct-timeline-dot {
  width: 14px;
  height: 14px;
  left: -21px;
  box-shadow: 0 0 8px currentColor;
}

.ct-timeline-status {
  font-weight: 700;
  font-size: 14px;
}

.ct-timeline-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.ct-timeline-notes {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}
.ct-timeline-assign {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
  font-size: 12px;
}
.ct-timeline-cust {
  font-weight: 600;
  color: var(--text);
}
.ct-timeline-loc {
  color: var(--text-secondary);
}
.ct-timeline-ds {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--primary-hover);
  background: var(--primary-subtle);
  border: 1px solid var(--border-red);
  padding: 1px 7px;
  border-radius: 20px;
}

@media (max-width: 768px) {
  .ct-header h2 {
    font-size: 22px;
  }

  .ct-grid {
    grid-template-columns: 1fr;
  }

  .ct-detail-grid {
    grid-template-columns: 1fr;
  }

  .ct-detail-header h2 {
    font-size: 22px;
  }

  .ct-filters {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }

  .ct-filter-pill {
    flex-shrink: 0;
  }
}

/* ══════════════════════════════════════════════════════════════════
   DASHBOARD
   ══════════════════════════════════════════════════════════════════ */
.dashboard {
  max-width: 100%;
}

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.dashboard-header h2 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

/* Summary stat cards */
.dash-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.dash-stat-card {
  background: var(--surface);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: all 0.25s ease;
}

.dash-stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(196, 26, 26, 0.4), transparent);
}

.dash-stat-card:hover {
  border-color: rgba(196, 26, 26, 0.15);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.dash-stat-value {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #e53e3e 0%, #c41a1a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.dash-stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Chart cards */
.dash-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.dash-chart-card {
  background: var(--surface);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.dash-chart-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(196, 26, 26, 0.2), transparent);
}

.dash-chart-card h3 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.dash-chart-wrap {
  height: clamp(220px, 28vh, 500px);
  position: relative;
}

.dash-chart-tall {
  height: clamp(280px, 35vh, 600px);
}

.dash-full-width {
  margin-bottom: 16px;
}

/* Recent activity */
.dash-recent {
  display: flex;
  flex-direction: column;
}

.dash-activity-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 13px;
}

.dash-activity-row:last-child {
  border-bottom: none;
}

.dash-activity-source {
  font-weight: 700;
  color: var(--primary-hover);
  min-width: 100px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.dash-activity-date {
  color: var(--text-secondary);
  min-width: 100px;
}

.dash-activity-detail {
  color: var(--text-muted);
  min-width: 80px;
  text-align: right;
}

/* Large screens — bigger cards, more padding */
@media (min-width: 1400px) {
  .dash-summary {
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
  }

  .dash-stat-card {
    padding: 36px 28px;
  }

  .dash-stat-value {
    font-size: 40px;
  }

  .dash-stat-label {
    font-size: 12px;
    margin-top: 6px;
  }

  .dash-charts-row {
    gap: 20px;
    margin-bottom: 20px;
  }

  .dash-chart-card {
    padding: 28px;
  }

  .dash-chart-card h3 {
    font-size: 14px;
    margin-bottom: 20px;
  }

  .dash-activity-row {
    padding: 14px 8px;
    font-size: 14px;
  }
}

/* Extra large screens */
@media (min-width: 1800px) {
  .dash-summary {
    gap: 24px;
  }

  .dash-stat-card {
    padding: 44px 32px;
  }

  .dash-stat-value {
    font-size: 48px;
  }

  .dash-charts-row {
    gap: 24px;
    margin-bottom: 24px;
  }

  .dash-chart-card {
    padding: 36px;
  }
}

@media (max-width: 768px) {
  .dashboard-header h2 {
    font-size: 22px;
  }

  .dash-summary {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .dash-stat-value {
    font-size: 24px;
  }

  .dash-stat-card {
    padding: 16px 12px;
  }

  .dash-charts-row {
    grid-template-columns: 1fr;
  }

  .dash-chart-wrap {
    height: 200px;
  }

  .dash-activity-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  .dash-activity-source {
    min-width: auto;
  }

  .dash-activity-date {
    min-width: auto;
  }

  .dash-activity-detail {
    min-width: auto;
    text-align: left;
  }
}

/* ══════════════════════════════════════════════════════════════════
   DELIVERY INTAKE FORM
   ══════════════════════════════════════════════════════════════════ */
.di-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
}

.di-header {
  margin-bottom: 24px;
}

.di-header h2 {
  font-size: 24px;
  font-weight: 800;
  margin: 12px 0 4px;
}

.di-subtitle {
  color: var(--text-secondary);
  font-size: 14px;
}

.di-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.di-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  backdrop-filter: blur(20px);
}

.di-section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ── Container slot builder (delivery intake) ─────────────────── */
.di-container-slots {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.di-container-slot {
  display: flex;
  align-items: center;
  gap: 8px;
}

.di-container-slot select.di-slot-size {
  flex: 1;
  min-width: 120px;
}

.di-container-slot .di-slot-qty {
  width: 60px;
  text-align: center;
}

.di-container-slot .di-slot-remove {
  color: var(--text-muted);
  font-size: 16px;
}

.di-container-slot .di-slot-remove:hover {
  color: #ef4444;
}

.di-toggle-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.di-toggle {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-sans);
}

.di-toggle:hover {
  color: var(--text-secondary);
  border-color: rgba(255,255,255,0.15);
}

.di-toggle.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.di-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.di-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.di-field.di-full {
  grid-column: 1 / -1;
}

.di-field.di-half {
  /* stays as one column */
}

.di-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.di-form select,
.di-form input,
.di-form textarea {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font-sans);
  background: rgba(8, 8, 10, 0.6);
  color: var(--text);
  outline: none;
  transition: all var(--transition);
  width: 100%;
}

.di-form select:focus,
.di-form input:focus,
.di-form textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.di-form textarea {
  resize: vertical;
  min-height: 60px;
}

.di-money-input {
  position: relative;
  display: flex;
  align-items: center;
}

.di-money-prefix {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  pointer-events: none;
  z-index: 1;
}

.di-money-input input {
  padding-left: 28px;
}

.di-submit-row {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 8px 0 32px;
}

.btn-lg {
  padding: 14px 32px;
  font-size: 16px;
  font-weight: 700;
}

@media (max-width: 768px) {
  .di-page {
    padding: 16px;
  }

  .di-section {
    padding: 16px;
  }

  .di-fields {
    grid-template-columns: 1fr;
  }

  .di-toggle-row {
    flex-wrap: wrap;
  }

  .di-submit-row {
    flex-direction: column;
  }

  .di-submit-row .btn {
    width: 100%;
    text-align: center;
  }
}

/* ── Delivery Sheet Detail ─────────────────────────────────────── */
.ds-detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.ds-detail-header h2 {
  font-size: 24px;
  font-weight: 800;
}

.ds-assign-card {
  background: var(--surface);
  border: 2px dashed var(--warning);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
}

.ds-assign-card.ds-assigned {
  border: 2px solid rgba(34, 197, 94, 0.3);
  border-style: solid;
  text-align: left;
}

.ds-assign-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

.ds-assign-card h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}

.ds-assign-card .ct-form-hint {
  margin-bottom: 16px;
}

.ds-assign-card .ct-action-form {
  text-align: left;
}

.ds-assign-card + .ds-assign-card {
  margin-top: 12px;
}

.ds-assigned .ds-assign-icon {
  color: var(--success);
}

/* ── Delivery Sheet Records Tables ──────────────────────────────── */
.ds-records-table-wrap {
  overflow-x: auto;
  margin-top: 8px;
}

.ds-records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ds-records-table th {
  text-align: left;
  padding: 8px 10px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.ds-records-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text-primary);
  white-space: nowrap;
}

.ds-records-table tr:last-child td {
  border-bottom: none;
}

.ds-records-table tbody tr:hover {
  background: rgba(255,255,255,0.03);
}

/* ══════════════════════════════════════════════════════════════════
   DATA ENTRY PAGE
   ══════════════════════════════════════════════════════════════════ */
.data-entry-page {
  max-width: 720px;
  margin: 0 auto;
}

.data-entry-header {
  margin-bottom: 28px;
}

.data-entry-header h2 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.data-entry-subtitle {
  color: var(--text-muted);
  font-size: 15px;
}

.data-entry-table-select {
  margin-bottom: 28px;
}

.data-entry-table-select label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.data-entry-table-select select {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  font-family: var(--font-sans);
  font-weight: 600;
  outline: none;
  background: var(--surface);
  backdrop-filter: blur(12px);
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235e5e70' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

.data-entry-table-select select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.data-entry-form {
  background: var(--surface);
  backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  position: relative;
}

/* Red shimmer on top of the form card */
.data-entry-form::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(196, 26, 26, 0.2) 25%,
    rgba(196, 26, 26, 0.4) 50%,
    rgba(196, 26, 26, 0.2) 75%,
    transparent 100%);
}

.data-entry-fields {
  padding: 32px 32px 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 24px;
}

.data-entry-fields .form-group {
  margin-bottom: 20px;
}

/* Make full-width fields span both columns */
.data-entry-fields .form-group:has(textarea) {
  grid-column: 1 / -1;
}

/* Identity badge fields span one column */
.data-entry-fields .form-group:first-child {
  grid-column: 1 / -1;
}

.data-entry-actions {
  display: flex;
  gap: 12px;
  padding: 20px 32px 28px;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}

.btn-lg {
  padding: 14px 28px;
  font-size: 15px;
  font-weight: 700;
  border-radius: var(--radius);
}

/* ── Data Entry Session Log ─────────────────────────────────────── */
.de-session-card {
  margin-top: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.de-session-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}

.de-session-header h3 {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.de-session-count {
  background: var(--primary-subtle);
  color: var(--primary-hover);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}

.de-session-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.de-session-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.de-session-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.de-session-table thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.de-session-table tbody td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.de-session-table tbody tr:last-child td {
  border-bottom: none;
}

.de-session-table tbody tr:hover {
  background: rgba(196, 26, 26, 0.03);
}

.de-session-actions {
  white-space: nowrap;
  text-align: right;
}

@media (max-width: 768px) {
  .de-session-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 12px 16px;
  }
}

@media (max-width: 768px) {
  .data-entry-page {
    max-width: 100%;
  }

  .data-entry-header h2 {
    font-size: 22px;
  }

  .data-entry-fields {
    grid-template-columns: 1fr;
    padding: 20px 16px 8px;
    gap: 0;
  }

  .data-entry-fields .form-group:first-child {
    grid-column: 1;
  }

  .data-entry-actions {
    flex-direction: column;
    padding: 16px;
  }

  .btn-lg {
    width: 100%;
    justify-content: center;
  }
}

/* ══════════════════════════════════════════════════════════════════
   ADMIN PANEL
   ══════════════════════════════════════════════════════════════════ */
.admin-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.admin-tab {
  padding: 12px 22px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition);
  font-family: var(--font-sans);
  letter-spacing: 0.01em;
}

.admin-tab:hover {
  color: var(--text-secondary);
  background: rgba(196, 26, 26, 0.03);
}

.admin-tab.active {
  color: var(--primary-hover);
  border-bottom-color: var(--primary);
}

/* ── Access Checkboxes ──────────────────────────────────────────── */
.access-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px;
}

.access-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
}

.access-item:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--border);
}

.access-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.access-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  margin: 20px 0 10px;
  font-weight: 700;
}

/* ══════════════════════════════════════════════════════════════════
   MOBILE & TABLET
   ══════════════════════════════════════════════════════════════════ */
.mobile-header {
  display: none;
}

.sidebar-overlay {
  display: none;
}

.sidebar-close {
  display: none;
}

@media (max-width: 768px) {

  .app {
    flex-direction: column;
  }

  .mobile-header {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(10, 10, 12, 0.95);
    backdrop-filter: blur(20px);
    color: #fff;
    padding: 14px 16px;
    position: sticky;
    top: 0;
    z-index: 900;
    border-bottom: 1px solid var(--border);
  }

  .hamburger {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
  }

  .mobile-title {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.3px;
  }

  .mobile-title span {
    background: linear-gradient(135deg, #e53e3e 0%, #c41a1a 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 1100;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    height: auto;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar h1 {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .sidebar-close {
    display: block;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.35);
    font-size: 26px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
  }

  .sidebar-close:hover {
    color: #fff;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 1050;
    backdrop-filter: blur(4px);
  }

  .sidebar-overlay.show {
    display: block;
  }

  .main {
    padding: 16px;
    min-height: calc(100vh - 52px);
    max-width: 100vw;
    height: auto;
    overflow-y: visible;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .toolbar h2 {
    font-size: 20px;
  }

  .search-box {
    width: 100%;
  }

  .sort-select {
    width: 100%;
  }

  .btn {
    padding: 11px 20px;
    font-size: 14px;
  }

  .btn-sm {
    padding: 8px 14px;
    font-size: 13px;
  }

  /* ── Switch to card layout on mobile ── */
  .table-wrapper-outer::before,
  .table-wrapper-outer::after {
    display: none;
  }

  .scroll-arrow {
    display: none !important;
  }

  .table-wrapper {
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
    overflow: hidden;
    max-width: 100%;
  }

  .data-table thead {
    display: none;
  }

  .data-table tbody {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .data-table {
    width: 100%;
    min-width: 0;
  }

  .data-table tr {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    backdrop-filter: blur(16px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    position: relative;
    max-width: 100%;
  }

  .data-table tr:hover td {
    background: transparent;
  }

  .data-table td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 8px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    max-width: none;
    white-space: normal;
    word-break: break-word;
    overflow: visible;
    text-overflow: unset;
    font-size: 14px;
    gap: 16px;
  }

  .data-table td:first-child {
    padding-top: 12px;
  }

  .data-table td:last-child {
    border-bottom: none;
    padding-bottom: 12px;
  }

  .data-table td::before {
    display: block;
    content: attr(data-label);
    font-weight: 700;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    flex-shrink: 0;
    padding-top: 3px;
    min-width: 90px;
  }

  .data-table td.actions {
    justify-content: flex-start;
    gap: 8px;
    padding: 10px 16px 14px;
    border-top: 1px solid var(--border);
    border-bottom: none;
    background: rgba(0, 0, 0, 0.2);
    flex-wrap: wrap;
    text-align: left;
  }

  .data-table td.actions .btn {
    flex-shrink: 0;
    font-size: 12px;
    padding: 6px 10px;
  }

  .data-table td.actions::before {
    display: none;
  }

  .data-table td.actions .btn {
    margin-left: 0;
  }

  .data-table .empty-row {
    background: transparent;
    border: 1px dashed var(--border);
  }

  .data-table .empty-cell {
    display: flex;
    justify-content: center;
    text-align: center;
    padding: 40px 16px;
    font-size: 14px;
  }

  .data-table .empty-cell::before {
    display: none !important;
  }

  .query-results {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .pagination {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }

  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    overflow-x: hidden;
  }

  .modal-header {
    padding: 16px;
    position: sticky;
    top: 0;
    background: var(--surface-solid);
    z-index: 1;
  }

  .modal-body {
    padding: 16px;
    overflow-x: hidden;
  }

  .modal-footer {
    padding: 12px 16px;
    flex-wrap: wrap;
    position: sticky;
    bottom: 0;
    background: var(--surface-solid);
    z-index: 1;
  }

  .query-name-input {
    width: 100%;
  }

  .query-textarea {
    min-height: 140px;
    font-size: 13px;
  }

  .query-actions {
    flex-direction: column;
  }

  .query-actions .btn {
    justify-content: center;
  }

  .toast {
    min-width: 0;
    max-width: calc(100vw - 40px);
    font-size: 13px;
  }

  .welcome h2 {
    font-size: 18px;
  }

  .admin-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .admin-tab {
    padding: 10px 16px;
    font-size: 12px;
    white-space: nowrap;
  }
}

/* ══════════════════════════════════════════════════════════════════
   MATERIALS OUT TABLE
   ══════════════════════════════════════════════════════════════════ */

.mo-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.mo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.mo-table thead th {
  padding: 12px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.mo-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  white-space: nowrap;
}

.mo-table tbody tr:last-child td {
  border-bottom: none;
}

.mo-table tbody tr:hover {
  background: rgba(196, 26, 26, 0.03);
}

/* Empty state */
.mo-table .empty-cell {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  border: none;
  font-size: 15px;
  display: table-cell;
}

.mo-table .empty-row {
  background: transparent;
}

.mo-type-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  background: var(--primary-subtle);
  color: var(--primary-hover);
  border: 1px solid rgba(196, 26, 26, 0.15);
  white-space: nowrap;
}

/* ── Mobile: Materials Out cards ──────────────────────────────────── */
@media (max-width: 768px) {
  .mo-table thead {
    display: none;
  }

  .mo-table tbody tr {
    display: block;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    position: relative;
  }

  .mo-table tbody tr:last-child {
    border-bottom: none;
  }

  .mo-table tbody td {
    display: block;
    padding: 2px 0;
    border-bottom: none;
    text-align: left !important;
    white-space: normal;
  }

  .mo-table tbody td::before {
    content: attr(data-label);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    margin-right: 8px;
  }

  .mo-table .empty-row {
    background: transparent;
    border: 1px dashed var(--border);
  }

  .mo-table .empty-cell {
    display: flex;
    justify-content: center;
    text-align: center;
    padding: 40px 16px;
    font-size: 14px;
  }

  .mo-table .empty-cell::before {
    display: none !important;
  }
}

/* Desktop: traditional table rows | Mobile: card layout */

/* ══════════════════════════════════════════════════════════════════
   BRAND & MOTION LAYER  ·  Contento's — black & red marble
   (appended: enhancements only, overrides nothing structural)
   ══════════════════════════════════════════════════════════════════ */

/* ── Brand logo (monochrome JPEG → white via invert + screen blend) ── */
.brand {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: flex-start;
  min-width: 0;
}
.brand-logo {
  height: 26px;
  width: auto;
  max-width: 182px;
  filter: invert(1) contrast(1.15) brightness(1.05);
  mix-blend-mode: screen;
  -webkit-user-drag: none;
  user-select: none;
  animation: brandIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.brand-sub {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 3.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-left: 3px;
}
.mobile-title .brand-logo { height: 20px; }
@keyframes brandIn {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: none; }
}

/* ── View entrance ── */
@keyframes viewEnter {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
.dashboard,
.ct-page,
.ct-detail,
.di-page,
.data-entry-page,
.query-editor-wrapper,
.welcome {
  animation: viewEnter 0.42s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ── Staggered card reveal ── */
@keyframes cardRise {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}
.ct-grid .ct-card,
.dash-summary .dash-stat-card {
  animation: cardRise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.ct-grid .ct-card:nth-child(1),  .dash-summary .dash-stat-card:nth-child(1) { animation-delay: 0.02s; }
.ct-grid .ct-card:nth-child(2),  .dash-summary .dash-stat-card:nth-child(2) { animation-delay: 0.06s; }
.ct-grid .ct-card:nth-child(3),  .dash-summary .dash-stat-card:nth-child(3) { animation-delay: 0.10s; }
.ct-grid .ct-card:nth-child(4),  .dash-summary .dash-stat-card:nth-child(4) { animation-delay: 0.14s; }
.ct-grid .ct-card:nth-child(5),  .dash-summary .dash-stat-card:nth-child(5) { animation-delay: 0.18s; }
.ct-grid .ct-card:nth-child(6) { animation-delay: 0.22s; }
.ct-grid .ct-card:nth-child(7) { animation-delay: 0.26s; }
.ct-grid .ct-card:nth-child(8) { animation-delay: 0.30s; }
.ct-grid .ct-card:nth-child(n+9) { animation-delay: 0.34s; }

/* ── Card hover lift + red glow ── */
.ct-card,
.dash-stat-card,
.ct-detail-card,
.ds-assign-card {
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.22s ease,
              border-color 0.22s ease;
  will-change: transform;
}
.ct-card:hover,
.dash-stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--border-red), 0 6px 22px rgba(196, 26, 26, 0.12);
  border-color: var(--border-red);
}
.ct-detail-card:hover { box-shadow: var(--shadow-md), 0 0 0 1px var(--border-red); }

/* ── Buttons: press feedback + primary sheen sweep ── */
.btn { position: relative; overflow: hidden; }
.btn:active { transform: translateY(1px) scale(0.985); }
.btn-primary::after,
.btn-success::after {
  content: "";
  position: absolute;
  top: 0;
  left: -120%;
  width: 60%;
  height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.18), transparent);
  transform: skewX(-18deg);
  transition: left 0.55s ease;
  pointer-events: none;
}
.btn-primary:hover::after,
.btn-success:hover::after { left: 130%; }

/* ── Filter pills: active pop ── */
.ct-filter-pill { transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1); }
.ct-filter-pill.active { transform: translateY(-1px); }
.ct-filter-pill:active { transform: scale(0.94); }

/* ── Status badges: gentle living glow ── */
@keyframes badgePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(196, 26, 26, 0); }
  50%      { box-shadow: 0 0 10px 0 rgba(196, 26, 26, 0.18); }
}
.ct-status-badge-lg { animation: badgePulse 3.2s ease-in-out infinite; }

/* ── Branded scrollbar ── */
* { scrollbar-width: thin; scrollbar-color: rgba(196, 26, 26, 0.35) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(196, 26, 26, 0.45), rgba(120, 12, 12, 0.4));
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(224, 48, 48, 0.6), rgba(150, 16, 16, 0.5));
  background-clip: padding-box;
}

/* ── Toast: subtle entry bounce already exists (slideIn); add depth ── */
.toast { box-shadow: var(--shadow-lg), 0 0 0 1px var(--border-red); }

/* ── Sidebar nav items: red wipe on hover ── */
.table-list li { position: relative; transition: color 0.2s ease, background 0.2s ease; }

/* ── Respect reduced-motion preferences ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ══════════════════════════════════════════════════════════════════
   COLLAPSIBLE SIDEBAR  ·  hide/show with smooth transition
   ══════════════════════════════════════════════════════════════════ */

/* Header becomes a row so the collapse button sits opposite the brand */
.sidebar h1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-collapse-btn {
  flex-shrink: 0;
  margin-top: 2px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.sidebar-collapse-btn:hover {
  background: var(--primary-subtle);
  border-color: var(--border-red);
  color: var(--text);
  transform: translateX(-1px);
}

/* Floating button to bring the sidebar back (desktop, when hidden) */
.sidebar-show-btn {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 950;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface-raised);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-red);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  transition: all var(--transition);
}
.sidebar-show-btn:hover {
  background: var(--primary-subtle);
  transform: translateX(2px);
  box-shadow: var(--shadow-md), 0 0 16px var(--primary-glow);
}

/* Desktop collapse behaviour */
@media (min-width: 769px) {
  .sidebar {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.22s ease,
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .main {
    transition: max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.3s ease;
  }
  .app.sidebar-collapsed .sidebar {
    width: 0;
    min-width: 0;
    opacity: 0;
    transform: translateX(-16px);
    border-right: none;
    box-shadow: none;
    pointer-events: none;
    overflow: hidden;
  }
  .app.sidebar-collapsed .main {
    max-width: 100vw;
    /* reserve a gutter so page content never renders under the floating show button */
    padding-left: 72px;
  }
  .app.sidebar-collapsed .sidebar-show-btn {
    display: flex;
    animation: brandIn 0.3s ease both;
  }
}

/* On mobile the slide-in drawer + hamburger handle this instead */
@media (max-width: 768px) {
  .sidebar-collapse-btn { display: none; }
  .sidebar-show-btn { display: none !important; }
}

/* ══════════════════════════════════════════════════════════════════
   CONDENSED CONTAINER FILTERS  ·  icon chips + yard dropdown
   ══════════════════════════════════════════════════════════════════ */
.ct-filters-bar {
  align-items: center;
  gap: 8px 10px;
}
.ct-filters-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

/* Compact status chip: icon + count by default, name reveals when active/hovered */
.ct-chip { padding: 7px 12px; }
.ct-chip-ico {
  font-size: 12px;
  line-height: 1;
  color: var(--pill-color, var(--text-secondary));
  transition: color var(--transition);
}
.ct-chip-name {
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  opacity: 0;
  transition: max-width 0.25s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.18s ease;
}
.ct-chip.active .ct-chip-name,
.ct-chip:hover .ct-chip-name {
  max-width: 120px;
  opacity: 1;
}
.ct-chip.active .ct-chip-ico { color: #fff; }

/* Yard dropdown styled as a pill */
.ct-yard-filter-wrap {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 8px 4px 13px;
  margin-left: auto;
  transition: all var(--transition);
}
.ct-yard-filter-wrap.active {
  border-color: var(--border-red);
  background: var(--primary-subtle);
}
.ct-yard-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}
.ct-yard-filter {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 12px !important;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  outline: none;
  padding: 2px 4px;
}
.ct-yard-filter:focus { outline: none; }
.ct-yard-filter option { background: var(--surface-solid); color: var(--text); }

@media (max-width: 768px) {
  .ct-yard-filter-wrap { margin-left: 0; }
}

/* ══════════════════════════════════════════════════════════════════
   OPERATIONAL DASHBOARD  ·  KPI accents, pickups, overdue flags
   ══════════════════════════════════════════════════════════════════ */
/* Per-metric colored accent on each KPI card's top bar */
.dash-stat-card::before {
  background: linear-gradient(90deg, transparent, var(--stat, rgba(196, 26, 26, 0.5)), transparent);
  height: 2.5px;
}
.dash-stat-card:hover {
  border-color: color-mix(in srgb, var(--stat, var(--primary)) 30%, transparent);
}

/* Unit (e.g. "t") and overdue flag inside the gradient-clipped value */
.dash-stat-unit {
  font-size: 17px;
  font-weight: 700;
  margin-left: 3px;
  -webkit-text-fill-color: var(--text-muted);
  color: var(--text-muted);
}
.dash-stat-flag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  margin-left: 8px;
  vertical-align: middle;
  -webkit-text-fill-color: #f87171;
  color: #f87171;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  padding: 1px 8px;
  border-radius: 20px;
}

/* Upcoming pickups list */
.dash-pill-warn {
  font-size: 11px;
  font-weight: 700;
  color: #f87171;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  padding: 2px 9px;
  border-radius: 20px;
  margin-left: 8px;
}
.dash-clickable {
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.dash-clickable:hover { background: rgba(255, 255, 255, 0.04); }
.dash-row-overdue { box-shadow: inset 3px 0 0 #ef4444; }
.dash-date-overdue { color: #f87171 !important; font-weight: 700; }
.dash-activity-source { font-weight: 600; flex: 1 1 auto; min-width: 0; }

/* ── Report builder (ported from DataDesk) ───────────────────────── */
.nt-flag { display:inline-flex; align-items:center; gap:4px; font-size:12px; color:var(--text-secondary); white-space:nowrap; cursor:pointer; }
.nt-flag input { width:auto; margin:0; }
.report-controls { padding: 20px; max-width: 820px; width: 100%; box-sizing: border-box; }
.report-section { margin: 16px 0; }
.report-section > label { display:block; font-size:13px; font-weight:600; color:var(--text-secondary); margin-bottom:8px; }
.rb-checks { display:flex; flex-wrap:wrap; gap:10px; max-height:150px; overflow:auto; padding:10px; border:1px solid var(--border); border-radius:var(--radius); background:var(--surface); }
.report-controls input, .report-controls select { max-width: 100%; min-width: 0; box-sizing: border-box; }
.rb-row { min-width: 0; flex-wrap: wrap; }
.rb-row > input, .rb-row > select { min-width: 0; box-sizing: border-box; }
.rb-row > .rb-fl-val, .rb-row > .rb-agg-col, .rb-row > .rb-fl-col { flex: 1 1 120px; }

/* ── Dashboard delivery/pickup calendar ──────────────────────────── */
.cal-head { display:flex; align-items:center; gap:16px; flex-wrap:wrap; margin-bottom:14px; }
.cal-head h3 { margin:0; }
.cal-nav { display:flex; align-items:center; gap:8px; }
.cal-month { font-weight:700; min-width:150px; text-align:center; }
.cal-legend { margin-left:auto; font-size:12px; color:var(--text-secondary); display:flex; align-items:center; gap:6px; }
.cal-dot { width:10px; height:10px; border-radius:3px; display:inline-block; }
.cal-dot.d { background:#2563eb; } .cal-dot.p { background:#d97706; margin-left:8px; }
.cal-grid { display:grid; grid-template-columns:repeat(7,1fr); gap:6px; }
.cal-dow { text-align:center; font-size:11px; font-weight:700; color:var(--text-muted); text-transform:uppercase; padding:4px 0; }
.cal-cell { min-height:74px; border:1px solid var(--border); border-radius:8px; padding:6px; cursor:pointer; transition:background .15s, border-color .15s; display:flex; flex-direction:column; gap:3px; overflow:hidden; }
.cal-cell:hover { border-color:var(--primary); }
.cal-cell.cal-out { opacity:0.4; }
.cal-cell.cal-today { box-shadow:inset 0 0 0 2px var(--primary); }
.cal-cell.cal-sel { background:var(--primary-subtle); border-color:var(--primary); }
.cal-num { font-size:12px; font-weight:600; color:var(--text-secondary); }
.cal-chip { font-size:10px; font-weight:700; color:#fff; border-radius:8px; padding:1px 6px; white-space:nowrap; align-self:flex-start; }
.cal-chip.d { background:#2563eb; } .cal-chip.p { background:#d97706; }
.cal-day-head { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:10px; margin:18px 0 6px; padding-top:14px; border-top:1px solid var(--border); }
.cal-day-head h4 { margin:0; font-size:14px; }
.cal-item { display:flex; align-items:center; gap:12px; padding:9px 10px; border-bottom:1px solid var(--border-subtle); cursor:pointer; }
.cal-item:hover { background:var(--primary-subtle); }
.cal-tag { font-size:10px; font-weight:700; color:#fff; border-radius:10px; padding:2px 9px; flex-shrink:0; }
.cal-tag.d { background:#2563eb; } .cal-tag.p { background:#d97706; }
.cal-item-cust { font-weight:600; }
.cal-item-site { color:var(--text-secondary); font-size:13px; }
.cal-item-size { color:var(--text-muted); font-size:12px; }
.cal-item-ds { margin-left:auto; color:var(--text-muted); font-size:12px; white-space:nowrap; }
@media (max-width:640px){ .cal-cell{ min-height:54px; } .cal-item{ flex-wrap:wrap; gap:6px; } .cal-item-ds{ margin-left:0; } }
