:root {
  --bg-base: #060a14;
  --bg-surface: rgba(13, 20, 36, 0.78);
  --bg-elevated: rgba(20, 30, 52, 0.85);
  --border: rgba(148, 163, 184, 0.14);
  --border-bright: rgba(99, 102, 241, 0.45);
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --indigo: #6366f1;
  --cyan: #22d3ee;
  --emerald: #10b981;
  --amber: #f59e0b;
  --rose: #f43f5e;
  --violet: #a855f7;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow-card: 0 18px 45px -20px rgba(0, 0, 0, 0.75);
  --font-sans: "Plus Jakarta Sans", "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", "Consolas", monospace;
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg-base);
  color: var(--text-main);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Ambient Animated Background */
.ambient-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(95px);
  opacity: 0.34;
  animation: floatOrb 18s ease-in-out infinite alternate;
}

.orb-1 {
  width: 460px;
  height: 460px;
  background: radial-gradient(circle, #4f46e5, transparent 70%);
  top: -120px;
  left: -80px;
}

.orb-2 {
  width: 520px;
  height: 520px;
  background: radial-gradient(circle, #0891b2, transparent 70%);
  bottom: -160px;
  right: -100px;
  animation-delay: -6s;
}

.orb-3 {
  width: 340px;
  height: 340px;
  background: radial-gradient(circle, #7c3aed, transparent 70%);
  top: 40%;
  left: 52%;
  opacity: 0.18;
  animation-delay: -11s;
}

.grid-overlay {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(148, 163, 184, 0.035) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(148, 163, 184, 0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at center, black 45%, transparent 90%);
}

@keyframes floatOrb {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(35px, -25px) scale(1.08); }
  100% { transform: translate(-25px, 30px) scale(0.95); }
}

/* App Shell */
.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 265px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  background: rgba(8, 13, 25, 0.88);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 24px;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 8px 24px -6px rgba(99, 102, 241, 0.7);
  flex-shrink: 0;
}

.brand-logo svg {
  width: 22px;
  height: 22px;
}

.brand-name {
  display: block;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.brand-sub {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 11px 13px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.89rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  text-align: left;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  transform: translateX(3px);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(34, 211, 238, 0.1));
  border-color: rgba(99, 102, 241, 0.38);
  color: #fff;
  box-shadow: 0 8px 20px -10px rgba(99, 102, 241, 0.65);
}

.nav-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

.nav-badge {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(244, 63, 94, 0.2);
  color: #fda4af;
  border: 1px solid rgba(244, 63, 94, 0.35);
}

.nav-badge.zero {
  background: rgba(16, 185, 129, 0.16);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.3);
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.conn-pill {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border);
  font-size: 0.76rem;
  color: var(--text-muted);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  position: relative;
  flex-shrink: 0;
}

.conn-pill.ok .pulse-dot {
  background: var(--emerald);
}

.conn-pill.ok .pulse-dot::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid var(--emerald);
  animation: pulseRing 2s infinite;
}

@keyframes pulseRing {
  0% { transform: scale(0.7); opacity: 0.9; }
  100% { transform: scale(1.9); opacity: 0; }
}

/* Main Content */
.main-content {
  padding: 24px 28px 40px;
  min-width: 0;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-menu-btn {
  display: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-main);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 1.2rem;
  cursor: pointer;
}

.page-title {
  margin: 0;
  font-size: 1.48rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.page-subtitle {
  margin: 3px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.quick-scan-box {
  position: relative;
  display: flex;
  align-items: center;
}

.scan-icon {
  position: absolute;
  left: 12px;
  color: var(--cyan);
  font-size: 1rem;
  pointer-events: none;
}

.quick-scan-box input {
  width: 245px;
  padding: 9px 14px 9px 34px;
  border-radius: 11px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.81rem;
  transition: all 0.25s ease;
}

.quick-scan-box input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.16);
  width: 275px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 11px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.22s ease, background 0.22s ease, border-color 0.22s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  box-shadow: 0 10px 24px -10px rgba(99, 102, 241, 0.85);
}
.btn-primary:hover {
  box-shadow: 0 14px 28px -8px rgba(99, 102, 241, 0.95);
}

