/* Modern Mobile-First Stylesheet for Termux Matrix Ops Hub */
:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #121826;
  --bg-card: #182234;
  --bg-card-hover: #1f2b42;
  --border-color: #27354f;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --accent-gold: #d4af37;
  --accent-blue: #38bdf8;
  --accent-green: #34d399;
  --accent-purple: #c084fc;
  --accent-rose: #fb7185;
  --danger: #f87171;
  --warning: #fbbf24;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 16px);
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #f1f5f9;
  --bg-card-hover: #e2e8f0;
  --border-color: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --accent-gold: #b45309;
  --accent-blue: #0284c7;
  --accent-green: #059669;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 75px; /* space for mobile bottom nav */
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(18, 24, 38, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  font-size: 20px;
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.header-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-live {
  background: rgba(52, 211, 153, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(52, 211, 153, 0.3);
}

.badge-pulse {
  width: 6px;
  height: 6px;
  background: var(--accent-green);
  border-radius: 50%;
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.icon-btn:hover {
  background: var(--bg-card-hover);
}

/* Shell Layout: Left Sidebar Menu + Right List Workspace */
.hub-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  flex: 1;
}

/* Left Sidebar Navigation (Desktop/Tablet) / Hidden on Mobile */
.desktop-nav {
  display: none;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  padding: 14px 10px;
}

.nav-tabs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}

.nav-group-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 10px 4px;
}

.nav-group-label:first-child {
  padding-top: 2px;
}

.tab-btn {
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
  width: 100%;
  gap: 8px;
  transition: all 0.18s;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  color: var(--accent-blue);
  background: rgba(56, 189, 248, 0.12);
  border-left-color: var(--accent-blue);
}

.tab-btn.tab-btn-atelier.active {
  color: var(--accent-gold);
  background: rgba(212, 175, 55, 0.12);
  border-left-color: var(--accent-gold);
}

.subnav-group.subnav-primary {
  padding: 2px 0 8px;
  margin-left: 0;
  border-left: none;
  gap: 4px;
}

.subnav-btn {
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  text-align: left;
  transition: all 0.16s;
}

.subnav-btn-muted {
  font-size: 12px;
  padding: 7px 10px;
  margin-top: 2px;
  opacity: 0.78;
}

.subnav-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.subnav-btn.active {
  color: var(--accent-gold);
  background: rgba(212, 175, 55, 0.13);
  border-left-color: var(--accent-gold);
}

.nav-collapse-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 10px;
  padding: 9px 10px;
  background: transparent;
  border: none;
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
}

.nav-collapse-toggle:hover {
  color: var(--text-main);
}

.matrix-tools-list {
  display: none;
  flex-direction: column;
  gap: 3px;
  padding-top: 4px;
}

.matrix-tools-list.open {
  display: flex;
}

.subnav-badge {
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.subnav-btn.active .subnav-badge {
  background: rgba(212, 175, 55, 0.24);
  color: var(--accent-gold);
}

/* Mobile Bottom Navigation Bar (App Bar) */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 60;
  background: rgba(18, 24, 38, 0.95);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  padding: 6px 4px calc(6px + var(--safe-bottom));
}

.mobile-nav-item {
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px 6px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s;
  flex: 1;
}

.mobile-nav-item .nav-icon {
  font-size: 18px;
  margin-bottom: 2px;
}

.mobile-nav-item.active {
  color: var(--accent-gold);
}

body.hub-tab-atelier .quick-actions-bar {
  display: none;
}

/* Minimal Atelier Workbench Bar & Clean Controls */
.atelier-compact-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.atelier-compact-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  min-width: 0;
}

.atelier-compact-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
}

.atelier-compact-status {
  font-size: 11px;
  color: var(--accent-green);
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.25);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.atelier-compact-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.atelier-tools-drawer {
  display: none;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  background: var(--bg-card);
  border: 1px solid rgba(212, 175, 55, 0.28);
  border-radius: var(--radius-md);
}

.atelier-tools-drawer.open {
  display: flex;
}

