:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #121826;
  --bg-card: rgba(26, 34, 52, 0.7);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(99, 102, 241, 0.4);
  --accent-primary: #6366f1;
  --accent-secondary: #8b5cf6;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  background-color: var(--bg-primary);
  background-image:
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.12) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-family);
  min-height: 100vh;
  line-height: 1.5;
}

/* App Header */
.app-header {
  background: rgba(18, 24, 38, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

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

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.brand-info h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.badge-tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.4);
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-weight: 600;
}

.breadcrumb-nav {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.breadcrumb-nav a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.breadcrumb-nav a:hover {
  color: var(--accent-cyan);
}

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

.btn-docs-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: #e2e8f0;
  text-decoration: none;
  font-size: 0.85rem;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-docs-link:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--accent-primary);
  color: #fff;
}

/* Main Container */
.main-wrapper {
  max-width: 1400px;
  margin: 1.5rem auto;
  padding: 0 1.5rem 3rem;
}

/* Control Bar */
.control-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

.control-inputs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.input-group-custom {
  display: flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.input-group-custom:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.input-group-custom .input-label {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.5rem 0.85rem;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  border-right: 1px solid var(--border-color);
}

.input-group-custom input {
  background: transparent;
  border: none;
  color: #fff;
  padding: 0.5rem 0.85rem;
  font-size: 0.9rem;
  outline: none;
  min-width: 160px;
}

.btn-fetch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: #fff;
  border: none;
  padding: 0.55rem 1.25rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.btn-fetch:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-fetch:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.search-box {
  display: flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.45rem 0.85rem;
  gap: 0.5rem;
  min-width: 260px;
}

.search-box input {
  background: transparent;
  border: none;
  color: #fff;
  outline: none;
  width: 100%;
  font-size: 0.85rem;
}

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

/* Metric Stats Strip */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: transform 0.2s, border-color 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.icon-blue {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
}

.icon-emerald {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.icon-cyan {
  background: rgba(6, 182, 212, 0.15);
  color: #22d3ee;
}

.icon-amber {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.stat-content .stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.stat-content .stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

/* Tab Navigation */
.view-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.25rem;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.6rem 1.1rem;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: #fff;
}

.tab-btn.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

/* Master Data Table */
.data-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.table-responsive {
  overflow-x: auto;
}

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

.custom-table th {
  background: rgba(15, 23, 42, 0.9);
  padding: 0.85rem 1rem;
  font-weight: 600;
  color: #cbd5e1;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
}

.custom-table td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: top;
}

.custom-table tr:hover td {
  background: rgba(99, 102, 241, 0.04);
}

.item-name-cell {
  font-weight: 600;
  color: #fff;
}

.uom-chip {
  display: inline-block;
  background: rgba(6, 182, 212, 0.15);
  color: #22d3ee;
  border: 1px solid rgba(6, 182, 212, 0.3);
  padding: 0.15rem 0.55rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* Nested Batch Pill & Details */
.batch-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.batch-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  display: grid;
  grid-template-columns: 2fr 1.5fr 1.2fr 1fr 1.2fr;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.batch-title {
  font-weight: 600;
  color: #a5b4fc;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.batch-godown {
  color: #cbd5e1;
}

.batch-balance {
  font-family: monospace;
  font-weight: 600;
  color: #34d399;
}

.batch-rate {
  font-family: monospace;
  color: #94a3b8;
}

.batch-val {
  font-family: monospace;
  font-weight: 600;
  color: #fbbf24;
  text-align: right;
}

.no-batch-muted {
  color: #64748b;
  font-style: italic;
  font-size: 0.8rem;
}

/* Status Indicator */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
}

.status-dot.loading {
  background: #f59e0b;
  animation: pulse 1s infinite alternate;
}

.status-dot.error {
  background: #ef4444;
}

@keyframes pulse {
  0% {
    transform: scale(0.8);
    opacity: 0.5;
  }

  100% {
    transform: scale(1.2);
    opacity: 1;
  }
}

/* Raw JSON Panel */
.json-viewer-container {
  background: #060910;
  border-radius: 12px;
  padding: 1.25rem;
  overflow: auto;
  max-height: 650px;
  border: 1px solid var(--border-color);
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: 0.82rem;
  color: #a5f3fc;
}

/* Empty / Loading States */
.empty-state {
  text-align: center;
  padding: 4rem 1.5rem;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 3rem;
  color: #475569;
  margin-bottom: 1rem;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

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

@media (max-width: 768px) {
  .batch-card {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .batch-val {
    text-align: left;
  }
}


.control-select {
  height: 42px;
  min-width: 120px;
  padding: 0 36px 0 14px;

  border: 1px solid #303a52;
  border-radius: 8px;

  background-color: #111827;
  color: var(--text-primary, #e5e7eb);

  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;

  cursor: pointer;
  outline: none;

  appearance: auto;
}

.control-select:hover {
  border-color: #4b5563;
}

.control-select:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.control-select option {
  background: #111827;
  color: #e5e7eb;
}