.btn-secondary {
  background: rgba(30, 41, 59, 0.85);
  border-color: var(--border);
  color: var(--text-main);
}
.btn-secondary:hover {
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(51, 65, 85, 0.8);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}
.btn-ghost:hover {
  color: var(--text-main);
  border-color: var(--cyan);
}

.btn-amber {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fcd34d;
}
.btn-amber:hover {
  background: rgba(245, 158, 11, 0.25);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 0.77rem;
  border-radius: 9px;
}

.btn-full {
  width: 100%;
  padding: 12px;
  font-size: 0.92rem;
}

/* Tab Transitions */
.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: panelFadeIn 0.38s cubic-bezier(0.22, 1, 0.36, 1) both;
}

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

.reveal-card {
  animation: cardRise 0.52s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: var(--delay, 0ms);
}

@keyframes cardRise {
  from { opacity: 0; transform: translateY(16px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--bg-surface);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  transition: transform 0.25s ease, border-color 0.25s ease;
}

.kpi-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-bright);
}

.kpi-card.alert-glow {
  border-color: rgba(244, 63, 94, 0.28);
  background: linear-gradient(180deg, rgba(244, 63, 94, 0.08), var(--bg-surface));
}

.kpi-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.kpi-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.kpi-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 1rem;
}
.kpi-icon.indigo { background: rgba(99, 102, 241, 0.18); }
.kpi-icon.cyan { background: rgba(34, 211, 238, 0.16); }
.kpi-icon.rose { background: rgba(244, 63, 94, 0.18); }
.kpi-icon.emerald { background: rgba(16, 185, 129, 0.18); }

.kpi-value {
  font-size: 1.78rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.kpi-value.money {
  font-size: 1.42rem;
}

.kpi-foot {
  margin-top: 8px;
  font-size: 0.77rem;
  color: var(--text-muted);
}

.text-rose { color: #fb7185; }
.text-emerald { color: #34d399; }
.text-right { text-align: right; }

/* Glass Cards & Layouts */
.glass-card {
  background: var(--bg-surface);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-card);
}

.grid-charts-main {
  display: grid;
  grid-template-columns: 1.75fr 1fr;
  gap: 18px;
  margin-bottom: 20px;
}

.grid-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.grid-movements {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 18px;
}

.mt-20 { margin-top: 20px; }

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-header h3 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
}

.card-header p {
  margin: 3px 0 0;
  font-size: 0.79rem;
  color: var(--text-muted);
}

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

.segmented-control {
  display: inline-flex;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
}

.seg-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 5px 10px;
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.seg-btn.active {
  background: var(--indigo);
  color: #fff;
}

/* Charts */
.chart-canvas-wrap {
  position: relative;
  width: 100%;
  min-height: 245px;
}

.svg-chart-box svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-line-anim {
  stroke-dasharray: 1600;
  stroke-dashoffset: 1600;
  animation: drawStroke 1.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes drawStroke {
  to { stroke-dashoffset: 0; }
}

.chart-legend-row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 5px;
}
.dot.emerald { background: var(--emerald); }
.dot.rose { background: var(--rose); }
.dot.cyan { background: var(--cyan); }

/* Donut Chart */
.donut-wrap {
  display: grid;
  place-items: center;
  padding: 6px 0 12px;
}

.status-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.legend-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--border);
  font-size: 0.77rem;
}

.legend-chip-left {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
}

.swatch {
  width: 9px;
  height: 9px;
  border-radius: 3px;
}

/* Watchlist & Category Bars */
.watchlist {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 330px;
  overflow-y: auto;
}

