/* ============================================================
   MSME Order + Inventory Agent — Dashboard Styles
   Dark theme · Glassmorphism · Gradient accents · Micro-animations
   ============================================================ */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* --- Design Tokens --- */
:root {
  /* Surfaces */
  --bg-primary: #0b0e17;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-card-hover: rgba(23, 33, 54, 0.85);
  --bg-glass: rgba(255, 255, 255, 0.04);
  --bg-input: rgba(255, 255, 255, 0.06);

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);

  /* Text */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-accent: #a5b4fc;

  /* Accents */
  --accent-indigo: #6366f1;
  --accent-violet: #8b5cf6;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-sky: #0ea5e9;
  --accent-teal: #14b8a6;

  /* Gradients */
  --gradient-brand: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
  --gradient-emerald: linear-gradient(135deg, #059669 0%, #10b981 100%);
  --gradient-amber: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
  --gradient-rose: linear-gradient(135deg, #e11d48 0%, #f43f5e 100%);
  --gradient-sky: linear-gradient(135deg, #0284c7 0%, #0ea5e9 100%);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow-indigo: 0 0 20px rgba(99, 102, 241, 0.15);
  --shadow-glow-emerald: 0 0 20px rgba(16, 185, 129, 0.15);

  /* Spacing */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Subtle grid background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% -20%, rgba(99, 102, 241, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(139, 92, 246, 0.05), transparent);
  pointer-events: none;
  z-index: 0;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.3);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 102, 241, 0.5);
}

/* --- Layout --- */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 32px 60px;
}

/* --- Header --- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 32px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 32px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-logo {
  width: 44px;
  height: 44px;
  background: var(--gradient-brand);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: var(--shadow-glow-indigo);
}

.header-title {
  font-size: 1.5rem;
  font-weight: 700;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.header-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-live {
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-live::before {
  content: '';
  width: 7px;
  height: 7px;
  background: var(--accent-emerald);
  border-radius: 50%;
  animation: pulse-dot 2s ease-in-out infinite;
}

.badge-uipath {
  background: rgba(14, 165, 233, 0.12);
  color: var(--accent-sky);
  border: 1px solid rgba(14, 165, 233, 0.2);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* --- Main Grid --- */
.main-grid {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 28px;
  align-items: start;
}

@media (max-width: 1100px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Card Base --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: border-color 0.3s, box-shadow 0.3s, transform 0.2s;
}

.card:hover {
  border-color: rgba(99, 102, 241, 0.15);
  box-shadow: var(--shadow-glow-indigo);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.card-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.card-icon-indigo { background: rgba(99, 102, 241, 0.15); }
.card-icon-emerald { background: rgba(16, 185, 129, 0.15); }
.card-icon-amber { background: rgba(245, 158, 11, 0.15); }
.card-icon-rose { background: rgba(244, 63, 94, 0.15); }
.card-icon-sky { background: rgba(14, 165, 233, 0.15); }
.card-icon-violet { background: rgba(139, 92, 246, 0.15); }
.card-icon-teal { background: rgba(20, 184, 166, 0.15); }

.card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  padding: 18px 22px 22px;
}

/* --- Input Panel (Left Side) --- */
.input-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.order-textarea {
  width: 100%;
  min-height: 130px;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  line-height: 1.6;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.order-textarea::placeholder {
  color: var(--text-muted);
}

.order-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Buttons */
.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--gradient-brand);
  color: white;
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.45);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--bg-glass);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.1);
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.2);
}

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

/* Sample Orders */
.sample-orders {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sample-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
}

.sample-btn:hover {
  background: rgba(99, 102, 241, 0.08);
  border-color: rgba(99, 102, 241, 0.2);
  color: var(--text-primary);
  transform: translateX(4px);
}

.sample-btn .sample-label {
  font-weight: 600;
  color: var(--text-accent);
  min-width: 110px;
}