.atelier-drawer-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.atelier-drawer-badges,
.atelier-drawer-btns {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.atelier-drawer-readiness {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

.wb-sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.wb-sec-sub {
  display: inline-block;
  margin-left: 8px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.wb-sec-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.wb-toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.wb-filter-strip {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 3px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
}

.wb-filter-pill {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.wb-filter-pill:hover {
  color: var(--text-main);
}

.wb-filter-pill.active {
  background: rgba(212, 175, 55, 0.18);
  color: var(--accent-gold);
}

.wb-search-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 200px;
  max-width: 380px;
}

.wb-search-inline .form-input {
  padding: 6px 10px;
  font-size: 12px;
}

.wb-sop-details {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

.wb-sop-details summary {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-gold);
  cursor: pointer;
  user-select: none;
}

/* Main Right Content / List Panel */
.app-container {
  width: 100%;
  min-width: 0;
  padding: 14px;
  flex: 1;
}

/* Views */
.view-panel {
  display: none;
  animation: fadeIn 0.2s ease-in-out;
}

.view-panel.active {
  display: block;
}

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

/* Cards & Grid */
.grid-cols-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.grid-cols-4 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 768px) {
  .grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
  .hub-shell {
    flex-direction: row;
    align-items: stretch;
    max-width: 1760px;
    margin: 0 auto;
  }
  .desktop-nav {
    display: flex;
    flex-direction: column;
    width: 244px;
    flex-shrink: 0;
    position: sticky;
    top: 53px;
    height: calc(100vh - 53px);
    overflow-y: auto;
  }
  .app-container {
    padding: 18px 22px;
  }
  .mobile-bottom-nav,
  .mobile-drawer-head,
  .mobile-sidebar-backdrop,
  #mobile-menu-toggle {
    display: none !important;
  }
  body { padding-bottom: 20px; }
}

/* Mobile Adaptation (< 768px): Slide-Over Left Drawer + Card-List Tables */
.mobile-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-gold);
}

.mobile-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1190;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(2px);
}

.mobile-sidebar-backdrop.open {
  display: block;
}

@media (max-width: 767px) {
  .hide-xs {
    display: none !important;
  }
  .app-header {
    padding: 8px 10px;
    gap: 8px;
  }
  .brand-wrapper {
    gap: 6px;
    min-width: 0;
  }
  .brand-logo {
    font-size: 15px;
    white-space: nowrap;
  }
  .badge-live {
    padding: 4px 6px;
  }
  .header-badges {
    gap: 5px;
    flex-shrink: 0;
  }
  .header-badges .icon-btn {
    padding: 5px 8px;
    font-size: 12px;
  }
  .hub-is-authed #mobile-menu-toggle {
    display: inline-flex !important;
    padding: 5px 9px;
    font-size: 15px;
  }
  .atelier-compact-bar {
    padding: 9px 10px;
  }
  .atelier-compact-title {
    font-size: 14px;
  }
  .wb-sec-sub {
    display: block;
    margin-left: 0;
    margin-top: 2px;
  }
  .wb-toolbar-row {
    flex-direction: column;
    align-items: stretch;
  }
  .wb-filter-strip {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .wb-filter-strip::-webkit-scrollbar {
    display: none;
  }
  .wb-search-inline {
    max-width: 100%;
    min-width: 0;
    width: 100%;
  }
  .desktop-nav {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 268px;
    max-width: 82vw;
    z-index: 1200;
    transform: translateX(-105%);
    transition: transform 0.24s ease;
    overflow-y: auto;
    padding: 14px 12px calc(24px + var(--safe-bottom));
    box-shadow: 8px 0 30px rgba(0, 0, 0, 0.6);
  }
  .desktop-nav.mobile-drawer-open {
    transform: translateX(0);
  }
  .app-container {
    padding: 10px 10px 24px;
    overflow-x: hidden;
  }
  .card {
    padding: 12px;
    margin-bottom: 12px;
  }
  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .stat-grid {
    gap: 8px;
  }
  .stat-box {
    padding: 10px;
  }
  .stat-value {
    font-size: 17px;
  }
  .mobile-bottom-nav {
    justify-content: space-around;
    overflow: hidden;
  }
  .mobile-nav-item {
    flex: 1;
    min-width: 0;
    padding: 4px 2px;
    white-space: nowrap;
  }
  .form-input,
  #wb-order-search,
  #wb-customer-search,
  #wb-utp-search-input {
    font-size: 16px;
  }
  #wb-order-search {
    width: 100% !important;
  }
  .hub-modal-backdrop {
    padding: 10px;
    align-items: flex-end;
  }
  .hub-modal-box {
    max-width: 100%;
    width: 100%;
    max-height: 88vh;
    padding: 14px;
    border-radius: 14px;
  }
  .data-table-wrapper {
    -webkit-overflow-scrolling: touch;
  }
  .atelier-wb-section .data-table thead {
    display: none;
  }
  .atelier-wb-section .data-table tbody,
  .atelier-wb-section .data-table tr {
    display: block;
    width: 100%;
  }
  .atelier-wb-section .data-table tbody tr {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 10px;
  }
  .atelier-wb-section .data-table tbody td {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    min-width: 0 !important;
    width: 100% !important;
    padding: 6px 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
    white-space: normal !important;
    word-break: break-word;
  }
  .atelier-wb-section .data-table tbody td:last-child {
    border-bottom: none;
    padding-bottom: 2px;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
  }
  .atelier-wb-section .data-table tbody td[data-label]::before {
    content: attr(data-label);
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.04em;
  }
  .atelier-wb-section .data-table tbody td[colspan] {
    align-items: center;
    justify-content: center;
    border-bottom: none;
  }
  .atelier-wb-section .data-table tbody td[colspan]::before {
    display: none;
  }
}