.watch-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(244, 63, 94, 0.22);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.watch-item:hover {
  transform: translateX(3px);
  border-color: rgba(244, 63, 94, 0.5);
}

.watch-title {
  font-weight: 600;
  font-size: 0.87rem;
}

.watch-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.watch-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.order-pill {
  padding: 4px 9px;
  border-radius: 8px;
  font-size: 0.74rem;
  font-weight: 700;
  background: rgba(245, 158, 11, 0.16);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.category-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cat-bar-row {
  display: grid;
  grid-template-columns: 95px 1fr 64px;
  align-items: center;
  gap: 10px;
  font-size: 0.79rem;
}

.cat-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.12);
  overflow: hidden;
}

.cat-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--indigo), var(--cyan));
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.divider-line {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

.mini-title {
  margin: 0 0 10px;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.traffic-mini-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 175px;
  overflow-y: auto;
}

.traffic-mini-item {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.77rem;
  color: var(--text-muted);
}

.ev-tag {
  padding: 2px 7px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.67rem;
  font-weight: 700;
  background: rgba(99, 102, 241, 0.18);
  color: #a5b4fc;
  flex-shrink: 0;
}

.ev-tag.STOCK_OUT, .ev-tag.ALERT_SENT { background: rgba(244, 63, 94, 0.18); color: #fda4af; }
.ev-tag.STOCK_IN { background: rgba(16, 185, 129, 0.18); color: #6ee7b7; }
.ev-tag.SCAN_BARCODE { background: rgba(34, 211, 238, 0.18); color: #67e8f9; }

/* Tables & Toolbar */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-wrap {
  flex: 1;
  min-width: 220px;
}

.toolbar input, .toolbar select, .compact-input {
  padding: 9px 13px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.84rem;
}

.search-wrap input {
  width: 100%;
}

.filter-group, .toolbar-right {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.data-table th {
  text-align: left;
  padding: 11px 12px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background 0.18s ease;
}

.data-table tbody tr:hover {
  background: rgba(99, 102, 241, 0.06);
}

.data-table.compact td, .data-table.compact th {
  padding: 9px 10px;
  font-size: 0.79rem;
}

.code-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--cyan);
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.18s ease;
}

.code-pill:hover {
  border-color: var(--cyan);
  transform: scale(1.03);
}

.stock-meter {
  width: 130px;
}

.stock-meter-nums {
  display: flex;
  justify-content: space-between;
  font-size: 0.77rem;
  margin-bottom: 4px;
}

.meter-track {
  height: 7px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.15);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.55s ease;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 700;
}

.status-badge.IN_STOCK {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.32);
}

.status-badge.LOW_STOCK {
  background: rgba(245, 158, 11, 0.16);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.status-badge.OUT_OF_STOCK {
  background: rgba(244, 63, 94, 0.18);
  color: #fda4af;
  border: 1px solid rgba(244, 63, 94, 0.4);
  animation: softBlink 2.2s infinite;
}

.status-badge.MAINTENANCE {
  background: rgba(168, 85, 247, 0.16);
  color: #d8b4fe;
  border: 1px solid rgba(168, 85, 247, 0.35);
}

.status-badge.RETIRED {
  background: rgba(100, 116, 139, 0.2);
  color: #cbd5e1;
  border: 1px solid rgba(100, 116, 139, 0.35);
}

@keyframes softBlink {
  0%, 100% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.35); }
  50% { box-shadow: 0 0 0 5px rgba(244, 63, 94, 0); }
}

.row-actions {
  display: inline-flex;
  gap: 5px;
}

.act-btn {
  padding: 5px 8px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.8);
  color: var(--text-main);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}

