/* ===================================================================
   NNC Flow - Midnight Broadcast Design System
   Theme: Deep Space Obsidian & Electric Lime Green
   Typography: Space Grotesk
   =================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  --bg-base: #06080c;
  --bg-primary: #0a0d14;
  --bg-surface: #101520;
  --bg-card: rgba(16, 21, 32, 0.85);
  --bg-card-hover: rgba(22, 29, 44, 0.95);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(0, 255, 102, 0.35);

  --accent-lime: #00ff66;
  --accent-lime-dim: #00cc52;
  --accent-glow: 0 0 20px rgba(0, 255, 102, 0.25);
  --accent-glow-intense: 0 0 30px rgba(0, 255, 102, 0.45);

  --text-main: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-dim: #475569;

  --badge-active-bg: rgba(0, 255, 102, 0.12);
  --badge-active-text: #00ff66;
  --badge-cooldown-bg: rgba(245, 158, 11, 0.15);
  --badge-cooldown-text: #fbbf24;
  --badge-paused-bg: rgba(100, 116, 139, 0.2);
  --badge-paused-text: #94a3b8;
  --badge-failed-bg: rgba(239, 68, 68, 0.15);
  --badge-failed-text: #f87171;

  --sidebar-width: 260px;
  --topbar-height: 70px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --transition-fast: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  overflow-x: hidden;
  max-width: 100vw;
  width: 100%;
}

body {
  background-color: var(--bg-base);
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(0, 255, 102, 0.03) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(14, 165, 233, 0.03) 0%, transparent 40%);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

a {
  color: var(--accent-lime);
  text-decoration: none;
  transition: var(--transition-fast);
}
a:hover {
  color: #fff;
  text-shadow: 0 0 8px rgba(0, 255, 102, 0.6);
}

/* ===================================================================
   LAYOUT ARCHITECTURE
   =================================================================== */

.app-wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-primary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  transition: var(--transition-fast);
}

.sidebar-header {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  gap: 0.85rem;
}

.sidebar-logo {
  height: 34px;
  width: auto;
  border-radius: var(--radius-sm);
  filter: drop-shadow(0 0 8px rgba(0, 255, 102, 0.4));
}

.brand-text {
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  color: #fff;
}
.brand-accent {
  color: var(--accent-lime);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0.75rem 0.75rem 0.25rem;
  font-weight: 600;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.65rem 0.85rem;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  font-size: 0.925rem;
  font-weight: 500;
  transition: var(--transition-fast);
}

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

.nav-link.active {
  background: rgba(0, 255, 102, 0.1);
  color: var(--accent-lime);
  border-left: 3px solid var(--accent-lime);
  font-weight: 600;
}

.nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.8;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-snippet {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  overflow: hidden;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--accent-lime);
}

.user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-badge {
  font-size: 0.7rem;
  color: var(--accent-lime);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* MAIN CONTENT AREA */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-height);
  background: rgba(10, 13, 20, 0.75);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.page-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.engine-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(0, 255, 102, 0.1);
  color: var(--accent-lime);
  border: 1px solid rgba(0, 255, 102, 0.25);
  box-shadow: var(--accent-glow);
}

.engine-pulse {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--accent-lime);
  animation: pulse-glow 2s infinite ease-in-out;
}

.engine-badge.offline {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
  box-shadow: none;
}
.engine-badge.offline .engine-pulse {
  background: #f87171;
  animation: none;
}

@keyframes pulse-glow {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 255, 102, 0.7); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 8px rgba(0, 255, 102, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 255, 102, 0); }
}

.page-container {
  padding: 2rem;
  flex: 1;
}

/* ===================================================================
   COMPONENTS: STAT CARDS & METRICS
   =================================================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
  transition: var(--transition-fast);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-glow);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.stat-title {
  font-size: 0.825rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-lime);
}

.stat-value {
  font-size: 2.25rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.1;
  font-family: 'JetBrains Mono', monospace;
}

.stat-footer {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ===================================================================
   CARDS & PANELS
   =================================================================== */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(12px);
  overflow: hidden;
  margin-bottom: 2rem;
  transition: var(--transition-fast);
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.01);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-body {
  padding: 1.5rem;
}