@media (max-width: 440px) {
  .app-header .badge-live {
    display: none;
  }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 14px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Stat Blocks */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

@media (min-width: 640px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}

.stat-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
  font-family: var(--font-mono);
}

.stat-sub {
  font-size: 11px;
  color: var(--accent-green);
  margin-top: 4px;
}

/* Form Controls */
.form-group {
  margin-bottom: 12px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-main);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent-blue);
}

/* Primary & Action Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: #0284c7;
  color: #fff;
}
.btn-primary:hover {
  background: #0369a1;
}

.btn-success {
  background: #059669;
  color: #fff;
}
.btn-success:hover {
  background: #047857;
}

.btn-gold {
  background: #d4af37;
  color: #0f172a;
}
.btn-gold:hover {
  background: #c59b27;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background: var(--bg-card-hover);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

/* Quick Action Toolbar */
.quick-actions-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 14px;
}

.quick-action-chip {
  flex-shrink: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.quick-action-chip:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-blue);
}

/* Embedded Sandbox Frame Viewer */
.embed-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 180px);
  min-height: 520px;
}

.embed-toolbar {
  background: var(--bg-card);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  gap: 8px;
  flex-wrap: wrap;
}

.embed-url-bar {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--accent-blue);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 180px;
}

.embed-viewport {
  flex: 1;
  display: flex;
  justify-content: center;
  background: #000;
  overflow: auto;
}

.embed-frame {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
  transition: width 0.2s ease;
}

.embed-frame.mode-phone {
  width: 375px;
  box-shadow: 0 0 20px rgba(0,0,0,0.8);
}

.embed-frame.mode-tablet {
  width: 768px;
  box-shadow: 0 0 20px rgba(0,0,0,0.8);
}

.embed-frame.mode-desktop {
  width: 100%;
}

/* Terminal Drawer */
.task-drawer {
  position: fixed;
  bottom: 60px;
  left: 0;
  right: 0;
  background: #06090e;
  border-top: 1px solid var(--border-color);
  z-index: 70;
  max-height: 45vh;
  display: none;
  flex-direction: column;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
}