.sample-btn .sample-text {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Results Panel (Right Side) --- */
.results-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.results-empty {
  text-align: center;
  padding: 80px 30px;
  color: var(--text-muted);
}

.results-empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.results-empty h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.results-empty p {
  font-size: 0.82rem;
}

/* --- Agent Pipeline Steps --- */
.pipeline-steps {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.step-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
  border: 1px solid transparent;
  transition: all 0.3s;
  animation: fadeSlideIn 0.4s ease forwards;
  opacity: 0;
}

.step-row.completed {
  border-color: rgba(16, 185, 129, 0.15);
}

.step-row.running {
  border-color: rgba(99, 102, 241, 0.25);
  background: rgba(99, 102, 241, 0.06);
}

.step-row.skipped {
  opacity: 0.5;
}

.step-row.error {
  border-color: rgba(244, 63, 94, 0.2);
  background: rgba(244, 63, 94, 0.04);
}

.step-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.step-icon.completed { background: rgba(16, 185, 129, 0.15); }
.step-icon.running { background: rgba(99, 102, 241, 0.15); animation: spin 1.2s linear infinite; }
.step-icon.skipped { background: rgba(100, 116, 139, 0.15); }
.step-icon.error { background: rgba(244, 63, 94, 0.15); }

.step-name {
  font-size: 0.82rem;
  font-weight: 600;
  flex: 1;
}

.step-detail {
  font-size: 0.72rem;
  color: var(--text-muted);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.step-time {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  min-width: 50px;
  text-align: right;
}

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

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

/* --- Stats Row --- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.stat-card {
  padding: 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  text-align: center;
  transition: all 0.3s;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(99, 102, 241, 0.2);
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 2px;
}

.stat-value.indigo { color: var(--accent-indigo); }
.stat-value.emerald { color: var(--accent-emerald); }
.stat-value.amber { color: var(--accent-amber); }
.stat-value.rose { color: var(--accent-rose); }
.stat-value.sky { color: var(--accent-sky); }

.stat-label {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* --- Items Table --- */
.items-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 4px;
}

.items-table th {
  padding: 8px 14px;
  text-align: left;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border-subtle);
}

.items-table td {
  padding: 10px 14px;
  font-size: 0.82rem;
  background: var(--bg-glass);
}

.items-table tr td:first-child {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.items-table tr td:last-child {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.items-table .item-name {
  font-weight: 600;
  text-transform: capitalize;
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
}

.status-in-stock {
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-emerald);
}

.status-shortage {
  background: rgba(245, 158, 11, 0.12);
  color: var(--accent-amber);
}

.status-not-found {
  background: rgba(244, 63, 94, 0.12);
  color: var(--accent-rose);
}

/* --- Summary Card --- */
.summary-text {
  font-size: 0.88rem;
  line-height: 1.8;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

/* --- Purchase Request --- */
.pr-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.pr-total {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent-amber);
}

.pr-status {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
}

.pr-status.needs-approval {
  background: rgba(244, 63, 94, 0.12);
  color: var(--accent-rose);
}

.pr-status.auto-approved {
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-emerald);
}

.pr-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pr-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-glass);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
}

.pr-item-name {
  font-weight: 600;
  text-transform: capitalize;
}

.pr-item-qty {
  color: var(--text-muted);
}

.pr-item-cost {
  font-weight: 600;
  color: var(--accent-amber);
  font-family: var(--font-mono);
}

/* --- History Panel --- */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 300px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.history-item:hover {
  background: rgba(99, 102, 241, 0.06);
  border-color: rgba(99, 102, 241, 0.15);
  transform: translateX(3px);
}

.history-id {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-accent);
  min-width: 32px;
}

.history-text {
  flex: 1;
  font-size: 0.78rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-status {
  font-size: 0.68rem;
  font-weight: 600;
}

.history-time {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* --- Inventory Panel --- */
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.inv-card {
  padding: 14px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: all 0.25s;
}

.inv-card:hover {
  border-color: rgba(99, 102, 241, 0.2);
  transform: translateY(-2px);
}

.inv-card.low-stock {
  border-color: rgba(245, 158, 11, 0.25);
}

.inv-name {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: capitalize;
  margin-bottom: 6px;
}

.inv-qty {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent-indigo);
}

.inv-qty.low {
  color: var(--accent-amber);
}

.inv-unit {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-left: 3px;
}

.inv-price {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-family: var(--font-mono);
}

.inv-category {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(99, 102, 241, 0.1);
  color: var(--text-accent);
}

/* --- Inventory Edit Controls --- */
.inv-qty-display {
  margin-bottom: 8px;
}

.inv-edit-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
}

.inv-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.inv-btn:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.3);
  color: var(--accent-indigo);
  transform: scale(1.1);
}

.inv-btn:active {
  transform: scale(0.95);
}

.inv-btn-plus:hover {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--accent-emerald);
}

.inv-btn-minus:hover {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.3);
  color: var(--accent-rose);
}

.inv-qty-input {
  width: 100%;
  min-width: 50px;
  max-width: 80px;
  padding: 5px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  outline: none;
  transition: all 0.2s;
  -moz-appearance: textfield;
}

