:root {
  --bg-main: #0b0f19;
  --bg-card: #182232;
  --border-dark: #000000;
  --text-main: #ffffff;
  --text-muted: #94a3b8;
  
  /* Neubrutalist Pop Colors */
  --neo-yellow: #facc15;
  --neo-cyan: #22d3ee;
  --neo-pink: #f43f5e;
  --neo-lime: #4ade80;
  --neo-purple: #c084fc;
  --neo-orange: #fb923c;
  --neo-white: #ffffff;
  
  --shadow-hard: 4px 4px 0px #000000;
  --shadow-hard-lg: 6px 6px 0px #000000;
  --font-sans: 'Space Grotesk', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.4;
  overflow-x: hidden;
}

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Navbar */
.neo-navbar {
  background-color: var(--bg-card);
  border-bottom: 3px solid var(--border-dark);
  padding: 0.8rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-badge {
  background-color: var(--neo-yellow);
  color: #000;
  font-weight: 800;
  font-size: 1.1rem;
  padding: 0.3rem 0.7rem;
  border: 3px solid var(--border-dark);
  box-shadow: 3px 3px 0px #000;
  border-radius: 4px;
}

.brand-title {
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.5px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-metrics {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-pill {
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.25rem 0.6rem;
  border: 2px solid var(--border-dark);
  box-shadow: 2px 2px 0px #000;
  border-radius: 4px;
  color: #000;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.env-toggle-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.85rem;
}

/* Neubrutalist Buttons */
.neo-btn {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 0.85rem;
  text-transform: uppercase;
  padding: 0.55rem 1.1rem;
  background-color: var(--neo-white);
  color: #000;
  border: 3px solid var(--border-dark);
  box-shadow: var(--shadow-hard);
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.1s ease-in-out;
}

.neo-btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0px #000;
}

.neo-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0px #000;
}

.neo-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: var(--shadow-hard);
}

.neo-yellow { background-color: var(--neo-yellow); }
.neo-cyan { background-color: var(--neo-cyan); }
.neo-pink { background-color: var(--neo-pink); color: #fff; }
.neo-lime { background-color: var(--neo-lime); }
.neo-white { background-color: var(--neo-white); }

.neo-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.75rem;
}

/* Inputs & Selects */
.neo-select, .neo-input, .neo-textarea {
  font-family: var(--font-sans);
  font-weight: 700;
  background-color: #0d1522;
  color: var(--text-main);
  border: 3px solid var(--border-dark);
  box-shadow: var(--shadow-hard);
  border-radius: 4px;
  padding: 0.5rem 0.8rem;
  outline: none;
}

.neo-select:focus, .neo-input:focus, .neo-textarea:focus {
  border-color: var(--neo-cyan);
}

.neo-sm-select {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
}

/* Body Layout */
.layout-body {
  display: flex;
  flex: 1;
}

/* Sidebar */
.sidebar {
  width: 250px;
  min-width: 180px;
  max-width: 380px;
  background-color: var(--bg-card);
  border-right: 3px solid var(--border-dark);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
}

.sidebar-resizer {
  position: absolute;
  top: 0;
  right: -5px;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  z-index: 10;
  transition: background 0.2s;
}