@media (min-width: 768px) {
  .task-drawer {
    bottom: 0;
  }
}

.task-drawer.open {
  display: flex;
}

.drawer-header {
  background: #0d131f;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.drawer-title {
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 8px;
}

.terminal-logs {
  flex: 1;
  padding: 10px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #38bdf8;
  line-height: 1.5;
  background: #06090e;
  min-height: 160px;
}

.terminal-line {
  margin-bottom: 3px;
  word-break: break-all;
}

/* Table styles */
.data-table-wrapper {
  overflow-x: auto;
}

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

.data-table th {
  text-align: left;
  padding: 8px 10px;
  background: var(--bg-secondary);
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
}

.data-table td {
  padding: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Palette swatches */
.palette-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

@media (min-width: 640px) {
  .palette-grid { grid-template-columns: repeat(4, 1fr); }
}

.color-swatch-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.swatch-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

/* ========================================================================= */
/* Cross-Module Closed-Loop Growth Flywheel Styles                           */
/* ========================================================================= */
.flywheel-container {
  background: linear-gradient(135deg, rgba(24, 34, 52, 0.95), rgba(18, 24, 38, 0.98));
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.flywheel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.flywheel-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.flywheel-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #fff;
}

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

@media (min-width: 768px) {
  .flywheel-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1024px) {
  .flywheel-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

.flywheel-step-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.flywheel-step-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-blue);
  background: var(--bg-card-hover);
}

.flywheel-step-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.flywheel-step-num {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  color: #fff;
}

.flywheel-step-name {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 2px;
  color: var(--text-main);
}

.flywheel-step-en {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.flywheel-kpi-val {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 2px;
}

.flywheel-kpi-lbl {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.flywheel-step-sub {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.3;
}

.flywheel-bridges-list {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.bridge-chip {
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-main);
}

/* Modal Popup Styles */
.hub-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.hub-modal-backdrop.open {
  display: flex;
}

.hub-modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  max-width: 540px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  padding: 18px;
  display: flex;
  flex-direction: column;
}

.hub-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.hub-modal-title {
  font-size: 15px;
  font-weight: 700;
}

/* Sourcing Opportunities & Viability Pipeline */
.sourcing-opp-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.sourcing-opp-card:hover {
  border-color: rgba(56, 189, 248, 0.4);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.sourcing-opp-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  gap: 8px;
}

.sourcing-decision-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
  white-space: nowrap;
}

.decision-p0 {
  background: rgba(52, 211, 153, 0.18);
  color: var(--accent-green);
  border: 1px solid rgba(52, 211, 153, 0.35);
}

.decision-p1 {
  background: rgba(212, 175, 55, 0.18);
  color: var(--accent-gold);
  border: 1px solid rgba(212, 175, 55, 0.35);
}

.decision-p2 {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-muted);
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.sourcing-metric-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin: 10px 0;
}

/* Multi-Station Governance Hub Switcher */
.station-switcher-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 16px;
}

.station-switch-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.station-switch-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}

.station-switch-btn.active {
  background: rgba(56, 189, 248, 0.12);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.2);
}

.governance-recs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.governance-rec-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.governance-rec-card h4 {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.rec-item {
  margin-bottom: 8px;
  padding: 8px;
  background: var(--bg-card);
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.45;
}

.rec-item strong {
  color: var(--text-main);
  font-size: 12px;
}

.rec-item p {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 3px;
}

/* 1688 UTP Universal Trade Protocol Sourcing UI */
.sourcing-1688-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.sourcing-1688-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.sourcing-1688-card:hover {
  border-color: #ff6600;
  transform: translateY(-2px);
}

.sourcing-1688-img-wrap {
  width: 100%;
  height: 160px;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(0,0,0,0.2);
  margin-bottom: 10px;
  position: relative;
}

.sourcing-1688-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sourcing-1688-price {
  font-size: 18px;
  font-weight: 800;
  color: #ff6600;
  font-family: var(--font-mono);
}

.sourcing-1688-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 102, 0, 0.12);
  color: #ff6600;
  border: 1px solid rgba(255, 102, 0, 0.3);
  display: inline-block;
  margin-right: 4px;
  margin-bottom: 4px;
}