.inv-qty-input::-webkit-inner-spin-button,
.inv-qty-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.inv-qty-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.inv-save-btn {
  width: 100%;
  padding: 6px 12px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 8px;
}

.inv-save-btn:hover {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.3);
  color: var(--text-accent);
}

.inv-save-btn.dirty {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--accent-emerald);
  animation: pulse-save 1.5s ease-in-out infinite;
}

.inv-save-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Card states for editing */
.inv-card.editing {
  border-color: rgba(99, 102, 241, 0.35);
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.12);
}

.inv-card.save-success {
  border-color: rgba(16, 185, 129, 0.4);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.15);
  animation: flash-success 0.6s ease;
}

@keyframes pulse-save {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

@keyframes flash-success {
  0% { background: rgba(16, 185, 129, 0.1); }
  100% { background: var(--bg-glass); }
}

/* --- Loading Spinner --- */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* --- Tabs --- */
.tab-bar {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-glass);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  margin-bottom: 20px;
}

.tab-btn {
  flex: 1;
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

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

.tab-btn.active {
  background: rgba(99, 102, 241, 0.12);
  color: var(--text-accent);
}

.tab-content {
  display: none;
  animation: fadeSlideIn 0.3s ease;
}

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

/* --- Footer Section --- */
.app-footer {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.app-footer a {
  color: var(--text-accent);
  text-decoration: none;
}

/* --- Confidence / Priority Meters --- */
.meter-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.meter {
  flex: 1;
  min-width: 120px;
}

.meter-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.meter-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.meter-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.meter-fill.indigo { background: var(--gradient-brand); }
.meter-fill.emerald { background: var(--gradient-emerald); }
.meter-fill.amber { background: var(--gradient-amber); }
.meter-fill.rose { background: var(--gradient-rose); }

.meter-value {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  margin-top: 4px;
  text-align: right;
}

/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.82rem;
  animation: toastIn 0.3s ease;
  max-width: 380px;
}

.toast.success { border-color: rgba(16, 185, 129, 0.3); }
.toast.error { border-color: rgba(244, 63, 94, 0.3); }
.toast.info { border-color: rgba(14, 165, 233, 0.3); }

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

/* --- Responsive --- */
@media (max-width: 768px) {
  .app-container {
    padding: 16px;
  }
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
  .inventory-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .btn-row {
    flex-direction: column;
  }
  .btn {
    width: 100%;
  }
}

/* ============================================================
   Analytics Tab Styles
   ============================================================ */
.analytics-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 900px) {
  .analytics-grid {
    grid-template-columns: 1fr;
  }
}

/* Custom CSS Horizontal Bar Chart */
.bar-chart-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 10px;
}

.chart-bar-row {
  display: grid;
  grid-template-columns: 120px 1fr 60px;
  align-items: center;
  gap: 12px;
}

.chart-bar-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: capitalize;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-bar-track {
  height: 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 5px;
  overflow: hidden;
  position: relative;
}

.chart-bar-fill {
  height: 100%;
  border-radius: 5px;
  background: var(--gradient-brand);
  width: 0; /* Animated in JS */
  transition: width 1s cubic-bezier(0.1, 0.8, 0.3, 1);
}

.chart-bar-fill.violet {
  background: linear-gradient(135deg, #8b5cf6 0%, #a855f7 100%);
}

.chart-bar-fill.emerald {
  background: var(--gradient-emerald);
}

.chart-bar-value {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
}

/* ============================================================
   Architecture Tab Styles
   ============================================================ */
.arch-diagram {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
}

.arch-section {
  width: 100%;
  max-width: 800px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s;
}

.arch-section:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(99, 102, 241, 0.2);
}

.arch-label {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-accent);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.arch-items {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.arch-item {
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
}

.arch-item.highlight {
  border-color: rgba(14, 165, 233, 0.4);
  background: rgba(14, 165, 233, 0.08);
  color: var(--accent-sky);
  font-weight: 600;
}

.arch-arrow-down {
  font-size: 1.2rem;
  color: var(--text-muted);
  user-select: none;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}

.arch-pipeline {
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  align-items: center;
  gap: 6px;
  width: 100%;
}

@media (max-width: 800px) {
  .arch-pipeline {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .arch-step-arrow {
    transform: rotate(90deg);
    text-align: center;
  }
}

.arch-step {
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 90px;
  transition: all 0.3s;
}

.arch-pipeline .arch-step { grid-column: span 1; }
.arch-pipeline .arch-step-arrow { grid-column: span 1; text-align: center; color: var(--text-muted); font-size: 0.8rem; }

.arch-pipeline .step-1,
.arch-pipeline .step-2,
.arch-pipeline .step-3,
.arch-pipeline .step-4,
.arch-pipeline .step-5,
.arch-pipeline .step-6 {
  grid-column: span 1;
}

.arch-step:hover {
  background: rgba(99, 102, 241, 0.06);
  border-color: rgba(99, 102, 241, 0.3);
}

.arch-step-num {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-indigo);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}

.arch-step-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 4px;
}