/* ===================================================================
   BUTTONS & CONTROLS
   =================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition-fast);
  text-decoration: none;
  line-height: 1;
}

.btn-primary {
  background: var(--accent-lime);
  color: #06080c;
  box-shadow: 0 0 15px rgba(0, 255, 102, 0.35);
}
.btn-primary:hover {
  background: #1aff75;
  box-shadow: var(--accent-glow-intense);
  transform: translateY(-1px);
  color: #000;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #fff;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.775rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  padding: 0.5rem;
  border-radius: var(--radius-md);
}

.btn-disabled, .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ===================================================================
   BADGES & STATUS
   =================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-active {
  background: var(--badge-active-bg);
  color: var(--badge-active-text);
  border: 1px solid rgba(0, 255, 102, 0.25);
}

.badge-cooldown {
  background: var(--badge-cooldown-bg);
  color: var(--badge-cooldown-text);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-paused {
  background: var(--badge-paused-bg);
  color: var(--badge-paused-text);
  border: 1px solid rgba(100, 116, 139, 0.3);
}

.badge-failed {
  background: var(--badge-failed-bg);
  color: var(--badge-failed-text);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-cap {
  font-family: 'JetBrains Mono', monospace;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}
.badge-cap.limit-hit {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.4);
}

/* ===================================================================
   TABLES
   =================================================================== */

.table-responsive {
  overflow-x: auto;
  width: 100%;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.table th {
  padding: 0.85rem 1.25rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(16, 21, 32, 0.5);
  font-weight: 600;
}

.table td {
  padding: 1rem 1.25rem;
  font-size: 0.875rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  vertical-align: middle;
}

.table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
  color: #fff;
}

/* ===================================================================
   FORMS & INPUTS
   =================================================================== */

.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(10, 13, 20, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  transition: var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-lime);
  box-shadow: 0 0 12px rgba(0, 255, 102, 0.2);
}

/* Checkbox & Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #1e293b;
  border-radius: 24px;
  transition: 0.3s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.3s;
}

input:checked + .slider {
  background-color: var(--accent-lime);
}

input:checked + .slider:before {
  transform: translateX(20px);
  background-color: #000;
}

/* ===================================================================
   PAGE CARDS GRID (DASHBOARD)
   =================================================================== */

.pages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 1.5rem;
}

.page-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  backdrop-filter: blur(12px);
  transition: var(--transition-fast);
}

.page-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-glow);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.page-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.page-card-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
}

.page-stats-row {
  display: flex;
  gap: 1.5rem;
  padding: 0.85rem 0;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 1.25rem;
}

.page-stat-item {
  display: flex;
  flex-direction: column;
}

.page-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.page-stat-val {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
}

.page-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ===================================================================
   ALERTS & FLASH MESSAGES
   =================================================================== */

.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
}

.alert-success {
  background: rgba(0, 255, 102, 0.12);
  border: 1px solid rgba(0, 255, 102, 0.3);
  color: #4ade80;
}

.alert-danger {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #f87171;
}

.alert-warning {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fbbf24;
}

.alert-info {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #60a5fa;
}

/* ===================================================================
   TRANSFER PIPELINE (IDM STYLE)
   =================================================================== */

.pipeline-card {
  background: linear-gradient(135deg, rgba(16, 21, 32, 0.9), rgba(10, 13, 20, 0.9));
  border: 1px solid var(--border-glow);
  box-shadow: 0 0 25px rgba(0, 255, 102, 0.1);
}

.progress-bar-container {
  height: 8px;
  background: #1e293b;
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: 0.5rem 0;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #00ff66, #38bdf8);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
  box-shadow: 0 0 10px rgba(0, 255, 102, 0.5);
}