.sourcing-1688-badge-super {
  background: rgba(212, 175, 55, 0.15);
  color: var(--accent-gold);
  border-color: rgba(212, 175, 55, 0.4);
}

/* =================================================================== */
/* Matrix Admin Suite: Unified Multi-Site Management Styles            */
/* =================================================================== */

.admin-nav-svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
  stroke: currentColor;
  fill: none;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 9999px;
  border: 1px solid transparent;
}

.badge-paid {
  background: rgba(52, 211, 153, 0.12);
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.3);
}

.badge-pending {
  background: rgba(251, 191, 36, 0.12);
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.3);
}

.badge-shipped {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.3);
}

.badge-delivered {
  background: rgba(192, 132, 252, 0.12);
  color: #c084fc;
  border-color: rgba(192, 132, 252, 0.3);
}

/* Station Management Cards */
.admin-site-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 14px;
}

.admin-site-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.admin-site-card:hover {
  border-color: rgba(56, 189, 248, 0.45);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.admin-site-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.admin-site-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-site-tagline {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.4;
}

.admin-site-meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 11px;
}

.admin-site-meta-item span {
  display: block;
  color: var(--text-muted);
  font-size: 10px;
}

.admin-site-meta-item strong {
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 11px;
}

.admin-site-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

/* CRM Stage Chips */
.crm-stage-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 7px;
  border-radius: 4px;
}

.stage-new {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.stage-dm-action {
  background: rgba(251, 113, 133, 0.18);
  color: #fb7185;
  border: 1px solid rgba(251, 113, 133, 0.4);
}

.stage-dm-sent {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.stage-email-delivered {
  background: rgba(192, 132, 252, 0.15);
  color: #c084fc;
  border: 1px solid rgba(192, 132, 252, 0.4);
}

.stage-sample-ordered {
  background: rgba(212, 175, 55, 0.2);
  color: var(--accent-gold);
  border: 1px solid rgba(212, 175, 55, 0.5);
}

.stage-bulk-order {
  background: rgba(52, 211, 153, 0.2);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.5);
}

/* Screenshot Preview Gallery */
.screenshot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 12px;
}

.screenshot-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.screenshot-card-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: #000;
  border-bottom: 1px solid var(--border-color);
}

.screenshot-card-body {
  padding: 10px 12px;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}





/* ========================================================================== */
/* Atelier Pouch B2B Operations Console & SLA Styling                         */
/* ========================================================================== */
.badge-sla-safe {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.35);
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
}

.badge-sla-warning {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.5);
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  animation: pulse-border 2s infinite;
}

.badge-sla-critical {
  background: rgba(239, 68, 68, 0.25);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.6);
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  animation: pulse-border 1s infinite;
}

.badge-sla-breached {
  background: rgba(153, 27, 27, 0.4);
  color: #fca5a5;
  border: 1px solid #ef4444;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
}

.badge-sla-done {
  background: rgba(113, 113, 122, 0.2);
  color: #a1a1aa;
  border: 1px solid rgba(113, 113, 122, 0.4);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
}

.voucher-badge {
  font-family: monospace;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: rgba(212, 175, 55, 0.12);
  color: var(--accent-gold);
  border: 1px dashed rgba(212, 175, 55, 0.4);
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-block;
}

.mold-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.2s ease;
}

.mold-card:hover {
  border-color: var(--accent-gold);
}

.mold-id-chip {
  font-family: monospace;
  font-weight: 700;
  font-size: 12px;
  color: var(--accent-gold);
  background: rgba(212, 175, 55, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(212, 175, 55, 0.25);
}

.kanban-dual-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 14px;
}

.kanban-col {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kanban-col-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 13px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.kanban-card {
  background: var(--bg-tertiary, #1f1f23);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.kanban-card:hover {
  border-color: var(--accent-blue);
}