.act-btn:hover { transform: translateY(-1px); }
.act-btn.in:hover { border-color: var(--emerald); color: #6ee7b7; }
.act-btn.out:hover { border-color: var(--rose); color: #fda4af; }
.act-btn.del:hover { border-color: var(--rose); background: rgba(244, 63, 94, 0.2); }

/* Forms & Stock Terminal */
.stack-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}

.form-group input, .form-group select {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.85rem;
}

.form-group input:focus, .form-group select:focus {
  outline: none;
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.16);
}

.inline-input-btn {
  display: flex;
  gap: 8px;
}

.inline-input-btn input {
  flex: 1;
}

.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: rgba(15, 23, 42, 0.9);
  padding: 5px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.mode-btn {
  padding: 10px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.81rem;
  cursor: pointer;
  transition: all 0.22s ease;
}

.mode-btn.active.in {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
}

.mode-btn.active.out {
  background: linear-gradient(135deg, #f43f5e, #e11d48);
  color: #fff;
}

.scanned-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(34, 211, 238, 0.08);
  border: 1px solid rgba(34, 211, 238, 0.35);
}

.preview-stock-nums {
  display: flex;
  gap: 14px;
  font-size: 0.84rem;
}

.hidden { display: none !important; }
.muted-small { font-size: 0.77rem; color: var(--text-muted); margin: 2px 0 0; }

/* Barcode Grid */
.barcode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 16px;
}

.barcode-card {
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.22s ease, border-color 0.22s ease;
}

.barcode-card:hover {
  transform: translateY(-3px);
  border-color: var(--cyan);
}

.barcode-img-box {
  background: #fff;
  border-radius: 10px;
  padding: 8px;
  display: grid;
  place-items: center;
}

.barcode-img-box img {
  max-width: 100%;
  height: auto;
}

.barcode-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

/* Telegram Phone Mockup */
.phone-mockup {
  max-width: 390px;
  margin: 4px auto 0;
  border-radius: 26px;
  border: 2px solid rgba(148, 163, 184, 0.25);
  background: #0b1422;
  overflow: hidden;
  box-shadow: 0 24px 50px -20px rgba(0, 0, 0, 0.9);
}

.phone-notch {
  width: 110px;
  height: 14px;
  margin: 8px auto 4px;
  border-radius: 999px;
  background: #1e293b;
}

.tg-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: #172133;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.tg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #22d3ee, #3b82f6);
  display: grid;
  place-items: center;
}

.tg-header strong { display: block; font-size: 0.86rem; }
.tg-header span { font-size: 0.72rem; color: #38bdf8; }

.tg-chat-area {
  padding: 16px;
  min-height: 230px;
  background: radial-gradient(circle at top right, rgba(34, 211, 238, 0.07), transparent 60%);
}

.tg-bubble {
  background: #1b283d;
  border: 1px solid rgba(56, 189, 248, 0.22);
  border-radius: 14px 14px 14px 4px;
  padding: 12px 14px;
  font-size: 0.79rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.tg-bubble code {
  background: rgba(15, 23, 42, 0.8);
  padding: 1px 5px;
  border-radius: 5px;
  color: var(--cyan);
}

.pill-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.stat-pill {
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Guide Steps */
.guide-steps {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.guide-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--border);
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--indigo);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.82rem;
  flex-shrink: 0;
}

.guide-step p {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.guide-step code {
  color: var(--cyan);
  font-family: var(--font-mono);
}

.form-actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 18, 0.75);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 50;
  animation: fadeIn 0.2s ease;
}