.arch-step-tech {
  font-size: 0.6rem;
  color: var(--text-muted);
  font-weight: 500;
}

.tech-stack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.tech-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  transition: all 0.3s;
}

.tech-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(99, 102, 241, 0.15);
  transform: translateY(-2px);
}

.tech-icon {
  font-size: 1.5rem;
}

.tech-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.tech-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ============================================================
   Modal & Receipt (Invoice View) Styles
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal-container {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  transition: color 0.2s;
  outline: none;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
  max-height: 70vh;
  overflow-y: auto;
}

.receipt {
  background: #ffffff;
  color: #1e293b;
  border-radius: var(--radius-md);
  padding: 24px;
  font-family: var(--font-sans);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  position: relative;
}

.receipt-header {
  text-align: center;
  border-bottom: 1px dashed #cbd5e1;
  padding-bottom: 16px;
  margin-bottom: 16px;
}

.receipt-store {
  font-size: 1.2rem;
  font-weight: 800;
  color: #0f172a;
}

.receipt-address {
  font-size: 0.72rem;
  color: #64748b;
  margin-top: 4px;
}

.receipt-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: #64748b;
  margin-top: 12px;
  text-align: left;
}

.receipt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  margin: 16px 0;
}

.receipt-table th {
  border-bottom: 1px solid #e2e8f0;
  padding: 6px 0;
  text-align: left;
  color: #475569;
  font-weight: 600;
}

.receipt-table td {
  padding: 8px 0;
  color: #334155;
  text-align: left;
}

.receipt-table .text-right {
  text-align: right;
}

.receipt-summary {
  border-top: 1px dashed #cbd5e1;
  padding-top: 12px;
  font-size: 0.78rem;
  color: #475569;
}

.receipt-summary-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.receipt-summary-row.total {
  font-size: 1.05rem;
  font-weight: 800;
  color: #0f172a;
  border-top: 1px solid #cbd5e1;
  padding-top: 10px;
  margin-top: 4px;
}

.receipt-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.68rem;
  color: #94a3b8;
  border-top: 1px solid #f1f5f9;
  padding-top: 12px;
}

.receipt-msg {
  font-weight: 500;
  color: #64748b;
  margin-bottom: 4px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* --- Added for 1st Prize Upgrades --- */

/* Warning Steps in Pipeline */
.step-row.warning {
  border-color: rgba(245, 158, 11, 0.2);
  background: rgba(245, 158, 11, 0.04);
}

.step-icon.warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
}

/* Voice Input / Microphone pulsing effect */
@keyframes pulse-glow-red {
  0%, 100% {
    box-shadow: 0 0 8px rgba(244, 63, 94, 0.4);
    background: rgba(244, 63, 94, 0.15);
  }
  50% {
    box-shadow: 0 0 20px rgba(244, 63, 94, 0.7);
    background: rgba(244, 63, 94, 0.3);
  }
}

.btn.pulse-red {
  color: #fff !important;
  background: rgba(244, 63, 94, 0.2) !important;
  border-color: rgba(244, 63, 94, 0.5) !important;
  animation: pulse-glow-red 1.5s infinite;
}

/* Reorder approvals cards */
.reorders-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 500px;
  overflow-y: auto;
  padding-right: 4px;
}

.reorder-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.25s ease;
}

.reorder-card:hover {
  border-color: rgba(245, 158, 11, 0.25);
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.06);
  transform: translateY(-2px);
}

.reorder-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.reorder-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.reorder-id {
  font-family: var(--font-mono);
  color: var(--text-accent);
  font-weight: 600;
}

.reorder-amount {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent-amber);
}

.reorder-items-summary {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.reorder-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: 20px;
}

.pr-status-badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.pr-status-pending {
  background: rgba(244, 63, 94, 0.12);
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.2);
}

.pr-status-approved {
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.pr-status-auto {
  background: rgba(14, 165, 233, 0.12);
  color: var(--accent-sky);
  border: 1px solid rgba(14, 165, 233, 0.2);
}