/* ===================================================================
   MOBILE NAVIGATION, MODALS & RESPONSIVE COMPONENTS
   =================================================================== */

#mobileToggle {
  display: none;
}

.sidebar-close-btn {
  display: none;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 98;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.sidebar-backdrop.active {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

body.sidebar-open-locked {
  overflow: hidden !important;
}

/* Modals & Dialogs */
.modal-overlay,
div[id$="Modal"][style*="position: fixed"],
div[id$="Modal"][style*="position:fixed"] {
  padding: 1rem;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
}

.modal-dialog,
div[id$="Modal"] > div {
  width: 100% !important;
  max-width: 520px !important;
  max-height: calc(100vh - 2.5rem) !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  margin: auto !important;
  box-sizing: border-box;
}

/* Responsive Table Container */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  max-width: 100%;
  display: block;
  contain: paint;
}

.table-responsive::-webkit-scrollbar {
  height: 6px;
}
.table-responsive::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: var(--radius-full);
}
.table-responsive::-webkit-scrollbar-thumb:hover {
  background: var(--accent-lime-dim);
}

/* Helper Grid & Flex Form Classes */
.inline-form-grid {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

/* ===================================================================
   RESPONSIVE DESIGN BREAKPOINTS
   =================================================================== */

/* Tablet & Smaller (< 992px) */
@media (max-width: 992px) {
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
    width: 100%;
  }

  .app-wrapper {
    overflow-x: hidden;
    max-width: 100vw;
    width: 100%;
  }

  #mobileToggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    padding: 0;
  }

  .sidebar {
    transform: translateX(-100%);
    z-index: 100;
    box-shadow: 10px 0 35px rgba(0, 0, 0, 0.7);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    max-width: 82vw;
  }

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

  .sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.25rem;
  }

  .sidebar-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-subtle);
    color: #fff;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    transition: var(--transition-fast);
  }
  .sidebar-close-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
  }

  .sidebar-nav .nav-link {
    min-height: 44px;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
  }

  .main-wrapper {
    margin-left: 0;
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    overflow-x: hidden;
  }

  .topbar {
    padding: 0.75rem 1.25rem;
    height: auto;
    min-height: 64px;
    gap: 0.85rem;
  }

  .page-container {
    padding: 1.25rem;
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    overflow-x: hidden;
  }
}