.modal-dialog {
  width: 100%;
  max-width: 600px;
  background: #0d1527;
  border: 1px solid var(--border-bright);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.8);
  animation: modalPop 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-dialog.modal-sm { max-width: 420px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalPop {
  from { opacity: 0; transform: scale(0.94) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-header h3 { margin: 0; font-size: 1.05rem; }

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.modal-footer.center { justify-content: center; }

.barcode-modal-body {
  text-align: center;
}

.bm-title { font-weight: 700; font-size: 1rem; }
.bm-meta { font-size: 0.79rem; color: var(--text-muted); margin: 4px 0 14px; }

.barcode-paper {
  background: #fff;
  padding: 14px;
  border-radius: 12px;
  display: inline-block;
  margin-bottom: 14px;
}

/* Toasts */
.toast-container {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 390px;
}

.toast {
  padding: 13px 16px;
  border-radius: 13px;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-size: 0.83rem;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.65);
  animation: toastSlide 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.toast.success { border-left: 4px solid var(--emerald); }
.toast.warning { border-left: 4px solid var(--amber); }
.toast.error { border-left: 4px solid var(--rose); }
.toast.telegram { border-left: 4px solid var(--cyan); }

@keyframes toastSlide {
  from { opacity: 0; transform: translateX(25px); }
  to { opacity: 1; transform: translateX(0); }
}

/* SVG Tooltip */
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(10, 15, 30, 0.95);
  border: 1px solid rgba(99, 102, 241, 0.45);
  padding: 8px 11px;
  border-radius: 10px;
  font-size: 0.76rem;
  color: #f8fafc;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.6);
  z-index: 10;
  white-space: nowrap;
}

/* Responsive */
@media (max-width: 1120px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-charts-main, .grid-two-col, .grid-movements { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    width: 265px;
    transition: left 0.28s ease;
  }
  .sidebar.open { left: 0; }
  .mobile-menu-btn { display: grid; place-items: center; }
  .quick-scan-box input { width: 190px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}

@media print {
  .sidebar, .topbar, .ambient-bg, .toast-container, .toolbar, .modal-backdrop {
    display: none !important;
  }
  .app-shell { display: block; }
  .main-content { padding: 0; }
  .tab-panel { display: none !important; }
  #tab-barcodes { display: block !important; }
  .barcode-card { break-inside: avoid; border: 1px solid #cbd5e1; color: #000; background: #fff; }
}

/* Auth Portal & User Profile Controls */
.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.auth-shell {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 470px;
}

.auth-card {
  background: rgba(11, 17, 32, 0.9);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border-bright);
  border-radius: 22px;
  padding: 28px;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.8);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.auth-brand h1 {
  margin: 0;
  font-size: 1.25rem;
}

.auth-brand p {
  margin: 3px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: rgba(15, 23, 42, 0.9);
  padding: 5px;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.auth-tab {
  padding: 9px 6px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.79rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.auth-tab.active {
  background: var(--indigo);
  color: #fff;
}

.auth-panel {
  display: none;
}

.auth-panel.active {
  display: flex;
  animation: panelFadeIn 0.3s ease both;
}

.auth-notice {
  padding: 11px 13px;
  border-radius: 11px;
  font-size: 0.8rem;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  line-height: 1.45;
}

.auth-notice.success { background: rgba(16, 185, 129, 0.14); border-color: rgba(16, 185, 129, 0.4); color: #6ee7b7; }
.auth-notice.error { background: rgba(244, 63, 94, 0.14); border-color: rgba(244, 63, 94, 0.4); color: #fda4af; }
.auth-notice.warning { background: rgba(245, 158, 11, 0.14); border-color: rgba(245, 158, 11, 0.4); color: #fcd34d; }
.auth-notice.info { background: rgba(34, 211, 238, 0.12); border-color: rgba(34, 211, 238, 0.35); color: #67e8f9; }

.dev-otp-box {
  padding: 12px;
  border-radius: 11px;
  background: rgba(34, 211, 238, 0.1);
  border: 1px dashed rgba(34, 211, 238, 0.5);
  font-size: 0.8rem;
  text-align: center;
}

.auth-hint {
  margin: 4px 0 0;
  font-size: 0.76rem;
  color: var(--text-muted);
  text-align: center;
}

.security-footer {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-dim);
  text-align: center;
}

.user-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 11px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border);
}

.user-card-info strong {
  display: block;
  font-size: 0.8rem;
  color: var(--text-main);
}

.user-card-info span {
  font-size: 0.71rem;
  color: var(--cyan);
  font-family: var(--font-mono);
}

.btn-logout {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(244, 63, 94, 0.38);
  background: rgba(244, 63, 94, 0.14);
  color: #fda4af;
  font-size: 0.73rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-logout:hover {
  background: rgba(244, 63, 94, 0.28);
}

.btn-emerald {
  background: rgba(16, 185, 129, 0.16);
  border-color: rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
}
.btn-emerald:hover {
  background: rgba(16, 185, 129, 0.28);
}

/* Theme Transition & Light Mode ([data-theme="light"]) */
body {
  transition: background-color 0.3s ease, color 0.3s ease;
}

.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
  border-color: var(--indigo);
  transform: translateY(-1px);
}

.role-pill {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  margin-left: 5px;
  vertical-align: middle;
}

.role-pill.ADMIN {
  background: rgba(99, 102, 241, 0.22);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.45);
}

.role-pill.USER {
  background: rgba(100, 116, 139, 0.22);
  color: #cbd5e1;
  border: 1px solid rgba(100, 116, 139, 0.35);
}

.auth-theme-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

html[data-theme="light"] {
  --bg-base: #f1f5f9;
  --bg-surface: rgba(255, 255, 255, 0.92);
  --bg-elevated: rgba(248, 250, 252, 0.96);
  --border: rgba(15, 23, 42, 0.11);
  --border-bright: rgba(79, 70, 229, 0.42);
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;
  --shadow-card: 0 14px 36px -18px rgba(15, 23, 42, 0.18);
}

html[data-theme="light"] .orb {
  opacity: 0.18;
}

html[data-theme="light"] .sidebar {
  background: rgba(255, 255, 255, 0.92);
}

html[data-theme="light"] .nav-item.active {
  background: linear-gradient(135deg, #4f46e5, #0891b2);
  color: #ffffff;
}

html[data-theme="light"] .conn-pill,
html[data-theme="light"] .user-card,
html[data-theme="light"] .legend-chip,
html[data-theme="light"] .watch-item,
html[data-theme="light"] .guide-step,
html[data-theme="light"] .stat-pill,
html[data-theme="light"] .barcode-card {
  background: #f8fafc;
}

html[data-theme="light"] .quick-scan-box input,
html[data-theme="light"] .toolbar input,
html[data-theme="light"] .toolbar select,
html[data-theme="light"] .compact-input,
html[data-theme="light"] .form-group input,
html[data-theme="light"] .form-group select,
html[data-theme="light"] .segmented-control,
html[data-theme="light"] .mode-toggle,
html[data-theme="light"] .auth-tabs {
  background: #ffffff;
  color: #0f172a;
}

html[data-theme="light"] .code-pill,
html[data-theme="light"] .act-btn {
  background: #f1f5f9;
  color: #0369a1;
}

html[data-theme="light"] .act-btn {
  color: #0f172a;
}

html[data-theme="light"] .modal-dialog,
html[data-theme="light"] .auth-card {
  background: #ffffff;
}

html[data-theme="light"] .toast {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.15);
}

html[data-theme="light"] .btn-secondary {
  background: #e2e8f0;
  color: #0f172a;
}

html[data-theme="light"] .status-badge.IN_STOCK { color: #047857; }
html[data-theme="light"] .status-badge.LOW_STOCK { color: #b45309; }
html[data-theme="light"] .status-badge.OUT_OF_STOCK { color: #be123c; }
html[data-theme="light"] .status-badge.MAINTENANCE { color: #7e22ce; }
html[data-theme="light"] .status-badge.RETIRED { color: #475569; }
html[data-theme="light"] .role-pill.ADMIN { color: #4338ca; }
html[data-theme="light"] .role-pill.USER { color: #475569; }
html[data-theme="light"] .phone-mockup { background: #111827; color: #f8fafc; }