.sidebar-resizer:hover, .sidebar-resizer.resizing {
  background-color: var(--neo-yellow);
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.nav-item {
  font-family: var(--font-sans);
  font-weight: 800;
  font-size: 0.9rem;
  padding: 0.75rem 1rem;
  background-color: #0d1522;
  color: var(--text-main);
  border: 3px solid var(--border-dark);
  box-shadow: var(--shadow-hard);
  border-radius: 4px;
  text-align: left;
  cursor: pointer;
  transition: all 0.1s;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

.nav-item:hover {
  background-color: var(--neo-yellow);
  color: #000;
}

.nav-item.active {
  background-color: var(--neo-cyan);
  color: #000;
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0px #000;
}

.status-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 3px solid var(--border-dark);
  box-shadow: var(--shadow-hard);
  border-radius: 4px;
  background-color: var(--neo-lime);
  color: #000;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: #000;
}

.status-head { font-weight: 800; font-size: 0.8rem; }
.status-sub { font-size: 0.7rem; font-weight: 600; opacity: 0.8; }

/* Main Content */
.main-content {
  flex: 1;
  padding: 1.75rem;
  max-width: calc(100vw - 250px);
}

.tab-page {
  display: none;
}

.tab-page.active {
  display: block;
}

/* Neubrutalist Cards */
.neo-card {
  background-color: var(--bg-card);
  border: 3px solid var(--border-dark);
  box-shadow: var(--shadow-hard);
  border-radius: 6px;
  padding: 1.1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.neo-yellow-bg { background-color: var(--neo-yellow); color: #000; }
.neo-cyan-bg { background-color: var(--neo-cyan); color: #000; }
.neo-pink-bg { background-color: var(--neo-pink); color: #fff; }
.neo-lime-bg { background-color: var(--neo-lime); color: #000; }

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

.kpi-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kpi-icon {
  font-size: 1.35rem;
  opacity: 0.75;
}

.kpi-tag {
  font-weight: 800;
  font-size: 0.7rem;
  letter-spacing: 0.5px;
}

.kpi-val {
  font-size: 1.75rem;
  font-weight: 800;
  margin: 0.3rem 0;
}

.kpi-sub {
  font-size: 0.75rem;
  font-weight: 700;
  opacity: 0.9;
}

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

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

.section-title {
  font-size: 0.95rem;
  font-weight: 800;
  margin-bottom: 1rem;
  text-transform: uppercase;
}

.role-bars {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.role-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}

.role-track {
  height: 12px;
  background-color: #0d1522;
  border: 2px solid var(--border-dark);
  border-radius: 3px;
  overflow: hidden;
}

.role-fill {
  height: 100%;
  background-color: var(--neo-yellow);
}

.stats-list {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  padding: 0.6rem 0.8rem;
  background-color: #0d1522;
  border: 2px solid var(--border-dark);
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 700;
}

/* Tables */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.table-container {
  overflow-x: auto;
  min-height: 350px;
  border: 3px solid var(--border-dark);
  border-radius: 4px;
  background-color: #0d1522;
}

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

.neo-table th, .neo-table td {
  padding: 0.45rem 0.75rem;
  border-bottom: 2px solid var(--border-dark);
  border-right: 2px solid var(--border-dark);
  white-space: nowrap;
}

.neo-table th {
  background-color: var(--neo-yellow);
  color: #000;
  font-weight: 800;
  text-transform: uppercase;
}

.neo-table tbody tr:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.02);
}

.neo-table tbody tr:hover {
  background-color: rgba(34, 211, 238, 0.1);
}

.pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  font-weight: 700;
  font-size: 0.85rem;
}

.pag-btns {
  display: flex;
  gap: 0.5rem;
}

/* Workbench */
.workbench-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.editor-box {
  margin-bottom: 1rem;
}

.neo-textarea {
  width: 100%;
  height: 220px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  resize: vertical;
}

.btn-group {
  display: flex;
  gap: 1rem;
}

.time-badge {
  font-family: var(--font-mono);
  background-color: var(--neo-lime);
  color: #000;
  font-weight: 800;
  padding: 0.2rem 0.5rem;
  border: 2px solid var(--border-dark);
  border-radius: 4px;
}

.neo-alert {
  padding: 0.8rem 1rem;
  border: 3px solid var(--border-dark);
  box-shadow: var(--shadow-hard);
  font-weight: 800;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.neo-alert.hidden { display: none; }
.neo-alert.success { background-color: var(--neo-lime); color: #000; }
.neo-alert.error { background-color: var(--neo-pink); color: #fff; }

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 220px;
  font-weight: 700;
  color: var(--text-muted);
}

/* FLOATING LOG DRAWER & BUTTON */
.floating-log-trigger {
  position: fixed;
  bottom: 25px;
  right: 25px;
  z-index: 100;
  box-shadow: 5px 5px 0px #000;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #000;
  animation: pulse 1.2s infinite;
}

.neo-drawer {
  position: fixed;
  bottom: 85px;
  right: 25px;
  width: 480px;
  height: 520px;
  max-width: calc(100vw - 50px);
  background-color: var(--bg-card);
  border: 4px solid var(--border-dark);
  box-shadow: 8px 8px 0px #000;
  border-radius: 6px;
  z-index: 101;
  display: flex;
  flex-direction: column;
  padding: 1rem;
}

.neo-drawer.hidden { display: none; }

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

.drawer-title h3 {
  font-size: 0.95rem;
  font-weight: 800;
}

.pulse-badge {
  font-size: 0.65rem;
  background-color: var(--neo-lime);
  color: #000;
  font-weight: 800;
  padding: 0.1rem 0.4rem;
  border: 2px solid #000;
}

.drawer-actions {
  display: flex;
  gap: 0.5rem;
}

.drawer-filter {
  margin-bottom: 0.8rem;
}

.log-stream-box {
  flex: 1;
  background-color: #0d1522;
  border: 3px solid var(--border-dark);
  overflow-y: auto;
  padding: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.log-line {
  padding: 0.3rem 0.5rem;
  border-radius: 3px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
}

.log-line.error { color: var(--neo-pink); font-weight: 700; }
.log-line.info { color: var(--neo-cyan); }

/* MODALS */
.neo-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.neo-modal-overlay.hidden { display: none; }

.neo-modal {
  background-color: var(--bg-card);
  border: 4px solid var(--border-dark);
  box-shadow: 10px 10px 0px #000;
  border-radius: 6px;
  width: 520px;
  max-width: 92vw;
  overflow: hidden;
}

.modal-head {
  padding: 0.8rem 1.2rem;
  border-bottom: 3px solid var(--border-dark);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-head h3 {
  font-size: 1rem;
  font-weight: 800;
  color: #000;
}

.modal-body {
  padding: 1.2rem;
}

.edit-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  max-height: 380px;
  overflow-y: auto;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field-group label {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
}

.modal-foot {
  padding: 1rem 1.2rem;
  background-color: #0d1522;
  border-top: 3px solid var(--border-dark);
  display: flex;
  justify-content: flex-end;
  gap: 0.8rem;
}

.sql-code-box {
  font-family: var(--font-mono);
  background-color: #0d1522;
  border: 2px solid var(--border-dark);
  padding: 0.75rem;
  font-size: 0.8rem;
  color: var(--neo-yellow);
  margin: 0.8rem 0;
  max-height: 120px;
  overflow-y: auto;
}

.dryrun-box {
  background-color: var(--neo-yellow);
  color: #000;
  font-weight: 800;
  font-size: 0.85rem;
  padding: 0.6rem 0.8rem;
  border: 2px solid #000;
  margin-bottom: 0.8rem;
}

.danger-warning {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--neo-pink);
}

.maint-feature-box {
  background-color: #0d1522;
  border: 2px solid var(--border-dark);
  border-radius: 6px;
  padding: 0.75rem 0.9rem;
}

.keyboard-row-card {
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.keyboard-row-card:hover {
  border-color: var(--neo-cyan) !important;
}

.tg-menu-box {
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
}

.mobile-only { display: none; }

/* RESPONSIVENESS & DEVICE ADAPTABILITY */
@media (max-width: 1100px) {
  .nav-metrics {
    display: none;
  }
}

@media (max-width: 900px) {
  .mobile-only { display: inline-flex; }
  .neo-navbar {
    padding: 0.6rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .sidebar {
    position: fixed;
    top: 60px;
    left: -260px;
    height: calc(100vh - 60px);
    z-index: 40;
    transition: left 0.2s ease-in-out;
  }
  .sidebar.open {
    left: 0;
  }
  .main-content {
    margin-left: 0;
    max-width: 100vw;
    padding: 0.9rem;
  }
  .grid-2col, .grid-3col, .workbench-grid {
    grid-template-columns: 1fr;
  }
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }
  .edit-form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 550px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .neo-drawer {
    right: 10px;
    bottom: 75px;
    width: calc(100vw - 20px);
    height: 460px;
  }
  .brand-title {
    font-size: 1rem;
  }
  .brand-badge {
    font-size: 0.95rem;
    padding: 0.2rem 0.5rem;
  }
  .neo-btn {
    padding: 0.45rem 0.8rem;
    font-size: 0.78rem;
  }
}