/* Phablets & Mobile Landscape (< 768px) */
@media (max-width: 768px) {
  .page-container {
    padding: 1rem 0.85rem;
  }

  .card {
    margin-bottom: 1.25rem;
    border-radius: var(--radius-md);
  }

  .card-header {
    padding: 1rem 1.15rem;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-start;
  }

  .card-body {
    padding: 1.15rem;
  }

  .card-title {
    font-size: 1rem;
  }

  /* Stat cards reflow */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.85rem;
    margin-bottom: 1.25rem;
  }

  .stat-card {
    padding: 1rem;
    border-radius: var(--radius-md);
  }

  .stat-title {
    font-size: 0.75rem;
  }

  .stat-value {
    font-size: 1.85rem;
  }

  .stat-footer {
    font-size: 0.75rem;
  }

  /* Table styling */
  .table {
    min-width: 600px;
  }

  .table th {
    padding: 0.75rem 0.85rem;
    font-size: 0.72rem;
  }

  .table td {
    padding: 0.85rem 0.85rem;
    font-size: 0.85rem;
  }

  /* Touch targets for buttons and controls */
  .btn {
    min-height: 42px;
    padding: 0.6rem 1rem;
    font-size: 0.875rem;
  }

  .btn-sm {
    min-height: 38px;
    padding: 0.45rem 0.85rem;
    font-size: 0.825rem;
  }

  .form-control {
    min-height: 44px;
    font-size: 16px !important; /* Prevents auto zoom in iOS */
    padding: 0.65rem 0.85rem;
  }

  .switch {
    width: 48px;
    height: 28px;
    min-height: 28px;
  }

  .slider:before {
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
  }

  input:checked + .slider:before {
    transform: translateX(20px);
  }

  /* Stack flex/grid forms on mobile */
  .inline-form-grid {
    flex-direction: column !important;
    gap: 0.75rem !important;
  }

  .inline-form-grid > div {
    min-width: 100% !important;
    flex: 1 1 100% !important;
    width: 100% !important;
  }

  .inline-form-grid .btn {
    width: 100% !important;
  }

  .card-body form[style*="display: flex"],
  .card-body form[style*="display:flex"] {
    flex-direction: column !important;
  }

  .card-body form[style*="display: flex"] > div,
  .card-body form[style*="display:flex"] > div {
    min-width: 100% !important;
    flex: 1 1 100% !important;
    width: 100% !important;
  }

  /* Grid containers override */
  div[style*="grid-template-columns: repeat(auto-fit, minmax(340px, 1fr))"],
  div[style*="grid-template-columns:repeat(auto-fit, minmax(340px, 1fr))"],
  .settings-grid {
    grid-template-columns: 1fr !important;
  }

  div[style*="grid-template-columns: 1fr 1fr"],
  div[style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

  div[style*="grid-template-columns: repeat(auto-fit, minmax(220px, 1fr))"],
  div[style*="grid-template-columns:repeat(auto-fit, minmax(220px, 1fr))"] {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }

  div[style*="grid-template-columns: repeat(auto-fit, minmax(260px, 1fr))"],
  div[style*="grid-template-columns:repeat(auto-fit, minmax(260px, 1fr))"] {
    grid-template-columns: 1fr !important;
  }

  /* Dashboard pages grid */
  .pages-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .page-card {
    padding: 1.15rem;
  }

  .page-card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    width: 100%;
  }

  .page-card-actions form {
    display: flex !important;
    width: 100%;
  }

  .page-card-actions form .btn,
  .page-card-actions > .btn {
    width: 100%;
    min-height: 40px;
    justify-content: center;
  }

  /* Modals */
  div[id$="Modal"] > div,
  .modal-dialog {
    padding: 1.25rem 1rem !important;
  }

  /* Alerts */
  .alert {
    padding: 0.85rem 1rem;
    font-size: 0.85rem;
    word-break: break-word;
  }
}

/* Small Smart Phones (< 480px, e.g. 360px - 430px) */
@media (max-width: 480px) {
  .topbar {
    padding: 0.65rem 0.75rem;
    gap: 0.5rem;
  }

  .page-title {
    font-size: 1.05rem;
  }

  .engine-badge {
    padding: 0.25rem 0.55rem;
    font-size: 0.72rem;
  }

  .page-container {
    padding: 0.85rem 0.65rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .stat-value {
    font-size: 1.65rem;
  }

  .page-card-actions {
    grid-template-columns: 1fr;
  }

  /* Modal footer buttons full width */
  div[id$="Modal"] form > div[style*="justify-content: flex-end"],
  .modal-dialog form > div[style*="justify-content: flex-end"],
  .modal-footer {
    flex-direction: column-reverse !important;
    width: 100%;
    gap: 0.6rem !important;
  }

  div[id$="Modal"] form > div[style*="justify-content: flex-end"] .btn,
  .modal-dialog form > div[style*="justify-content: flex-end"] .btn,
  .modal-footer .btn {
    width: 100% !important;
    min-height: 42px;
  }

  /* Login box responsive padding */
  .login-box {
    padding: 1.5rem 1.15rem !important;
  }

  /* Founder hero */
  .founder-hero {
    padding: 2rem 1rem !important;
  }

  .founder-avatar {
    width: 110px !important;
    height: 110px !important;
  }

  .social-btn {
    width: 100% !important;
    justify-content: center !important;
    padding: 0.75rem 1rem !important;
  }
}

